Search in sources :

Example 6 with NodeContainer

use of org.kie.api.definition.process.NodeContainer in project jbpm by kiegroup.

the class ProcessHandler method assignLanes.

private void assignLanes(NodeContainer nodeContainer, Map<String, String> laneMapping) {
    for (Node node : nodeContainer.getNodes()) {
        String lane = null;
        String uniqueId = (String) node.getMetaData().get("UniqueId");
        if (uniqueId != null) {
            lane = laneMapping.get(uniqueId);
        } else {
            lane = laneMapping.get(XmlBPMNProcessDumper.getUniqueNodeId(node));
        }
        if (lane != null) {
            ((NodeImpl) node).setMetaData("Lane", lane);
            if (node instanceof HumanTaskNode) {
                ((HumanTaskNode) node).setSwimlane(lane);
            }
        }
        if (node instanceof NodeContainer) {
            assignLanes((NodeContainer) node, laneMapping);
        }
    }
}
Also used : NodeImpl(org.jbpm.workflow.core.impl.NodeImpl) ExtendedNodeImpl(org.jbpm.workflow.core.impl.ExtendedNodeImpl) HumanTaskNode(org.jbpm.workflow.core.node.HumanTaskNode) BoundaryEventNode(org.jbpm.workflow.core.node.BoundaryEventNode) StartNode(org.jbpm.workflow.core.node.StartNode) CompositeNode(org.jbpm.workflow.core.node.CompositeNode) StateNode(org.jbpm.workflow.core.node.StateNode) RuleSetNode(org.jbpm.workflow.core.node.RuleSetNode) SubProcessNode(org.jbpm.workflow.core.node.SubProcessNode) CompositeContextNode(org.jbpm.workflow.core.node.CompositeContextNode) StateBasedNode(org.jbpm.workflow.core.node.StateBasedNode) EventSubProcessNode(org.jbpm.workflow.core.node.EventSubProcessNode) FaultNode(org.jbpm.workflow.core.node.FaultNode) WorkItemNode(org.jbpm.workflow.core.node.WorkItemNode) ActionNode(org.jbpm.workflow.core.node.ActionNode) EndNode(org.jbpm.workflow.core.node.EndNode) EventNode(org.jbpm.workflow.core.node.EventNode) Node(org.kie.api.definition.process.Node) NodeContainer(org.kie.api.definition.process.NodeContainer) HumanTaskNode(org.jbpm.workflow.core.node.HumanTaskNode)

Example 7 with NodeContainer

use of org.kie.api.definition.process.NodeContainer 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 8 with NodeContainer

use of org.kie.api.definition.process.NodeContainer in project jbpm by kiegroup.

the class RuleFlowProcessValidator method validateCompensationIntermediateOrEndEvent.

protected void validateCompensationIntermediateOrEndEvent(Node node, RuleFlowProcess process, List<ProcessValidationError> errors) {
    if (node.getMetaData().containsKey("Compensation")) {
        // Validate that activityRef in throw/end compensation event refers to "visible" compensation
        String activityRef = (String) node.getMetaData().get("Compensation");
        Node refNode = null;
        if (activityRef != null) {
            Queue<Node> nodeQueue = new LinkedList<Node>();
            nodeQueue.addAll(Arrays.asList(process.getNodes()));
            while (!nodeQueue.isEmpty()) {
                Node polledNode = nodeQueue.poll();
                if (activityRef.equals(polledNode.getMetaData().get("UniqueId"))) {
                    refNode = polledNode;
                    break;
                }
                if (node instanceof NodeContainer) {
                    nodeQueue.addAll(Arrays.asList(((NodeContainer) node).getNodes()));
                }
            }
        }
        if (refNode == null) {
            addErrorMessage(process, node, errors, "Does not reference an activity that exists (" + activityRef + ") in its compensation event definition.");
        }
        CompensationScope compensationScope = (CompensationScope) ((NodeImpl) node).resolveContext(CompensationScope.COMPENSATION_SCOPE, activityRef);
        if (compensationScope == null) {
            addErrorMessage(process, node, errors, "References an activity (" + activityRef + ") in its compensation event definition that is not visible to it.");
        }
    }
}
Also used : ForEachNode(org.jbpm.workflow.core.node.ForEachNode) BoundaryEventNode(org.jbpm.workflow.core.node.BoundaryEventNode) DynamicNode(org.jbpm.workflow.core.node.DynamicNode) StartNode(org.jbpm.workflow.core.node.StartNode) CompositeNode(org.jbpm.workflow.core.node.CompositeNode) StateNode(org.jbpm.workflow.core.node.StateNode) RuleSetNode(org.jbpm.workflow.core.node.RuleSetNode) SubProcessNode(org.jbpm.workflow.core.node.SubProcessNode) CatchLinkNode(org.jbpm.workflow.core.node.CatchLinkNode) ForEachJoinNode(org.jbpm.workflow.core.node.ForEachNode.ForEachJoinNode) MilestoneNode(org.jbpm.workflow.core.node.MilestoneNode) ThrowLinkNode(org.jbpm.workflow.core.node.ThrowLinkNode) EventSubProcessNode(org.jbpm.workflow.core.node.EventSubProcessNode) TimerNode(org.jbpm.workflow.core.node.TimerNode) FaultNode(org.jbpm.workflow.core.node.FaultNode) WorkItemNode(org.jbpm.workflow.core.node.WorkItemNode) ActionNode(org.jbpm.workflow.core.node.ActionNode) EndNode(org.jbpm.workflow.core.node.EndNode) EventNode(org.jbpm.workflow.core.node.EventNode) Node(org.kie.api.definition.process.Node) ForEachSplitNode(org.jbpm.workflow.core.node.ForEachNode.ForEachSplitNode) NodeContainer(org.kie.api.definition.process.NodeContainer) CompensationScope(org.jbpm.process.core.context.exception.CompensationScope) LinkedList(java.util.LinkedList)

