Search in sources :

Example 6 with StartNode

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

the class StartNodeHandler method writeNode.

public void writeNode(Node node, StringBuilder xmlDump, boolean includeMeta) {
    StartNode startNode = (StartNode) node;
    writeNode("start", startNode, xmlDump, includeMeta);
    List<Trigger> triggers = startNode.getTriggers();
    if ((triggers == null || triggers.isEmpty()) && (!includeMeta || !containsMetaData(startNode))) {
        endNode(xmlDump);
    } else {
        xmlDump.append(">" + EOL);
        if (includeMeta) {
            writeMetaData(startNode, xmlDump);
        }
        if (triggers != null) {
            xmlDump.append("      <triggers>" + EOL);
            for (Trigger trigger : triggers) {
                if (trigger instanceof ConstraintTrigger) {
                    xmlDump.append("        <trigger type=\"constraint\" >" + EOL);
                    xmlDump.append("          <constraint type=\"rule\" dialect=\"mvel\" >" + ((ConstraintTrigger) trigger).getConstraint() + "</constraint>" + EOL);
                    Map<String, String> inMappings = trigger.getInMappings();
                    if (inMappings != null && !inMappings.isEmpty()) {
                        for (Map.Entry<String, String> entry : inMappings.entrySet()) {
                            xmlDump.append("          <mapping type=\"in\" from=\"" + XmlDumper.replaceIllegalChars(entry.getValue()) + "\" to=\"" + entry.getKey() + "\" />" + EOL);
                        }
                    }
                    xmlDump.append("        </trigger>" + EOL);
                } else if (trigger instanceof EventTrigger) {
                    xmlDump.append("        <trigger type=\"event\" >" + EOL);
                    xmlDump.append("          <eventFilters>" + EOL);
                    for (EventFilter filter : ((EventTrigger) trigger).getEventFilters()) {
                        if (filter instanceof EventTypeFilter) {
                            xmlDump.append("             <eventFilter " + "type=\"eventType\" " + "eventType=\"" + ((EventTypeFilter) filter).getType() + "\" />" + EOL);
                        } else {
                            throw new IllegalArgumentException("Unknown filter type: " + filter);
                        }
                    }
                    xmlDump.append("          </eventFilters>" + EOL);
                    Map<String, String> inMappings = trigger.getInMappings();
                    if (inMappings != null && !inMappings.isEmpty()) {
                        for (Map.Entry<String, String> entry : inMappings.entrySet()) {
                            xmlDump.append("          <mapping type=\"in\" from=\"" + XmlDumper.replaceIllegalChars(entry.getValue()) + "\" to=\"" + entry.getKey() + "\" />" + EOL);
                        }
                    }
                    xmlDump.append("        </trigger>" + EOL);
                } else {
                    throw new IllegalArgumentException("Unknown trigger type " + trigger);
                }
            }
            xmlDump.append("      </triggers>" + EOL);
        }
        endNode("start", xmlDump);
    }
}
Also used : ConstraintTrigger(io.automatiko.engine.workflow.process.core.node.ConstraintTrigger) StartNode(io.automatiko.engine.workflow.process.core.node.StartNode) EventFilter(io.automatiko.engine.workflow.base.core.event.EventFilter) EventTypeFilter(io.automatiko.engine.workflow.base.core.event.EventTypeFilter) Trigger(io.automatiko.engine.workflow.process.core.node.Trigger) EventTrigger(io.automatiko.engine.workflow.process.core.node.EventTrigger) ConstraintTrigger(io.automatiko.engine.workflow.process.core.node.ConstraintTrigger) Map(java.util.Map) EventTrigger(io.automatiko.engine.workflow.process.core.node.EventTrigger)

Example 7 with StartNode

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

the class TriggerHandler method start.

