Search in sources :

Example 1 with NodeContainer

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

the class DefinitionsHandler method postProcessNodes.

protected void postProcessNodes(NodeContainer nodeContainer, List<Variable> parentVariables, ExtensibleXmlParser parser) throws SAXException {
    for (Node node : nodeContainer.getNodes()) {
        List<Variable> variables = new LinkedList<>(parentVariables);
        VariableScope variableScope = (VariableScope) ((ContextContainer) nodeContainer).getDefaultContext(VariableScope.VARIABLE_SCOPE);
        if (variableScope != null) {
            variables.addAll(variableScope.getVariables());
        }
        if (node instanceof NodeContainer) {
            postProcessNodes((NodeContainer) node, variables, parser);
        } else {
            if (node instanceof ActionNode) {
                ActionNode actionNode = (ActionNode) node;
                ProcessAction action = actionNode.getAction();
                if (action instanceof ConsequenceAction) {
                    ConsequenceAction consequenceAction = (ConsequenceAction) action;
                    switch(consequenceAction.getDialect()) {
                        case "java":
                            if (actionNode.getAction().getMetaData("Action") == null) {
                                actionNode.getAction().setMetaData("Action", new MvelAction(actionNode));
                            }
                            break;
                        case "mvel":
                            if (actionNode.getAction().getMetaData("Action") == null) {
                                actionNode.getAction().setMetaData("Action", new MvelAction(actionNode));
                            }
                            break;
                        default:
                    }
                }
            }
        }
    }
}
Also used : ProcessAction(io.automatiko.engine.workflow.process.core.ProcessAction) Variable(io.automatiko.engine.workflow.base.core.context.variable.Variable) Node(io.automatiko.engine.api.definition.process.Node) ForEachNode(io.automatiko.engine.workflow.process.core.node.ForEachNode) ActionNode(io.automatiko.engine.workflow.process.core.node.ActionNode) WorkItemNode(io.automatiko.engine.workflow.process.core.node.WorkItemNode) ConsequenceAction(io.automatiko.engine.workflow.process.core.impl.ConsequenceAction) ActionNode(io.automatiko.engine.workflow.process.core.node.ActionNode) NodeContainer(io.automatiko.engine.workflow.process.core.NodeContainer) LinkedList(java.util.LinkedList) VariableScope(io.automatiko.engine.workflow.base.core.context.variable.VariableScope)

Example 2 with NodeContainer

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

the class IntermediateCatchEventHandler 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
    org.w3c.dom.Node xmlNode = element.getFirstChild();
    while (xmlNode != null) {
        String nodeName = xmlNode.getNodeName();
        if ("signalEventDefinition".equals(nodeName)) {
            // reuse already created EventNode
            handleSignalNode(node, element, uri, localName, parser);
            node.setMetaData(EVENT_TYPE, "signal");
            node.setMetaData("functionFlowContinue", "true");
            break;
        } else if ("messageEventDefinition".equals(nodeName)) {
            // reuse already created EventNode
            handleMessageNode(node, element, uri, localName, parser);
            node.setMetaData(EVENT_TYPE, "message");
            node.setMetaData("functionFlowContinue", "true");
            break;
        } else if ("timerEventDefinition".equals(nodeName)) {
            // create new timerNode
            TimerNode timerNode = new TimerNode();
            timerNode.setId(node.getId());
            timerNode.setName(node.getName());
            timerNode.setMetaData("UniqueId", node.getMetaData().get("UniqueId"));
            node = timerNode;
            node.setMetaData(EVENT_TYPE, "timer");
            handleTimerNode(node, element, uri, localName, parser);
            node.setMetaData("functionFlowContinue", "true");
            break;
        } else if ("conditionalEventDefinition".equals(nodeName)) {
            // create new stateNode
            StateNode stateNode = new StateNode();
            stateNode.setId(node.getId());
            stateNode.setName(node.getName());
            stateNode.setMetaData("UniqueId", node.getMetaData().get("UniqueId"));
            node = stateNode;
            node.setMetaData(EVENT_TYPE, "conditional");
            handleStateNode(node, element, uri, localName, parser);
            node.setMetaData("functionFlowContinue", "true");
            break;
        } else if ("linkEventDefinition".equals(nodeName)) {
            CatchLinkNode linkNode = new CatchLinkNode();
            linkNode.setId(node.getId());
            node = linkNode;
            node.setMetaData(EVENT_TYPE, "link");
            handleLinkNode(element, node, xmlNode, parser);
            break;
        }
        xmlNode = xmlNode.getNextSibling();
    }
    node.setMetaData("DataOutputs", new LinkedHashMap<String, String>(dataOutputTypes));
    NodeContainer nodeContainer = (NodeContainer) parser.getParent();
    nodeContainer.addNode(node);
    ((ProcessBuildData) parser.getData()).addNode(node);
    return node;
}
Also used : CatchLinkNode(io.automatiko.engine.workflow.process.core.node.CatchLinkNode) ProcessBuildData(io.automatiko.engine.workflow.compiler.xml.ProcessBuildData) Element(org.w3c.dom.Element) TimerNode(io.automatiko.engine.workflow.process.core.node.TimerNode) CompositeNode(io.automatiko.engine.workflow.process.core.node.CompositeNode) CatchLinkNode(io.automatiko.engine.workflow.process.core.node.CatchLinkNode) Node(io.automatiko.engine.workflow.process.core.Node) StateNode(io.automatiko.engine.workflow.process.core.node.StateNode) EventNode(io.automatiko.engine.workflow.process.core.node.EventNode) StateNode(io.automatiko.engine.workflow.process.core.node.StateNode) NodeContainer(io.automatiko.engine.workflow.process.core.NodeContainer) TimerNode(io.automatiko.engine.workflow.process.core.node.TimerNode)

