Search in sources :

Example 16 with Split

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

the class XmlBPMNProcessDumper method visitConnection.

public void visitConnection(Connection connection, StringBuilder xmlDump, int metaDataType) {
    // if the connection was generated by a link event, don't dump.
    if (isConnectionRepresentingLinkEvent(connection)) {
        return;
    }
    // if the connection is a hidden one (compensations), don't dump
    Object hidden = ((ConnectionImpl) connection).getMetaData("hidden");
    if (hidden != null && ((Boolean) hidden)) {
        return;
    }
    xmlDump.append("    <sequenceFlow id=\"" + getUniqueNodeId(connection.getFrom()) + "-" + getUniqueNodeId(connection.getTo()) + "\" sourceRef=\"" + getUniqueNodeId(connection.getFrom()) + "\" ");
    // TODO fromType, toType
    xmlDump.append("targetRef=\"" + getUniqueNodeId(connection.getTo()) + "\" ");
    if (metaDataType == META_DATA_AS_NODE_PROPERTY) {
        String bendpoints = (String) connection.getMetaData().get("bendpoints");
        if (bendpoints != null) {
            xmlDump.append("g:bendpoints=\"" + bendpoints + "\" ");
        }
    }
    if (connection.getFrom() instanceof Split) {
        Split split = (Split) connection.getFrom();
        if (split.getType() == Split.TYPE_XOR || split.getType() == Split.TYPE_OR) {
            Constraint constraint = split.getConstraint(connection);
            if (constraint == null) {
                xmlDump.append(">" + EOL + "      <conditionExpression xsi:type=\"tFormalExpression\" />");
            } else {
                if (constraint.getName() != null && constraint.getName().trim().length() > 0) {
                    xmlDump.append("name=\"" + XmlBPMNProcessDumper.replaceIllegalCharsAttribute(constraint.getName()) + "\" ");
                }
                if (constraint.getPriority() != 0) {
                    xmlDump.append("tns:priority=\"" + constraint.getPriority() + "\" ");
                }
                xmlDump.append(">" + EOL + "      <conditionExpression xsi:type=\"tFormalExpression\" ");
                if ("code".equals(constraint.getType())) {
                    if (JavaDialect.ID.equals(constraint.getDialect())) {
                        xmlDump.append("language=\"" + JAVA_LANGUAGE + "\" ");
                    } else if ("XPath".equals(constraint.getDialect())) {
                        xmlDump.append("language=\"" + XPATH_LANGUAGE + "\" ");
                    } else if ("JavaScript".equals(constraint.getDialect())) {
                        xmlDump.append("language=\"" + JAVASCRIPT_LANGUAGE + "\" ");
                    }
                } else {
                    xmlDump.append("language=\"" + RULE_LANGUAGE + "\" ");
                }
                String constraintString = constraint.getConstraint();
                if (constraintString == null) {
                    constraintString = "";
                }
                xmlDump.append(">" + XmlDumper.replaceIllegalChars(constraintString) + "</conditionExpression>");
            }
            xmlDump.append(EOL + "    </sequenceFlow>" + EOL);
        } else {
            xmlDump.append("/>" + EOL);
        }
    } else {
        xmlDump.append("/>" + EOL);
    }
}
Also used : Constraint(org.jbpm.workflow.core.Constraint) ConnectionImpl(org.jbpm.workflow.core.impl.ConnectionImpl) Split(org.jbpm.workflow.core.node.Split)

Example 17 with Split

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

the class XmlBPMNProcessDumper method visitNodesDi.

private void visitNodesDi(Node[] nodes, StringBuilder xmlDump) {
    for (Node node : nodes) {
        Integer x = (Integer) node.getMetaData().get("x");
        Integer y = (Integer) node.getMetaData().get("y");
        Integer width = (Integer) node.getMetaData().get("width");
        Integer height = (Integer) node.getMetaData().get("height");
        if (x == null) {
            x = 0;
        }
        if (y == null) {
            y = 0;
        }
        if (width == null) {
            width = 48;
        }
        if (height == null) {
            height = 48;
        }
        if (node instanceof StartNode || node instanceof EndNode || node instanceof EventNode || node instanceof FaultNode) {
            int offsetX = (int) ((width - 48) / 2);
            width = 48;
            x = x + offsetX;
            int offsetY = (int) ((height - 48) / 2);
            y = y + offsetY;
            height = 48;
        } else if (node instanceof Join || node instanceof Split) {
            int offsetX = (int) ((width - 48) / 2);
            width = 48;
            x = x + offsetX;
            int offsetY = (int) ((height - 48) / 2);
            y = y + offsetY;
            height = 48;
        }
        int parentOffsetX = 0;
        int parentOffsetY = 0;
        NodeContainer nodeContainer = node.getNodeContainer();
        while (nodeContainer instanceof CompositeNode) {
            CompositeNode parent = (CompositeNode) nodeContainer;
            Integer parentX = (Integer) parent.getMetaData().get("x");
            if (parentX != null) {
                parentOffsetX += parentX;
            }
            Integer parentY = (Integer) parent.getMetaData().get("y");
            if (parentY != null) {
                parentOffsetY += (Integer) parent.getMetaData().get("y");
            }
            nodeContainer = parent.getNodeContainer();
        }
        x += parentOffsetX;
        y += parentOffsetY;
        xmlDump.append("      <bpmndi:BPMNShape bpmnElement=\"" + getUniqueNodeId(node) + "\" >" + EOL + "        <dc:Bounds x=\"" + x + "\" " + "y=\"" + y + "\" " + "width=\"" + width + "\" " + "height=\"" + height + "\" />" + EOL + "      </bpmndi:BPMNShape>" + EOL);
        if (node instanceof CompositeNode) {
            visitNodesDi(((CompositeNode) node).getNodes(), xmlDump);
        }
    }
}
Also used : FaultNode(org.jbpm.workflow.core.node.FaultNode) StartNode(org.jbpm.workflow.core.node.StartNode) EventNode(org.jbpm.workflow.core.node.EventNode) CompositeNode(org.jbpm.workflow.core.node.CompositeNode) EndNode(org.jbpm.workflow.core.node.EndNode) HumanTaskNode(org.jbpm.workflow.core.node.HumanTaskNode) ForEachNode(org.jbpm.workflow.core.node.ForEachNode) StartNode(org.jbpm.workflow.core.node.StartNode) CompositeNode(org.jbpm.workflow.core.node.CompositeNode) FaultNode(org.jbpm.workflow.core.node.FaultNode) WorkItemNode(org.jbpm.workflow.core.node.WorkItemNode) ActionNode(org.jbpm.workflow.core.node.ActionNode) EndNode(org.jbpm.workflow.core.node.EndNode) EventNode(org.jbpm.workflow.core.node.EventNode) Node(org.kie.api.definition.process.Node) Join(org.jbpm.workflow.core.node.Join) NodeContainer(org.kie.api.definition.process.NodeContainer) Split(org.jbpm.workflow.core.node.Split) Constraint(org.jbpm.workflow.core.Constraint)

