Search in sources :

Example 1 with ExtendedNodeImpl

use of org.jbpm.workflow.core.impl.ExtendedNodeImpl in project jbpm by kiegroup.

the class ProcessHandler method handleIntermediateOrEndThrowCompensationEvent.

protected void handleIntermediateOrEndThrowCompensationEvent(ExtendedNodeImpl throwEventNode) {
    if (throwEventNode.getMetaData("compensation-activityRef") != null) {
        String activityRef = (String) throwEventNode.getMetaData().remove("compensation-activityRef");
        NodeContainer nodeParent = (NodeContainer) throwEventNode.getNodeContainer();
        if (nodeParent instanceof EventSubProcessNode) {
            boolean compensationEventSubProcess = false;
            List<Trigger> startTriggers = ((EventSubProcessNode) nodeParent).findStartNode().getTriggers();
            CESP_CHECK: for (Trigger trigger : startTriggers) {
                if (trigger instanceof EventTrigger) {
                    for (EventFilter filter : ((EventTrigger) trigger).getEventFilters()) {
                        if (((EventTypeFilter) filter).getType().equals("Compensation")) {
                            compensationEventSubProcess = true;
                            break CESP_CHECK;
                        }
                    }
                }
            }
            if (compensationEventSubProcess) {
                // BPMN2 spec, p. 252, p. 248: intermediate and end compensation event visibility scope
                nodeParent = (NodeContainer) ((NodeImpl) nodeParent).getNodeContainer();
            }
        }
        String parentId;
        if (nodeParent instanceof RuleFlowProcess) {
            parentId = ((RuleFlowProcess) nodeParent).getId();
        } else {
            parentId = (String) ((NodeImpl) nodeParent).getMetaData("UniqueId");
        }
        String compensationEvent;
        if (activityRef.length() == 0) {
            // general/implicit compensation
            compensationEvent = CompensationScope.IMPLICIT_COMPENSATION_PREFIX + parentId;
        } else {
            // specific compensation
            compensationEvent = activityRef;
        }
        DroolsConsequenceAction compensationAction = new DroolsConsequenceAction("java", PROCESS_INSTANCE_SIGNAL_EVENT + "Compensation\", \"" + compensationEvent + "\");");
        if (throwEventNode instanceof ActionNode) {
            ((ActionNode) throwEventNode).setAction(compensationAction);
        } else if (throwEventNode instanceof EndNode) {
            List<DroolsAction> actions = new ArrayList<DroolsAction>();
            actions.add(compensationAction);
            ((EndNode) throwEventNode).setActions(EndNode.EVENT_NODE_ENTER, actions);
        }
    }
}
Also used : DroolsAction(org.jbpm.workflow.core.DroolsAction) RuleFlowProcess(org.jbpm.ruleflow.core.RuleFlowProcess) NodeImpl(org.jbpm.workflow.core.impl.NodeImpl) ExtendedNodeImpl(org.jbpm.workflow.core.impl.ExtendedNodeImpl) DroolsConsequenceAction(org.jbpm.workflow.core.impl.DroolsConsequenceAction) EventSubProcessNode(org.jbpm.workflow.core.node.EventSubProcessNode) ActionNode(org.jbpm.workflow.core.node.ActionNode) NodeContainer(org.kie.api.definition.process.NodeContainer) EventFilter(org.jbpm.process.core.event.EventFilter) EventTypeFilter(org.jbpm.process.core.event.EventTypeFilter) ConstraintTrigger(org.jbpm.workflow.core.node.ConstraintTrigger) EventTrigger(org.jbpm.workflow.core.node.EventTrigger) Trigger(org.jbpm.workflow.core.node.Trigger) EndNode(org.jbpm.workflow.core.node.EndNode) List(java.util.List) ArrayList(java.util.ArrayList) EventTrigger(org.jbpm.workflow.core.node.EventTrigger)

Example 2 with ExtendedNodeImpl

use of org.jbpm.workflow.core.impl.ExtendedNodeImpl in project jbpm by kiegroup.

the class ExtendedNodeInstanceImpl method triggerEvent.

protected void triggerEvent(String type) {
    ExtendedNodeImpl extendedNode = getExtendedNode();
    if (extendedNode == null) {
        return;
    }
    List<DroolsAction> actions = extendedNode.getActions(type);
    if (actions != null) {
        for (DroolsAction droolsAction : actions) {
            Action action = (Action) droolsAction.getMetaData("Action");
            executeAction(action);
        }
    }
}
Also used : DroolsAction(org.jbpm.workflow.core.DroolsAction) Action(org.jbpm.process.instance.impl.Action) DroolsAction(org.jbpm.workflow.core.DroolsAction) ExtendedNodeImpl(org.jbpm.workflow.core.impl.ExtendedNodeImpl)

Aggregations

DroolsAction (org.jbpm.workflow.core.DroolsAction)2 ExtendedNodeImpl (org.jbpm.workflow.core.impl.ExtendedNodeImpl)2 ArrayList (java.util.ArrayList)1 List (java.util.List)1 EventFilter (org.jbpm.process.core.event.EventFilter)1 EventTypeFilter (org.jbpm.process.core.event.EventTypeFilter)1 Action (org.jbpm.process.instance.impl.Action)1 RuleFlowProcess (org.jbpm.ruleflow.core.RuleFlowProcess)1 DroolsConsequenceAction (org.jbpm.workflow.core.impl.DroolsConsequenceAction)1 NodeImpl (org.jbpm.workflow.core.impl.NodeImpl)1 ActionNode (org.jbpm.workflow.core.node.ActionNode)1 ConstraintTrigger (org.jbpm.workflow.core.node.ConstraintTrigger)1 EndNode (org.jbpm.workflow.core.node.EndNode)1 EventSubProcessNode (org.jbpm.workflow.core.node.EventSubProcessNode)1 EventTrigger (org.jbpm.workflow.core.node.EventTrigger)1 Trigger (org.jbpm.workflow.core.node.Trigger)1 NodeContainer (org.kie.api.definition.process.NodeContainer)1