use of org.jbpm.workflow.instance.node.CompositeNodeInstance in project jbpm by kiegroup.
the class ProcessServiceImpl method collectActiveSignals.
protected Collection<String> collectActiveSignals(Collection<NodeInstance> activeNodes) {
Collection<String> activeNodesComposite = new ArrayList<>();
for (NodeInstance nodeInstance : activeNodes) {
if (nodeInstance instanceof EventNodeInstance) {
String type = ((EventNodeInstance) nodeInstance).getEventNode().getType();
if (type != null && !type.startsWith("Message-")) {
activeNodesComposite.add(VariableUtil.resolveVariable(type, nodeInstance));
}
}
if (nodeInstance instanceof CompositeNodeInstance) {
Collection<NodeInstance> currentNodeInstances = ((CompositeNodeInstance) nodeInstance).getNodeInstances();
// recursively check current nodes
activeNodesComposite.addAll(collectActiveSignals(currentNodeInstances));
}
}
return activeNodesComposite;
}
use of org.jbpm.workflow.instance.node.CompositeNodeInstance in project jbpm by kiegroup.
the class WorkflowProcessInstanceImpl method nodeInstanceCompleted.
public void nodeInstanceCompleted(NodeInstance nodeInstance, String outType) {
Node nodeInstanceNode = nodeInstance.getNode();
if (nodeInstanceNode != null) {
Object compensationBoolObj = nodeInstanceNode.getMetaData().get("isForCompensation");
boolean isForCompensation = compensationBoolObj == null ? false : ((Boolean) compensationBoolObj);
if (isForCompensation) {
return;
}
}
if (nodeInstance instanceof EndNodeInstance || ((org.jbpm.workflow.core.WorkflowProcess) getWorkflowProcess()).isDynamic() || nodeInstance instanceof CompositeNodeInstance) {
if (((org.jbpm.workflow.core.WorkflowProcess) getProcess()).isAutoComplete()) {
if (canComplete()) {
setState(ProcessInstance.STATE_COMPLETED);
}
}
} else {
throw new IllegalArgumentException("Completing a node instance that has no outgoing connection is not supported.");
}
}
use of org.jbpm.workflow.instance.node.CompositeNodeInstance in project jbpm by kiegroup.
the class CompensationEventListener method createNodeInstanceContainers.
private Stack<NodeInstance> createNodeInstanceContainers(Node toCompensateNode, boolean generalCompensation) {
Stack<NodeContainer> nestedNodes = new Stack<NodeContainer>();
Stack<NodeInstance> generatedInstances = new Stack<NodeInstance>();
NodeContainer parentContainer = toCompensateNode.getNodeContainer();
while (!(parentContainer instanceof RuleFlowProcess)) {
nestedNodes.add(parentContainer);
parentContainer = ((Node) parentContainer).getNodeContainer();
}
NodeInstanceContainer parentInstance;
if (nestedNodes.isEmpty()) {
// nestedNodes is empty
parentInstance = (NodeInstanceContainer) getProcessInstance();
} else {
parentInstance = (NodeInstanceContainer) ((WorkflowProcessInstanceImpl) getProcessInstance()).getNodeInstance((Node) nestedNodes.pop());
generatedInstances.add((NodeInstance) parentInstance);
}
NodeInstanceContainer childInstance = parentInstance;
while (!nestedNodes.isEmpty()) {
// generate
childInstance = (NodeInstanceContainer) parentInstance.getNodeInstance((Node) nestedNodes.pop());
assert childInstance instanceof CompositeNodeInstance : "A node with child nodes should end up creating a CompositeNodeInstance type.";
// track and modify
generatedInstances.add((NodeInstance) childInstance);
// loop
parentInstance = (CompositeContextNodeInstance) childInstance;
}
if (generalCompensation) {
childInstance = (NodeInstanceContainer) parentInstance.getNodeInstance(toCompensateNode);
generatedInstances.add((NodeInstance) childInstance);
}
return generatedInstances;
}
use of org.jbpm.workflow.instance.node.CompositeNodeInstance in project jbpm by kiegroup.
the class NodeInstanceImpl method getUniqueId.
public String getUniqueId() {
String result = "" + getId();
NodeInstanceContainer parent = getNodeInstanceContainer();
while (parent instanceof CompositeNodeInstance) {
CompositeNodeInstance nodeInstance = (CompositeNodeInstance) parent;
result = nodeInstance.getId() + ":" + result;
parent = nodeInstance.getNodeInstanceContainer();
}
return result;
}
Aggregations