Search in sources :

Example 11 with ActionExceptionHandler

use of org.jbpm.process.core.context.exception.ActionExceptionHandler 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);
    }
}
Also used : DroolsAction(org.jbpm.workflow.core.DroolsAction) ContextContainer(org.jbpm.process.core.ContextContainer) BoundaryEventNode(org.jbpm.workflow.core.node.BoundaryEventNode) EventNode(org.jbpm.workflow.core.node.EventNode) CancelNodeInstanceAction(org.jbpm.process.instance.impl.CancelNodeInstanceAction) DroolsConsequenceAction(org.jbpm.workflow.core.impl.DroolsConsequenceAction) ExceptionScope(org.jbpm.process.core.context.exception.ExceptionScope) ActionExceptionHandler(org.jbpm.process.core.context.exception.ActionExceptionHandler)

Aggregations

ActionExceptionHandler (org.jbpm.process.core.context.exception.ActionExceptionHandler)11 DroolsConsequenceAction (org.jbpm.workflow.core.impl.DroolsConsequenceAction)8 ExceptionScope (org.jbpm.process.core.context.exception.ExceptionScope)6 DroolsAction (org.jbpm.workflow.core.DroolsAction)5 ContextContainer (org.jbpm.process.core.ContextContainer)4 EventNode (org.jbpm.workflow.core.node.EventNode)4 ArrayList (java.util.ArrayList)2 ExceptionHandler (org.jbpm.process.core.context.exception.ExceptionHandler)2 EventTypeFilter (org.jbpm.process.core.event.EventTypeFilter)2 CancelNodeInstanceAction (org.jbpm.process.instance.impl.CancelNodeInstanceAction)2 RuleFlowProcess (org.jbpm.ruleflow.core.RuleFlowProcess)2 Constraint (org.jbpm.workflow.core.Constraint)2 ConstraintImpl (org.jbpm.workflow.core.impl.ConstraintImpl)2 BoundaryEventNode (org.jbpm.workflow.core.node.BoundaryEventNode)2 StringReader (java.io.StringReader)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 List (java.util.List)1 Map (java.util.Map)1 Diff (org.custommonkey.xmlunit.Diff)1