Search in sources :

Example 36 with RegistryContext

use of org.drools.core.command.impl.RegistryContext in project drools by kiegroup.

the class QueryCommand method execute.

public QueryResults execute(Context context) {
    KieSession ksession = ((RegistryContext) context).lookup(KieSession.class);
    if (this.arguments == null || this.arguments.isEmpty()) {
        this.arguments = Collections.emptyList();
    }
    for (int j = 0; j < arguments.size(); j++) {
        if (arguments.get(j) instanceof Variable) {
            arguments.set(j, Variable.v);
        }
    }
    QueryResults results = ksession.getQueryResults(name, this.arguments.toArray());
    if (this.outIdentifier != null) {
        ((RegistryContext) context).lookup(ExecutionResultImpl.class).setResult(this.outIdentifier, new FlatQueryResults((QueryResultsImpl) results));
    }
    return results;
}
Also used : QueryResultsImpl(org.drools.core.QueryResultsImpl) Variable(org.kie.api.runtime.rule.Variable) ExecutionResultImpl(org.drools.core.runtime.impl.ExecutionResultImpl) KieSession(org.kie.api.runtime.KieSession) RegistryContext(org.drools.core.command.impl.RegistryContext) FlatQueryResults(org.drools.core.runtime.rule.impl.FlatQueryResults) FlatQueryResults(org.drools.core.runtime.rule.impl.FlatQueryResults) QueryResults(org.kie.api.runtime.rule.QueryResults)

Example 37 with RegistryContext

use of org.drools.core.command.impl.RegistryContext in project drools by kiegroup.

the class UpdateCommand method execute.

public Void execute(Context context) {
    KieSession ksession = ((RegistryContext) context).lookup(KieSession.class);
    EntryPoint ep = ksession.getEntryPoint(handle.getEntryPointId());
    if (modifiedProperties != null) {
        ep.update(handle, object, modifiedProperties);
    } else {
        ep.update(handle, object);
    }
    return null;
}
Also used : EntryPoint(org.kie.api.runtime.rule.EntryPoint) KieSession(org.kie.api.runtime.KieSession) RegistryContext(org.drools.core.command.impl.RegistryContext)

Example 38 with RegistryContext

use of org.drools.core.command.impl.RegistryContext in project drools by kiegroup.

the class GetEntryPointsCommand method execute.

public Collection<? extends EntryPoint> execute(Context context) {
    KieSession ksession = ((RegistryContext) context).lookup(KieSession.class);
    Collection<? extends EntryPoint> eps = ksession.getEntryPoints();
    EntryPointCreator epCreator = (EntryPointCreator) context.get(EntryPointCreator.class.getName());
    if (epCreator == null) {
        return eps;
    }
    Collection<EntryPoint> result = new ArrayList<EntryPoint>();
    for (EntryPoint ep : eps) {
        result.add(epCreator.getEntryPoint(ep.getEntryPointId()));
    }
    return result;
}
Also used : ArrayList(java.util.ArrayList) EntryPointCreator(org.drools.core.command.EntryPointCreator) EntryPoint(org.kie.api.runtime.rule.EntryPoint) KieSession(org.kie.api.runtime.KieSession) RegistryContext(org.drools.core.command.impl.RegistryContext)

Example 39 with RegistryContext

use of org.drools.core.command.impl.RegistryContext in project drools by kiegroup.

the class GetFactHandleInEntryPointCommand method execute.

public FactHandle execute(Context context) {
    KieSession ksession = ((RegistryContext) context).lookup(KieSession.class);
    EntryPoint ep = ksession.getEntryPoint(entryPoint);
    InternalFactHandle factHandle = (InternalFactHandle) ep.getFactHandle(object);
    if (factHandle != null) {
        InternalFactHandle handle = factHandle.clone();
        if (disconnected) {
            handle.disconnect();
        }
        return handle;
    }
    return null;
}
Also used : EntryPoint(org.kie.api.runtime.rule.EntryPoint) KieSession(org.kie.api.runtime.KieSession) RegistryContext(org.drools.core.command.impl.RegistryContext) InternalFactHandle(org.drools.core.common.InternalFactHandle)

Example 40 with RegistryContext

use of org.drools.core.command.impl.RegistryContext in project drools by kiegroup.

the class GetObjectInEntryPointCommand method execute.

public Object execute(Context context) {
    KieSession ksession = ((RegistryContext) context).lookup(KieSession.class);
    EntryPoint ep = ksession.getEntryPoint(entryPoint);
    Object object = ep.getObject(factHandle);
    if (this.outIdentifier != null) {
        ((RegistryContext) context).lookup(ExecutionResultImpl.class).setResult(this.outIdentifier, object);
    }
    return object;
}
Also used : ExecutionResultImpl(org.drools.core.runtime.impl.ExecutionResultImpl) EntryPoint(org.kie.api.runtime.rule.EntryPoint) KieSession(org.kie.api.runtime.KieSession) RegistryContext(org.drools.core.command.impl.RegistryContext)

Aggregations

RegistryContext (org.drools.core.command.impl.RegistryContext)58 KieSession (org.kie.api.runtime.KieSession)52 ExecutionResultImpl (org.drools.core.runtime.impl.ExecutionResultImpl)20 EntryPoint (org.kie.api.runtime.rule.EntryPoint)12 FactHandle (org.kie.api.runtime.rule.FactHandle)10 ArrayList (java.util.ArrayList)8 ProcessInstance (org.kie.api.runtime.process.ProcessInstance)7 InternalFactHandle (org.drools.core.common.InternalFactHandle)6 DefaultFactHandle (org.drools.core.common.DefaultFactHandle)4 HashMap (java.util.HashMap)3 RequestContextImpl (org.drools.core.command.RequestContextImpl)3 Context (org.kie.api.runtime.Context)3 KieContainer (org.kie.api.runtime.KieContainer)3 Collection (java.util.Collection)2 List (java.util.List)2 Map (java.util.Map)2 EntryPointCreator (org.drools.core.command.EntryPointCreator)2 StatefulKnowledgeSessionImpl (org.drools.core.impl.StatefulKnowledgeSessionImpl)2 KieServices (org.kie.api.KieServices)2 CorrelationAwareProcessRuntime (org.kie.internal.process.CorrelationAwareProcessRuntime)2