Search in sources :

Example 1 with ForEachNode

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

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

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

the class ForEachNodeHandler method handleNode.

protected void handleNode(final Node node, final Element element, final String uri, final String localName, final ExtensibleXmlParser parser) throws SAXException {
    super.handleNode(node, element, uri, localName, parser);
    ForEachNode forEachNode = (ForEachNode) node;
    final String variableName = element.getAttribute("variableName");
    if (variableName != null && variableName.length() != 0) {
        forEachNode.setVariable(variableName, new ObjectDataType());
    }
    final String collectionExpression = element.getAttribute("collectionExpression");
    if (collectionExpression != null && collectionExpression.length() != 0) {
        forEachNode.setCollectionExpression(collectionExpression);
    }
    final String waitForCompletion = element.getAttribute("waitForCompletion");
    if ("false".equals(waitForCompletion)) {
        forEachNode.setWaitForCompletion(false);
    }
}
Also used : ForEachNode(io.automatiko.engine.workflow.process.core.node.ForEachNode) ObjectDataType(io.automatiko.engine.workflow.base.core.datatype.impl.type.ObjectDataType)

Example 4 with ForEachNode

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

the class ForEachNodeHandler method writeAttributes.

protected void writeAttributes(CompositeNode compositeNode, StringBuilder xmlDump, boolean includeMeta) {
    ForEachNode forEachNode = (ForEachNode) compositeNode;
    String variableName = forEachNode.getVariableName();
    if (variableName != null) {
        xmlDump.append("variableName=\"" + variableName + "\" ");
    }
    String collectionExpression = forEachNode.getCollectionExpression();
    if (collectionExpression != null) {
        xmlDump.append("collectionExpression=\"" + XmlDumper.replaceIllegalChars(collectionExpression) + "\" ");
    }
    boolean waitForCompletion = forEachNode.isWaitForCompletion();
    if (!waitForCompletion) {
        xmlDump.append("waitForCompletion=\"false\" ");
    }
}
Also used : ForEachNode(io.automatiko.engine.workflow.process.core.node.ForEachNode)

Example 5 with ForEachNode

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

the class SvgBpmnProcessImageGenerator method buildNodeContainer.

/*
     * Build methods
     */
