Search in sources :

Example 11 with DeploymentNotFoundException

use of org.jbpm.services.api.DeploymentNotFoundException in project jbpm by kiegroup.

the class AdHocProcessServiceImpl method startProcess.

@Override
public Long startProcess(String deploymentId, String processId, CorrelationKey correlationKey, Map<String, Object> params, Long parentProcessInstanceId) {
    DeployedUnit deployedUnit = deploymentService.getDeployedUnit(deploymentId);
    if (deployedUnit == null) {
        throw new DeploymentNotFoundException("No deployments available for " + deploymentId);
    }
    if (!deployedUnit.isActive()) {
        throw new DeploymentNotFoundException("Deployments " + deploymentId + " is not active");
    }
    RuntimeManager manager = deployedUnit.getRuntimeManager();
    params = process(params, ((InternalRuntimeManager) manager).getEnvironment().getClassLoader());
    RuntimeEngine engine = manager.getRuntimeEngine(ProcessInstanceIdContext.get());
    KieSession ksession = engine.getKieSession();
    ProcessInstance pi = null;
    try {
        pi = ((CorrelationAwareProcessRuntime) ksession).createProcessInstance(processId, correlationKey, params);
        pi = ksession.execute(new StartProcessInstanceWithParentCommand(pi.getId(), parentProcessInstanceId));
        return pi.getId();
    } finally {
        disposeRuntimeEngine(manager, engine);
    }
}
Also used : DeploymentNotFoundException(org.jbpm.services.api.DeploymentNotFoundException) RuntimeEngine(org.kie.api.runtime.manager.RuntimeEngine) DeployedUnit(org.jbpm.services.api.model.DeployedUnit) RuntimeManager(org.kie.api.runtime.manager.RuntimeManager) InternalRuntimeManager(org.kie.internal.runtime.manager.InternalRuntimeManager) KieSession(org.kie.api.runtime.KieSession) ProcessInstance(org.kie.api.runtime.process.ProcessInstance) StartProcessInstanceWithParentCommand(org.jbpm.kie.services.impl.cmd.StartProcessInstanceWithParentCommand)

Example 12 with DeploymentNotFoundException

use of org.jbpm.services.api.DeploymentNotFoundException in project jbpm by kiegroup.

the class ProcessServiceImpl method startProcess.

@Override
public Long startProcess(String deploymentId, String processId, Map<String, Object> params) {
    DeployedUnit deployedUnit = deploymentService.getDeployedUnit(deploymentId);
    if (deployedUnit == null) {
        throw new DeploymentNotFoundException("No deployments available for " + deploymentId);
    }
    if (!deployedUnit.isActive()) {
        throw new DeploymentNotFoundException("Deployments " + deploymentId + " is not active");
    }
    RuntimeManager manager = deployedUnit.getRuntimeManager();
    params = process(params, ((InternalRuntimeManager) manager).getEnvironment().getClassLoader());
    RuntimeEngine engine = manager.getRuntimeEngine(getContext(params));
    KieSession ksession = engine.getKieSession();
    ProcessInstance pi;
    try {
        pi = ksession.startProcess(processId, params);
        return pi.getId();
    } finally {
        disposeRuntimeEngine(manager, engine);
    }
}
Also used : DeploymentNotFoundException(org.jbpm.services.api.DeploymentNotFoundException) RuntimeEngine(org.kie.api.runtime.manager.RuntimeEngine) DeployedUnit(org.jbpm.services.api.model.DeployedUnit) RuntimeManager(org.kie.api.runtime.manager.RuntimeManager) InternalRuntimeManager(org.kie.internal.runtime.manager.InternalRuntimeManager) KieSession(org.kie.api.runtime.KieSession) RuleFlowProcessInstance(org.jbpm.ruleflow.instance.RuleFlowProcessInstance) ProcessInstance(org.kie.api.runtime.process.ProcessInstance) WorkflowProcessInstance(org.kie.api.runtime.process.WorkflowProcessInstance)

Example 13 with DeploymentNotFoundException

use of org.jbpm.services.api.DeploymentNotFoundException in project jbpm by kiegroup.

the class ProcessServiceImpl method getWorkItemByProcessInstance.

@Override
public List<WorkItem> getWorkItemByProcessInstance(String deploymentId, Long processInstanceId) {
    DeployedUnit deployedUnit = deploymentService.getDeployedUnit(deploymentId);
    if (deployedUnit == null) {
        throw new DeploymentNotFoundException("No deployments available for " + deploymentId);
    }
    RuntimeManager manager = deployedUnit.getRuntimeManager();
    RuntimeEngine engine = manager.getRuntimeEngine(ProcessInstanceIdContext.get(processInstanceId));
    try {
        KieSession ksession = engine.getKieSession();
        List<WorkItem> workItems = new ArrayList<>();
        Collection<NodeInstanceDesc> nodes = dataService.getProcessInstanceHistoryActive(processInstanceId, null);
        for (NodeInstanceDesc node : nodes) {
            if (node.getWorkItemId() != null) {
                workItems.add(((WorkItemManager) ksession.getWorkItemManager()).getWorkItem(node.getWorkItemId()));
            }
        }
        return workItems;
    } catch (SessionNotFoundException e) {
        throw new ProcessInstanceNotFoundException("Process instance with id " + processInstanceId + " was not found", e);
    } finally {
        disposeRuntimeEngine(manager, engine);
    }
}
Also used : DeploymentNotFoundException(org.jbpm.services.api.DeploymentNotFoundException) RuntimeEngine(org.kie.api.runtime.manager.RuntimeEngine) DeployedUnit(org.jbpm.services.api.model.DeployedUnit) RuntimeManager(org.kie.api.runtime.manager.RuntimeManager) InternalRuntimeManager(org.kie.internal.runtime.manager.InternalRuntimeManager) ArrayList(java.util.ArrayList) KieSession(org.kie.api.runtime.KieSession) ProcessInstanceNotFoundException(org.jbpm.services.api.ProcessInstanceNotFoundException) WorkItem(org.kie.api.runtime.process.WorkItem) NodeInstanceDesc(org.jbpm.services.api.model.NodeInstanceDesc) SessionNotFoundException(org.kie.internal.runtime.manager.SessionNotFoundException)

