Search in sources :

Example 21 with NodeContainer

use of io.automatiko.engine.workflow.process.core.NodeContainer in project automatiko-engine by automatiko-io.

the class EndEventHandler method end.

public Object end(final String uri, final String localName, final ExtensibleXmlParser parser) throws SAXException {
    final Element element = parser.endElementBuilder();
    Node node = (Node) parser.getCurrent();
    // determine type of event definition, so the correct type of node
    // can be generated
    super.handleNode(node, element, uri, localName, parser);
    org.w3c.dom.Node xmlNode = element.getFirstChild();
    while (xmlNode != null) {
        String nodeName = xmlNode.getNodeName();
        if ("terminateEventDefinition".equals(nodeName)) {
            // reuse already created EndNode
            handleTerminateNode(node, element, uri, localName, parser);
            node.setMetaData("functionFlowContinue", "true");
            break;
        } else if ("signalEventDefinition".equals(nodeName)) {
            handleSignalNode(node, element, uri, localName, parser);
            node.setMetaData("functionFlowContinue", "true");
        } else if ("messageEventDefinition".equals(nodeName)) {
            handleMessageNode(node, element, uri, localName, parser);
            node.setMetaData("functionFlowContinue", "true");
        } else if ("errorEventDefinition".equals(nodeName)) {
            // create new faultNode
            FaultNode faultNode = new FaultNode();
            faultNode.setId(node.getId());
            faultNode.setName(node.getName());
            faultNode.setTerminateParent(true);
            faultNode.setMetaData("UniqueId", node.getMetaData().get("UniqueId"));
            node = faultNode;
            super.handleNode(node, element, uri, localName, parser);
            handleErrorNode(node, element, uri, localName, parser);
            node.setMetaData("functionFlowContinue", "true");
            break;
        } else if ("escalationEventDefinition".equals(nodeName)) {
            // create new faultNode
            FaultNode faultNode = new FaultNode();
            faultNode.setId(node.getId());
            faultNode.setName(node.getName());
            faultNode.setMetaData("UniqueId", node.getMetaData().get("UniqueId"));
            node = faultNode;
            super.handleNode(node, element, uri, localName, parser);
            handleEscalationNode(node, element, uri, localName, parser);
            node.setMetaData("functionFlowContinue", "true");
            break;
        } else if ("compensateEventDefinition".equals(nodeName)) {
            // reuse already created ActionNode
            handleThrowCompensationEventNode(node, element, uri, localName, parser);
            node.setMetaData("functionFlowContinue", "true");
            break;
        }
        xmlNode = xmlNode.getNextSibling();
    }
    NodeContainer nodeContainer = (NodeContainer) parser.getParent();
    nodeContainer.addNode(node);
    ((ProcessBuildData) parser.getData()).addNode(node);
    return node;
}
Also used : FaultNode(io.automatiko.engine.workflow.process.core.node.FaultNode) ProcessBuildData(io.automatiko.engine.workflow.compiler.xml.ProcessBuildData) Element(org.w3c.dom.Element) FaultNode(io.automatiko.engine.workflow.process.core.node.FaultNode) Node(io.automatiko.engine.workflow.process.core.Node) EndNode(io.automatiko.engine.workflow.process.core.node.EndNode) NodeContainer(io.automatiko.engine.workflow.process.core.NodeContainer)

Example 22 with NodeContainer

use of io.automatiko.engine.workflow.process.core.NodeContainer in project automatiko-engine by automatiko-io.

the class ScriptTaskHandler method end.

