use of org.jbpm.services.api.NodeInstanceNotFoundException 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.NodeInstanceNotFoundException in project jbpm by kiegroup.
the class RetriggerNodeInstanceCommand method execute.
public Void execute(Context context) {
KieSession kieSession = ((RegistryContext) context).lookup(KieSession.class);
logger.debug("About to retrigger node instance with id {} on process instance {}", nodeInstanceId, processInstanceId);
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 retriggered", nodeInstance);
((NodeInstanceImpl) nodeInstance).retrigger(true);
logger.debug("Node instance {} retriggered successfully", nodeInstance);
return null;
}
Aggregations