Search in sources :

Example 1 with IntermediateLink

use of io.automatiko.engine.workflow.bpmn2.core.IntermediateLink 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 2 with IntermediateLink

use of io.automatiko.engine.workflow.bpmn2.core.IntermediateLink 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 3 with IntermediateLink

use of io.automatiko.engine.workflow.bpmn2.core.IntermediateLink in project kogito-runtimes by kiegroup.

the class ProcessHandler method end.

@Override
@SuppressWarnings("unchecked")
public Object end(final String uri, final String localName, final ExtensibleXmlParser parser) throws SAXException {
    parser.endElementBuilder();
    RuleFlowProcess process = (RuleFlowProcess) 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);
    postProcessCollaborations(process, parser);
    return process;
}
Also used : RuleFlowProcess(org.jbpm.ruleflow.core.RuleFlowProcess) Association(org.jbpm.bpmn2.core.Association) SequenceFlow(org.jbpm.bpmn2.core.SequenceFlow) Lane(org.jbpm.bpmn2.core.Lane) List(java.util.List) ArrayList(java.util.ArrayList) IntermediateLink(org.jbpm.bpmn2.core.IntermediateLink)

Example 4 with IntermediateLink

use of io.automatiko.engine.workflow.bpmn2.core.IntermediateLink in project kogito-runtimes 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 IntermediateLink

use of io.automatiko.engine.workflow.bpmn2.core.IntermediateLink in project kogito-runtimes by kiegroup.

the class IntermediateThrowEventHandler method handleLinkNode.

protected void handleLinkNode(Element element, Node node, org.w3c.dom.Node xmlLinkNode, ExtensibleXmlParser parser) {
    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();
    NodeContainer nodeContainer = (NodeContainer) parser.getParent();
    IntermediateLink aLink = new IntermediateLink();
    aLink.setName(name);
    aLink.setUniqueId(id);
    while (null != xmlNode) {
        String nodeName = xmlNode.getNodeName();
        if (LINK_TARGET.equals(nodeName)) {
            String target = xmlNode.getTextContent();
            node.setMetaData(LINK_TARGET, target);
        }
        if (LINK_SOURCE.equals(nodeName)) {
            String source = xmlNode.getTextContent();
            ArrayList<String> sources = (ArrayList<String>) node.getMetaData().get(LINK_SOURCE);
            // if there is no list, create one
            if (null == sources) {
                sources = new ArrayList<String>();
            }
            // to connect nodes.
            aLink.addSource(source);
            // to do the xml dump
            sources.add(source);
            node.setMetaData(LINK_SOURCE, sources);
        }
        xmlNode = xmlNode.getNextSibling();
    }
    aLink.configureThrow();
    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)

Aggregations

ArrayList (java.util.ArrayList)12 List (java.util.List)11 IntermediateLink (org.jbpm.bpmn2.core.IntermediateLink)9 RuleFlowProcess (org.jbpm.ruleflow.core.RuleFlowProcess)6 CompositeNode (org.jbpm.workflow.core.node.CompositeNode)6 NamedNodeMap (org.w3c.dom.NamedNodeMap)6 IntermediateLink (io.automatiko.engine.workflow.bpmn2.core.IntermediateLink)5 CompositeNode (io.automatiko.engine.workflow.process.core.node.CompositeNode)3 NodeContainer (org.jbpm.workflow.core.NodeContainer)3 CompositeContextNode (org.jbpm.workflow.core.node.CompositeContextNode)3 Association (io.automatiko.engine.workflow.bpmn2.core.Association)2 SequenceFlow (io.automatiko.engine.workflow.bpmn2.core.SequenceFlow)2 NodeContainer (io.automatiko.engine.workflow.process.core.NodeContainer)2 CompositeContextNode (io.automatiko.engine.workflow.process.core.node.CompositeContextNode)2 ExecutableProcess (io.automatiko.engine.workflow.process.executable.core.ExecutableProcess)2 Collection (java.util.Collection)2 HashMap (java.util.HashMap)2 LinkedHashSet (java.util.LinkedHashSet)2 Association (org.jbpm.bpmn2.core.Association)2 SequenceFlow (org.jbpm.bpmn2.core.SequenceFlow)2