use of io.automatiko.engine.workflow.process.core.node.Split in project automatiko-engine by automatiko-io.
the class ProcessHandler method linkConnections.
public 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 IllegalArgumentException("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.process.core.node.Split in project automatiko-engine by automatiko-io.
the class JoinInstance method checkNodes.
private boolean checkNodes(Set<Long> vistedNodes, Node startAt, Node currentNode, Node lookFor) {
if (currentNode == null) {
// for dynamic/ad hoc task there is no node
return false;
}
List<Connection> connections = currentNode.getOutgoingConnections(io.automatiko.engine.workflow.process.core.Node.CONNECTION_DEFAULT_TYPE);
// special handling for XOR split as it usually is used for arbitrary loops
if (currentNode instanceof Split && ((Split) currentNode).getType() == Split.TYPE_XOR) {
if (vistedNodes.contains(startAt.getId())) {
return false;
}
for (Connection conn : connections) {
Set<Long> xorCopy = new HashSet<Long>(vistedNodes);
Node nextNode = conn.getTo();
if (nextNode == null) {
continue;
} else {
xorCopy.add(nextNode.getId());
if (nextNode.getId() != lookFor.getId()) {
checkNodes(xorCopy, currentNode, nextNode, lookFor);
}
}
if (xorCopy.contains(lookFor.getId())) {
vistedNodes.addAll(xorCopy);
return true;
}
}
} else {
for (Connection conn : connections) {
Node nextNode = conn.getTo();
if (nextNode == null) {
continue;
} else {
if (vistedNodes.contains(nextNode.getId())) {
// we have already been here so let's continue
continue;
}
if (nextNode.getId() == lookFor.getId()) {
// we found the node that we are looking for, add it and continue to find out
// other parts
// as it could be part of a loop
vistedNodes.add(nextNode.getId());
continue;
}
vistedNodes.add(nextNode.getId());
if (startAt.getId() == nextNode.getId()) {
return true;
} else {
boolean nestedCheck = checkNodes(vistedNodes, startAt, nextNode, lookFor);
if (nestedCheck) {
return true;
}
}
}
}
}
return false;
}
use of io.automatiko.engine.workflow.process.core.node.Split in project automatiko-engine by automatiko-io.
the class SplitInstance method internalTrigger.
public void internalTrigger(final NodeInstance from, String type) {
if (!io.automatiko.engine.workflow.process.core.Node.CONNECTION_DEFAULT_TYPE.equals(type)) {
throw new IllegalArgumentException("A Split only accepts default incoming connections!");
}
triggerTime = new Date();
final Split split = getSplit();
try {
executeStrategy(split, type);
} catch (WorkflowRuntimeException wre) {
throw wre;
} catch (Exception e) {
throw new WorkflowRuntimeException(this, getProcessInstance(), "Unable to execute Split: " + e.getMessage(), e);
}
}
use of io.automatiko.engine.workflow.process.core.node.Split in project automatiko-engine by automatiko-io.
the class SvgBpmnProcessImageGenerator method buildGateway.
protected void buildGateway(int x, int y, Node node, SVGGraphics2D g2) throws IOException {
setNodeId(node, g2);
x += x(node);
y += y(node);
int width = width(node);
int height = height(node);
Polygon p = new Polygon();
p.addPoint(x, y + (height / 2));
p.addPoint(x + (width / 2), y);
p.addPoint(x + width, y + (height / 2));
p.addPoint(x + (width / 2), y + height);
g2.drawPolygon(p);
setTextNodeId(node, g2);
drawCenteredString(g2, node.getName(), p.getBounds(), g2.getFont(), (height(node) / 2) + 10);
Font current = g2.getFont();
g2.setFont(new Font("Montserrat", Font.BOLD, 25));
String gatewayMarker = "";
if (node instanceof Split) {
switch(((Split) node).getType()) {
case Split.TYPE_XOR:
gatewayMarker = "X";
break;
case Split.TYPE_AND:
gatewayMarker = "+";
break;
case Split.TYPE_OR:
gatewayMarker = "o";
break;
default:
break;
}
} else if (node instanceof Join) {
switch(((Join) node).getType()) {
case Join.TYPE_XOR:
gatewayMarker = "X";
break;
case Join.TYPE_AND:
gatewayMarker = "+";
break;
case Join.TYPE_OR:
gatewayMarker = "o";
break;
default:
break;
}
}
drawCenteredString(g2, gatewayMarker, p.getBounds(), g2.getFont(), 0);
g2.setFont(current);
}
use of io.automatiko.engine.workflow.process.core.node.Split in project automatiko-engine by automatiko-io.
the class ServerlessWorkflowFactory method eventBasedSplit.
public Split eventBasedSplit(long id, String name, NodeContainer nodeContainer) {
Split split = new Split();
split.setId(id);
split.setName(name);
split.setType(Split.TYPE_XAND);
split.setMetaData(UNIQUE_ID_PARAM, Long.toString(id));
split.setMetaData(EVENTBASED_PARAM, "true");
nodeContainer.addNode(split);
return split;
}
Aggregations