use of org.jbpm.services.api.ProcessInstanceNotFoundException in project jbpm by kiegroup.
the class ProcessInstanceAdminServiceImpl method getProcessNodes.
@Override
public Collection<ProcessNode> getProcessNodes(long processInstanceId) throws ProcessInstanceNotFoundException {
ProcessInstanceDesc pi = runtimeDataService.getProcessInstanceById(processInstanceId);
if (pi == null) {
throw new ProcessInstanceNotFoundException("Process instance with id " + processInstanceId + " not found");
}
Collection<ProcessNode> nodes = processService.execute(pi.getDeploymentId(), ProcessInstanceIdContext.get(processInstanceId), new ListNodesCommand(processInstanceId));
return nodes;
}
use of org.jbpm.services.api.ProcessInstanceNotFoundException in project jbpm by kiegroup.
the class ProcessInstanceAdminServiceImpl method updateTimer.
@Override
public void updateTimer(long processInstanceId, long timerId, long delay, long period, int repeatLimit) throws NodeInstanceNotFoundException, ProcessInstanceNotFoundException {
ProcessInstanceDesc pi = runtimeDataService.getProcessInstanceById(processInstanceId);
if (pi == null) {
throw new ProcessInstanceNotFoundException("Process instance with id " + processInstanceId + " not found");
}
processService.execute(pi.getDeploymentId(), ProcessInstanceIdContext.get(processInstanceId), new UpdateTimerCommand(processInstanceId, timerId, delay, period, repeatLimit));
}
use of org.jbpm.services.api.ProcessInstanceNotFoundException in project jbpm by kiegroup.
the class CancelNodeInstanceCommand method execute.
public Void execute(Context context) {
logger.debug("About to cancel node instance with id {} on process instance {}", nodeInstanceId, processInstanceId);
KieSession kieSession = ((RegistryContext) context).lookup(KieSession.class);
RuleFlowProcessInstance wfp = (RuleFlowProcessInstance) kieSession.getProcessInstance(processInstanceId, false);
if (wfp == null) {
throw new ProcessInstanceNotFoundException("Process instance with id " + processInstanceId + " not found");
}
NodeInstance nodeInstance = wfp.getNodeInstances(true).stream().filter(ni -> ni.getId() == nodeInstanceId).findFirst().orElse(null);
if (nodeInstance == null) {
throw new NodeInstanceNotFoundException("Node instance with id " + nodeInstanceId + " not found");
}
logger.debug("Found node instance {} to be canceled", nodeInstance);
((NodeInstanceImpl) nodeInstance).cancel();
logger.debug("Node instance {} canceled successfully", nodeInstance);
return null;
}
use of org.jbpm.services.api.ProcessInstanceNotFoundException in project jbpm by kiegroup.
the class ListNodesCommand method execute.
public List<ProcessNode> execute(Context context) {
List<ProcessNode> nodes = null;
KieSession kieSession = ((RegistryContext) context).lookup(KieSession.class);
RuleFlowProcessInstance wfp = (RuleFlowProcessInstance) kieSession.getProcessInstance(processInstanceId, true);
if (wfp == null) {
throw new ProcessInstanceNotFoundException("No process instance can be found for id " + processInstanceId);
}
String processId = wfp.getProcessId();
nodes = wfp.getRuleFlowProcess().getNodesRecursively().stream().map(n -> new ProcessNodeImpl(n.getName(), n.getId(), n.getClass().getSimpleName(), processId)).collect(Collectors.toList());
return nodes;
}
use of org.jbpm.services.api.ProcessInstanceNotFoundException in project jbpm by kiegroup.
the class CaseServiceImpl method addDynamicSubprocess.
@Override
public Long addDynamicSubprocess(Long processInstanceId, String processId, Map<String, Object> parameters) throws CaseNotFoundException {
ProcessInstanceDesc pi = runtimeDataService.getProcessInstanceById(processInstanceId);
if (pi == null || !pi.getState().equals(ProcessInstance.STATE_ACTIVE)) {
throw new ProcessInstanceNotFoundException("No process instance found with id " + processInstanceId + " or it's not active anymore");
}
String caseId = pi.getCorrelationKey();
authorizationManager.checkOperationAuthorization(caseId, ProtectedOperation.ADD_PROCESS_TO_CASE);
return processService.execute(pi.getDeploymentId(), ProcessInstanceIdContext.get(processInstanceId), new AddDynamicProcessCommand(identityProvider, caseId, pi.getId(), processId, parameters));
}
Aggregations