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);
}
}
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);
}
}
}
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);
}
Aggregations