Search in sources :

Example 16 with RegistryContext

use of org.kie.internal.command.RegistryContext in project drools by kiegroup.

the class UpdateInEntryPointCommand method execute.

public Void execute(Context context) {
    KieSession ksession = ((RegistryContext) context).lookup(KieSession.class);
    EntryPoint ep = ksession.getEntryPoint(entryPoint);
    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.kie.internal.command.RegistryContext)

Example 17 with RegistryContext

use of org.kie.internal.command.RegistryContext in project drools by kiegroup.

the class ExecuteCommand method execute.

public ExecutionResults execute(Context context) {
    KieSession ksession = ((RegistryContext) context).lookup(KieSession.class);
    ExecutionResults kresults = ksession.execute(this.command);
    if (this.outIdentifier != null) {
        ((RegistryContext) context).lookup(ExecutionResultImpl.class).setResult(this.outIdentifier, kresults);
    }
    if (disconnected) {
        ExecutionResultImpl disconnectedResults = new ExecutionResultImpl();
        HashMap<String, Object> disconnectedHandles = new HashMap<String, Object>();
        for (String key : kresults.getIdentifiers()) {
            FactHandle handle = (FactHandle) kresults.getFactHandle(key);
            if (handle != null) {
                DefaultFactHandle disconnectedHandle = ((DefaultFactHandle) handle).clone();
                disconnectedHandle.disconnect();
                disconnectedHandles.put(key, disconnectedHandle);
            }
        }
        disconnectedResults.setFactHandles(disconnectedHandles);
        disconnectedResults.setResults((HashMap) ((ExecutionResultImpl) kresults).getResults());
        return disconnectedResults;
    }
    return kresults;
}
Also used : DefaultFactHandle(org.drools.core.common.DefaultFactHandle) HashMap(java.util.HashMap) DefaultFactHandle(org.drools.core.common.DefaultFactHandle) FactHandle(org.kie.api.runtime.rule.FactHandle) ExecutionResults(org.kie.api.runtime.ExecutionResults) ExecutionResultImpl(org.drools.core.runtime.impl.ExecutionResultImpl) KieSession(org.kie.api.runtime.KieSession) RegistryContext(org.kie.internal.command.RegistryContext)

Example 18 with RegistryContext

use of org.kie.internal.command.RegistryContext in project drools by kiegroup.

the class GetKieContainerCommand method execute.

public KieContainer execute(Context context) {
    // use the new API to retrieve the session by ID
    KieServices kieServices = KieServices.Factory.get();
    KieContainer kieContainer = kieServices.newKieContainer(releaseId);
    ((RegistryContext) context).register(KieContainer.class, kieContainer);
    return kieContainer;
}
Also used : KieServices(org.kie.api.KieServices) RegistryContext(org.kie.internal.command.RegistryContext) KieContainer(org.kie.api.runtime.KieContainer)

Example 19 with RegistryContext

use of org.kie.internal.command.RegistryContext in project drools by kiegroup.

the class SetActiveAgendaGroup method execute.

@Override
public Void execute(Context context) {
    KieSession ksession = ((RegistryContext) context).lookup(KieSession.class);
    ksession.getAgenda().getAgendaGroup(agendaGroup).setFocus();
    return null;
}
Also used : KieSession(org.kie.api.runtime.KieSession) RegistryContext(org.kie.internal.command.RegistryContext)

Example 20 with RegistryContext

use of org.kie.internal.command.RegistryContext in project drools by kiegroup.

the class SetGlobalCommand method execute.

public Object execute(Context context) {
    KieSession ksession = ((RegistryContext) context).lookup(KieSession.class);
    if (this.outIdentifier != null) {
        ((RegistryContext) context).lookup(ExecutionResultImpl.class).setResult(this.outIdentifier, object);
    }
    ksession.setGlobal(this.identifier, this.object);
    // returning the object is necessary for drools-simulator
    return this.object;
}
Also used : ExecutionResultImpl(org.drools.core.runtime.impl.ExecutionResultImpl) KieSession(org.kie.api.runtime.KieSession) RegistryContext(org.kie.internal.command.RegistryContext)

Aggregations

RegistryContext (org.kie.internal.command.RegistryContext)126 KieSession (org.kie.api.runtime.KieSession)106 ExecutionResultImpl (org.drools.core.runtime.impl.ExecutionResultImpl)37 Context (org.kie.api.runtime.Context)27 ProcessInstance (org.kie.api.runtime.process.ProcessInstance)27 ArrayList (java.util.ArrayList)17 FactHandle (org.kie.api.runtime.rule.FactHandle)16 Test (org.junit.Test)14 CaseFileInstance (org.jbpm.casemgmt.api.model.instance.CaseFileInstance)13 List (java.util.List)12 CaseEventSupport (org.jbpm.casemgmt.impl.event.CaseEventSupport)12 EntryPoint (org.kie.api.runtime.rule.EntryPoint)12 Map (java.util.Map)11 HashMap (java.util.HashMap)10 ProcessInstanceNotFoundException (org.jbpm.services.api.ProcessInstanceNotFoundException)9 ExecutableCommand (org.kie.api.command.ExecutableCommand)9 WorkflowProcessInstance (org.jbpm.workflow.instance.WorkflowProcessInstance)8 NodeInstance (org.kie.api.runtime.process.NodeInstance)8 StatefulKnowledgeSession (org.kie.internal.runtime.StatefulKnowledgeSession)8 Collection (java.util.Collection)7