Search in sources :

Example 1 with SequenceFlow

use of org.jbpm.bpmn2.core.SequenceFlow in project jbpm by kiegroup.

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);
        } 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>) forEachNode.getMetaData(ProcessHandler.CONNECTIONS);
    ProcessHandler.linkConnections(forEachNode, connections);
    ProcessHandler.linkBoundaryEvents(forEachNode);
    // 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(org.jbpm.bpmn2.core.Association) SequenceFlow(org.jbpm.bpmn2.core.SequenceFlow) ForEachNode(org.jbpm.workflow.core.node.ForEachNode) List(java.util.List)

Example 2 with SequenceFlow

use of org.jbpm.bpmn2.core.SequenceFlow in project jbpm by kiegroup.

the class SubProcessHandler method handleCompositeContextNode.

@SuppressWarnings("unchecked")
protected void handleCompositeContextNode(final Node node, final Element element, final String uri, final String localName, final ExtensibleXmlParser parser) throws SAXException {
    super.handleNode(node, element, uri, localName, parser);
    CompositeContextNode compositeNode = (CompositeContextNode) node;
    List<SequenceFlow> connections = (List<SequenceFlow>) compositeNode.getMetaData(ProcessHandler.CONNECTIONS);
    handleScript(compositeNode, element, "onEntry");
    handleScript(compositeNode, element, "onExit");
    List<IntermediateLink> throwLinks = (List<IntermediateLink>) compositeNode.getMetaData(ProcessHandler.LINKS);
    ProcessHandler.linkIntermediateLinks(compositeNode, throwLinks);
    ProcessHandler.linkConnections(compositeNode, connections);
    ProcessHandler.linkBoundaryEvents(compositeNode);
    // This must be done *after* linkConnections(process, connections)
    // because it adds hidden connections for compensations
    List<Association> associations = (List<Association>) compositeNode.getMetaData(ProcessHandler.ASSOCIATIONS);
    ProcessHandler.linkAssociations((Definitions) compositeNode.getMetaData("Definitions"), compositeNode, associations);
// TODO: do we fully support interruping ESP's?
/**
 *        for( org.kie.api.definition.process.Node subNode : compositeNode.getNodes() ) {
 *            if( subNode instanceof StartNode ) {
 *                if( ! ((StartNode) subNode).isInterrupting() ) {
 *                    throw new IllegalArgumentException("Non-interrupting event subprocesses are not yet fully supported." );
 *                }
 *            }
 *        }
 */
}
Also used : Association(org.jbpm.bpmn2.core.Association) CompositeContextNode(org.jbpm.workflow.core.node.CompositeContextNode) SequenceFlow(org.jbpm.bpmn2.core.SequenceFlow) List(java.util.List) IntermediateLink(org.jbpm.bpmn2.core.IntermediateLink)

Example 3 with SequenceFlow

use of org.jbpm.bpmn2.core.SequenceFlow in project jbpm by kiegroup.

the class ProcessHandler method linkConnections.

public static 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(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(target.getId(), NodeImpl.CONNECTION_DEFAULT_TYPE), constraint);
            }
        }
    }
}
Also used : NodeImpl(org.jbpm.workflow.core.impl.NodeImpl) ExtendedNodeImpl(org.jbpm.workflow.core.impl.ExtendedNodeImpl) Constraint(org.jbpm.workflow.core.Constraint) SequenceFlow(org.jbpm.bpmn2.core.SequenceFlow) HumanTaskNode(org.jbpm.workflow.core.node.HumanTaskNode) BoundaryEventNode(org.jbpm.workflow.core.node.BoundaryEventNode) StartNode(org.jbpm.workflow.core.node.StartNode) CompositeNode(org.jbpm.workflow.core.node.CompositeNode) StateNode(org.jbpm.workflow.core.node.StateNode) RuleSetNode(org.jbpm.workflow.core.node.RuleSetNode) SubProcessNode(org.jbpm.workflow.core.node.SubProcessNode) CompositeContextNode(org.jbpm.workflow.core.node.CompositeContextNode) StateBasedNode(org.jbpm.workflow.core.node.StateBasedNode) EventSubProcessNode(org.jbpm.workflow.core.node.EventSubProcessNode) FaultNode(org.jbpm.workflow.core.node.FaultNode) WorkItemNode(org.jbpm.workflow.core.node.WorkItemNode) ActionNode(org.jbpm.workflow.core.node.ActionNode) EndNode(org.jbpm.workflow.core.node.EndNode) EventNode(org.jbpm.workflow.core.node.EventNode) Node(org.kie.api.definition.process.Node) Connection(org.jbpm.workflow.core.Connection) ConnectionImpl(org.jbpm.workflow.core.impl.ConnectionImpl) EventFilter(org.jbpm.process.core.event.EventFilter) BoundaryEventNode(org.jbpm.workflow.core.node.BoundaryEventNode) EventNode(org.jbpm.workflow.core.node.EventNode) EventTypeFilter(org.jbpm.process.core.event.EventTypeFilter) Split(org.jbpm.workflow.core.node.Split) ConnectionRef(org.jbpm.workflow.core.impl.ConnectionRef)

