Search in sources :

Example 1 with CompositeNode

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

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

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

the class NodeInnerClassesTest method testNodeReading.

@Test
public void testNodeReading() {
    ExecutableProcess process = new ExecutableProcess();
    process.setId("org.company.core.process.event");
    process.setName("Event Process");
    List<Variable> variables = new ArrayList<Variable>();
    Variable variable = new Variable();
    variable.setName("event");
    ObjectDataType personDataType = new ObjectDataType(Person.class);
    variable.setType(personDataType);
    variables.add(variable);
    process.getVariableScope().setVariables(variables);
    process.setDynamic(true);
    CompositeNode compositeNode = new CompositeNode();
    compositeNode.setName("CompositeNode");
    compositeNode.setId(2);
    ForEachNode forEachNode = new ForEachNode();
    ForEachNode.ForEachSplitNode split = new ForEachNode.ForEachSplitNode();
    split.setName("ForEachSplit");
    split.setMetaData("hidden", true);
    split.setMetaData("UniqueId", forEachNode.getMetaData("Uniqueid") + ":foreach:split");
    forEachNode.internalAddNode(split);
    forEachNode.linkIncomingConnections(io.automatiko.engine.workflow.process.core.Node.CONNECTION_DEFAULT_TYPE, new CompositeNode.NodeAndType(split, io.automatiko.engine.workflow.process.core.Node.CONNECTION_DEFAULT_TYPE));
    process.addNode(forEachNode);
    InternalProcessRuntime ksession = createProcessRuntime(process);
    TestProcessEventListener procEventListener = new TestProcessEventListener();
    ksession.addEventListener(procEventListener);
    ProcessInstance processInstance = ksession.startProcess("org.company.core.process.event");
    assertNotNull(processInstance);
}
Also used : Variable(io.automatiko.engine.workflow.base.core.context.variable.Variable) ArrayList(java.util.ArrayList) ObjectDataType(io.automatiko.engine.workflow.base.core.datatype.impl.type.ObjectDataType) CompositeNode(io.automatiko.engine.workflow.process.core.node.CompositeNode) ExecutableProcess(io.automatiko.engine.workflow.process.executable.core.ExecutableProcess) ForEachNode(io.automatiko.engine.workflow.process.core.node.ForEachNode) InternalProcessRuntime(io.automatiko.engine.workflow.base.instance.InternalProcessRuntime) ProcessInstance(io.automatiko.engine.api.runtime.process.ProcessInstance) TestProcessEventListener(io.automatiko.engine.workflow.process.test.TestProcessEventListener) Test(org.junit.jupiter.api.Test) AbstractBaseTest(io.automatiko.engine.workflow.test.util.AbstractBaseTest)

Example 4 with CompositeNode

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

the class CompositeNodeHandler method writeNode.

