use of org.jbpm.workflow.core.impl.ConnectionRef in project jbpm by kiegroup.
the class SplitNodeBuilder method build.
public void build(Process process, ProcessDescr processDescr, ProcessBuildContext context, Node node) {
Split splitNode = (Split) node;
if (splitNode.getType() != Split.TYPE_XOR && splitNode.getType() != Split.TYPE_OR) {
// we only process or/xor
return;
}
// we need to clone the map, so we can update the original while iterating.
Map<ConnectionRef, Constraint> map = new HashMap<ConnectionRef, Constraint>(splitNode.getConstraints());
for (Iterator<Map.Entry<ConnectionRef, Constraint>> it = map.entrySet().iterator(); it.hasNext(); ) {
Map.Entry<ConnectionRef, Constraint> entry = it.next();
ConnectionRef connection = entry.getKey();
ConstraintImpl constraint = (ConstraintImpl) entry.getValue();
Connection outgoingConnection = null;
for (Connection out : splitNode.getDefaultOutgoingConnections()) {
if (out.getToType().equals(connection.getToType()) && out.getTo().getId() == connection.getNodeId()) {
outgoingConnection = out;
}
}
if (outgoingConnection == null) {
throw new IllegalArgumentException("Could not find outgoing connection");
}
if (constraint == null && splitNode.isDefault(outgoingConnection)) {
// do nothing since conditions are ignored for default sequence flow
} else if (constraint != null && "rule".equals(constraint.getType())) {
RuleConstraintEvaluator ruleConstraint = new RuleConstraintEvaluator();
ruleConstraint.setDialect(constraint.getDialect());
ruleConstraint.setName(constraint.getName());
ruleConstraint.setPriority(constraint.getPriority());
ruleConstraint.setDefault(constraint.isDefault());
ruleConstraint.setType(constraint.getType());
ruleConstraint.setConstraint(constraint.getConstraint());
splitNode.setConstraint(outgoingConnection, ruleConstraint);
} else if (constraint != null && "code".equals(constraint.getType())) {
ReturnValueConstraintEvaluator returnValueConstraint = new ReturnValueConstraintEvaluator();
returnValueConstraint.setDialect(constraint.getDialect());
returnValueConstraint.setName(constraint.getName());
returnValueConstraint.setPriority(constraint.getPriority());
returnValueConstraint.setDefault(constraint.isDefault());
returnValueConstraint.setType(constraint.getType());
returnValueConstraint.setConstraint(constraint.getConstraint());
splitNode.setConstraint(outgoingConnection, returnValueConstraint);
ReturnValueDescr returnValueDescr = new ReturnValueDescr();
returnValueDescr.setText(constraint.getConstraint());
returnValueDescr.setResource(processDescr.getResource());
ProcessDialect dialect = ProcessDialectRegistry.getDialect(constraint.getDialect());
dialect.getReturnValueEvaluatorBuilder().build(context, returnValueConstraint, returnValueDescr, (NodeImpl) node);
}
}
}
use of org.jbpm.workflow.core.impl.ConnectionRef in project jbpm by kiegroup.
the class Split method isDefault.
public boolean isDefault(final Connection connection) {
if (connection == null) {
throw new IllegalArgumentException("connection is null");
}
if (this.type == TYPE_OR || this.type == TYPE_XOR) {
ConnectionRef ref = new ConnectionRef(connection.getTo().getId(), connection.getToType());
Constraint constraint = this.constraints.get(ref);
String defaultConnection = (String) getMetaData().get("Default");
String connectionId = (String) connection.getMetaData().get("UniqueId");
if (constraint != null) {
return constraint.isDefault();
} else if (constraint == null && connectionId.equals(defaultConnection)) {
return true;
} else {
return false;
}
}
throw new UnsupportedOperationException("Constraints are " + "only supported with XOR or OR split types, not with: " + getType());
}
use of org.jbpm.workflow.core.impl.ConnectionRef in project jbpm by kiegroup.
the class Split method removeConstraint.
public void removeConstraint(Connection connection) {
ConnectionRef ref = new ConnectionRef(connection.getTo().getId(), connection.getToType());
internalRemoveConstraint(ref);
}
use of org.jbpm.workflow.core.impl.ConnectionRef in project jbpm by kiegroup.
the class SplitNodeHandler method writeNode.
public void writeNode(Node node, StringBuilder xmlDump, boolean includeMeta) {
Split splitNode = (Split) node;
writeNode("split", splitNode, xmlDump, includeMeta);
int type = splitNode.getType();
if (type != 0) {
xmlDump.append("type=\"" + type + "\" ");
}
if (splitNode.getConstraints().isEmpty()) {
endNode(xmlDump);
} else {
xmlDump.append(">" + EOL);
if (includeMeta) {
writeMetaData(splitNode, xmlDump);
}
xmlDump.append(" <constraints>" + EOL);
for (Map.Entry<ConnectionRef, Constraint> entry : splitNode.getConstraints().entrySet()) {
ConnectionRef connection = entry.getKey();
Constraint constraint = entry.getValue();
xmlDump.append(" <constraint " + "toNodeId=\"" + connection.getNodeId() + "\" " + "toType=\"" + connection.getToType() + "\" ");
String name = constraint.getName();
if (name != null && !"".equals(name)) {
xmlDump.append("name=\"" + XmlDumper.replaceIllegalChars(constraint.getName()) + "\" ");
}
int priority = constraint.getPriority();
if (priority != 0) {
xmlDump.append("priority=\"" + constraint.getPriority() + "\" ");
}
xmlDump.append("type=\"" + constraint.getType() + "\" ");
String dialect = constraint.getDialect();
if (dialect != null && !"".equals(dialect)) {
xmlDump.append("dialect=\"" + dialect + "\" ");
}
String constraintString = constraint.getConstraint();
if (constraintString != null) {
xmlDump.append(">" + XmlDumper.replaceIllegalChars(constraintString) + "</constraint>" + EOL);
} else {
xmlDump.append("/>" + EOL);
}
}
xmlDump.append(" </constraints>" + EOL);
endNode("split", xmlDump);
}
}
use of org.jbpm.workflow.core.impl.ConnectionRef 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