use of org.jbpm.process.core.ContextContainer in project jbpm by kiegroup.
the class ProcessHandler method linkBoundaryEscalationEvent.
private static void linkBoundaryEscalationEvent(NodeContainer nodeContainer, Node node, String attachedTo, Node attachedNode) {
boolean cancelActivity = (Boolean) node.getMetaData().get("CancelActivity");
String escalationCode = (String) node.getMetaData().get("EscalationEvent");
String escalationStructureRef = (String) node.getMetaData().get("EscalationStructureRef");
ContextContainer compositeNode = (ContextContainer) attachedNode;
ExceptionScope exceptionScope = (ExceptionScope) compositeNode.getDefaultContext(ExceptionScope.EXCEPTION_SCOPE);
if (exceptionScope == null) {
exceptionScope = new ExceptionScope();
compositeNode.addContext(exceptionScope);
compositeNode.setDefaultContext(exceptionScope);
}
String variable = ((EventNode) node).getVariableName();
ActionExceptionHandler exceptionHandler = new ActionExceptionHandler();
DroolsConsequenceAction action = new DroolsConsequenceAction("java", PROCESS_INSTANCE_SIGNAL_EVENT + "Escalation-" + attachedTo + "-" + escalationCode + "\", kcontext.getVariable(\"" + variable + "\"));");
exceptionHandler.setAction(action);
exceptionHandler.setFaultVariable(variable);
exceptionScope.setExceptionHandler(escalationCode, exceptionHandler);
if (escalationStructureRef != null) {
exceptionScope.setExceptionHandler(escalationStructureRef, exceptionHandler);
}
if (cancelActivity) {
List<DroolsAction> actions = ((EventNode) node).getActions(EndNode.EVENT_NODE_EXIT);
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_EXIT, actions);
}
}
Aggregations