public Object end(final String uri, final String localName, final ExtensibleXmlParser parser) throws SAXException {
    final Element element = parser.endElementBuilder();
    Node node = (Node) parser.getCurrent();
    // determine type of event definition, so the correct type of node can be generated
    handleNode(node, element, uri, localName, parser);
    org.w3c.dom.Node xmlNode = element.getFirstChild();
    int uniqueIdGen = 1;
    while (xmlNode != null) {
        String nodeName = xmlNode.getNodeName();
        if ("multiInstanceLoopCharacteristics".equals(nodeName)) {
            // create new timerNode
            ForEachNode forEachNode = new ForEachNode();
            forEachNode.setId(node.getId());
            String uniqueId = (String) node.getMetaData().get("UniqueId");
            forEachNode.setMetaData("UniqueId", uniqueId);
            node.setMetaData("UniqueId", uniqueId + ":" + uniqueIdGen++);
            forEachNode.addNode(node);
            forEachNode.linkIncomingConnections(NodeImpl.CONNECTION_DEFAULT_TYPE, node.getId(), NodeImpl.CONNECTION_DEFAULT_TYPE);
            forEachNode.linkOutgoingConnections(node.getId(), NodeImpl.CONNECTION_DEFAULT_TYPE, NodeImpl.CONNECTION_DEFAULT_TYPE);
            forEachNode.setSequential(Boolean.parseBoolean(((Element) xmlNode).getAttribute("isSequential")));
            Node orignalNode = node;
            node = forEachNode;
            handleForEachNode(node, element, uri, localName, parser);
            // remove input/output collection data input/output of for each to avoid problems when running in variable strict mode
            if (orignalNode instanceof ActionNode) {
                adjustNodeConfiguration(orignalNode, forEachNode);
            }
            break;
        }
        xmlNode = xmlNode.getNextSibling();
    }
    NodeContainer nodeContainer = (NodeContainer) parser.getParent();
    nodeContainer.addNode(node);
    ((ProcessBuildData) parser.getData()).addNode(node);
    return node;
}
Also used : ProcessBuildData(io.automatiko.engine.workflow.compiler.xml.ProcessBuildData) Element(org.w3c.dom.Element) ForEachNode(io.automatiko.engine.workflow.process.core.node.ForEachNode) ActionNode(io.automatiko.engine.workflow.process.core.node.ActionNode) Node(io.automatiko.engine.workflow.process.core.Node) ActionNode(io.automatiko.engine.workflow.process.core.node.ActionNode) ForEachNode(io.automatiko.engine.workflow.process.core.node.ForEachNode) NodeContainer(io.automatiko.engine.workflow.process.core.NodeContainer)

Example 23 with NodeContainer

use of io.automatiko.engine.workflow.process.core.NodeContainer in project automatiko-engine by automatiko-io.

the class SubProcessHandler method end.

public Object end(final String uri, final String localName, final ExtensibleXmlParser parser) throws SAXException {
    final Element element = parser.endElementBuilder();
    Node node = (Node) parser.getCurrent();
    // determine type of event definition, so the correct type of node can be
    // generated
    boolean found = false;
    org.w3c.dom.Node xmlNode = element.getFirstChild();
    while (xmlNode != null) {
        String nodeName = xmlNode.getNodeName();
        if ("multiInstanceLoopCharacteristics".equals(nodeName)) {
            Boolean isAsync = Boolean.parseBoolean((String) node.getMetaData().get("customAsync"));
            // create new timerNode
            ForEachNode forEachNode = new ForEachNode();
            forEachNode.setId(node.getId());
            forEachNode.setName(node.getName());
            forEachNode.setSequential(Boolean.parseBoolean(((Element) xmlNode).getAttribute("isSequential")));
            forEachNode.setAutoComplete(((CompositeContextNode) node).isAutoComplete());
            // for (io.automatiko.engine.api.definition.process.Node subNode : ((CompositeContextNode) node)
            // .getNodes()) {
            // 
            // forEachNode.addNode(subNode);
            // }
            forEachNode.addNode(node);
            forEachNode.linkIncomingConnections(NodeImpl.CONNECTION_DEFAULT_TYPE, node.getId(), NodeImpl.CONNECTION_DEFAULT_TYPE);
            forEachNode.linkOutgoingConnections(node.getId(), NodeImpl.CONNECTION_DEFAULT_TYPE, NodeImpl.CONNECTION_DEFAULT_TYPE);
            forEachNode.setMetaData("UniqueId", ((CompositeContextNode) node).getMetaData("UniqueId"));
            // forEachNode.setMetaData(ProcessHandler.CONNECTIONS,
            // ((CompositeContextNode) node).getMetaData(ProcessHandler.CONNECTIONS));
            VariableScope v = (VariableScope) ((CompositeContextNode) node).getDefaultContext(VariableScope.VARIABLE_SCOPE);
            // ((VariableScope) ((CompositeContextNode) forEachNode.internalGetNode(2))
            // .getDefaultContext(VariableScope.VARIABLE_SCOPE)).setVariables(v.getVariables());
            List<SequenceFlow> connections = (List<SequenceFlow>) ((CompositeContextNode) node).getMetaData(ProcessHandler.CONNECTIONS);
            ProcessHandler processHandler = new ProcessHandler();
            processHandler.linkConnections((io.automatiko.engine.api.definition.process.NodeContainer) node, connections);
            processHandler.linkBoundaryEvents((io.automatiko.engine.api.definition.process.NodeContainer) node);
            node = forEachNode;
            handleForEachNode(node, element, uri, localName, parser, isAsync);
            found = true;
            break;
        }
        xmlNode = xmlNode.getNextSibling();
    }
    if (!found) {
        handleCompositeContextNode(node, element, uri, localName, parser);
    }
    NodeContainer nodeContainer = (NodeContainer) parser.getParent();
    nodeContainer.addNode(node);
    ((ProcessBuildData) parser.getData()).addNode(node);
    return node;
}
Also used : SequenceFlow(io.automatiko.engine.workflow.bpmn2.core.SequenceFlow) Element(org.w3c.dom.Element) ForEachNode(io.automatiko.engine.workflow.process.core.node.ForEachNode) EventSubProcessNode(io.automatiko.engine.workflow.process.core.node.EventSubProcessNode) CompositeContextNode(io.automatiko.engine.workflow.process.core.node.CompositeContextNode) StartNode(io.automatiko.engine.workflow.process.core.node.StartNode) Node(io.automatiko.engine.workflow.process.core.Node) NodeContainer(io.automatiko.engine.workflow.process.core.NodeContainer) ProcessBuildData(io.automatiko.engine.workflow.compiler.xml.ProcessBuildData) ForEachNode(io.automatiko.engine.workflow.process.core.node.ForEachNode) List(java.util.List) VariableScope(io.automatiko.engine.workflow.base.core.context.variable.VariableScope)

