Search in sources :

Example 11 with SequenceFlow

use of io.automatiko.engine.workflow.bpmn2.core.SequenceFlow in project automatiko-engine by automatiko-io.

the class ProcessHandler method end.

@SuppressWarnings("unchecked")
public Object end(final String uri, final String localName, final ExtensibleXmlParser parser) throws SAXException {
    parser.endElementBuilder();
    ExecutableProcess process = (ExecutableProcess) parser.getCurrent();
    List<IntermediateLink> throwLinks = (List<IntermediateLink>) process.getMetaData(LINKS);
    linkIntermediateLinks(process, throwLinks);
    List<SequenceFlow> connections = (List<SequenceFlow>) process.getMetaData(CONNECTIONS);
    linkConnections(process, connections);
    linkBoundaryEvents(process);
    // This must be done *after* linkConnections(process, connections)
    // because it adds hidden connections for compensations
    List<Association> associations = (List<Association>) process.getMetaData(ASSOCIATIONS);
    linkAssociations((Definitions) process.getMetaData("Definitions"), process, associations);
    List<Lane> lanes = (List<Lane>) process.getMetaData(LaneHandler.LANES);
    assignLanes(process, lanes);
    postProcessNodes(process, process);
    // process tags if any defined
    processTags(process);
    return process;
}
Also used : DataAssociation(io.automatiko.engine.workflow.process.core.node.DataAssociation) Association(io.automatiko.engine.workflow.bpmn2.core.Association) SequenceFlow(io.automatiko.engine.workflow.bpmn2.core.SequenceFlow) Lane(io.automatiko.engine.workflow.bpmn2.core.Lane) ExecutableProcess(io.automatiko.engine.workflow.process.executable.core.ExecutableProcess) List(java.util.List) ArrayList(java.util.ArrayList) IntermediateLink(io.automatiko.engine.workflow.bpmn2.core.IntermediateLink)

Example 12 with SequenceFlow

use of io.automatiko.engine.workflow.bpmn2.core.SequenceFlow in project automatiko-engine by automatiko-io.

the class ProcessHandler method linkConnections.

public void linkConnections(NodeContainer nodeContainer, List<SequenceFlow> connections) {
    if (connections != null) {
        for (SequenceFlow connection : connections) {
            String sourceRef = connection.getSourceRef();
            Node source = findNodeByIdOrUniqueIdInMetadata(nodeContainer, sourceRef, "Could not find source node for connection:" + sourceRef);
            if (source instanceof EventNode) {
                for (EventFilter eventFilter : ((EventNode) source).getEventFilters()) {
                    if (eventFilter instanceof EventTypeFilter) {
                        if ("Compensation".equals(((EventTypeFilter) eventFilter).getType())) {
                            // BPMN Method & Style, 2nd Ed. (Silver), states this on P. 131
                            throw new IllegalArgumentException("A Compensation Boundary Event can only be *associated* with a compensation activity via an Association, not via a Sequence Flow element.");
                        }
                    }
                }
            }
            String targetRef = connection.getTargetRef();
            Node target = findNodeByIdOrUniqueIdInMetadata(nodeContainer, targetRef, "Could not find target node for connection:" + targetRef);
            Connection result = new ConnectionImpl(source, NodeImpl.CONNECTION_DEFAULT_TYPE, target, NodeImpl.CONNECTION_DEFAULT_TYPE);
            result.setMetaData("bendpoints", connection.getBendpoints());
            result.setMetaData("UniqueId", connection.getId());
            if ("true".equals(System.getProperty("jbpm.enable.multi.con"))) {
                NodeImpl nodeImpl = (NodeImpl) source;
                Constraint constraint = buildConstraint(connection, nodeImpl);
                if (constraint != null) {
                    nodeImpl.addConstraint(new ConnectionRef(connection.getId(), target.getId(), NodeImpl.CONNECTION_DEFAULT_TYPE), constraint);
                }
            } else if (source instanceof Split) {
                Split split = (Split) source;
                Constraint constraint = buildConstraint(connection, split);
                split.addConstraint(new ConnectionRef(connection.getId(), target.getId(), NodeImpl.CONNECTION_DEFAULT_TYPE), constraint);
            }
        }
    }
}
Also used : NodeImpl(io.automatiko.engine.workflow.process.core.impl.NodeImpl) ExtendedNodeImpl(io.automatiko.engine.workflow.process.core.impl.ExtendedNodeImpl) Constraint(io.automatiko.engine.workflow.process.core.Constraint) SequenceFlow(io.automatiko.engine.workflow.bpmn2.core.SequenceFlow) StateBasedNode(io.automatiko.engine.workflow.process.core.node.StateBasedNode) CompositeContextNode(io.automatiko.engine.workflow.process.core.node.CompositeContextNode) 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) SubProcessNode(io.automatiko.engine.workflow.process.core.node.SubProcessNode) RuleSetNode(io.automatiko.engine.workflow.process.core.node.RuleSetNode) 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) 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) Connection(io.automatiko.engine.workflow.process.core.Connection) ConnectionImpl(io.automatiko.engine.workflow.process.core.impl.ConnectionImpl) EventFilter(io.automatiko.engine.workflow.base.core.event.EventFilter) BoundaryEventNode(io.automatiko.engine.workflow.process.core.node.BoundaryEventNode) EventNode(io.automatiko.engine.workflow.process.core.node.EventNode) EventTypeFilter(io.automatiko.engine.workflow.base.core.event.EventTypeFilter) Split(io.automatiko.engine.workflow.process.core.node.Split) ConnectionRef(io.automatiko.engine.workflow.process.core.impl.ConnectionRef)