Example 18 with Split

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

the class SplitHandler method writeNode.

public void writeNode(Node node, StringBuilder xmlDump, int metaDataType) {
    Split split = (Split) node;
    String type = null;
    switch(split.getType()) {
        case Split.TYPE_AND:
            type = "parallelGateway";
            writeNode(type, node, xmlDump, metaDataType);
            break;
        case Split.TYPE_XOR:
            type = "exclusiveGateway";
            writeNode(type, node, xmlDump, metaDataType);
            for (Map.Entry<ConnectionRef, Constraint> entry : split.getConstraints().entrySet()) {
                if (entry.getValue() != null && entry.getValue().isDefault()) {
                    xmlDump.append("default=\"" + XmlBPMNProcessDumper.getUniqueNodeId(split) + "-" + XmlBPMNProcessDumper.getUniqueNodeId(node.getNodeContainer().getNode(entry.getKey().getNodeId())) + "\" ");
                    break;
                }
            }
            break;
        case Split.TYPE_OR:
            type = "inclusiveGateway";
            writeNode(type, node, xmlDump, metaDataType);
            for (Map.Entry<ConnectionRef, Constraint> entry : split.getConstraints().entrySet()) {
                if (entry.getValue() != null && entry.getValue().isDefault()) {
                    xmlDump.append("default=\"" + XmlBPMNProcessDumper.getUniqueNodeId(split) + "-" + XmlBPMNProcessDumper.getUniqueNodeId(node.getNodeContainer().getNode(entry.getKey().getNodeId())) + "\" ");
                    break;
                }
            }
            break;
        case Split.TYPE_XAND:
            type = "eventBasedGateway";
            writeNode(type, node, xmlDump, metaDataType);
            break;
        default:
            type = "complexGateway";
            writeNode(type, node, xmlDump, metaDataType);
    }
    xmlDump.append("gatewayDirection=\"Diverging\" >" + EOL);
    writeExtensionElements(node, xmlDump);
    endNode(type, xmlDump);
}
Also used : Constraint(org.jbpm.workflow.core.Constraint) Split(org.jbpm.workflow.core.node.Split) Map(java.util.Map) ConnectionRef(org.jbpm.workflow.core.impl.ConnectionRef)

Aggregations

Split (org.jbpm.workflow.core.node.Split)18 Constraint (org.jbpm.workflow.core.Constraint)9 Join (org.jbpm.workflow.core.node.Join)8 EventNode (org.jbpm.workflow.core.node.EventNode)6 StartNode (org.jbpm.workflow.core.node.StartNode)6 ActionNode (org.jbpm.workflow.core.node.ActionNode)5 EndNode (org.jbpm.workflow.core.node.EndNode)5 FaultNode (org.jbpm.workflow.core.node.FaultNode)5 StateNode (org.jbpm.workflow.core.node.StateNode)5 WorkItemNode (org.jbpm.workflow.core.node.WorkItemNode)5 Connection (org.kie.api.definition.process.Connection)5 HashMap (java.util.HashMap)4 Map (java.util.Map)4 ConnectionRef (org.jbpm.workflow.core.impl.ConnectionRef)4 DynamicNode (org.jbpm.workflow.core.node.DynamicNode)4 ForEachNode (org.jbpm.workflow.core.node.ForEachNode)4 HumanTaskNode (org.jbpm.workflow.core.node.HumanTaskNode)4 MilestoneNode (org.jbpm.workflow.core.node.MilestoneNode)4 RuleSetNode (org.jbpm.workflow.core.node.RuleSetNode)4 SubProcessNode (org.jbpm.workflow.core.node.SubProcessNode)4