Example 14 with DeploymentNotFoundException

use of org.jbpm.services.api.DeploymentNotFoundException in project jbpm by kiegroup.

the class ProcessServiceImpl method signalProcessInstance.

@Override
public void signalProcessInstance(String deploymentId, Long processInstanceId, String signalName, Object event) {
    DeployedUnit deployedUnit = deploymentService.getDeployedUnit(deploymentId);
    if (deployedUnit == null) {
        throw new DeploymentNotFoundException("No deployments available for " + deploymentId);
    }
    RuntimeManager manager = deployedUnit.getRuntimeManager();
    event = process(event, ((InternalRuntimeManager) manager).getEnvironment().getClassLoader());
    RuntimeEngine engine = manager.getRuntimeEngine(ProcessInstanceIdContext.get(processInstanceId));
    try {
        KieSession ksession = engine.getKieSession();
        ksession.signalEvent(signalName, event, processInstanceId);
    } catch (SessionNotFoundException e) {
        throw new ProcessInstanceNotFoundException("Process instance with id " + processInstanceId + " was not found", e);
    } finally {
        disposeRuntimeEngine(manager, engine);
    }
}
Also used : DeploymentNotFoundException(org.jbpm.services.api.DeploymentNotFoundException) RuntimeEngine(org.kie.api.runtime.manager.RuntimeEngine) DeployedUnit(org.jbpm.services.api.model.DeployedUnit) RuntimeManager(org.kie.api.runtime.manager.RuntimeManager) InternalRuntimeManager(org.kie.internal.runtime.manager.InternalRuntimeManager) KieSession(org.kie.api.runtime.KieSession) ProcessInstanceNotFoundException(org.jbpm.services.api.ProcessInstanceNotFoundException) SessionNotFoundException(org.kie.internal.runtime.manager.SessionNotFoundException)

Example 15 with DeploymentNotFoundException

use of org.jbpm.services.api.DeploymentNotFoundException in project jbpm by kiegroup.

the class ProcessServiceImpl method signalEvent.

@Override
public void signalEvent(String deploymentId, String signalName, Object event) {
    DeployedUnit deployedUnit = deploymentService.getDeployedUnit(deploymentId);
    if (deployedUnit == null) {
        throw new DeploymentNotFoundException("No deployments available for " + deploymentId);
    }
    RuntimeManager manager = deployedUnit.getRuntimeManager();
    event = process(event, ((InternalRuntimeManager) manager).getEnvironment().getClassLoader());
    manager.signalEvent(signalName, event);
}
Also used : DeploymentNotFoundException(org.jbpm.services.api.DeploymentNotFoundException) DeployedUnit(org.jbpm.services.api.model.DeployedUnit) RuntimeManager(org.kie.api.runtime.manager.RuntimeManager) InternalRuntimeManager(org.kie.internal.runtime.manager.InternalRuntimeManager)

Aggregations

DeploymentNotFoundException (org.jbpm.services.api.DeploymentNotFoundException)19 DeployedUnit (org.jbpm.services.api.model.DeployedUnit)18 RuntimeManager (org.kie.api.runtime.manager.RuntimeManager)18 InternalRuntimeManager (org.kie.internal.runtime.manager.InternalRuntimeManager)18 KieSession (org.kie.api.runtime.KieSession)17 RuntimeEngine (org.kie.api.runtime.manager.RuntimeEngine)17 ProcessInstanceNotFoundException (org.jbpm.services.api.ProcessInstanceNotFoundException)13 SessionNotFoundException (org.kie.internal.runtime.manager.SessionNotFoundException)13 ProcessInstance (org.kie.api.runtime.process.ProcessInstance)5 WorkflowProcessInstance (org.kie.api.runtime.process.WorkflowProcessInstance)5 RuleFlowProcessInstance (org.jbpm.ruleflow.instance.RuleFlowProcessInstance)4 WorkItem (org.kie.api.runtime.process.WorkItem)4 WorkItemManager (org.drools.core.process.instance.WorkItemManager)3 WorkItemNotFoundException (org.jbpm.services.api.WorkItemNotFoundException)3 ArrayList (java.util.ArrayList)2 WorkflowProcessInstanceImpl (org.jbpm.workflow.instance.impl.WorkflowProcessInstanceImpl)2 SetProcessInstanceVariablesCommand (org.drools.core.command.runtime.process.SetProcessInstanceVariablesCommand)1 KModuleDeploymentUnit (org.jbpm.kie.services.impl.KModuleDeploymentUnit)1 StartProcessInstanceWithParentCommand (org.jbpm.kie.services.impl.cmd.StartProcessInstanceWithParentCommand)1 AbstractKieServicesBaseTest (org.jbpm.kie.test.util.AbstractKieServicesBaseTest)1