Search in sources :

Example 11 with MilestoneNode

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

the class TaskHandler 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);
            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 WorkItemNode) {
                ((WorkItemNode) orignalNode).adjustOutMapping(forEachNode.getOutputCollectionExpression());
            }
            break;
        }
        xmlNode = xmlNode.getNextSibling();
    }
    // replace node in case it's milestone
    if (node instanceof WorkItemNode && ((WorkItemNode) node).getWork().getName().equals("Milestone")) {
        WorkItemNode workItemNode = (WorkItemNode) node;
        String milestoneCondition = (String) ((WorkItemNode) node).getWork().getParameter("Condition");
        if (milestoneCondition == null) {
            // if not given that means once activated it's achieved
            milestoneCondition = "";
        }
        MilestoneNode milestoneNode = new MilestoneNode();
        milestoneNode.setId(workItemNode.getId());
        milestoneNode.setConstraint(milestoneCondition);
        milestoneNode.setMetaData(workItemNode.getMetaData());
        milestoneNode.setName(workItemNode.getName());
        milestoneNode.setNodeContainer(workItemNode.getNodeContainer());
        node = milestoneNode;
    }
    NodeContainer nodeContainer = (NodeContainer) parser.getParent();
    nodeContainer.addNode(node);
    ((ProcessBuildData) parser.getData()).addNode(node);
    return node;
}
Also used : ProcessBuildData(org.jbpm.compiler.xml.ProcessBuildData) Element(org.w3c.dom.Element) ForEachNode(org.jbpm.workflow.core.node.ForEachNode) WorkItemNode(org.jbpm.workflow.core.node.WorkItemNode) Node(org.jbpm.workflow.core.Node) MilestoneNode(org.jbpm.workflow.core.node.MilestoneNode) WorkItemNode(org.jbpm.workflow.core.node.WorkItemNode) ForEachNode(org.jbpm.workflow.core.node.ForEachNode) NodeContainer(org.jbpm.workflow.core.NodeContainer) MilestoneNode(org.jbpm.workflow.core.node.MilestoneNode)

Aggregations

MilestoneNode (org.jbpm.workflow.core.node.MilestoneNode)11 StartNode (org.jbpm.workflow.core.node.StartNode)8 ArrayList (java.util.ArrayList)7 ActionNode (org.jbpm.workflow.core.node.ActionNode)6 EndNode (org.jbpm.workflow.core.node.EndNode)6 EventNode (org.jbpm.workflow.core.node.EventNode)6 EventTypeFilter (org.jbpm.process.core.event.EventTypeFilter)5 RuleFlowProcess (org.jbpm.ruleflow.core.RuleFlowProcess)5 DroolsConsequenceAction (org.jbpm.workflow.core.impl.DroolsConsequenceAction)5 DynamicNode (org.jbpm.workflow.core.node.DynamicNode)5 Join (org.jbpm.workflow.core.node.Join)5 Test (org.junit.Test)5 Variable (org.jbpm.process.core.context.variable.Variable)4 ObjectDataType (org.jbpm.process.core.datatype.impl.type.ObjectDataType)4 DroolsAction (org.jbpm.workflow.core.DroolsAction)4 ConnectionImpl (org.jbpm.workflow.core.impl.ConnectionImpl)4 HashMap (java.util.HashMap)3 Action (org.jbpm.process.instance.impl.Action)3 Person (org.jbpm.process.test.Person)3 TestProcessEventListener (org.jbpm.process.test.TestProcessEventListener)3