Search in sources :

Example 11 with ContextContainer

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);
    }
}
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

ContextContainer (org.jbpm.process.core.ContextContainer)11 ActionExceptionHandler (org.jbpm.process.core.context.exception.ActionExceptionHandler)4 ExceptionScope (org.jbpm.process.core.context.exception.ExceptionScope)4 List (java.util.List)3 CompensationScope (org.jbpm.process.core.context.exception.CompensationScope)3 Variable (org.jbpm.process.core.context.variable.Variable)3 VariableScope (org.jbpm.process.core.context.variable.VariableScope)3 DroolsAction (org.jbpm.workflow.core.DroolsAction)3 DroolsConsequenceAction (org.jbpm.workflow.core.impl.DroolsConsequenceAction)3 BoundaryEventNode (org.jbpm.workflow.core.node.BoundaryEventNode)3 EventNode (org.jbpm.workflow.core.node.EventNode)3 CompensationHandler (org.jbpm.process.core.context.exception.CompensationHandler)2 CancelNodeInstanceAction (org.jbpm.process.instance.impl.CancelNodeInstanceAction)2 RuleFlowProcess (org.jbpm.ruleflow.core.RuleFlowProcess)2 Node (org.kie.api.definition.process.Node)2 SAXParseException (org.xml.sax.SAXParseException)2 ArrayList (java.util.ArrayList)1 Map (java.util.Map)1 ItemDefinition (org.jbpm.bpmn2.core.ItemDefinition)1 ProcessBuildData (org.jbpm.compiler.xml.ProcessBuildData)1