Example 24 with NodeContainer

use of io.automatiko.engine.workflow.process.core.NodeContainer in project automatiko-engine by automatiko-io.

the class TaskHandler method end.

public Object end(final String uri, final String localName, final ExtensibleXmlParser parser) throws SAXException {
    final Element element = parser.endElementBuilder();
    Node node = (Node) parser.getCurrent();
    // determine type of event definition, so the correct type of node can be
    // generated
    handleNode(node, element, uri, localName, parser);
    org.w3c.dom.Node xmlNode = element.getFirstChild();
    int uniqueIdGen = 1;
    while (xmlNode != null) {
        String nodeName = xmlNode.getNodeName();
        if ("multiInstanceLoopCharacteristics".equals(nodeName)) {
            // create new timerNode
            ForEachNode forEachNode = new ForEachNode();
            forEachNode.setId(node.getId());
            String uniqueId = (String) node.getMetaData().get("UniqueId");
            forEachNode.setMetaData("UniqueId", uniqueId);
            node.setMetaData("UniqueId", uniqueId + ":" + uniqueIdGen++);
            forEachNode.addNode(node);
            forEachNode.linkIncomingConnections(NodeImpl.CONNECTION_DEFAULT_TYPE, node.getId(), NodeImpl.CONNECTION_DEFAULT_TYPE);
            forEachNode.linkOutgoingConnections(node.getId(), NodeImpl.CONNECTION_DEFAULT_TYPE, NodeImpl.CONNECTION_DEFAULT_TYPE);
            forEachNode.setSequential(Boolean.parseBoolean(((Element) xmlNode).getAttribute("isSequential")));
            Node orignalNode = node;
            node = forEachNode;
            handleForEachNode(node, element, uri, localName, parser);
            // running in variable strict mode
            if (orignalNode instanceof WorkItemNode) {
                adjustNodeConfiguration(orignalNode, forEachNode);
            }
            break;
        }
        xmlNode = xmlNode.getNextSibling();
    }
    // replace node in case it's milestone
    if (node instanceof WorkItemNode && ((WorkItemNode) node).getWork().getName().equals("Milestone")) {
        WorkItemNode workItemNode = (WorkItemNode) node;
        String milestoneCondition = (String) ((WorkItemNode) node).getWork().getParameter(CONDITION);
        MilestoneNode milestoneNode = new MilestoneNode();
        milestoneNode.setId(workItemNode.getId());
        milestoneNode.setMetaData(workItemNode.getMetaData());
        milestoneNode.setConditionExpression(milestoneCondition);
        milestoneNode.setName(workItemNode.getName());
        milestoneNode.setParentContainer(workItemNode.getParentContainer());
        node = milestoneNode;
    }
    NodeContainer nodeContainer = (NodeContainer) parser.getParent();
    nodeContainer.addNode(node);
    ((ProcessBuildData) parser.getData()).addNode(node);
    return node;
}
Also used : ProcessBuildData(io.automatiko.engine.workflow.compiler.xml.ProcessBuildData) Element(org.w3c.dom.Element) Node(io.automatiko.engine.workflow.process.core.Node) ForEachNode(io.automatiko.engine.workflow.process.core.node.ForEachNode) MilestoneNode(io.automatiko.engine.workflow.process.core.node.MilestoneNode) WorkItemNode(io.automatiko.engine.workflow.process.core.node.WorkItemNode) WorkItemNode(io.automatiko.engine.workflow.process.core.node.WorkItemNode) ForEachNode(io.automatiko.engine.workflow.process.core.node.ForEachNode) NodeContainer(io.automatiko.engine.workflow.process.core.NodeContainer) MilestoneNode(io.automatiko.engine.workflow.process.core.node.MilestoneNode)