Example 9 with NodeContainer

use of org.kie.api.definition.process.NodeContainer in project jbpm by kiegroup.

the class CompensationEventListener method findNode.

private Node findNode(String nodeId) {
    Node found = null;
    Queue<Node> allProcessNodes = new LinkedList<Node>();
    allProcessNodes.addAll(Arrays.asList(instance.getNodeContainer().getNodes()));
    while (!allProcessNodes.isEmpty()) {
        Node node = allProcessNodes.poll();
        if (nodeId.equals(node.getMetaData().get("UniqueId"))) {
            found = node;
            break;
        }
        if (node instanceof NodeContainer) {
            allProcessNodes.addAll(Arrays.asList(((NodeContainer) node).getNodes()));
        }
    }
    return found;
}
Also used : Node(org.kie.api.definition.process.Node) NodeContainer(org.kie.api.definition.process.NodeContainer) LinkedList(java.util.LinkedList)

Example 10 with NodeContainer

use of org.kie.api.definition.process.NodeContainer in project jbpm by kiegroup.

the class CompensationTest method findNode.

private Node findNode(RuleFlowProcess process, String nodeName) {
    Node found = null;
    Queue<org.kie.api.definition.process.Node> nodes = new LinkedList<org.kie.api.definition.process.Node>();
    nodes.addAll(Arrays.asList(process.getNodes()));
    while (!nodes.isEmpty()) {
        org.kie.api.definition.process.Node node = nodes.poll();
        if (node.getName().equals(nodeName)) {
            found = (Node) node;
        }
        if (node instanceof NodeContainer) {
            nodes.addAll(Arrays.asList(((NodeContainer) node).getNodes()));
        }
    }
    assertNotNull("Could not find node (" + nodeName + ").", found);
    return found;
}
Also used : BoundaryEventNode(org.jbpm.workflow.core.node.BoundaryEventNode) StartNode(org.jbpm.workflow.core.node.StartNode) CompositeNode(org.jbpm.workflow.core.node.CompositeNode) EventSubProcessNode(org.jbpm.workflow.core.node.EventSubProcessNode) WorkItemNode(org.jbpm.workflow.core.node.WorkItemNode) CompositeContextNode(org.jbpm.workflow.core.node.CompositeContextNode) ActionNode(org.jbpm.workflow.core.node.ActionNode) EndNode(org.jbpm.workflow.core.node.EndNode) Node(org.jbpm.workflow.core.Node) NodeContainer(org.kie.api.definition.process.NodeContainer) LinkedList(java.util.LinkedList)

Aggregations

NodeContainer (org.kie.api.definition.process.NodeContainer)18 Node (org.kie.api.definition.process.Node)12 StartNode (org.jbpm.workflow.core.node.StartNode)9 CompositeNode (org.jbpm.workflow.core.node.CompositeNode)8 ActionNode (org.jbpm.workflow.core.node.ActionNode)7 EndNode (org.jbpm.workflow.core.node.EndNode)7 EventNode (org.jbpm.workflow.core.node.EventNode)6 EventSubProcessNode (org.jbpm.workflow.core.node.EventSubProcessNode)6 HumanTaskNode (org.jbpm.workflow.core.node.HumanTaskNode)6 WorkItemNode (org.jbpm.workflow.core.node.WorkItemNode)6 BoundaryEventNode (org.jbpm.workflow.core.node.BoundaryEventNode)5 FaultNode (org.jbpm.workflow.core.node.FaultNode)5 StateNode (org.jbpm.workflow.core.node.StateNode)5 RuleFlowProcess (org.jbpm.ruleflow.core.RuleFlowProcess)4 NodeImpl (org.jbpm.workflow.core.impl.NodeImpl)4 CompositeContextNode (org.jbpm.workflow.core.node.CompositeContextNode)4 RuleSetNode (org.jbpm.workflow.core.node.RuleSetNode)4 ArrayList (java.util.ArrayList)3 LinkedList (java.util.LinkedList)3 List (java.util.List)3