Search in sources :

Example 1 with NodeNotFoundException

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;
}
Also used : RuleFlowProcessInstance(org.jbpm.ruleflow.instance.RuleFlowProcessInstance) NodeNotFoundException(org.jbpm.services.api.NodeNotFoundException) Node(org.kie.api.definition.process.Node) KieSession(org.kie.api.runtime.KieSession) RegistryContext(org.drools.core.command.impl.RegistryContext) ProcessInstanceNotFoundException(org.jbpm.services.api.ProcessInstanceNotFoundException)

Aggregations

RegistryContext (org.drools.core.command.impl.RegistryContext)1 RuleFlowProcessInstance (org.jbpm.ruleflow.instance.RuleFlowProcessInstance)1 NodeNotFoundException (org.jbpm.services.api.NodeNotFoundException)1 ProcessInstanceNotFoundException (org.jbpm.services.api.ProcessInstanceNotFoundException)1 Node (org.kie.api.definition.process.Node)1 KieSession (org.kie.api.runtime.KieSession)1