Example 13 with SequenceFlow

use of io.automatiko.engine.workflow.bpmn2.core.SequenceFlow in project automatiko-engine by automatiko-io.

the class SubProcessHandler method handleForEachNode.

@SuppressWarnings("unchecked")
protected void handleForEachNode(final Node node, final Element element, final String uri, final String localName, final ExtensibleXmlParser parser, boolean isAsync) throws SAXException {
    super.handleNode(node, element, uri, localName, parser);
    ForEachNode forEachNode = (ForEachNode) node;
    org.w3c.dom.Node xmlNode = element.getFirstChild();
    while (xmlNode != null) {
        String nodeName = xmlNode.getNodeName();
        if ("ioSpecification".equals(nodeName)) {
            readIoSpecification(xmlNode, dataInputs, dataOutputs, dataInputTypes, dataOutputTypes);
        } else if ("dataInputAssociation".equals(nodeName)) {
            readDataInputAssociation(xmlNode, inputAssociation);
        } else if ("dataOutputAssociation".equals(nodeName)) {
            readDataOutputAssociation(xmlNode, outputAssociation);
        } else if ("multiInstanceLoopCharacteristics".equals(nodeName)) {
            readMultiInstanceLoopCharacteristics(xmlNode, forEachNode, parser);
        }
        xmlNode = xmlNode.getNextSibling();
    }
    handleScript(forEachNode, element, "onEntry");
    handleScript(forEachNode, element, "onExit");
    // List<SequenceFlow> connections = (List<SequenceFlow>) ((CompositeNode) node).getMetaData(ProcessHandler.CONNECTIONS);
    // ProcessHandler processHandler = new ProcessHandler();
    // processHandler.linkConnections((io.automatiko.engine.api.definition.process.NodeContainer) node, connections);
    // processHandler.linkBoundaryEvents((io.automatiko.engine.api.definition.process.NodeContainer) node);
    // This must be done *after* linkConnections(process, connections)
    // because it adds hidden connections for compensations
    List<Association> associations = (List<Association>) forEachNode.getMetaData(ProcessHandler.ASSOCIATIONS);
    ProcessHandler.linkAssociations((Definitions) forEachNode.getMetaData("Definitions"), forEachNode, associations);
    applyAsync(node, isAsync);
}
Also used : Association(io.automatiko.engine.workflow.bpmn2.core.Association) ForEachNode(io.automatiko.engine.workflow.process.core.node.ForEachNode) List(java.util.List)

Example 14 with SequenceFlow

use of io.automatiko.engine.workflow.bpmn2.core.SequenceFlow in project automatiko-engine by automatiko-io.

the class SequenceFlowHandler method end.

public Object end(final String uri, final String localName, final ExtensibleXmlParser parser) throws SAXException {
    final Element element = parser.endElementBuilder();
    SequenceFlow sequenceFlow = (SequenceFlow) parser.getCurrent();
    org.w3c.dom.Node xmlNode = element.getFirstChild();
    while (xmlNode != null) {
        String nodeName = xmlNode.getNodeName();
        if ("conditionExpression".equals(nodeName)) {
            String expression = xmlNode.getTextContent();
            org.w3c.dom.Node languageNode = xmlNode.getAttributes().getNamedItem("language");
            if (languageNode != null) {
                String language = languageNode.getNodeValue();
                if (XmlBPMNProcessDumper.JAVA_LANGUAGE.equals(language)) {
                    sequenceFlow.setLanguage("java");
                } else if (XmlBPMNProcessDumper.MVEL_LANGUAGE.equals(language)) {
                    sequenceFlow.setLanguage("mvel");
                } else if (XmlBPMNProcessDumper.RULE_LANGUAGE.equals(language)) {
                    sequenceFlow.setType("rule");
                } else if (XmlBPMNProcessDumper.XPATH_LANGUAGE.equals(language)) {
                    sequenceFlow.setLanguage("XPath");
                } else if (XmlBPMNProcessDumper.JAVASCRIPT_LANGUAGE.equals(language)) {
                    sequenceFlow.setLanguage("JavaScript");
                } else if (XmlBPMNProcessDumper.FEEL_LANGUAGE.equals(language) || XmlBPMNProcessDumper.DMN_FEEL_LANGUAGE.equals(language)) {
                    sequenceFlow.setLanguage("FEEL");
                } else {
                    throw new IllegalArgumentException("Unknown language " + language);
                }
            }
            sequenceFlow.setExpression(expression);
        }
        xmlNode = xmlNode.getNextSibling();
    }
    return sequenceFlow;
}
Also used : SequenceFlow(io.automatiko.engine.workflow.bpmn2.core.SequenceFlow) Element(org.w3c.dom.Element)