public Object start(final String uri, final String localName, final Attributes attrs, final ExtensibleXmlParser parser) throws SAXException {
    parser.startElementBuilder(localName, attrs);
    StartNode startNode = (StartNode) parser.getParent();
    String type = attrs.getValue("type");
    emptyAttributeCheck(localName, "type", type, parser);
    Trigger trigger = null;
    if ("constraint".equals(type)) {
        trigger = new ConstraintTrigger();
    } else if ("event".equals(type)) {
        trigger = new EventTrigger();
    } else {
        throw new SAXException("Unknown trigger type " + type);
    }
    startNode.addTrigger(trigger);
    return trigger;
}
Also used : ConstraintTrigger(io.automatiko.engine.workflow.process.core.node.ConstraintTrigger) StartNode(io.automatiko.engine.workflow.process.core.node.StartNode) Trigger(io.automatiko.engine.workflow.process.core.node.Trigger) EventTrigger(io.automatiko.engine.workflow.process.core.node.EventTrigger) ConstraintTrigger(io.automatiko.engine.workflow.process.core.node.ConstraintTrigger) EventTrigger(io.automatiko.engine.workflow.process.core.node.EventTrigger) SAXException(org.xml.sax.SAXException)

Example 8 with StartNode

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

Example 9 with StartNode

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

the class ExecutableProcessFactory method postProcessNodes.

private void postProcessNodes(ExecutableProcess process, NodeContainer container) {
    List<String> eventSubProcessHandlers = new ArrayList<String>();
    for (Node node : container.getNodes()) {
        if (node instanceof NodeContainer) {
            // prepare event sub process
            if (node instanceof EventSubProcessNode) {
                EventSubProcessNode eventSubProcessNode = (EventSubProcessNode) node;
                Node[] nodes = eventSubProcessNode.getNodes();
                for (Node subNode : nodes) {
                    // avoids cyclomatic complexity
                    if (subNode instanceof StartNode) {
                        processEventSubprocessStartNode(process, ((StartNode) subNode), eventSubProcessNode, eventSubProcessHandlers);
                    }
                }
            }
            postProcessNodes(process, (NodeContainer) node);
        }
    }
    // process fault node to disable termnate parent if there is event subprocess handler
    for (Node node : container.getNodes()) {
        if (node instanceof FaultNode) {
            FaultNode faultNode = (FaultNode) node;
            if (eventSubProcessHandlers.contains(faultNode.getFaultName())) {
                faultNode.setTerminateParent(false);
            }
        }
    }
}
Also used : FaultNode(io.automatiko.engine.workflow.process.core.node.FaultNode) StartNode(io.automatiko.engine.workflow.process.core.node.StartNode) EventSubProcessNode(io.automatiko.engine.workflow.process.core.node.EventSubProcessNode) StateBasedNode(io.automatiko.engine.workflow.process.core.node.StateBasedNode) FaultNode(io.automatiko.engine.workflow.process.core.node.FaultNode) EventSubProcessNode(io.automatiko.engine.workflow.process.core.node.EventSubProcessNode) CompositeNode(io.automatiko.engine.workflow.process.core.node.CompositeNode) Node(io.automatiko.engine.api.definition.process.Node) 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) ArrayList(java.util.ArrayList) NodeContainer(io.automatiko.engine.api.definition.process.NodeContainer)

Example 10 with StartNode

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

the class ExecutableProcessFactory method executionTimeout.