Example 25 with NodeContainer

use of io.automatiko.engine.workflow.process.core.NodeContainer in project automatiko-engine by automatiko-io.

the class StartNodeFactory method timer.

public StartNodeFactory timer(String delay, String period, String date, int timeType) {
    Timer timer = new Timer();
    timer.setDate(date);
    timer.setDelay(delay);
    timer.setPeriod(period);
    timer.setTimeType(timeType);
    getStartNode().setTimer(timer);
    if (nodeContainer instanceof CompositeContextNode) {
        ProcessAction noop = new ProcessAction();
        Action action = kcontext -> {
        };
        noop.wire(action);
        ((CompositeContextNode) nodeContainer).addTimer(timer, noop);
    }
    return this;
}
Also used : ProcessAction(io.automatiko.engine.workflow.process.core.ProcessAction) Arrays(java.util.Arrays) Timer(io.automatiko.engine.workflow.base.core.timer.Timer) Assignment(io.automatiko.engine.workflow.process.core.node.Assignment) Predicate(java.util.function.Predicate) ProcessAction(io.automatiko.engine.workflow.process.core.ProcessAction) NodeContainer(io.automatiko.engine.workflow.process.core.NodeContainer) ExecutableNodeContainerFactory(io.automatiko.engine.workflow.process.executable.core.ExecutableNodeContainerFactory) ProcessContext(io.automatiko.engine.api.runtime.process.ProcessContext) Action(io.automatiko.engine.workflow.base.instance.impl.Action) List(java.util.List) EventTypeFilter(io.automatiko.engine.workflow.base.core.event.EventTypeFilter) DataAssociation(io.automatiko.engine.workflow.process.core.node.DataAssociation) CompositeContextNode(io.automatiko.engine.workflow.process.core.node.CompositeContextNode) StartNode(io.automatiko.engine.workflow.process.core.node.StartNode) Mappable(io.automatiko.engine.workflow.base.core.context.variable.Mappable) EventTrigger(io.automatiko.engine.workflow.process.core.node.EventTrigger) Node(io.automatiko.engine.workflow.process.core.Node) ProcessAction(io.automatiko.engine.workflow.process.core.ProcessAction) Action(io.automatiko.engine.workflow.base.instance.impl.Action) Timer(io.automatiko.engine.workflow.base.core.timer.Timer) CompositeContextNode(io.automatiko.engine.workflow.process.core.node.CompositeContextNode)

Aggregations

NodeContainer (io.automatiko.engine.workflow.process.core.NodeContainer)25 Node (io.automatiko.engine.workflow.process.core.Node)12 List (java.util.List)11 ProcessBuildData (io.automatiko.engine.workflow.compiler.xml.ProcessBuildData)10 ActionNode (io.automatiko.engine.workflow.process.core.node.ActionNode)10 ArrayList (java.util.ArrayList)10 ExecutableProcess (io.automatiko.engine.workflow.process.executable.core.ExecutableProcess)9 CompositeContextNode (io.automatiko.engine.workflow.process.core.node.CompositeContextNode)8 EventNode (io.automatiko.engine.workflow.process.core.node.EventNode)8 ForEachNode (io.automatiko.engine.workflow.process.core.node.ForEachNode)8 WorkItemNode (io.automatiko.engine.workflow.process.core.node.WorkItemNode)8 Element (org.w3c.dom.Element)8 Node (io.automatiko.engine.api.definition.process.Node)7 BoundaryEventNode (io.automatiko.engine.workflow.process.core.node.BoundaryEventNode)7 EndNode (io.automatiko.engine.workflow.process.core.node.EndNode)7 StartNode (io.automatiko.engine.workflow.process.core.node.StartNode)7 VariableScope (io.automatiko.engine.workflow.base.core.context.variable.VariableScope)6 ProcessAction (io.automatiko.engine.workflow.process.core.ProcessAction)6 ConsequenceAction (io.automatiko.engine.workflow.process.core.impl.ConsequenceAction)6 Assignment (io.automatiko.engine.workflow.process.core.node.Assignment)6