Search in sources :

Example 1 with NodeContainer

use of org.jbpm.workflow.core.NodeContainer 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 2 with NodeContainer

use of org.jbpm.workflow.core.NodeContainer in project jbpm by kiegroup.

the class BoundaryEventHandler 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();
    String attachedTo = element.getAttribute("attachedToRef");
    Attr cancelActivityAttr = element.getAttributeNode("cancelActivity");
    boolean cancelActivity = Boolean.parseBoolean(cancelActivityAttr.getValue());
    // determine type of event definition, so the correct type of node can be generated
    org.w3c.dom.Node xmlNode = element.getFirstChild();
    while (xmlNode != null) {
        String nodeName = xmlNode.getNodeName();
        if ("escalationEventDefinition".equals(nodeName)) {
            // reuse already created EventNode
            handleEscalationNode(node, element, uri, localName, parser, attachedTo, cancelActivity);
            break;
        } else if ("errorEventDefinition".equals(nodeName)) {
            // reuse already created EventNode
            handleErrorNode(node, element, uri, localName, parser, attachedTo, cancelActivity);
            break;
        } else if ("timerEventDefinition".equals(nodeName)) {
            // reuse already created EventNode
            handleTimerNode(node, element, uri, localName, parser, attachedTo, cancelActivity);
            break;
        } else if ("compensateEventDefinition".equals(nodeName)) {
            // reuse already created EventNode
            handleCompensationNode(node, element, uri, localName, parser, attachedTo, cancelActivity);
            break;
        } else if ("signalEventDefinition".equals(nodeName)) {
            // reuse already created EventNode
            handleSignalNode(node, element, uri, localName, parser, attachedTo, cancelActivity);
            break;
        } else if ("conditionalEventDefinition".equals(nodeName)) {
            handleConditionNode(node, element, uri, localName, parser, attachedTo, cancelActivity);
            break;
        } else if ("messageEventDefinition".equals(nodeName)) {
            handleMessageNode(node, element, uri, localName, parser, attachedTo, cancelActivity);
            break;
        }
        xmlNode = xmlNode.getNextSibling();
    }
    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) BoundaryEventNode(org.jbpm.workflow.core.node.BoundaryEventNode) EventNode(org.jbpm.workflow.core.node.EventNode) Node(org.jbpm.workflow.core.Node) NodeContainer(org.jbpm.workflow.core.NodeContainer) Attr(org.w3c.dom.Attr)

Example 3 with NodeContainer

use of org.jbpm.workflow.core.NodeContainer 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 NodeContainer

use of org.jbpm.workflow.core.NodeContainer in project jbpm by kiegroup.

the class IntermediateCatchEventHandler method handleLinkNode.

protected void handleLinkNode(Element element, Node node, org.w3c.dom.Node xmlLinkNode, ExtensibleXmlParser parser) {
    NodeContainer nodeContainer = (NodeContainer) parser.getParent();
    node.setName(element.getAttribute("name"));
    NamedNodeMap linkAttr = xmlLinkNode.getAttributes();
    String name = linkAttr.getNamedItem("name").getNodeValue();
    String id = element.getAttribute("id");
    node.setMetaData("UniqueId", id);
    node.setMetaData(LINK_NAME, name);
    org.w3c.dom.Node xmlNode = xmlLinkNode.getFirstChild();
    IntermediateLink aLink = new IntermediateLink();
    aLink.setName(name);
    aLink.setUniqueId(id);
    while (null != xmlNode) {
        String nodeName = xmlNode.getNodeName();
        if ("target".equals(nodeName)) {
            String target = xmlNode.getTextContent();
            node.setMetaData("target", target);
            aLink.setTarget(target);
        }
        if ("source".equals(nodeName)) {
            String source = xmlNode.getTextContent();
            node.setMetaData("source", source);
            aLink.addSource(source);
        }
        xmlNode = xmlNode.getNextSibling();
    }
    if (nodeContainer instanceof RuleFlowProcess) {
        RuleFlowProcess process = (RuleFlowProcess) nodeContainer;
        List<IntermediateLink> links = (List<IntermediateLink>) process.getMetaData().get(ProcessHandler.LINKS);
        if (null == links) {
            links = new ArrayList<IntermediateLink>();
        }
        links.add(aLink);
        process.setMetaData(ProcessHandler.LINKS, links);
    } else if (nodeContainer instanceof CompositeNode) {
        CompositeNode subprocess = (CompositeNode) nodeContainer;
        List<IntermediateLink> links = (List<IntermediateLink>) subprocess.getMetaData().get(ProcessHandler.LINKS);
        if (null == links) {
            links = new ArrayList<IntermediateLink>();
        }
        links.add(aLink);
        subprocess.setMetaData(ProcessHandler.LINKS, links);
    }
}
Also used : RuleFlowProcess(org.jbpm.ruleflow.core.RuleFlowProcess) NamedNodeMap(org.w3c.dom.NamedNodeMap) ArrayList(java.util.ArrayList) NodeContainer(org.jbpm.workflow.core.NodeContainer) IntermediateLink(org.jbpm.bpmn2.core.IntermediateLink) CompositeNode(org.jbpm.workflow.core.node.CompositeNode) ArrayList(java.util.ArrayList) List(java.util.List)

