Search in sources :

Example 1 with CompositeNodeInstance

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;
}
Also used : CompositeNodeInstance(org.jbpm.workflow.instance.node.CompositeNodeInstance) ArrayList(java.util.ArrayList) NodeInstance(org.kie.api.runtime.process.NodeInstance) EventNodeInstance(org.jbpm.workflow.instance.node.EventNodeInstance) CompositeNodeInstance(org.jbpm.workflow.instance.node.CompositeNodeInstance) EventNodeInstance(org.jbpm.workflow.instance.node.EventNodeInstance)

Example 2 with CompositeNodeInstance

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.");
    }
}
Also used : CompositeNodeInstance(org.jbpm.workflow.instance.node.CompositeNodeInstance) DynamicNode(org.jbpm.workflow.core.node.DynamicNode) AsyncEventNode(org.jbpm.workflow.core.node.AsyncEventNode) StateBasedNode(org.jbpm.workflow.core.node.StateBasedNode) EventSubProcessNode(org.jbpm.workflow.core.node.EventSubProcessNode) ActionNode(org.jbpm.workflow.core.node.ActionNode) EndNode(org.jbpm.workflow.core.node.EndNode) EventNode(org.jbpm.workflow.core.node.EventNode) Node(org.kie.api.definition.process.Node) EndNodeInstance(org.jbpm.workflow.instance.node.EndNodeInstance) WorkflowProcess(org.kie.api.definition.process.WorkflowProcess)

Example 3 with CompositeNodeInstance

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;
}
Also used : RuleFlowProcess(org.jbpm.ruleflow.core.RuleFlowProcess) NodeInstanceContainer(org.jbpm.workflow.instance.NodeInstanceContainer) CompositeNodeInstance(org.jbpm.workflow.instance.node.CompositeNodeInstance) NodeContainer(org.kie.api.definition.process.NodeContainer) NodeInstance(org.jbpm.workflow.instance.NodeInstance) CompositeNodeInstance(org.jbpm.workflow.instance.node.CompositeNodeInstance) CompositeContextNodeInstance(org.jbpm.workflow.instance.node.CompositeContextNodeInstance) Stack(java.util.Stack)

Example 4 with CompositeNodeInstance

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;
}
Also used : NodeInstanceContainer(org.kie.api.runtime.process.NodeInstanceContainer) CompositeNodeInstance(org.jbpm.workflow.instance.node.CompositeNodeInstance)

Aggregations

CompositeNodeInstance (org.jbpm.workflow.instance.node.CompositeNodeInstance)4 ArrayList (java.util.ArrayList)1 Stack (java.util.Stack)1 RuleFlowProcess (org.jbpm.ruleflow.core.RuleFlowProcess)1 ActionNode (org.jbpm.workflow.core.node.ActionNode)1 AsyncEventNode (org.jbpm.workflow.core.node.AsyncEventNode)1 DynamicNode (org.jbpm.workflow.core.node.DynamicNode)1 EndNode (org.jbpm.workflow.core.node.EndNode)1 EventNode (org.jbpm.workflow.core.node.EventNode)1 EventSubProcessNode (org.jbpm.workflow.core.node.EventSubProcessNode)1 StateBasedNode (org.jbpm.workflow.core.node.StateBasedNode)1 NodeInstance (org.jbpm.workflow.instance.NodeInstance)1 NodeInstanceContainer (org.jbpm.workflow.instance.NodeInstanceContainer)1 CompositeContextNodeInstance (org.jbpm.workflow.instance.node.CompositeContextNodeInstance)1 EndNodeInstance (org.jbpm.workflow.instance.node.EndNodeInstance)1 EventNodeInstance (org.jbpm.workflow.instance.node.EventNodeInstance)1 Node (org.kie.api.definition.process.Node)1 NodeContainer (org.kie.api.definition.process.NodeContainer)1 WorkflowProcess (org.kie.api.definition.process.WorkflowProcess)1 NodeInstance (org.kie.api.runtime.process.NodeInstance)1