Example 15 with SequenceFlow

use of io.automatiko.engine.workflow.bpmn2.core.SequenceFlow in project automatiko-engine by automatiko-io.

the class SequenceFlowHandler method start.

@SuppressWarnings("unchecked")
public Object start(final String uri, final String localName, final Attributes attrs, final ExtensibleXmlParser parser) throws SAXException {
    parser.startElementBuilder(localName, attrs);
    final String id = attrs.getValue("id");
    final String sourceRef = attrs.getValue("sourceRef");
    final String targetRef = attrs.getValue("targetRef");
    final String bendpoints = attrs.getValue("g:bendpoints");
    final String name = attrs.getValue("name");
    final String priority = attrs.getValue("https://automatiko.io", "priority");
    NodeContainer nodeContainer = (NodeContainer) parser.getParent();
    List<SequenceFlow> connections = null;
    if (nodeContainer instanceof ExecutableProcess) {
        ExecutableProcess process = (ExecutableProcess) nodeContainer;
        connections = (List<SequenceFlow>) process.getMetaData(ProcessHandler.CONNECTIONS);
        if (connections == null) {
            connections = new ArrayList<>();
            process.setMetaData(ProcessHandler.CONNECTIONS, connections);
        }
    } else if (nodeContainer instanceof CompositeNode) {
        CompositeNode compositeNode = (CompositeNode) nodeContainer;
        connections = (List<SequenceFlow>) compositeNode.getMetaData(ProcessHandler.CONNECTIONS);
        if (connections == null) {
            connections = new ArrayList<>();
            compositeNode.setMetaData(ProcessHandler.CONNECTIONS, connections);
        }
    }
    SequenceFlow connection = new SequenceFlow(id, sourceRef, targetRef);
    connection.setBendpoints(bendpoints);
    connection.setName(name);
    if (priority != null) {
        connection.setPriority(Integer.parseInt(priority));
    }
    if (connections != null) {
        connections.add(connection);
    }
    return connection;
}
Also used : CompositeNode(io.automatiko.engine.workflow.process.core.node.CompositeNode) SequenceFlow(io.automatiko.engine.workflow.bpmn2.core.SequenceFlow) ArrayList(java.util.ArrayList) NodeContainer(io.automatiko.engine.workflow.process.core.NodeContainer) ExecutableProcess(io.automatiko.engine.workflow.process.executable.core.ExecutableProcess) ArrayList(java.util.ArrayList) List(java.util.List)

Aggregations

List (java.util.List)15 SequenceFlow (org.jbpm.bpmn2.core.SequenceFlow)13 SequenceFlow (io.automatiko.engine.workflow.bpmn2.core.SequenceFlow)7 ArrayList (java.util.ArrayList)6 Association (org.jbpm.bpmn2.core.Association)5 RuleFlowProcess (org.jbpm.ruleflow.core.RuleFlowProcess)4 CompositeContextNode (org.jbpm.workflow.core.node.CompositeContextNode)4 CompositeNode (org.jbpm.workflow.core.node.CompositeNode)4 Association (io.automatiko.engine.workflow.bpmn2.core.Association)3 IntermediateLink (org.jbpm.bpmn2.core.IntermediateLink)3 NodeContainer (org.jbpm.workflow.core.NodeContainer)3 EventSubProcessNode (org.jbpm.workflow.core.node.EventSubProcessNode)3 StartNode (org.jbpm.workflow.core.node.StartNode)3 Element (org.w3c.dom.Element)3 CompositeContextNode (io.automatiko.engine.workflow.process.core.node.CompositeContextNode)2 CompositeNode (io.automatiko.engine.workflow.process.core.node.CompositeNode)2 ExecutableProcess (io.automatiko.engine.workflow.process.executable.core.ExecutableProcess)2 EventFilter (org.jbpm.process.core.event.EventFilter)2 EventTypeFilter (org.jbpm.process.core.event.EventTypeFilter)2 Connection (org.jbpm.workflow.core.Connection)2