Search in sources :

Example 26 with ProcessBuildData

use of org.jbpm.compiler.xml.ProcessBuildData 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)

Example 27 with ProcessBuildData

use of org.jbpm.compiler.xml.ProcessBuildData in project jbpm by kiegroup.

the class ProcessHandler method start.

public Object start(final String uri, final String localName, final Attributes attrs, final ExtensibleXmlParser parser) throws SAXException {
    parser.startElementBuilder(localName, attrs);
    String id = attrs.getValue("id");
    String name = attrs.getValue("name");
    String packageName = attrs.getValue("http://www.jboss.org/drools", "packageName");
    String dynamic = attrs.getValue("http://www.jboss.org/drools", "adHoc");
    String version = attrs.getValue("http://www.jboss.org/drools", "version");
    RuleFlowProcess process = new RuleFlowProcess();
    process.setAutoComplete(true);
    process.setId(id);
    if (name == null) {
        name = id;
    }
    process.setName(name);
    process.setType("RuleFlow");
    if (packageName == null) {
        packageName = "org.drools.bpmn2";
    }
    process.setPackageName(packageName);
    if ("true".equals(dynamic)) {
        process.setDynamic(true);
        process.setAutoComplete(false);
    }
    if (version != null) {
        process.setVersion(version);
    }
    ((ProcessBuildData) parser.getData()).addProcess(process);
    // register the definitions object as metadata of process.
    process.setMetaData("Definitions", parser.getParent());
    // register bpmn2 imports as meta data of process
    Object typedImports = ((ProcessBuildData) parser.getData()).getMetaData("Bpmn2Imports");
    if (typedImports != null) {
        process.setMetaData("Bpmn2Imports", typedImports);
    }
    // register item definitions as meta data of process
    Object itemDefinitions = ((ProcessBuildData) parser.getData()).getMetaData("ItemDefinitions");
    if (itemDefinitions != null) {
        process.setMetaData("ItemDefinitions", itemDefinitions);
    }
    // for unique id's of nodes, start with one to avoid returning wrong nodes for dynamic nodes
    parser.getMetaData().put("idGen", new AtomicInteger(1));
    return process;
}
Also used : RuleFlowProcess(org.jbpm.ruleflow.core.RuleFlowProcess) ProcessBuildData(org.jbpm.compiler.xml.ProcessBuildData) AtomicInteger(java.util.concurrent.atomic.AtomicInteger)

Example 28 with ProcessBuildData

use of org.jbpm.compiler.xml.ProcessBuildData in project jbpm by kiegroup.

the class BPMNPlaneHandler method end.

public Object end(final String uri, final String localName, final ExtensibleXmlParser parser) throws SAXException {
    parser.endElementBuilder();
    ProcessInfo processInfo = (ProcessInfo) parser.getCurrent();
    List<Process> processes = ((ProcessBuildData) parser.getData()).getProcesses();
    RuleFlowProcess process = null;
    for (Process p : processes) {
        if (p.getId() != null && p.getId().equals(processInfo.getProcessRef())) {
            process = (RuleFlowProcess) p;
            break;
        }
    }
    if (process != null) {
        for (NodeInfo nodeInfo : processInfo.getNodeInfos()) {
            processNodeInfo(nodeInfo, process.getNodes());
        }
        postProcessNodeOffset(process.getNodes(), 0, 0);
        for (ConnectionInfo connectionInfo : processInfo.getConnectionInfos()) {
            if (connectionInfo.getBendpoints() != null) {
                processConnectionInfo(connectionInfo, process.getNodes());
            }
        }
    }
    return processInfo;
}
Also used : RuleFlowProcess(org.jbpm.ruleflow.core.RuleFlowProcess) ProcessBuildData(org.jbpm.compiler.xml.ProcessBuildData) NodeInfo(org.jbpm.bpmn2.xml.di.BPMNShapeHandler.NodeInfo) Process(org.kie.api.definition.process.Process) RuleFlowProcess(org.jbpm.ruleflow.core.RuleFlowProcess) ConnectionInfo(org.jbpm.bpmn2.xml.di.BPMNEdgeHandler.ConnectionInfo)

Aggregations

ProcessBuildData (org.jbpm.compiler.xml.ProcessBuildData)28 Map (java.util.Map)12 Element (org.w3c.dom.Element)11 Node (org.jbpm.workflow.core.Node)8 NodeContainer (org.jbpm.workflow.core.NodeContainer)8 HashMap (java.util.HashMap)7 List (java.util.List)7 ArrayList (java.util.ArrayList)5 RuleFlowProcess (org.jbpm.ruleflow.core.RuleFlowProcess)4 ActionNode (org.jbpm.workflow.core.node.ActionNode)4 ForEachNode (org.jbpm.workflow.core.node.ForEachNode)4 Error (org.jbpm.bpmn2.core.Error)3 Escalation (org.jbpm.bpmn2.core.Escalation)3 ItemDefinition (org.jbpm.bpmn2.core.ItemDefinition)3 DroolsConsequenceAction (org.jbpm.workflow.core.impl.DroolsConsequenceAction)3 EndNode (org.jbpm.workflow.core.node.EndNode)3 EventNode (org.jbpm.workflow.core.node.EventNode)3 FaultNode (org.jbpm.workflow.core.node.FaultNode)3 WorkItemNode (org.jbpm.workflow.core.node.WorkItemNode)3 Message (org.jbpm.bpmn2.core.Message)2