use of io.automatiko.engine.api.definition.process.NodeContainer in project automatiko-engine by automatiko-io.
the class XmlBPMNProcessDumper method getUniqueNodeId.
public static String getUniqueNodeId(Node node) {
String result = (String) node.getMetaData().get("UniqueId");
if (result != null) {
return result;
}
result = node.getId() + "";
NodeContainer nodeContainer = node.getParentContainer();
while (nodeContainer instanceof CompositeNode) {
CompositeNode composite = (CompositeNode) nodeContainer;
result = composite.getId() + "-" + result;
nodeContainer = composite.getParentContainer();
}
return "_" + result;
}
use of io.automatiko.engine.api.definition.process.NodeContainer in project automatiko-engine by automatiko-io.
the class BPMNPlaneHandler method processConnectionInfo.
private boolean processConnectionInfo(ConnectionInfo connectionInfo, Node[] nodes) {
for (Node node : nodes) {
for (List<Connection> connections : node.getOutgoingConnections().values()) {
for (Connection connection : connections) {
String id = (String) connection.getMetaData().get("UniqueId");
if (id != null && id.equals(connectionInfo.getElementRef())) {
((ConnectionImpl) connection).setMetaData("bendpoints", connectionInfo.getBendpoints());
((ConnectionImpl) connection).setMetaData("x", connectionInfo.getXs());
((ConnectionImpl) connection).setMetaData("y", connectionInfo.getYs());
return true;
}
}
}
if (node instanceof NodeContainer) {
boolean found = processConnectionInfo(connectionInfo, ((NodeContainer) node).getNodes());
if (found) {
return true;
}
}
}
return false;
}
use of io.automatiko.engine.api.definition.process.NodeContainer in project automatiko-engine by automatiko-io.
the class NodeImpl method getUniqueId.
public String getUniqueId() {
String result = id + "";
NodeContainer nodeContainer = getParentContainer();
while (nodeContainer instanceof CompositeNode) {
CompositeNode composite = (CompositeNode) nodeContainer;
result = composite.getId() + ":" + result;
nodeContainer = composite.getParentContainer();
}
return result;
}
use of io.automatiko.engine.api.definition.process.NodeContainer in project automatiko-engine by automatiko-io.
the class CompensationTest method findNode.
private Node findNode(ExecutableProcess process, String nodeName) {
Node found = null;
Queue<io.automatiko.engine.api.definition.process.Node> nodes = new LinkedList<io.automatiko.engine.api.definition.process.Node>();
nodes.addAll(Arrays.asList(process.getNodes()));
while (!nodes.isEmpty()) {
io.automatiko.engine.api.definition.process.Node node = nodes.poll();
if (node.getName().equals(nodeName)) {
found = (Node) node;
}
if (node instanceof NodeContainer) {
nodes.addAll(Arrays.asList(((NodeContainer) node).getNodes()));
}
}
assertNotNull(found, "Could not find node (" + nodeName + ").");
return found;
}
use of io.automatiko.engine.api.definition.process.NodeContainer in project automatiko-engine by automatiko-io.
the class ProcessHandler method linkBoundaryTimerEvent.
protected void linkBoundaryTimerEvent(NodeContainer nodeContainer, Node node, String attachedTo, Node attachedNode) {
boolean cancelActivity = (Boolean) node.getMetaData().get("CancelActivity");
StateBasedNode compositeNode = (StateBasedNode) attachedNode;
String timeDuration = (String) node.getMetaData().get("TimeDuration");
String timeCycle = (String) node.getMetaData().get("TimeCycle");
String timeDate = (String) node.getMetaData().get("TimeDate");
Timer timer = new Timer();
if (timeDuration != null) {
timer.setDelay(timeDuration);
timer.setTimeType(Timer.TIME_DURATION);
ConsequenceAction consequenceAction = createJavaAction(new SignalProcessInstanceAction("Timer-" + attachedTo + "-" + timeDuration + "-" + node.getId(), kcontext -> kcontext.getNodeInstance().getId(), SignalProcessInstanceAction.PROCESS_INSTANCE_SCOPE));
compositeNode.addTimer(timer, consequenceAction);
} else if (timeCycle != null) {
int index = timeCycle.indexOf("###");
if (index != -1) {
String period = timeCycle.substring(index + 3);
timeCycle = timeCycle.substring(0, index);
timer.setPeriod(period);
}
timer.setDelay(timeCycle);
timer.setTimeType(Timer.TIME_CYCLE);
String finalTimeCycle = timeCycle;
ConsequenceAction action = createJavaAction(new SignalProcessInstanceAction("Timer-" + attachedTo + "-" + finalTimeCycle + (timer.getPeriod() == null ? "" : "###" + timer.getPeriod()) + "-" + node.getId(), kcontext -> kcontext.getNodeInstance().getId(), SignalProcessInstanceAction.PROCESS_INSTANCE_SCOPE));
compositeNode.addTimer(timer, action);
} else if (timeDate != null) {
timer.setDate(timeDate);
timer.setTimeType(Timer.TIME_DATE);
ConsequenceAction action = createJavaAction(new SignalProcessInstanceAction("Timer-" + attachedTo + "-" + timeDate + "-" + node.getId(), kcontext -> kcontext.getNodeInstance().getId(), SignalProcessInstanceAction.PROCESS_INSTANCE_SCOPE));
compositeNode.addTimer(timer, action);
}
if (cancelActivity) {
List<ProcessAction> actions = ((EventNode) node).getActions(EndNode.EVENT_NODE_EXIT);
if (actions == null) {
actions = new ArrayList<ProcessAction>();
}
ConsequenceAction action = createJavaAction(new CancelNodeInstanceAction(attachedTo));
actions.add(action);
((EventNode) node).setActions(EndNode.EVENT_NODE_EXIT, actions);
}
}
Aggregations