use of org.jbpm.kie.services.impl.cmd.StartProcessInstanceWithParentCommand 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);
}
}
Aggregations