Search in sources :

Example 21 with RegistryContext

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

the class ApplyPmmlModelCommand method execute.

@Override
public PMML4Result execute(Context context) {
    if (requestData == null) {
        throw new IllegalStateException("ApplyPmmlModelCommand requires request data (PMMLRequestData) to execute");
    }
    RegistryContext registryContext = (RegistryContext) context;
    PMML4Result toReturn = PMMLCommandExecutorFactory.get().newPMMLCommandExecutor().execute(requestData, context);
    // Needed to update the ExecutionResultImpl and the Registry context,
    // as done inside legacy implementation
    Optional<ExecutionResultImpl> execRes = Optional.ofNullable(registryContext.lookup(ExecutionResultImpl.class));
    registryContext.register(PMML4Result.class, toReturn);
    execRes.ifPresent(result -> result.setResult("results", toReturn));
    return toReturn;
}
Also used : PMML4Result(org.kie.api.pmml.PMML4Result) ExecutionResultImpl(org.drools.core.runtime.impl.ExecutionResultImpl) RegistryContext(org.kie.internal.command.RegistryContext)

Example 22 with RegistryContext

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

the class AbortProcessInstanceCommand method execute.

public Void execute(Context context) {
    KieSession ksession = ((RegistryContext) context).lookup(KieSession.class);
    if (processInstanceId == null) {
        return null;
    }
    ksession.abortProcessInstance(processInstanceId);
    return null;
}
Also used : KieSession(org.kie.api.runtime.KieSession) RegistryContext(org.kie.internal.command.RegistryContext)

Example 23 with RegistryContext

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

the class CompleteWorkItemCommand method execute.

public Void execute(Context context) {
    KieSession ksession = ((RegistryContext) context).lookup(KieSession.class);
    ksession.getWorkItemManager().completeWorkItem(workItemId, results);
    return null;
}
Also used : KieSession(org.kie.api.runtime.KieSession) RegistryContext(org.kie.internal.command.RegistryContext)

Example 24 with RegistryContext

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

the class CreateProcessInstanceCommand 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 = (ProcessInstance) ksession.createProcessInstance(processId, parameters);
    if (this.outIdentifier != null) {
        ((RegistryContext) context).lookup(ExecutionResultImpl.class).setResult(this.outIdentifier, processInstance.getId());
    }
    return processInstance;
}
Also used : ExecutionResultImpl(org.drools.core.runtime.impl.ExecutionResultImpl) KieSession(org.kie.api.runtime.KieSession) RegistryContext(org.kie.internal.command.RegistryContext) ProcessInstance(org.kie.api.runtime.process.ProcessInstance)

Example 25 with RegistryContext

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

the class GetProcessInstanceCommand method execute.

public ProcessInstance execute(Context context) {
    KieSession ksession = ((RegistryContext) context).lookup(KieSession.class);
    if (processInstanceId == null) {
        return null;
    }
    final ProcessInstance processInstance = ksession.getProcessInstance(processInstanceId, readOnly);
    if (this.outIdentifier != null) {
        ((RegistryContext) context).lookup(ExecutionResultImpl.class).setResult(this.outIdentifier, processInstance);
    }
    return processInstance;
}
Also used : ExecutionResultImpl(org.drools.core.runtime.impl.ExecutionResultImpl) KieSession(org.kie.api.runtime.KieSession) RegistryContext(org.kie.internal.command.RegistryContext) ProcessInstance(org.kie.api.runtime.process.ProcessInstance)

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