Search in sources :

Example 1 with Node

use of io.automatiko.engine.workflow.process.core.Node 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 2 with Node

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

the class CompositeContextNodeHandler method writeNode.

public void writeNode(Node node, StringBuilder xmlDump, int metaDataType) {
    CompositeContextNode compositeNode = (CompositeContextNode) node;
    String nodeType = "subProcess";
    if (node.getMetaData().get("Transaction") != null) {
        nodeType = "transaction";
    }
    writeNode(nodeType, compositeNode, xmlDump, metaDataType);
    if (compositeNode instanceof EventSubProcessNode) {
        xmlDump.append(" triggeredByEvent=\"true\" ");
    }
    Object isForCompensationObject = compositeNode.getMetaData("isForCompensation");
    if (isForCompensationObject != null && ((Boolean) isForCompensationObject)) {
        xmlDump.append("isForCompensation=\"true\" ");
    }
    xmlDump.append(">" + EOL);
    writeExtensionElements(compositeNode, xmlDump);
    // variables
    VariableScope variableScope = (VariableScope) compositeNode.getDefaultContext(VariableScope.VARIABLE_SCOPE);
    if (variableScope != null && !variableScope.getVariables().isEmpty()) {
        xmlDump.append("    <!-- variables -->" + EOL);
        for (Variable variable : variableScope.getVariables()) {
            xmlDump.append("    <property id=\"" + XmlBPMNProcessDumper.replaceIllegalCharsAttribute(variable.getName()) + "\" ");
            if (variable.getType() != null) {
                xmlDump.append("itemSubjectRef=\"" + XmlBPMNProcessDumper.getUniqueNodeId(compositeNode) + "-" + XmlBPMNProcessDumper.replaceIllegalCharsAttribute(variable.getName()) + "Item\"");
            }
            // TODO: value
            xmlDump.append("/>" + EOL);
        }
    }
    // nodes
    List<Node> subNodes = getSubNodes(compositeNode);
    XmlBPMNProcessDumper.INSTANCE.visitNodes(subNodes, xmlDump, metaDataType);
    // connections
    visitConnectionsAndAssociations(compositeNode, xmlDump, metaDataType);
    endNode(nodeType, xmlDump);
}
Also used : Variable(io.automatiko.engine.workflow.base.core.context.variable.Variable) CompositeContextNode(io.automatiko.engine.workflow.process.core.node.CompositeContextNode) EventSubProcessNode(io.automatiko.engine.workflow.process.core.node.EventSubProcessNode) CompositeContextNode(io.automatiko.engine.workflow.process.core.node.CompositeContextNode) CompositeNode(io.automatiko.engine.workflow.process.core.node.CompositeNode) Node(io.automatiko.engine.workflow.process.core.Node) EventSubProcessNode(io.automatiko.engine.workflow.process.core.node.EventSubProcessNode) VariableScope(io.automatiko.engine.workflow.base.core.context.variable.VariableScope)

Example 3 with Node

use of io.automatiko.engine.workflow.process.core.Node 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 4 with Node

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

the class AbstractNodeHandler method getErrorIdForErrorCode.

protected String getErrorIdForErrorCode(String errorCode, Node node) {
    io.automatiko.engine.api.definition.process.NodeContainer parent = node.getParentContainer();
    while (!(parent instanceof ExecutableProcess) && parent instanceof Node) {
        parent = ((Node) parent).getParentContainer();
    }
    if (!(parent instanceof ExecutableProcess)) {
        throw new RuntimeException("This should never happen: !(parent instanceof RuleFlowProcess): parent is " + parent.getClass().getSimpleName());
    }
    List<Error> errors = ((Definitions) ((ExecutableProcess) parent).getMetaData("Definitions")).getErrors();
    Error error = null;
    for (Error listError : errors) {
        if (errorCode.equals(listError.getErrorCode())) {
            error = listError;
            break;
        } else if (errorCode.equals(listError.getId())) {
            error = listError;
            break;
        }
    }
    if (error == null) {
        throw new IllegalArgumentException("Could not find error with errorCode " + errorCode);
    }
    return error.getId();
}
Also used : 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) Definitions(io.automatiko.engine.workflow.bpmn2.core.Definitions) Error(io.automatiko.engine.workflow.bpmn2.core.Error) ExecutableProcess(io.automatiko.engine.workflow.process.executable.core.ExecutableProcess)

Example 5 with Node

use of io.automatiko.engine.workflow.process.core.Node 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

Node (io.automatiko.engine.workflow.process.core.Node)36 ActionNode (io.automatiko.engine.workflow.process.core.node.ActionNode)19 EndNode (io.automatiko.engine.workflow.process.core.node.EndNode)19 CompositeContextNode (io.automatiko.engine.workflow.process.core.node.CompositeContextNode)16 StartNode (io.automatiko.engine.workflow.process.core.node.StartNode)16 WorkItemNode (io.automatiko.engine.workflow.process.core.node.WorkItemNode)16 BoundaryEventNode (io.automatiko.engine.workflow.process.core.node.BoundaryEventNode)15 ArrayList (java.util.ArrayList)14 NodeContainer (io.automatiko.engine.workflow.process.core.NodeContainer)13 EventSubProcessNode (io.automatiko.engine.workflow.process.core.node.EventSubProcessNode)13 ExecutableProcess (io.automatiko.engine.workflow.process.executable.core.ExecutableProcess)13 CompositeNode (io.automatiko.engine.workflow.process.core.node.CompositeNode)12 ProcessBuildData (io.automatiko.engine.workflow.compiler.xml.ProcessBuildData)11 Element (org.w3c.dom.Element)11 EventNode (io.automatiko.engine.workflow.process.core.node.EventNode)10 ForEachNode (io.automatiko.engine.workflow.process.core.node.ForEachNode)10 AbstractBaseTest (io.automatiko.engine.workflow.test.util.AbstractBaseTest)8 Test (org.junit.jupiter.api.Test)8 SubProcessNode (io.automatiko.engine.workflow.process.core.node.SubProcessNode)6 TimerNode (io.automatiko.engine.workflow.process.core.node.TimerNode)6