use of io.automatiko.engine.workflow.bpmn2.core.Association in project jbpm by kiegroup.
the class AbstractCompositeNodeHandler method visitConnectionsAndAssociations.
protected void visitConnectionsAndAssociations(Node node, StringBuilder xmlDump, int metaDataType) {
// add associations
List<Connection> connections = getSubConnections((CompositeNode) node);
xmlDump.append(" <!-- connections -->" + EOL);
for (Connection connection : connections) {
XmlBPMNProcessDumper.INSTANCE.visitConnection(connection, xmlDump, metaDataType);
}
// add associations
List<Association> associations = (List<Association>) node.getMetaData().get(ProcessHandler.ASSOCIATIONS);
if (associations != null) {
for (Association association : associations) {
XmlBPMNProcessDumper.INSTANCE.visitAssociation(association, xmlDump);
}
}
}
use of io.automatiko.engine.workflow.bpmn2.core.Association in project kogito-runtimes by kiegroup.
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;
KogitoNode targetNode = (KogitoNode) 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 ProcessParsingValidationException(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 ProcessParsingValidationException("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", null);
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.bpmn2.core.Association in project kogito-runtimes by kiegroup.
the class AbstractCompositeNodeHandler method visitConnectionsAndAssociations.
protected void visitConnectionsAndAssociations(Node node, StringBuilder xmlDump, int metaDataType) {
// add associations
List<Connection> connections = getSubConnections((CompositeNode) node);
xmlDump.append(" <!-- connections -->" + EOL);
for (Connection connection : connections) {
XmlBPMNProcessDumper.INSTANCE.visitConnection(connection, xmlDump, metaDataType);
}
// add associations
List<Association> associations = (List<Association>) node.getMetaData().get(ProcessHandler.ASSOCIATIONS);
if (associations != null) {
for (Association association : associations) {
XmlBPMNProcessDumper.INSTANCE.visitAssociation(association, xmlDump);
}
}
}
use of io.automatiko.engine.workflow.bpmn2.core.Association in project automatiko-engine by automatiko-io.
the class AssociationHandler method start.
public Object start(final String uri, final String localName, final Attributes attrs, final ExtensibleXmlParser parser) throws SAXException {
parser.startElementBuilder(localName, attrs);
Association association = new Association();
association.setId(attrs.getValue("id"));
association.setSourceRef(attrs.getValue("sourceRef"));
association.setTargetRef(attrs.getValue("targetRef"));
String direction = attrs.getValue("associationDirection");
if (direction != null) {
boolean acceptableDirection = false;
direction = direction.toLowerCase();
String[] possibleDirections = { "none", "one", "both" };
for (String acceptable : possibleDirections) {
if (acceptable.equals(direction)) {
acceptableDirection = true;
break;
}
}
if (!acceptableDirection) {
throw new IllegalArgumentException("Unknown direction '" + direction + "' used in Association " + association.getId());
}
}
association.setDirection(direction);
/**
* BPMN2 spec, p. 66: "At this point, BPMN provides three standard Artifacts:
* Associations, Groups, and Text Annotations. ... When an Artifact is defined
* it is contained within a Collaboration or a FlowElementsContainer (a Process
* or Choreography)."
*
* (In other words: associations must be defined within a process, not outside)
*/
List<Association> associations = null;
NodeContainer nodeContainer = (NodeContainer) parser.getParent();
if (nodeContainer instanceof Process) {
ExecutableProcess process = (ExecutableProcess) nodeContainer;
associations = (List<Association>) process.getMetaData(ASSOCIATIONS);
if (associations == null) {
associations = new ArrayList<>();
process.setMetaData(ASSOCIATIONS, associations);
}
} else if (nodeContainer instanceof CompositeNode) {
CompositeContextNode compositeNode = (CompositeContextNode) nodeContainer;
associations = (List<Association>) compositeNode.getMetaData(ASSOCIATIONS);
if (associations == null) {
associations = new ArrayList<>();
compositeNode.setMetaData(ProcessHandler.ASSOCIATIONS, associations);
}
} else {
associations = new ArrayList<>();
}
associations.add(association);
return association;
}
use of io.automatiko.engine.workflow.bpmn2.core.Association in project automatiko-engine by automatiko-io.
the class AbstractCompositeNodeHandler method visitConnectionsAndAssociations.
protected void visitConnectionsAndAssociations(Node node, StringBuilder xmlDump, int metaDataType) {
// add associations
List<Connection> connections = getSubConnections((CompositeNode) node);
xmlDump.append(" <!-- connections -->" + EOL);
for (Connection connection : connections) {
XmlBPMNProcessDumper.INSTANCE.visitConnection(connection, xmlDump, metaDataType);
}
// add associations
List<Association> associations = (List<Association>) node.getMetaData().get(ProcessHandler.ASSOCIATIONS);
if (associations != null) {
for (Association association : associations) {
XmlBPMNProcessDumper.INSTANCE.visitAssociation(association, xmlDump);
}
}
}
Aggregations