use of io.automatiko.engine.workflow.bpmn2.core.SequenceFlow in project kogito-runtimes by kiegroup.
the class AdHocSubProcessHandler method handleNode.
@SuppressWarnings("unchecked")
@Override
protected Node handleNode(final Node node, final Element element, final String uri, final String localName, final ExtensibleXmlParser parser) throws SAXException {
super.handleNode(node, element, uri, localName, parser);
DynamicNode dynamicNode = (DynamicNode) node;
String cancelRemainingInstances = element.getAttribute("cancelRemainingInstances");
if ("false".equals(cancelRemainingInstances)) {
dynamicNode.setCancelRemainingInstances(false);
}
// by default it should not autocomplete as it's adhoc
org.w3c.dom.Node xmlNode = element.getFirstChild();
dynamicNode.setActivationCondition((String) node.getMetaData().get(CUSTOM_ACTIVATION_CONDITION));
while (xmlNode != null) {
String nodeName = xmlNode.getNodeName();
if (COMPLETION_CONDITION.equals(nodeName)) {
String expression = xmlNode.getTextContent();
if (AUTOCOMPLETE_EXPRESSIONS.contains(expression)) {
dynamicNode.setAutoComplete(true);
} else {
dynamicNode.setCompletionCondition(expression);
}
}
xmlNode = xmlNode.getNextSibling();
}
List<SequenceFlow> connections = (List<SequenceFlow>) dynamicNode.getMetaData(ProcessHandler.CONNECTIONS);
ProcessHandler.linkConnections(dynamicNode, connections);
ProcessHandler.linkBoundaryEvents(dynamicNode);
handleScript(dynamicNode, element, "onEntry");
handleScript(dynamicNode, element, "onExit");
return node;
}
use of io.automatiko.engine.workflow.bpmn2.core.SequenceFlow in project kogito-runtimes by kiegroup.
the class ProcessHandler method linkConnections.
public static void linkConnections(NodeContainer nodeContainer, List<SequenceFlow> connections) {
if (connections != null) {
for (SequenceFlow connection : connections) {
String sourceRef = connection.getSourceRef();
Node source = findNodeByIdOrUniqueIdInMetadata(nodeContainer, sourceRef, "Could not find source node for connection:" + sourceRef);
if (source instanceof EventNode) {
for (EventFilter eventFilter : ((EventNode) source).getEventFilters()) {
if (eventFilter instanceof EventTypeFilter) {
if ("Compensation".equals(((EventTypeFilter) eventFilter).getType())) {
// BPMN Method & Style, 2nd Ed. (Silver), states this on P. 131
throw new ProcessParsingValidationException("A Compensation Boundary Event can only be *associated* with a compensation activity via an Association, not via a Sequence Flow element.");
}
}
}
}
String targetRef = connection.getTargetRef();
Node target = findNodeByIdOrUniqueIdInMetadata(nodeContainer, targetRef, "Could not find target node for connection:" + targetRef);
Connection result = new ConnectionImpl(source, NodeImpl.CONNECTION_DEFAULT_TYPE, target, NodeImpl.CONNECTION_DEFAULT_TYPE);
result.setMetaData("bendpoints", connection.getBendpoints());
result.setMetaData("UniqueId", connection.getId());
if ("true".equals(System.getProperty("jbpm.enable.multi.con"))) {
NodeImpl nodeImpl = (NodeImpl) source;
Constraint constraint = buildConstraint(connection, nodeImpl);
if (constraint != null) {
nodeImpl.addConstraint(new ConnectionRef(connection.getId(), target.getId(), NodeImpl.CONNECTION_DEFAULT_TYPE), constraint);
}
} else if (source instanceof Split) {
Split split = (Split) source;
Constraint constraint = buildConstraint(connection, split);
split.addConstraint(new ConnectionRef(connection.getId(), target.getId(), NodeImpl.CONNECTION_DEFAULT_TYPE), constraint);
}
}
}
}
use of io.automatiko.engine.workflow.bpmn2.core.SequenceFlow in project kogito-runtimes by kiegroup.
the class ProcessHandler method end.
@Override
@SuppressWarnings("unchecked")
public Object end(final String uri, final String localName, final ExtensibleXmlParser parser) throws SAXException {
parser.endElementBuilder();
RuleFlowProcess process = (RuleFlowProcess) parser.getCurrent();
List<IntermediateLink> throwLinks = (List<IntermediateLink>) process.getMetaData(LINKS);
linkIntermediateLinks(process, throwLinks);
List<SequenceFlow> connections = (List<SequenceFlow>) process.getMetaData(CONNECTIONS);
linkConnections(process, connections);
linkBoundaryEvents(process);
// This must be done *after* linkConnections(process, connections)
// because it adds hidden connections for compensations
List<Association> associations = (List<Association>) process.getMetaData(ASSOCIATIONS);
linkAssociations((Definitions) process.getMetaData("Definitions"), process, associations);
List<Lane> lanes = (List<Lane>) process.getMetaData(LaneHandler.LANES);
assignLanes(process, lanes);
postProcessNodes(process, process);
postProcessCollaborations(process, parser);
return process;
}
use of io.automatiko.engine.workflow.bpmn2.core.SequenceFlow in project kogito-runtimes by kiegroup.
the class SequenceFlowHandler method start.
@SuppressWarnings("unchecked")
public Object start(final String uri, final String localName, final Attributes attrs, final ExtensibleXmlParser parser) throws SAXException {
parser.startElementBuilder(localName, attrs);
final String id = attrs.getValue("id");
final String sourceRef = attrs.getValue("sourceRef");
final String targetRef = attrs.getValue("targetRef");
final String bendpoints = attrs.getValue("g:bendpoints");
final String name = attrs.getValue("name");
final String priority = attrs.getValue("http://www.jboss.org/drools", "priority");
NodeContainer nodeContainer = (NodeContainer) parser.getParent();
List<SequenceFlow> connections = null;
if (nodeContainer instanceof RuleFlowProcess) {
RuleFlowProcess process = (RuleFlowProcess) nodeContainer;
connections = (List<SequenceFlow>) process.getMetaData(ProcessHandler.CONNECTIONS);
if (connections == null) {
connections = new ArrayList<>();
process.setMetaData(ProcessHandler.CONNECTIONS, connections);
}
} else if (nodeContainer instanceof CompositeNode) {
CompositeNode compositeNode = (CompositeNode) nodeContainer;
connections = (List<SequenceFlow>) compositeNode.getMetaData(ProcessHandler.CONNECTIONS);
if (connections == null) {
connections = new ArrayList<>();
compositeNode.setMetaData(ProcessHandler.CONNECTIONS, connections);
}
}
SequenceFlow connection = new SequenceFlow(id, sourceRef, targetRef);
connection.setBendpoints(bendpoints);
connection.setName(name);
if (priority != null) {
connection.setPriority(Integer.parseInt(priority));
}
if (connections != null) {
connections.add(connection);
}
return connection;
}
use of io.automatiko.engine.workflow.bpmn2.core.SequenceFlow in project kogito-runtimes by kiegroup.
the class SubProcessHandler method handleNode.
@Override
protected Node handleNode(Node node, Element element, String uri, String localName, ExtensibleXmlParser parser) throws SAXException {
CompositeContextNode compositeNode = (CompositeContextNode) node;
super.handleNode(node, element, uri, localName, parser);
handleScript(compositeNode, element, "onEntry");
handleScript(compositeNode, element, "onExit");
compositeNode.setIoSpecification(readIOEspecification(parser, element));
compositeNode.setMultiInstanceSpecification(readMultiInstanceSpecification(parser, element, compositeNode.getIoSpecification()));
Node outcome = compositeNode;
if (compositeNode.getMultiInstanceSpecification().hasMultiInstanceInput()) {
ForEachNode forEachNode = (ForEachNode) decorateMultiInstanceSpecificationSubProcess(compositeNode, compositeNode.getMultiInstanceSpecification());
handleScript(forEachNode, element, "onEntry");
handleScript(forEachNode, element, "onExit");
List<SequenceFlow> connections = (List<SequenceFlow>) forEachNode.getMetaData(ProcessHandler.CONNECTIONS);
ProcessHandler.linkConnections(forEachNode, connections);
ProcessHandler.linkBoundaryEvents(forEachNode);
// This must be done *after* linkConnections(process, connections)
// because it adds hidden connections for compensations
List<Association> associations = (List<Association>) forEachNode.getMetaData(ProcessHandler.ASSOCIATIONS);
ProcessHandler.linkAssociations((Definitions) forEachNode.getMetaData("Definitions"), forEachNode, associations);
applyAsync(node, Boolean.parseBoolean((String) compositeNode.getMetaData().get("customAsync")));
outcome = forEachNode;
} else {
handleCompositeContextNode(compositeNode);
}
NodeContainer nodeContainer = (NodeContainer) parser.getParent();
nodeContainer.addNode(outcome);
return outcome;
}
Aggregations