use of org.jbpm.process.instance.impl.SignalNodeInstanceAction in project jbpm by kiegroup.
the class ProcessHandler method linkBoundaryTimerEvent.
private static 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();
timer.setName(concatName(compositeNode.getName(), node.getName()));
if (timeDuration != null) {
timer.setDelay(timeDuration);
timer.setTimeType(Timer.TIME_DURATION);
DroolsConsequenceAction action = new DroolsConsequenceAction("java", null);
action.setMetaData("Action", new SignalNodeInstanceAction("Timer-" + attachedTo + "-" + timeDuration + "-" + node.getId()));
compositeNode.addTimer(timer, action);
} 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);
DroolsConsequenceAction action = new DroolsConsequenceAction("java", null);
action.setMetaData("Action", new SignalNodeInstanceAction("Timer-" + attachedTo + "-" + timeCycle + (timer.getPeriod() == null ? "" : "###" + timer.getPeriod()) + "-" + node.getId()));
compositeNode.addTimer(timer, action);
} else if (timeDate != null) {
timer.setDate(timeDate);
timer.setTimeType(Timer.TIME_DATE);
DroolsConsequenceAction action = new DroolsConsequenceAction("java", null);
action.setMetaData("Action", new SignalNodeInstanceAction("Timer-" + attachedTo + "-" + timeDate + "-" + node.getId()));
compositeNode.addTimer(timer, action);
}
if (cancelActivity) {
List<DroolsAction> actions = ((EventNode) node).getActions(EndNode.EVENT_NODE_BOUNDARY);
if (actions == null) {
actions = new ArrayList<DroolsAction>();
}
DroolsConsequenceAction cancelAction = new DroolsConsequenceAction("java", null);
cancelAction.setMetaData("Action", new CancelNodeInstanceAction(attachedTo));
actions.add(cancelAction);
((EventNode) node).setActions(EndNode.EVENT_NODE_BOUNDARY, actions);
}
}
Aggregations