public ExecutableProcessFactory executionTimeout(int nodeIdCounter, String timeoutExpression, long... extranodes) {
    int nodeId = ++nodeIdCounter;
    EventSubProcessNodeFactory eventSubProcessNode4 = eventSubProcessNode(nodeId);
    eventSubProcessNode4.name("Execution timeout");
    eventSubProcessNode4.metaData("UniqueId", "SubProcess_" + nodeId);
    eventSubProcessNode4.metaData("hidden_node", true);
    eventSubProcessNode4.keepActive(true);
    eventSubProcessNode4.event("Timer-" + nodeId);
    eventSubProcessNode4.autoComplete(true);
    int startNodeId = ++nodeIdCounter;
    StartNodeFactory startNode5 = eventSubProcessNode4.startNode(startNodeId);
    startNode5.name("Execution timeout :: start");
    startNode5.interrupting(true);
    startNode5.metaData("UniqueId", "StartEvent_" + startNodeId);
    startNode5.metaData("TriggerType", "Timer");
    startNode5.done();
    startNode5.timer(timeoutExpression, null, null, 1);
    int endNodeId = ++nodeIdCounter;
    EndNodeFactory endNode7 = eventSubProcessNode4.endNode(endNodeId);
    endNode7.name("Execution timeout :: end");
    endNode7.terminate(false);
    endNode7.metaData("UniqueId", "EndEvent_" + endNodeId);
    endNode7.done();
    if (extranodes != null && extranodes.length > 0) {
        for (long extraNodId : extranodes) {
            Node node = getNodeContainer().getNode(extraNodId);
            getNodeContainer().removeNode(node);
            eventSubProcessNode4.getNodeContainer().addNode(node);
        }
        if (extranodes.length == 1) {
            eventSubProcessNode4.connection(startNodeId, extranodes[0], "SequenceFlow_e_" + startNodeId);
            eventSubProcessNode4.connection(extranodes[0], endNodeId, "SequenceFlow_e_" + endNodeId);
        } else {
            eventSubProcessNode4.connection(startNodeId, extranodes[0], "SequenceFlow_e_" + startNodeId);
            int counter = 1;
            for (long extraNodId : extranodes) {
                if (counter > extranodes.length) {
                    eventSubProcessNode4.connection(extraNodId, extranodes[counter], "SequenceFlow_e_" + counter);
                    counter++;
                }
            }
            eventSubProcessNode4.connection(extranodes[extranodes.length - 1], endNodeId, "SequenceFlow_e_" + endNodeId);
        }
    } else {
        eventSubProcessNode4.connection(startNodeId, endNodeId, "SequenceFlow_" + startNodeId);
    }
    eventSubProcessNode4.done();
    return this;
}
Also used : EventSubProcessNodeFactory(io.automatiko.engine.workflow.process.executable.core.factory.EventSubProcessNodeFactory) StartNodeFactory(io.automatiko.engine.workflow.process.executable.core.factory.StartNodeFactory) StateBasedNode(io.automatiko.engine.workflow.process.core.node.StateBasedNode) FaultNode(io.automatiko.engine.workflow.process.core.node.FaultNode) EventSubProcessNode(io.automatiko.engine.workflow.process.core.node.EventSubProcessNode) CompositeNode(io.automatiko.engine.workflow.process.core.node.CompositeNode) Node(io.automatiko.engine.api.definition.process.Node) 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) EndNodeFactory(io.automatiko.engine.workflow.process.executable.core.factory.EndNodeFactory)

Aggregations

StartNode (io.automatiko.engine.workflow.process.core.node.StartNode)43 EndNode (io.automatiko.engine.workflow.process.core.node.EndNode)25 ExecutableProcess (io.automatiko.engine.workflow.process.executable.core.ExecutableProcess)20 ActionNode (io.automatiko.engine.workflow.process.core.node.ActionNode)19 ArrayList (java.util.ArrayList)18 EventSubProcessNode (io.automatiko.engine.workflow.process.core.node.EventSubProcessNode)17 Node (io.automatiko.engine.api.definition.process.Node)15 CompositeNode (io.automatiko.engine.workflow.process.core.node.CompositeNode)15 EventTypeFilter (io.automatiko.engine.workflow.base.core.event.EventTypeFilter)13 EventNode (io.automatiko.engine.workflow.process.core.node.EventNode)13 EventTrigger (io.automatiko.engine.workflow.process.core.node.EventTrigger)13 WorkItemNode (io.automatiko.engine.workflow.process.core.node.WorkItemNode)13 ProcessAction (io.automatiko.engine.workflow.process.core.ProcessAction)10 ConsequenceAction (io.automatiko.engine.workflow.process.core.impl.ConsequenceAction)10 BoundaryEventNode (io.automatiko.engine.workflow.process.core.node.BoundaryEventNode)10 InternalProcessRuntime (io.automatiko.engine.workflow.base.instance.InternalProcessRuntime)9 Action (io.automatiko.engine.workflow.base.instance.impl.Action)8 FaultNode (io.automatiko.engine.workflow.process.core.node.FaultNode)8 Test (org.junit.jupiter.api.Test)8 ProcessContext (io.automatiko.engine.api.runtime.process.ProcessContext)7