Example 4 with SequenceFlow

use of org.jbpm.bpmn2.core.SequenceFlow in project jbpm by kiegroup.

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("http://www.jboss.org/drools", "priority");
    NodeContainer nodeContainer = (NodeContainer) parser.getParent();
    List<SequenceFlow> connections = null;
    if (nodeContainer instanceof RuleFlowProcess) {
        RuleFlowProcess process = (RuleFlowProcess) nodeContainer;
        connections = (List<SequenceFlow>) process.getMetaData(ProcessHandler.CONNECTIONS);
        if (connections == null) {
            connections = new ArrayList<SequenceFlow>();
            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<SequenceFlow>();
            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));
    }
    connections.add(connection);
    return connection;
}
Also used : RuleFlowProcess(org.jbpm.ruleflow.core.RuleFlowProcess) CompositeNode(org.jbpm.workflow.core.node.CompositeNode) SequenceFlow(org.jbpm.bpmn2.core.SequenceFlow) ArrayList(java.util.ArrayList) NodeContainer(org.jbpm.workflow.core.NodeContainer) ArrayList(java.util.ArrayList) List(java.util.List)

Example 5 with SequenceFlow

use of org.jbpm.bpmn2.core.SequenceFlow in project jbpm by kiegroup.

the class AdHocSubProcessHandler method handleNode.

@SuppressWarnings("unchecked")
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);
    DynamicNode dynamicNode = (DynamicNode) node;
    String cancelRemainingInstances = element.getAttribute("cancelRemainingInstances");
    if ("false".equals(cancelRemainingInstances)) {
        dynamicNode.setCancelRemainingInstances(false);
    }
    // by default it should not autocomplete as it's adhoc
    dynamicNode.setAutoComplete(false);
    dynamicNode.setActivationExpression((String) dynamicNode.getMetaData("customActivationCondition"));
    org.w3c.dom.Node xmlNode = element.getFirstChild();
    while (xmlNode != null) {
        String nodeName = xmlNode.getNodeName();
        if ("completionCondition".equals(nodeName)) {
            String expression = xmlNode.getTextContent();
            if (AUTOCOMPLETE_EXPRESSIONS.contains(expression)) {
                dynamicNode.setAutoComplete(true);
            } else {
                dynamicNode.setCompletionExpression(expression == null ? "" : expression);
            }
            org.w3c.dom.Node languageNode = xmlNode.getAttributes().getNamedItem("language");
            if (languageNode != null) {
                String language = languageNode.getNodeValue();
                if (XmlBPMNProcessDumper.MVEL_LANGUAGE.equals(language)) {
                    dynamicNode.setLanguage("mvel");
                } else if (XmlBPMNProcessDumper.RULE_LANGUAGE.equals(language)) {
                    dynamicNode.setLanguage("rule");
                } else {
                    throw new IllegalArgumentException("Unknown language " + language);
                }
            } else {
                dynamicNode.setLanguage("mvel");
            }
        }
        xmlNode = xmlNode.getNextSibling();
    }
    List<SequenceFlow> connections = (List<SequenceFlow>) dynamicNode.getMetaData(ProcessHandler.CONNECTIONS);
    ProcessHandler.linkConnections(dynamicNode, connections);
    ProcessHandler.linkBoundaryEvents(dynamicNode);
    handleScript(dynamicNode, element, "onEntry");
    handleScript(dynamicNode, element, "onExit");
}
Also used : SequenceFlow(org.jbpm.bpmn2.core.SequenceFlow) DynamicNode(org.jbpm.workflow.core.node.DynamicNode) List(java.util.List)

Aggregations

SequenceFlow (org.jbpm.bpmn2.core.SequenceFlow)7 List (java.util.List)5 Association (org.jbpm.bpmn2.core.Association)3 ArrayList (java.util.ArrayList)2 IntermediateLink (org.jbpm.bpmn2.core.IntermediateLink)2 RuleFlowProcess (org.jbpm.ruleflow.core.RuleFlowProcess)2 CompositeContextNode (org.jbpm.workflow.core.node.CompositeContextNode)2 CompositeNode (org.jbpm.workflow.core.node.CompositeNode)2 Lane (org.jbpm.bpmn2.core.Lane)1 EventFilter (org.jbpm.process.core.event.EventFilter)1 EventTypeFilter (org.jbpm.process.core.event.EventTypeFilter)1 Connection (org.jbpm.workflow.core.Connection)1 Constraint (org.jbpm.workflow.core.Constraint)1 NodeContainer (org.jbpm.workflow.core.NodeContainer)1 ConnectionImpl (org.jbpm.workflow.core.impl.ConnectionImpl)1 ConnectionRef (org.jbpm.workflow.core.impl.ConnectionRef)1 ExtendedNodeImpl (org.jbpm.workflow.core.impl.ExtendedNodeImpl)1 NodeImpl (org.jbpm.workflow.core.impl.NodeImpl)1 ActionNode (org.jbpm.workflow.core.node.ActionNode)1 BoundaryEventNode (org.jbpm.workflow.core.node.BoundaryEventNode)1