public void writeNode(Node node, StringBuilder xmlDump, boolean includeMeta) {
    super.writeNode(getNodeName(), node, xmlDump, includeMeta);
    CompositeNode compositeNode = (CompositeNode) node;
    writeAttributes(compositeNode, xmlDump, includeMeta);
    xmlDump.append(">" + EOL);
    if (includeMeta) {
        writeMetaData(compositeNode, xmlDump);
    }
    for (String eventType : compositeNode.getActionTypes()) {
        writeActions(eventType, compositeNode.getActions(eventType), xmlDump);
    }
    writeTimers(compositeNode.getTimers(), xmlDump);
    if (compositeNode instanceof CompositeContextNode) {
        VariableScope variableScope = (VariableScope) ((CompositeContextNode) compositeNode).getDefaultContext(VariableScope.VARIABLE_SCOPE);
        if (variableScope != null) {
            List<Variable> variables = variableScope.getVariables();
            XmlWorkflowProcessDumper.visitVariables(variables, xmlDump);
        }
        ExceptionScope exceptionScope = (ExceptionScope) ((CompositeContextNode) compositeNode).getDefaultContext(ExceptionScope.EXCEPTION_SCOPE);
        if (exceptionScope != null) {
            XmlWorkflowProcessDumper.visitExceptionHandlers(exceptionScope.getExceptionHandlers(), xmlDump);
        }
    }
    xmlDump.append("      </connections>" + EOL);
    Map<String, CompositeNode.NodeAndType> inPorts = getInPorts(compositeNode);
    xmlDump.append("      <in-ports>" + EOL);
    for (Map.Entry<String, CompositeNode.NodeAndType> entry : inPorts.entrySet()) {
        xmlDump.append("        <in-port type=\"" + entry.getKey() + "\" nodeId=\"" + entry.getValue().getNodeId() + "\" nodeInType=\"" + entry.getValue().getType() + "\" />" + EOL);
    }
    xmlDump.append("      </in-ports>" + EOL);
    Map<String, CompositeNode.NodeAndType> outPorts = getOutPorts(compositeNode);
    xmlDump.append("      <out-ports>" + EOL);
    for (Map.Entry<String, CompositeNode.NodeAndType> entry : outPorts.entrySet()) {
        xmlDump.append("        <out-port type=\"" + entry.getKey() + "\" nodeId=\"" + entry.getValue().getNodeId() + "\" nodeOutType=\"" + entry.getValue().getType() + "\" />" + EOL);
    }
    xmlDump.append("      </out-ports>" + EOL);
    endNode(getNodeName(), xmlDump);
}
Also used : CompositeNode(io.automatiko.engine.workflow.process.core.node.CompositeNode) Variable(io.automatiko.engine.workflow.base.core.context.variable.Variable) CompositeContextNode(io.automatiko.engine.workflow.process.core.node.CompositeContextNode) ExceptionScope(io.automatiko.engine.workflow.base.core.context.exception.ExceptionScope) Map(java.util.Map) VariableScope(io.automatiko.engine.workflow.base.core.context.variable.VariableScope)

Example 5 with CompositeNode

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

the class InPortHandler method start.

public Object start(final String uri, final String localName, final Attributes attrs, final ExtensibleXmlParser parser) throws SAXException {
    parser.startElementBuilder(localName, attrs);
    CompositeNode compositeNode = (CompositeNode) parser.getParent();
    final String type = attrs.getValue("type");
    emptyAttributeCheck(localName, "type", type, parser);
    final String nodeId = attrs.getValue("nodeId");
    emptyAttributeCheck(localName, "nodeId", nodeId, parser);
    final String nodeInType = attrs.getValue("nodeInType");
    emptyAttributeCheck(localName, "nodeInType", nodeInType, parser);
    compositeNode.linkIncomingConnections(type, new Long(nodeId), nodeInType);
    return null;
}
Also used : CompositeNode(io.automatiko.engine.workflow.process.core.node.CompositeNode)

Aggregations

CompositeNode (io.automatiko.engine.workflow.process.core.node.CompositeNode)27 EndNode (io.automatiko.engine.workflow.process.core.node.EndNode)16 StartNode (io.automatiko.engine.workflow.process.core.node.StartNode)16 ArrayList (java.util.ArrayList)15 ActionNode (io.automatiko.engine.workflow.process.core.node.ActionNode)14 Node (io.automatiko.engine.api.definition.process.Node)13 EventNode (io.automatiko.engine.workflow.process.core.node.EventNode)13 EventSubProcessNode (io.automatiko.engine.workflow.process.core.node.EventSubProcessNode)12 WorkItemNode (io.automatiko.engine.workflow.process.core.node.WorkItemNode)12 FaultNode (io.automatiko.engine.workflow.process.core.node.FaultNode)11 List (java.util.List)11 ExecutableProcess (io.automatiko.engine.workflow.process.executable.core.ExecutableProcess)10 BoundaryEventNode (io.automatiko.engine.workflow.process.core.node.BoundaryEventNode)9 Variable (io.automatiko.engine.workflow.base.core.context.variable.Variable)8 CompositeContextNode (io.automatiko.engine.workflow.process.core.node.CompositeContextNode)8 ForEachNode (io.automatiko.engine.workflow.process.core.node.ForEachNode)8 StateNode (io.automatiko.engine.workflow.process.core.node.StateNode)8 NodeContainer (io.automatiko.engine.api.definition.process.NodeContainer)7 EventTypeFilter (io.automatiko.engine.workflow.base.core.event.EventTypeFilter)7 VariableScope (io.automatiko.engine.workflow.base.core.context.variable.VariableScope)6