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, CorrelationKey correlationKey, 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 = ((CorrelationAwareProcessRuntime) ksession).startProcess(processId, correlationKey, params);
return pi.getId();
} finally {
disposeRuntimeEngine(manager, engine);
}
}
use of org.jbpm.services.api.DeploymentNotFoundException in project jbpm by kiegroup.
the class ProcessServiceImpl method completeWorkItem.
@Override
public void completeWorkItem(String deploymentId, Long processInstanceId, Long id, Map<String, Object> results) {
DeployedUnit deployedUnit = deploymentService.getDeployedUnit(deploymentId);
if (deployedUnit == null) {
throw new DeploymentNotFoundException("No deployments available for " + deploymentId);
}
RuntimeManager manager = deployedUnit.getRuntimeManager();
results = process(results, ((InternalRuntimeManager) manager).getEnvironment().getClassLoader());
RuntimeEngine engine = manager.getRuntimeEngine(ProcessInstanceIdContext.get(processInstanceId));
try {
KieSession ksession = engine.getKieSession();
WorkItem workItem = ((WorkItemManager) ksession.getWorkItemManager()).getWorkItem(id);
if (workItem == null) {
throw new WorkItemNotFoundException("Work item with id " + id + " was not found");
}
ksession.getWorkItemManager().completeWorkItem(id, results);
} catch (SessionNotFoundException e) {
throw new ProcessInstanceNotFoundException("Process instance with id " + processInstanceId + " was not found", e);
} finally {
disposeRuntimeEngine(manager, engine);
}
}
use of org.jbpm.services.api.DeploymentNotFoundException in project jbpm by kiegroup.
the class ProcessServiceImpl method getAvailableSignals.
@Override
public Collection<String> getAvailableSignals(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();
ProcessInstance processInstance = ksession.getProcessInstance(processInstanceId);
Collection<String> activeSignals = new ArrayList<>();
if (processInstance != null) {
((ProcessInstanceImpl) processInstance).setProcess(ksession.getKieBase().getProcess(processInstance.getProcessId()));
Collection<NodeInstance> activeNodes = ((WorkflowProcessInstance) processInstance).getNodeInstances();
Collection<String> activeBoundaryNodesSignals = getActiveBoundaryNodesSignals(processInstance, activeNodes);
activeSignals.addAll(collectActiveSignals(activeNodes));
activeSignals.addAll(activeBoundaryNodesSignals);
}
return activeSignals;
} catch (SessionNotFoundException e) {
throw new ProcessInstanceNotFoundException("Process instance with id " + processInstanceId + " was not found", e);
} finally {
disposeRuntimeEngine(manager, engine);
}
}
use of org.jbpm.services.api.DeploymentNotFoundException in project jbpm by kiegroup.
the class ProcessServiceImpl method setProcessVariables.
@Override
public void setProcessVariables(String deploymentId, Long processInstanceId, Map<String, Object> variables) {
DeployedUnit deployedUnit = deploymentService.getDeployedUnit(deploymentId);
if (deployedUnit == null) {
throw new DeploymentNotFoundException("No deployments available for " + deploymentId);
}
RuntimeManager manager = deployedUnit.getRuntimeManager();
variables = process(variables, ((InternalRuntimeManager) manager).getEnvironment().getClassLoader());
RuntimeEngine engine = manager.getRuntimeEngine(ProcessInstanceIdContext.get(processInstanceId));
try {
KieSession ksession = engine.getKieSession();
ProcessInstance pi = ksession.getProcessInstance(processInstanceId);
if (pi == null) {
throw new ProcessInstanceNotFoundException("Process instance with id " + processInstanceId + " was not found");
}
ksession.execute(new SetProcessInstanceVariablesCommand(processInstanceId, variables));
} catch (SessionNotFoundException e) {
throw new ProcessInstanceNotFoundException("Process instance with id " + processInstanceId + " was not found", e);
} finally {
disposeRuntimeEngine(manager, engine);
}
}
Aggregations