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);
}
}
}
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);
}
}
}
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.");
}
}
}
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;
}
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;
}
Aggregations