use of org.jbpm.workflow.instance.NodeInstance in project jbpm by kiegroup.
the class RuleFlowProcessInstance method internalStart.
public void internalStart(String trigger) {
StartNode startNode = getRuleFlowProcess().getStart(trigger);
if (startNode != null) {
((NodeInstance) getNodeInstance(startNode)).trigger(null, null);
}
// activate ad hoc fragments if they are marked as such
List<Node> autoStartNodes = getRuleFlowProcess().getAutoStartNodes();
autoStartNodes.forEach(austoStartNode -> signalEvent(austoStartNode.getName(), null));
}
use of org.jbpm.workflow.instance.NodeInstance in project jbpm by kiegroup.
the class DefaultExceptionScopeInstance method handleException.
public void handleException(ExceptionHandler handler, String exception, Object params) {
if (handler instanceof ActionExceptionHandler) {
ActionExceptionHandler exceptionHandler = (ActionExceptionHandler) handler;
Action action = (Action) exceptionHandler.getAction().getMetaData("Action");
try {
ProcessInstance processInstance = getProcessInstance();
ProcessContext processContext = new ProcessContext(processInstance.getKnowledgeRuntime());
ContextInstanceContainer contextInstanceContainer = getContextInstanceContainer();
if (contextInstanceContainer instanceof NodeInstance) {
processContext.setNodeInstance((NodeInstance) contextInstanceContainer);
} else {
processContext.setProcessInstance(processInstance);
}
String faultVariable = exceptionHandler.getFaultVariable();
if (faultVariable != null) {
processContext.setVariable(faultVariable, params);
}
action.execute(processContext);
} catch (Exception e) {
throw new RuntimeException("unable to execute Action", e);
}
} else {
throw new IllegalArgumentException("Unknown exception handler " + handler);
}
}
use of org.jbpm.workflow.instance.NodeInstance in project jbpm by kiegroup.
the class CompositeNodeInstance method triggerCompleted.
public void triggerCompleted(String outType) {
boolean cancelRemainingInstances = getCompositeNode().isCancelRemainingInstances();
((org.jbpm.workflow.instance.NodeInstanceContainer) getNodeInstanceContainer()).setCurrentLevel(getLevel());
triggerCompleted(outType, cancelRemainingInstances);
if (cancelRemainingInstances) {
while (!nodeInstances.isEmpty()) {
NodeInstance nodeInstance = (NodeInstance) nodeInstances.get(0);
((org.jbpm.workflow.instance.NodeInstance) nodeInstance).cancel();
}
}
}
use of org.jbpm.workflow.instance.NodeInstance in project jbpm by kiegroup.
the class CompositeNodeInstance method internalTrigger.
public void internalTrigger(final org.kie.api.runtime.process.NodeInstance from, String type) {
super.internalTrigger(from, type);
// if node instance was cancelled, abort
if (getNodeInstanceContainer().getNodeInstance(getId()) == null) {
return;
}
CompositeNode.NodeAndType nodeAndType = getCompositeNode().internalGetLinkedIncomingNode(type);
if (nodeAndType != null) {
List<Connection> connections = nodeAndType.getNode().getIncomingConnections(nodeAndType.getType());
for (Iterator<Connection> iterator = connections.iterator(); iterator.hasNext(); ) {
Connection connection = iterator.next();
if ((connection.getFrom() instanceof CompositeNode.CompositeNodeStart) && (from == null || ((CompositeNode.CompositeNodeStart) connection.getFrom()).getInNode().getId() == from.getNodeId())) {
NodeInstance nodeInstance = getNodeInstance(connection.getFrom());
((org.jbpm.workflow.instance.NodeInstance) nodeInstance).trigger(null, nodeAndType.getType());
return;
}
}
} else {
// try to search for start nodes
boolean found = false;
for (Node node : getCompositeNode().getNodes()) {
if (node instanceof StartNode) {
StartNode startNode = (StartNode) node;
if (startNode.getTriggers() == null || startNode.getTriggers().isEmpty()) {
NodeInstance nodeInstance = getNodeInstance(startNode);
((org.jbpm.workflow.instance.NodeInstance) nodeInstance).trigger(null, null);
found = true;
}
}
}
if (found) {
return;
}
}
if (isLinkedIncomingNodeRequired()) {
throw new IllegalArgumentException("Could not find start for composite node: " + type);
}
}
use of org.jbpm.workflow.instance.NodeInstance in project jbpm by kiegroup.
the class CompositeNodeInstance method cancel.
public void cancel() {
while (!nodeInstances.isEmpty()) {
NodeInstance nodeInstance = (NodeInstance) nodeInstances.get(0);
((org.jbpm.workflow.instance.NodeInstance) nodeInstance).cancel();
}
super.cancel();
}
Aggregations