Search in sources :

Example 1 with ForEachNode

use of org.jbpm.workflow.core.node.ForEachNode in project jbpm by kiegroup.

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(org.jbpm.workflow.core.node.ForEachNode) ObjectDataType(org.jbpm.process.core.datatype.impl.type.ObjectDataType)

Example 2 with ForEachNode

use of org.jbpm.workflow.core.node.ForEachNode 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 3 with ForEachNode

use of org.jbpm.workflow.core.node.ForEachNode in project jbpm by kiegroup.

the class CallActivityHandler method end.

@SuppressWarnings("unchecked")
@Override
public Object end(String uri, String localName, ExtensibleXmlParser parser) throws SAXException {
    final Element element = parser.endElementBuilder();
    Node node = (Node) parser.getCurrent();
    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++);
            node.setMetaData("hidden", true);
            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);
            Node orignalNode = node;
            node = forEachNode;
            handleForEachNode(node, element, uri, localName, parser);
            // remove output collection data output of for each to avoid problems when running in variable strict mode
            if (orignalNode instanceof SubProcessNode) {
                ((SubProcessNode) orignalNode).adjustOutMapping(forEachNode.getOutputCollectionExpression());
            }
            Map<String, String> dataInputs = (Map<String, String>) orignalNode.getMetaData().remove("DataInputs");
            Map<String, String> dataOutputs = (Map<String, String>) orignalNode.getMetaData().remove("DataOutputs");
            orignalNode.setMetaData("MICollectionOutput", dataOutputs.get(((ForEachNode) node).getMetaData("MICollectionOutput")));
            orignalNode.setMetaData("MICollectionInput", dataInputs.get(((ForEachNode) node).getMetaData("MICollectionInput")));
            break;
        }
        xmlNode = xmlNode.getNextSibling();
    }
    NodeContainer nodeContainer = (NodeContainer) parser.getParent();
    nodeContainer.addNode(node);
    ((ProcessBuildData) parser.getData()).addNode(node);
    return node;
}
Also used : Element(org.w3c.dom.Element) ForEachNode(org.jbpm.workflow.core.node.ForEachNode) Node(org.jbpm.workflow.core.Node) SubProcessNode(org.jbpm.workflow.core.node.SubProcessNode) WorkItemNode(org.jbpm.workflow.core.node.WorkItemNode) NodeContainer(org.jbpm.workflow.core.NodeContainer) ProcessBuildData(org.jbpm.compiler.xml.ProcessBuildData) SubProcessNode(org.jbpm.workflow.core.node.SubProcessNode) ForEachNode(org.jbpm.workflow.core.node.ForEachNode) HashMap(java.util.HashMap) Map(java.util.Map)

Example 4 with ForEachNode

use of org.jbpm.workflow.core.node.ForEachNode in project jbpm by kiegroup.

the class CallActivityHandler method handleForEachNode.

protected void handleForEachNode(final Node node, final Element element, final String uri, final String localName, final ExtensibleXmlParser parser) throws SAXException {
    ForEachNode forEachNode = (ForEachNode) node;
    org.w3c.dom.Node xmlNode = element.getFirstChild();
    while (xmlNode != null) {
        String nodeName = xmlNode.getNodeName();
        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();
    }
}
Also used : ForEachNode(org.jbpm.workflow.core.node.ForEachNode)

Example 5 with ForEachNode

use of org.jbpm.workflow.core.node.ForEachNode in project jbpm by kiegroup.

the class ForEachNodeHandler method writeNode.

public void writeNode(Node node, StringBuilder xmlDump, int metaDataType) {
    ForEachNode forEachNode = (ForEachNode) node;
    writeNode("subProcess", forEachNode, xmlDump, metaDataType);
    xmlDump.append(" >" + EOL);
    writeExtensionElements(node, xmlDump);
    // ioSpecification and dataInputAssociation
    xmlDump.append("      <ioSpecification>" + EOL);
    String parameterName = forEachNode.getVariableName();
    if (parameterName != null) {
        xmlDump.append("        <dataInput id=\"" + XmlBPMNProcessDumper.getUniqueNodeId(forEachNode) + "_input\" name=\"MultiInstanceInput\" />" + EOL);
    }
    xmlDump.append("        <inputSet/>" + EOL + "        <outputSet/>" + EOL + "      </ioSpecification>" + EOL);
    String collectionExpression = forEachNode.getCollectionExpression();
    if (collectionExpression != null) {
        xmlDump.append("      <dataInputAssociation>" + EOL + "        <sourceRef>" + XmlDumper.replaceIllegalChars(collectionExpression) + "</sourceRef>" + EOL + "        <targetRef>" + XmlBPMNProcessDumper.getUniqueNodeId(forEachNode) + "_input</targetRef>" + EOL + "      </dataInputAssociation>" + EOL);
    }
    // multiInstanceLoopCharacteristics
    xmlDump.append("      <multiInstanceLoopCharacteristics>" + EOL + "        <loopDataInputRef>" + XmlBPMNProcessDumper.getUniqueNodeId(forEachNode) + "_input</loopDataInputRef>" + EOL);
    if (parameterName != null) {
        xmlDump.append("        <inputDataItem id=\"" + XmlBPMNProcessDumper.replaceIllegalCharsAttribute(parameterName) + "\" itemSubjectRef=\"" + XmlBPMNProcessDumper.getUniqueNodeId(forEachNode) + "_multiInstanceItemType\"/>" + EOL);
    }
    xmlDump.append("      </multiInstanceLoopCharacteristics>" + EOL);
    // nodes
    List<Node> subNodes = getSubNodes(forEachNode);
    XmlBPMNProcessDumper.INSTANCE.visitNodes(subNodes, xmlDump, metaDataType);
    // connections
    visitConnectionsAndAssociations(forEachNode, xmlDump, metaDataType);
    endNode("subProcess", xmlDump);
}
Also used : Node(org.jbpm.workflow.core.Node) ForEachNode(org.jbpm.workflow.core.node.ForEachNode) CompositeNode(org.jbpm.workflow.core.node.CompositeNode) ForEachNode(org.jbpm.workflow.core.node.ForEachNode)

Aggregations

ForEachNode (org.jbpm.workflow.core.node.ForEachNode)14 Node (org.jbpm.workflow.core.Node)6 ActionNode (org.jbpm.workflow.core.node.ActionNode)6 StartNode (org.jbpm.workflow.core.node.StartNode)6 WorkItemNode (org.jbpm.workflow.core.node.WorkItemNode)6 EndNode (org.jbpm.workflow.core.node.EndNode)5 ArrayList (java.util.ArrayList)4 HashMap (java.util.HashMap)4 ObjectDataType (org.jbpm.process.core.datatype.impl.type.ObjectDataType)4 EventNode (org.jbpm.workflow.core.node.EventNode)4 FaultNode (org.jbpm.workflow.core.node.FaultNode)4 MilestoneNode (org.jbpm.workflow.core.node.MilestoneNode)4 SubProcessNode (org.jbpm.workflow.core.node.SubProcessNode)4 List (java.util.List)3 Work (org.jbpm.process.core.Work)3 EventTypeFilter (org.jbpm.process.core.event.EventTypeFilter)3 RuleFlowProcess (org.jbpm.ruleflow.core.RuleFlowProcess)3 DroolsConsequenceAction (org.jbpm.workflow.core.impl.DroolsConsequenceAction)3 CompositeContextNode (org.jbpm.workflow.core.node.CompositeContextNode)3 CompositeNode (org.jbpm.workflow.core.node.CompositeNode)3