throw new IllegalArgumentException("Could not find node to attach to: " + attachedTo);
}
}
if (type.startsWith("Escalation-")) {
boolean cancelActivity = (Boolean) node.getMetaData().get("CancelActivity");
CompositeContextNode compositeNode = (CompositeContextNode) attachedNode;
ExceptionScope exceptionScope = (ExceptionScope)
compositeNode.getDefaultContext(ExceptionScope.EXCEPTION_SCOPE);
if (exceptionScope == null) {
exceptionScope = new ExceptionScope();
compositeNode.addContext(exceptionScope);
compositeNode.setDefaultContext(exceptionScope);
}
String escalationCode = (String) node.getMetaData().get("EscalationEvent");
ActionExceptionHandler exceptionHandler = new ActionExceptionHandler();
exceptionHandler.setAction(new DroolsConsequenceAction("java",
(cancelActivity ? "((org.drools.workflow.instance.NodeInstance) kcontext.getNodeInstance()).cancel();" : "") +
"kcontext.getProcessInstance().signalEvent(\"Escalation-" + attachedTo + "-" + escalationCode + "\", null);"));
exceptionScope.setExceptionHandler(escalationCode, exceptionHandler);
} else if (type.startsWith("Error-")) {
CompositeContextNode compositeNode = (CompositeContextNode) attachedNode;
ExceptionScope exceptionScope = (ExceptionScope)
compositeNode.getDefaultContext(ExceptionScope.EXCEPTION_SCOPE);
if (exceptionScope == null) {
exceptionScope = new ExceptionScope();
compositeNode.addContext(exceptionScope);
compositeNode.setDefaultContext(exceptionScope);
}
String errorCode = (String) node.getMetaData().get("ErrorEvent");
ActionExceptionHandler exceptionHandler = new ActionExceptionHandler();
exceptionHandler.setAction(new DroolsConsequenceAction("java",
"((org.drools.workflow.instance.NodeInstance) kcontext.getNodeInstance()).cancel();" +
"kcontext.getProcessInstance().signalEvent(\"Error-" + attachedTo + "-" + errorCode + "\", null);"));
exceptionScope.setExceptionHandler(errorCode, exceptionHandler);
} else if (type.startsWith("Timer-")) {
boolean cancelActivity = (Boolean) node.getMetaData().get("CancelActivity");
CompositeContextNode compositeNode = (CompositeContextNode) attachedNode;
String timeCycle = (String) node.getMetaData().get("TimeCycle");
Timer timer = new Timer();
timer.setDelay(timeCycle);
compositeNode.addTimer(timer, new DroolsConsequenceAction("java",
(cancelActivity ? "((org.drools.workflow.instance.NodeInstance) kcontext.getNodeInstance()).cancel();" : "") +
"kcontext.getProcessInstance().signalEvent(\"Timer-" + attachedTo + "-" + timeCycle + "\", null);"));
} else if (type.startsWith("Compensate-")) {
String uniqueId = (String) node.getMetaData().get("UniqueId");
String eventType = "Compensate-" + uniqueId;