use of io.automatiko.engine.workflow.process.core.node.EventNode in project automatiko-engine by automatiko-io.
the class ExecutableProcessFactory method linkBoundaryTimerEvent.
protected void linkBoundaryTimerEvent(Node node, String attachedTo, Node attachedNode) {
boolean cancelActivity = (Boolean) node.getMetaData().get(CANCEL_ACTIVITY);
StateBasedNode compositeNode = (StateBasedNode) attachedNode;
String timeDuration = (String) node.getMetaData().get(TIME_DURATION);
String timeCycle = (String) node.getMetaData().get(TIME_CYCLE);
String timeDate = (String) node.getMetaData().get(TIME_DATE);
Timer timer = new Timer();
if (timeDuration != null) {
timer.setDelay(timeDuration);
timer.setTimeType(Timer.TIME_DURATION);
compositeNode.addTimer(timer, timerAction("Timer-" + attachedTo + "-" + timeDuration + "-" + node.getId()));
} 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);
compositeNode.addTimer(timer, timerAction("Timer-" + attachedTo + "-" + timeCycle + (timer.getPeriod() == null ? "" : "###" + timer.getPeriod()) + "-" + node.getId()));
} else if (timeDate != null) {
timer.setDate(timeDate);
timer.setTimeType(Timer.TIME_DATE);
compositeNode.addTimer(timer, timerAction("Timer-" + attachedTo + "-" + timeDate + "-" + node.getId()));
}
if (cancelActivity) {
List<ProcessAction> actions = ((EventNode) node).getActions(EVENT_NODE_EXIT);
if (actions == null) {
actions = new ArrayList<>();
}
ConsequenceAction cancelAction = new ConsequenceAction("java", null);
cancelAction.setMetaData(ACTION, new CancelNodeInstanceAction(attachedTo));
actions.add(cancelAction);
((EventNode) node).setActions(EVENT_NODE_EXIT, actions);
}
}
use of io.automatiko.engine.workflow.process.core.node.EventNode in project automatiko-engine by automatiko-io.
the class ExecutableProcessFactory method linkBoundaryEvents.
protected void linkBoundaryEvents(NodeContainer nodeContainer) {
for (Node node : nodeContainer.getNodes()) {
if (node instanceof CompositeNode) {
CompositeNode compositeNode = (CompositeNode) node;
linkBoundaryEvents(compositeNode.getNodeContainer());
}
if (node instanceof EventNode) {
final String attachedTo = (String) node.getMetaData().get(ATTACHED_TO);
if (attachedTo != null) {
Node attachedNode = findNodeByIdOrUniqueIdInMetadata(nodeContainer, attachedTo, "Could not find node to attach to: " + attachedTo);
for (EventFilter filter : ((EventNode) node).getEventFilters()) {
String type = ((EventTypeFilter) filter).getType();
if (type.startsWith("Timer-")) {
linkBoundaryTimerEvent(node, attachedTo, attachedNode);
} else if (node.getMetaData().get(SIGNAL_NAME) != null || type.startsWith("Message-")) {
linkBoundarySignalEvent(node, attachedTo);
} else if (type.startsWith("Error-")) {
linkBoundaryErrorEvent(nodeContainer, node, attachedTo, attachedNode);
} else if (type.startsWith("Condition-") || type.startsWith("RuleFlowStateEvent-")) {
linkBoundaryConditionEvent(nodeContainer, node, attachedTo, attachedNode);
} else if (type.startsWith("Compensation")) {
addCompensationScope(getExecutableProcess(), node, nodeContainer, attachedTo);
}
}
}
}
}
}
Aggregations