Example 3 with NodeContainer

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

the class IntermediateCatchEventHandler method handleLinkNode.

protected void handleLinkNode(Element element, Node node, org.w3c.dom.Node xmlLinkNode, ExtensibleXmlParser parser) {
    NodeContainer nodeContainer = (NodeContainer) parser.getParent();
    node.setName(element.getAttribute("name"));
    NamedNodeMap linkAttr = xmlLinkNode.getAttributes();
    String name = linkAttr.getNamedItem("name").getNodeValue();
    String id = element.getAttribute("id");
    node.setMetaData("UniqueId", id);
    node.setMetaData(LINK_NAME, name);
    org.w3c.dom.Node xmlNode = xmlLinkNode.getFirstChild();
    IntermediateLink aLink = new IntermediateLink();
    aLink.setName(name);
    aLink.setUniqueId(id);
    while (null != xmlNode) {
        String nodeName = xmlNode.getNodeName();
        if ("target".equals(nodeName)) {
            String target = xmlNode.getTextContent();
            node.setMetaData("target", target);
            aLink.setTarget(target);
        }
        if ("source".equals(nodeName)) {
            String source = xmlNode.getTextContent();
            node.setMetaData("source", source);
            aLink.addSource(source);
        }
        xmlNode = xmlNode.getNextSibling();
    }
    if (nodeContainer instanceof ExecutableProcess) {
        ExecutableProcess process = (ExecutableProcess) nodeContainer;
        List<IntermediateLink> links = (List<IntermediateLink>) process.getMetaData().get(ProcessHandler.LINKS);
        if (null == links) {
            links = new ArrayList<IntermediateLink>();
        }
        links.add(aLink);
        process.setMetaData(ProcessHandler.LINKS, links);
    } else if (nodeContainer instanceof CompositeNode) {
        CompositeNode subprocess = (CompositeNode) nodeContainer;
        List<IntermediateLink> links = (List<IntermediateLink>) subprocess.getMetaData().get(ProcessHandler.LINKS);
        if (null == links) {
            links = new ArrayList<IntermediateLink>();
        }
        links.add(aLink);
        subprocess.setMetaData(ProcessHandler.LINKS, links);
    }
}
Also used : NamedNodeMap(org.w3c.dom.NamedNodeMap) ArrayList(java.util.ArrayList) NodeContainer(io.automatiko.engine.workflow.process.core.NodeContainer) IntermediateLink(io.automatiko.engine.workflow.bpmn2.core.IntermediateLink) CompositeNode(io.automatiko.engine.workflow.process.core.node.CompositeNode) ExecutableProcess(io.automatiko.engine.workflow.process.executable.core.ExecutableProcess) ArrayList(java.util.ArrayList) List(java.util.List)

Example 4 with NodeContainer

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

the class BusinessRuleTaskHandler 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 RuleSetNode) {
                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) RuleSetNode(io.automatiko.engine.workflow.process.core.node.RuleSetNode) Element(org.w3c.dom.Element) ForEachNode(io.automatiko.engine.workflow.process.core.node.ForEachNode) RuleSetNode(io.automatiko.engine.workflow.process.core.node.RuleSetNode) Node(io.automatiko.engine.workflow.process.core.Node) ForEachNode(io.automatiko.engine.workflow.process.core.node.ForEachNode) NodeContainer(io.automatiko.engine.workflow.process.core.NodeContainer)

Example 5 with NodeContainer

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

the class AbstractNodeHandler 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();
    handleNode(node, element, uri, localName, parser);
    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) ActionNode(io.automatiko.engine.workflow.process.core.node.ActionNode) EndNode(io.automatiko.engine.workflow.process.core.node.EndNode) EventNode(io.automatiko.engine.workflow.process.core.node.EventNode) NodeContainer(io.automatiko.engine.workflow.process.core.NodeContainer)

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