Search in sources :

Example 16 with NodeContainer

use of io.automatiko.engine.api.definition.process.NodeContainer in project automatiko-engine by automatiko-io.

the class BPMNPlaneHandler method processNodeInfo.

private boolean processNodeInfo(NodeInfo nodeInfo, Node[] nodes) {
    if (nodeInfo == null || nodeInfo.getNodeRef() == null) {
        return false;
    }
    for (Node node : nodes) {
        String id = (String) node.getMetaData().get("UniqueId");
        if (nodeInfo.getNodeRef().equals(id)) {
            ((io.automatiko.engine.workflow.process.core.Node) node).setMetaData("x", nodeInfo.getX());
            ((io.automatiko.engine.workflow.process.core.Node) node).setMetaData("y", nodeInfo.getY());
            ((io.automatiko.engine.workflow.process.core.Node) node).setMetaData("width", nodeInfo.getWidth());
            ((io.automatiko.engine.workflow.process.core.Node) node).setMetaData("height", nodeInfo.getHeight());
            return true;
        }
        if (node instanceof NodeContainer) {
            boolean found = processNodeInfo(nodeInfo, ((NodeContainer) node).getNodes());
            if (found) {
                return true;
            }
        }
    }
    return false;
}
Also used : ForEachNode(io.automatiko.engine.workflow.process.core.node.ForEachNode) Node(io.automatiko.engine.api.definition.process.Node) NodeContainer(io.automatiko.engine.api.definition.process.NodeContainer)

Example 17 with NodeContainer

use of io.automatiko.engine.api.definition.process.NodeContainer in project automatiko-engine by automatiko-io.

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.getParentContainer();
    while (!(parentContainer instanceof ExecutableProcess)) {
        nestedNodes.add(parentContainer);
        parentContainer = ((Node) parentContainer).getParentContainer();
    }
    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;
    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 = childInstance;
    }
    if (generalCompensation) {
        childInstance = (NodeInstanceContainer) parentInstance.getNodeInstance(toCompensateNode);
        generatedInstances.add((NodeInstance) childInstance);
    }
    return generatedInstances;
}
Also used : NodeInstanceContainer(io.automatiko.engine.workflow.process.instance.NodeInstanceContainer) CompositeNodeInstance(io.automatiko.engine.workflow.process.instance.node.CompositeNodeInstance) NodeContainer(io.automatiko.engine.api.definition.process.NodeContainer) ExecutableProcess(io.automatiko.engine.workflow.process.executable.core.ExecutableProcess) NodeInstance(io.automatiko.engine.workflow.process.instance.NodeInstance) CompositeNodeInstance(io.automatiko.engine.workflow.process.instance.node.CompositeNodeInstance) Stack(java.util.Stack)

Aggregations

NodeContainer (io.automatiko.engine.api.definition.process.NodeContainer)17 Node (io.automatiko.engine.api.definition.process.Node)12 CompositeNode (io.automatiko.engine.workflow.process.core.node.CompositeNode)10 EndNode (io.automatiko.engine.workflow.process.core.node.EndNode)9 EventSubProcessNode (io.automatiko.engine.workflow.process.core.node.EventSubProcessNode)9 StartNode (io.automatiko.engine.workflow.process.core.node.StartNode)9 ActionNode (io.automatiko.engine.workflow.process.core.node.ActionNode)8 WorkItemNode (io.automatiko.engine.workflow.process.core.node.WorkItemNode)8 BoundaryEventNode (io.automatiko.engine.workflow.process.core.node.BoundaryEventNode)7 EventNode (io.automatiko.engine.workflow.process.core.node.EventNode)7 FaultNode (io.automatiko.engine.workflow.process.core.node.FaultNode)7 ForEachNode (io.automatiko.engine.workflow.process.core.node.ForEachNode)5 RuleSetNode (io.automatiko.engine.workflow.process.core.node.RuleSetNode)5 StateBasedNode (io.automatiko.engine.workflow.process.core.node.StateBasedNode)5 StateNode (io.automatiko.engine.workflow.process.core.node.StateNode)5 SubProcessNode (io.automatiko.engine.workflow.process.core.node.SubProcessNode)5 EventFilter (io.automatiko.engine.workflow.base.core.event.EventFilter)4 EventTypeFilter (io.automatiko.engine.workflow.base.core.event.EventTypeFilter)4 ConnectionImpl (io.automatiko.engine.workflow.process.core.impl.ConnectionImpl)4 ExtendedNodeImpl (io.automatiko.engine.workflow.process.core.impl.ExtendedNodeImpl)4