Search in sources :

Example 26 with RegistryContext

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

the class ClearRuleFlowGroupCommand method execute.

public Void execute(Context context) {
    KieSession ksession = ((RegistryContext) context).lookup(KieSession.class);
    ((StatefulKnowledgeSessionImpl) ksession).getAgenda().getRuleFlowGroup(this.name).clear();
    return null;
}
Also used : StatefulKnowledgeSessionImpl(org.drools.core.impl.StatefulKnowledgeSessionImpl) KieSession(org.kie.api.runtime.KieSession) RegistryContext(org.drools.core.command.impl.RegistryContext)

Example 27 with RegistryContext

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

the class GetEntryPointCommand method execute.

public EntryPoint execute(Context context) {
    KieSession ksession = ((RegistryContext) context).lookup(KieSession.class);
    EntryPoint ep = ksession.getEntryPoint(name);
    if (ep == null) {
        return null;
    }
    EntryPointCreator epCreator = (EntryPointCreator) context.get(EntryPointCreator.class.getName());
    return epCreator != null ? epCreator.getEntryPoint(name) : ep;
}
Also used : EntryPoint(org.kie.api.runtime.rule.EntryPoint) EntryPointCreator(org.drools.core.command.EntryPointCreator) KieSession(org.kie.api.runtime.KieSession) RegistryContext(org.drools.core.command.impl.RegistryContext)

Example 28 with RegistryContext

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

the class GetFactHandleCommand method execute.

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

Example 29 with RegistryContext

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

the class StartCorrelatedProcessCommand 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).startProcess(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 30 with RegistryContext

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

the class StartProcessInstanceCommand method execute.

public ProcessInstance execute(Context context) {
    KieSession ksession = ((RegistryContext) context).lookup(KieSession.class);
    ProcessInstance processInstance = (ProcessInstance) ksession.startProcessInstance(processInstanceId);
    return processInstance;
}
Also used : KieSession(org.kie.api.runtime.KieSession) RegistryContext(org.drools.core.command.impl.RegistryContext) ProcessInstance(org.kie.api.runtime.process.ProcessInstance)

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