protected void buildNodeContainer(int x, int y, NodeContainer nodeContainer, SVGGraphics2D g2) {
    try {
        for (Node node : nodeContainer.getNodes()) {
            if (node instanceof StartNode) {
                buildStartEvent(x, y, (StartNode) node, g2);
            } else if (node instanceof EndNode) {
                buildEndEvent(x, y, (EndNode) node, g2);
            } else if (node instanceof FaultNode) {
                buildErrorEndEvent(x, y, (FaultNode) node, g2);
            } else if (node instanceof BoundaryEventNode) {
                buildBoundaryEvent(x, y, node, g2);
            } else if (node instanceof EventNode || node instanceof StateNode) {
                buildIntermediateEvent(x, y, node, g2);
            } else if (node instanceof HumanTaskNode) {
                buildHumanTaskNode(x, y, (HumanTaskNode) node, g2);
            } else if (node instanceof ActionNode) {
                buildScriptTaskNode(x, y, (ActionNode) node, g2);
            } else if (node instanceof WorkItemNode) {
                buildServiceTaskNode(x, y, (WorkItemNode) node, g2);
            } else if (node instanceof Split || node instanceof Join) {
                buildGateway(x, y, node, g2);
            } else if (node instanceof ForEachNode) {
                buildNodeContainer(x(node), y(node), ((ForEachNode) node).getCompositeNode(), g2);
            } else if (node instanceof CompositeNode) {
                buildSubprocessNode(x, y, (CompositeNode) node, g2);
                int sx = x(node);
                int sy = y(node);
                buildNodeContainer(sx, sy, (CompositeNode) node, g2);
            } else if (node instanceof RuleSetNode) {
                buildBusinessRuleTaskNode(x, y, (RuleSetNode) node, g2);
            } else if (node instanceof TimerNode) {
                buildTimerEvent(x, y, (TimerNode) node, g2);
            } else if (node instanceof SubProcessNode) {
                buildCallActivity(x, y, (SubProcessNode) node, g2);
            }
            buildSequenceFlow(x, y, node, g2);
        }
    } catch (IOException e) {
        throw new UncheckedIOException(e);
    }
}
Also used : StartNode(io.automatiko.engine.workflow.process.core.node.StartNode) RuleSetNode(io.automatiko.engine.workflow.process.core.node.RuleSetNode) SubProcessNode(io.automatiko.engine.workflow.process.core.node.SubProcessNode) RuleSetNode(io.automatiko.engine.workflow.process.core.node.RuleSetNode) TimerNode(io.automatiko.engine.workflow.process.core.node.TimerNode) CompositeNode(io.automatiko.engine.workflow.process.core.node.CompositeNode) Node(io.automatiko.engine.api.definition.process.Node) HumanTaskNode(io.automatiko.engine.workflow.process.core.node.HumanTaskNode) BoundaryEventNode(io.automatiko.engine.workflow.process.core.node.BoundaryEventNode) ForEachNode(io.automatiko.engine.workflow.process.core.node.ForEachNode) ActionNode(io.automatiko.engine.workflow.process.core.node.ActionNode) FaultNode(io.automatiko.engine.workflow.process.core.node.FaultNode) EventSubProcessNode(io.automatiko.engine.workflow.process.core.node.EventSubProcessNode) StateNode(io.automatiko.engine.workflow.process.core.node.StateNode) WorkItemNode(io.automatiko.engine.workflow.process.core.node.WorkItemNode) StartNode(io.automatiko.engine.workflow.process.core.node.StartNode) EndNode(io.automatiko.engine.workflow.process.core.node.EndNode) EventNode(io.automatiko.engine.workflow.process.core.node.EventNode) StateNode(io.automatiko.engine.workflow.process.core.node.StateNode) ActionNode(io.automatiko.engine.workflow.process.core.node.ActionNode) Join(io.automatiko.engine.workflow.process.core.node.Join) UncheckedIOException(java.io.UncheckedIOException) BoundaryEventNode(io.automatiko.engine.workflow.process.core.node.BoundaryEventNode) IOException(java.io.IOException) UncheckedIOException(java.io.UncheckedIOException) FaultNode(io.automatiko.engine.workflow.process.core.node.FaultNode) BoundaryEventNode(io.automatiko.engine.workflow.process.core.node.BoundaryEventNode) EventNode(io.automatiko.engine.workflow.process.core.node.EventNode) CompositeNode(io.automatiko.engine.workflow.process.core.node.CompositeNode) EndNode(io.automatiko.engine.workflow.process.core.node.EndNode) SubProcessNode(io.automatiko.engine.workflow.process.core.node.SubProcessNode) EventSubProcessNode(io.automatiko.engine.workflow.process.core.node.EventSubProcessNode) WorkItemNode(io.automatiko.engine.workflow.process.core.node.WorkItemNode) ForEachNode(io.automatiko.engine.workflow.process.core.node.ForEachNode) TimerNode(io.automatiko.engine.workflow.process.core.node.TimerNode) Split(io.automatiko.engine.workflow.process.core.node.Split) HumanTaskNode(io.automatiko.engine.workflow.process.core.node.HumanTaskNode)

Aggregations

ForEachNode (io.automatiko.engine.workflow.process.core.node.ForEachNode)18 Node (io.automatiko.engine.workflow.process.core.Node)6 ProcessBuildData (io.automatiko.engine.workflow.compiler.xml.ProcessBuildData)5 NodeContainer (io.automatiko.engine.workflow.process.core.NodeContainer)5 CompositeNode (io.automatiko.engine.workflow.process.core.node.CompositeNode)5 Element (org.w3c.dom.Element)5 Node (io.automatiko.engine.api.definition.process.Node)4 ActionNode (io.automatiko.engine.workflow.process.core.node.ActionNode)4 StartNode (io.automatiko.engine.workflow.process.core.node.StartNode)4 WorkItemNode (io.automatiko.engine.workflow.process.core.node.WorkItemNode)4 List (java.util.List)4 ObjectDataType (io.automatiko.engine.workflow.base.core.datatype.impl.type.ObjectDataType)3 EndNode (io.automatiko.engine.workflow.process.core.node.EndNode)3 EventNode (io.automatiko.engine.workflow.process.core.node.EventNode)3 EventSubProcessNode (io.automatiko.engine.workflow.process.core.node.EventSubProcessNode)3 FaultNode (io.automatiko.engine.workflow.process.core.node.FaultNode)3 RuleSetNode (io.automatiko.engine.workflow.process.core.node.RuleSetNode)3 SubProcessNode (io.automatiko.engine.workflow.process.core.node.SubProcessNode)3 Work (io.automatiko.engine.workflow.base.core.Work)2 EventTypeFilter (io.automatiko.engine.workflow.base.core.event.EventTypeFilter)2