use of org.jbpm.services.api.NodeNotFoundException in project jbpm by kiegroup.
the class TriggerNodeCommand method execute.
public Void execute(Context context) {
KieSession kieSession = ((RegistryContext) context).lookup(KieSession.class);
logger.debug("About to trigger (create) node instance for node {} in process instance {}", nodeId, processInstanceId);
RuleFlowProcessInstance wfp = (RuleFlowProcessInstance) kieSession.getProcessInstance(processInstanceId, false);
if (wfp == null) {
throw new ProcessInstanceNotFoundException("Process instance with id " + processInstanceId + " not found");
}
Node node = wfp.getRuleFlowProcess().getNodesRecursively().stream().filter(ni -> ni.getId() == nodeId).findFirst().orElse(null);
if (node == null) {
throw new NodeNotFoundException("Node instance with id " + nodeId + " not found");
}
logger.debug("Triggering node {} on process instance {}", node, wfp);
wfp.getNodeInstance(node).trigger(null, org.jbpm.workflow.core.Node.CONNECTION_DEFAULT_TYPE);
logger.debug("Node {} successfully triggered", node);
return null;
}
Aggregations