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);
}
}
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);
}
}
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);
}
}
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);
}
}
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);
}
Aggregations