Example 5 with NodeContainer

use of org.jbpm.workflow.core.NodeContainer in project jbpm by kiegroup.

the class IntermediateThrowEventHandler method end.

public Object end(final String uri, final String localName, final ExtensibleXmlParser parser) throws SAXException {
    final Element element = parser.endElementBuilder();
    ActionNode node = (ActionNode) parser.getCurrent();
    // determine type of event definition, so the correct type of node
    // can be generated
    org.w3c.dom.Node xmlNode = element.getFirstChild();
    while (xmlNode != null) {
        String nodeName = xmlNode.getNodeName();
        if ("signalEventDefinition".equals(nodeName)) {
            // reuse already created ActionNode
            handleSignalNode(node, element, uri, localName, parser);
            break;
        } else if ("messageEventDefinition".equals(nodeName)) {
            // reuse already created ActionNode
            handleMessageNode(node, element, uri, localName, parser);
            break;
        } else if ("escalationEventDefinition".equals(nodeName)) {
            // reuse already created ActionNode
            handleEscalationNode(node, element, uri, localName, parser);
            break;
        } else if ("compensateEventDefinition".equals(nodeName)) {
            // reuse already created ActionNode
            handleThrowCompensationEventNode(node, element, uri, localName, parser);
            break;
        } else if ("linkEventDefinition".equals(nodeName)) {
            ThrowLinkNode linkNode = new ThrowLinkNode();
            linkNode.setId(node.getId());
            handleLinkNode(element, linkNode, xmlNode, parser);
            NodeContainer nodeContainer = (NodeContainer) parser.getParent();
            nodeContainer.addNode(linkNode);
            ((ProcessBuildData) parser.getData()).addNode(node);
            // we break the while and stop the execution of this method.
            return linkNode;
        }
        xmlNode = xmlNode.getNextSibling();
    }
    // none event definition
    if (node.getAction() == null) {
        node.setAction(new DroolsConsequenceAction("mvel", ""));
        node.setMetaData("NodeType", "IntermediateThrowEvent-None");
    }
    NodeContainer nodeContainer = (NodeContainer) parser.getParent();
    nodeContainer.addNode(node);
    return node;
}
Also used : ProcessBuildData(org.jbpm.compiler.xml.ProcessBuildData) DroolsConsequenceAction(org.jbpm.workflow.core.impl.DroolsConsequenceAction) Element(org.w3c.dom.Element) ActionNode(org.jbpm.workflow.core.node.ActionNode) NodeContainer(org.jbpm.workflow.core.NodeContainer) ThrowLinkNode(org.jbpm.workflow.core.node.ThrowLinkNode)

Aggregations

NodeContainer (org.jbpm.workflow.core.NodeContainer)17 Node (org.jbpm.workflow.core.Node)9 Element (org.w3c.dom.Element)9 ProcessBuildData (org.jbpm.compiler.xml.ProcessBuildData)8 ForEachNode (org.jbpm.workflow.core.node.ForEachNode)6 ArrayList (java.util.ArrayList)5 CompositeNode (org.jbpm.workflow.core.node.CompositeNode)5 List (java.util.List)4 RuleFlowProcess (org.jbpm.ruleflow.core.RuleFlowProcess)4 ActionNode (org.jbpm.workflow.core.node.ActionNode)4 EventNode (org.jbpm.workflow.core.node.EventNode)4 EndNode (org.jbpm.workflow.core.node.EndNode)3 WorkItemNode (org.jbpm.workflow.core.node.WorkItemNode)3 IntermediateLink (org.jbpm.bpmn2.core.IntermediateLink)2 BoundaryEventNode (org.jbpm.workflow.core.node.BoundaryEventNode)2 CompositeContextNode (org.jbpm.workflow.core.node.CompositeContextNode)2 Node (org.kie.api.definition.process.Node)2 NamedNodeMap (org.w3c.dom.NamedNodeMap)2 HashMap (java.util.HashMap)1 Map (java.util.Map)1