Search in sources :

Example 56 with RegistryContext

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

the class RegisterChannelCommand method execute.

public Void execute(Context context) {
    KieSession ksession = ((RegistryContext) context).lookup(KieSession.class);
    ksession.registerChannel(name, channel);
    return null;
}
Also used : KieSession(org.kie.api.runtime.KieSession) RegistryContext(org.drools.core.command.impl.RegistryContext)

Example 57 with RegistryContext

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

the class CreateCorrelatedProcessInstanceCommand method execute.

public ProcessInstance execute(Context context) {
    KieSession ksession = ((RegistryContext) context).lookup(KieSession.class);
    if (data != null) {
        for (Object o : data) {
            ksession.insert(o);
        }
    }
    ProcessInstance processInstance = ((CorrelationAwareProcessRuntime) ksession).createProcessInstance(processId, correlationKey, parameters);
    if (this.outIdentifier != null) {
        ((RegistryContext) context).lookup(ExecutionResultImpl.class).setResult(this.outIdentifier, processInstance.getId());
    }
    return processInstance;
}
Also used : CorrelationAwareProcessRuntime(org.kie.internal.process.CorrelationAwareProcessRuntime) ExecutionResultImpl(org.drools.core.runtime.impl.ExecutionResultImpl) KieSession(org.kie.api.runtime.KieSession) RegistryContext(org.drools.core.command.impl.RegistryContext) ProcessInstance(org.kie.api.runtime.process.ProcessInstance)

Example 58 with RegistryContext

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

the class GetWorkItemIdsCommand method execute.

public List<Long> execute(Context context) {
    KieSession ksession = ((RegistryContext) context).lookup(KieSession.class);
    Set<WorkItem> workItems = ((WorkItemManager) ksession.getWorkItemManager()).getWorkItems();
    List<Long> workItemIds = new ArrayList<Long>(workItems.size());
    for (WorkItem workItem : workItems) {
        workItemIds.add(workItem.getId());
    }
    return workItemIds;
}
Also used : ArrayList(java.util.ArrayList) KieSession(org.kie.api.runtime.KieSession) RegistryContext(org.drools.core.command.impl.RegistryContext) WorkItem(org.drools.core.process.instance.WorkItem) WorkItemManager(org.drools.core.process.instance.WorkItemManager)

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