use of io.automatiko.engine.workflow.process.core.impl.ConnectionImpl in project automatiko-engine by automatiko-io.
the class ProcessHandler method linkAssociations.
public static void linkAssociations(Definitions definitions, NodeContainer nodeContainer, List<Association> associations) {
if (associations != null) {
for (Association association : associations) {
String sourceRef = association.getSourceRef();
Object source = null;
try {
source = findNodeOrDataStoreByUniqueId(definitions, nodeContainer, sourceRef, "Could not find source [" + sourceRef + "] for association " + association.getId() + "]");
} catch (IllegalArgumentException e) {
// source not found
}
String targetRef = association.getTargetRef();
Object target = null;
try {
target = findNodeOrDataStoreByUniqueId(definitions, nodeContainer, targetRef, "Could not find target [" + targetRef + "] for association [" + association.getId() + "]");
} catch (IllegalArgumentException e) {
// target not found
}
if (source == null || target == null) {
// TODO: ignoring this association for now
} else if (target instanceof DataStore || source instanceof DataStore) {
// TODO: ignoring data store associations for now
} else if (source instanceof EventNode) {
EventNode sourceNode = (EventNode) source;
Node targetNode = (Node) target;
checkBoundaryEventCompensationHandler(association, sourceNode, targetNode);
// make sure IsForCompensation is set to true on target
NodeImpl targetNodeImpl = (NodeImpl) target;
String isForCompensation = "isForCompensation";
Object compensationObject = targetNodeImpl.getMetaData(isForCompensation);
if (compensationObject == null) {
targetNodeImpl.setMetaData(isForCompensation, true);
logger.warn("Setting {} attribute to true for node {}", isForCompensation, targetRef);
} else if (!Boolean.parseBoolean(compensationObject.toString())) {
throw new IllegalArgumentException(isForCompensation + " attribute [" + compensationObject + "] should be true for Compensation Activity [" + targetRef + "]");
}
// put Compensation Handler in CompensationHandlerNode
NodeContainer sourceParent = sourceNode.getParentContainer();
NodeContainer targetParent = targetNode.getParentContainer();
if (!sourceParent.equals(targetParent)) {
throw new IllegalArgumentException("Compensation Associations may not cross (sub-)process boundaries,");
}
// connect boundary event to compensation activity
ConnectionImpl connection = new ConnectionImpl(sourceNode, NodeImpl.CONNECTION_DEFAULT_TYPE, targetNode, NodeImpl.CONNECTION_DEFAULT_TYPE);
connection.setMetaData("UniqueId", association.getId());
connection.setMetaData("hidden", true);
connection.setMetaData("association", true);
// Compensation use cases:
// - boundary event --associated-> activity
// - implicit sub process compensation handler + recursive?
/**
* BPMN2 spec, p.442: "A Compensation Event Sub-process becomes enabled when its
* parent Activity transitions into state Completed. At that time, a snapshot of
* the data associated with the parent Acitivity is taken and kept for later
* usage by the Compensation Event Sub-Process."
*/
}
}
}
}
use of io.automatiko.engine.workflow.process.core.impl.ConnectionImpl in project automatiko-engine by automatiko-io.
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 ("java".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 if ("FEEL".equals(constraint.getDialect())) {
xmlDump.append("language=\"" + FEEL_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);
}
}
Aggregations