use of io.automatiko.engine.workflow.process.core.node.Join in project automatiko-engine by automatiko-io.
the class SvgBpmnProcessImageGenerator method buildNodeContainer.
/*
* Build methods
*/
protected void buildNodeContainer(int x, int y, NodeContainer nodeContainer, SVGGraphics2D g2) {
try {
for (Node node : nodeContainer.getNodes()) {
if (node instanceof StartNode) {
buildStartEvent(x, y, (StartNode) node, g2);
} else if (node instanceof EndNode) {
buildEndEvent(x, y, (EndNode) node, g2);
} else if (node instanceof FaultNode) {
buildErrorEndEvent(x, y, (FaultNode) node, g2);
} else if (node instanceof BoundaryEventNode) {
buildBoundaryEvent(x, y, node, g2);
} else if (node instanceof EventNode || node instanceof StateNode) {
buildIntermediateEvent(x, y, node, g2);
} else if (node instanceof HumanTaskNode) {
buildHumanTaskNode(x, y, (HumanTaskNode) node, g2);
} else if (node instanceof ActionNode) {
buildScriptTaskNode(x, y, (ActionNode) node, g2);
} else if (node instanceof WorkItemNode) {
buildServiceTaskNode(x, y, (WorkItemNode) node, g2);
} else if (node instanceof Split || node instanceof Join) {
buildGateway(x, y, node, g2);
} else if (node instanceof ForEachNode) {
buildNodeContainer(x(node), y(node), ((ForEachNode) node).getCompositeNode(), g2);
} else if (node instanceof CompositeNode) {
buildSubprocessNode(x, y, (CompositeNode) node, g2);
int sx = x(node);
int sy = y(node);
buildNodeContainer(sx, sy, (CompositeNode) node, g2);
} else if (node instanceof RuleSetNode) {
buildBusinessRuleTaskNode(x, y, (RuleSetNode) node, g2);
} else if (node instanceof TimerNode) {
buildTimerEvent(x, y, (TimerNode) node, g2);
} else if (node instanceof SubProcessNode) {
buildCallActivity(x, y, (SubProcessNode) node, g2);
}
buildSequenceFlow(x, y, node, g2);
}
} catch (IOException e) {
throw new UncheckedIOException(e);
}
}
use of io.automatiko.engine.workflow.process.core.node.Join in project automatiko-engine by automatiko-io.
the class JoinHandler method writeNode.
public void writeNode(Node node, StringBuilder xmlDump, int metaDataType) {
Join join = (Join) node;
String type = null;
switch(join.getType()) {
case Join.TYPE_AND:
type = "parallelGateway";
break;
case Join.TYPE_XOR:
type = "exclusiveGateway";
break;
case Join.TYPE_OR:
type = "inclusiveGateway";
break;
default:
type = "complexGateway";
}
writeNode(type, node, xmlDump, metaDataType);
xmlDump.append("gatewayDirection=\"Converging\" >" + EOL);
writeExtensionElements(join, xmlDump);
endNode(type, xmlDump);
}
use of io.automatiko.engine.workflow.process.core.node.Join in project automatiko-engine by automatiko-io.
the class JoinInstance 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("An ActionNode only accepts default incoming connections!");
}
triggerTime = new Date();
final Join join = getJoin();
switch(join.getType()) {
case Join.TYPE_XOR:
triggerCompleted();
break;
case Join.TYPE_AND:
Integer count = (Integer) this.triggers.get(from.getNodeId());
if (count == null) {
this.triggers.put(from.getNodeId(), 1);
} else {
this.triggers.put(from.getNodeId(), count.intValue() + 1);
}
if (checkAllActivated()) {
decreaseAllTriggers();
triggerCompleted();
}
break;
case Join.TYPE_DISCRIMINATOR:
boolean triggerCompleted = triggers.isEmpty();
triggers.put(from.getNodeId(), new Integer(1));
if (checkAllActivated()) {
resetAllTriggers();
}
if (triggerCompleted) {
triggerCompleted();
}
break;
case Join.TYPE_N_OF_M:
count = (Integer) this.triggers.get(from.getNodeId());
if (count == null) {
this.triggers.put(from.getNodeId(), 1);
} else {
this.triggers.put(from.getNodeId(), count.intValue() + 1);
}
int counter = 0;
for (final Connection connection : getJoin().getDefaultIncomingConnections()) {
if (this.triggers.get(connection.getFrom().getId()) != null) {
counter++;
}
}
String n = join.getN();
Integer number = null;
if (n.startsWith("#{") && n.endsWith("}")) {
n = n.substring(2, n.length() - 1);
VariableScopeInstance variableScopeInstance = (VariableScopeInstance) resolveContextInstance(VariableScope.VARIABLE_SCOPE, n);
if (variableScopeInstance == null) {
throw new IllegalArgumentException("Could not find variable " + n + " when executing join.");
}
Object value = variableScopeInstance.getVariable(n);
if (value instanceof Number) {
number = ((Number) value).intValue();
} else {
throw new IllegalArgumentException("Variable " + n + " did not return a number when executing join: " + value);
}
} else {
number = Integer.parseInt(n);
}
if (counter >= number) {
resetAllTriggers();
NodeInstanceContainer nodeInstanceContainer = (NodeInstanceContainer) getNodeInstanceContainer();
cancelRemainingDirectFlows(nodeInstanceContainer, getJoin());
triggerCompleted();
}
break;
case Join.TYPE_OR:
NodeInstanceContainer nodeInstanceContainer = (NodeInstanceContainer) getNodeInstanceContainer();
boolean activePathExists = existsActiveDirectFlow(nodeInstanceContainer, getJoin());
if (!activePathExists) {
triggerCompleted();
}
break;
default:
throw new IllegalArgumentException("Illegal join type " + join.getType());
}
}
use of io.automatiko.engine.workflow.process.core.node.Join 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.Join in project automatiko-engine by automatiko-io.
the class ComplexGatewayHandler method createNode.
protected Node createNode(Attributes attrs) {
final String type = attrs.getValue("gatewayDirection");
if ("Converging".equals(type)) {
Join join = new Join();
join.setType(Join.TYPE_UNDEFINED);
return join;
} else if ("Diverging".equals(type)) {
Split split = new Split();
split.setType(Split.TYPE_UNDEFINED);
return split;
} else {
throw new IllegalArgumentException("Unknown gateway direction: " + type);
}
}
Aggregations