use of org.jbpm.process.core.event.EventFilter in project jbpm by kiegroup.
the class EventNodeHandler method writeNode.
public void writeNode(Node node, StringBuilder xmlDump, boolean includeMeta) {
EventNode eventNode = (EventNode) node;
writeNode("eventNode", eventNode, xmlDump, includeMeta);
String variableName = eventNode.getVariableName();
if (variableName != null && variableName.length() != 0) {
xmlDump.append("variableName=\"" + variableName + "\" ");
}
String scope = eventNode.getScope();
if (scope != null && scope.length() != 0) {
xmlDump.append("scope=\"" + scope + "\" ");
}
xmlDump.append(">" + EOL);
if (includeMeta) {
writeMetaData(eventNode, xmlDump);
}
xmlDump.append(" <eventFilters>" + EOL);
for (EventFilter filter : eventNode.getEventFilters()) {
if (filter instanceof EventTypeFilter) {
xmlDump.append(" <eventFilter " + "type=\"eventType\" " + "eventType=\"" + ((EventTypeFilter) filter).getType() + "\" />" + EOL);
} else {
throw new IllegalArgumentException("Unknown filter type: " + filter);
}
}
xmlDump.append(" </eventFilters>" + EOL);
endNode("eventNode", xmlDump);
}
use of org.jbpm.process.core.event.EventFilter in project jbpm by kiegroup.
the class StartEventHandler method handleCompensationNode.
protected void handleCompensationNode(final StartNode startNode, final Element element, final org.w3c.dom.Node xmlNode, final ExtensibleXmlParser parser) throws SAXException {
if (startNode.isInterrupting()) {
logger.warn("Compensation Event Sub-Processes [" + startNode.getMetaData("UniqueId") + "] may not be specified as interrupting:" + " overriding attribute and setting to not-interrupting.");
}
startNode.setInterrupting(false);
/**
* From the BPMN2 spec, P.264:
* "For a Start Event:
* This Event "catches" the compensation for an Event Sub-Process. No further information is required.
* The Event Sub-Process will provide the id necessary to match the Compensation Event with the Event
* that threw the compensation"
*
* In other words, the id of the Sub-Process containing this Event Sub-Process is what should be used
* as the activityRef value in any Intermediate (throw) or End compensation event that targets
* this particular Event Sub-Process.
*
* This is similar to the logic used for a Compensation Boundary Event: it's signaled using
* the id of the activity to which the CBE is attached to.
*/
String activityRef = ((Element) xmlNode).getAttribute("activityRef");
if (activityRef != null && activityRef.length() > 0) {
logger.warn("activityRef value [" + activityRef + "] on Start Event '" + startNode.getMetaData("UniqueId") + "' ignored per the BPMN2 specification.");
}
// so that this node will get processed in ProcessHandler.postProcessNodes(...)
EventTrigger startTrigger = new EventTrigger();
EventFilter eventFilter = new NonAcceptingEventTypeFilter();
((NonAcceptingEventTypeFilter) eventFilter).setType("Compensation");
startTrigger.addEventFilter(eventFilter);
List<Trigger> startTriggers = new ArrayList<Trigger>();
startTriggers.add(startTrigger);
startNode.setTriggers(startTriggers);
String mapping = (String) startNode.getMetaData("TriggerMapping");
if (mapping != null) {
startTrigger.addInMapping(mapping, startNode.getOutMapping(mapping));
}
}
use of org.jbpm.process.core.event.EventFilter in project jbpm by kiegroup.
the class ProcessHandler method linkConnections.
public static void linkConnections(NodeContainer nodeContainer, List<SequenceFlow> connections) {
if (connections != null) {
for (SequenceFlow connection : connections) {
String sourceRef = connection.getSourceRef();
Node source = findNodeByIdOrUniqueIdInMetadata(nodeContainer, sourceRef, "Could not find source node for connection:" + sourceRef);
if (source instanceof EventNode) {
for (EventFilter eventFilter : ((EventNode) source).getEventFilters()) {
if (eventFilter instanceof EventTypeFilter) {
if ("Compensation".equals(((EventTypeFilter) eventFilter).getType())) {
// BPMN Method & Style, 2nd Ed. (Silver), states this on P. 131
throw new IllegalArgumentException("A Compensation Boundary Event can only be *associated* with a compensation activity via an Association, not via a Sequence Flow element.");
}
}
}
}
String targetRef = connection.getTargetRef();
Node target = findNodeByIdOrUniqueIdInMetadata(nodeContainer, targetRef, "Could not find target node for connection:" + targetRef);
Connection result = new ConnectionImpl(source, NodeImpl.CONNECTION_DEFAULT_TYPE, target, NodeImpl.CONNECTION_DEFAULT_TYPE);
result.setMetaData("bendpoints", connection.getBendpoints());
result.setMetaData("UniqueId", connection.getId());
if ("true".equals(System.getProperty("jbpm.enable.multi.con"))) {
NodeImpl nodeImpl = (NodeImpl) source;
Constraint constraint = buildConstraint(connection, nodeImpl);
if (constraint != null) {
nodeImpl.addConstraint(new ConnectionRef(target.getId(), NodeImpl.CONNECTION_DEFAULT_TYPE), constraint);
}
} else if (source instanceof Split) {
Split split = (Split) source;
Constraint constraint = buildConstraint(connection, split);
split.addConstraint(new ConnectionRef(target.getId(), NodeImpl.CONNECTION_DEFAULT_TYPE), constraint);
}
}
}
}
use of org.jbpm.process.core.event.EventFilter in project jbpm by kiegroup.
the class ProcessHandler method linkBoundaryEvents.
public static void linkBoundaryEvents(NodeContainer nodeContainer) {
for (Node node : nodeContainer.getNodes()) {
if (node instanceof EventNode) {
final String attachedTo = (String) node.getMetaData().get("AttachedTo");
if (attachedTo != null) {
for (EventFilter filter : ((EventNode) node).getEventFilters()) {
String type = ((EventTypeFilter) filter).getType();
Node attachedNode = findNodeByIdOrUniqueIdInMetadata(nodeContainer, attachedTo, "Could not find node to attach to: " + attachedTo);
//
if (!(attachedNode instanceof StateBasedNode) && !type.equals("Compensation")) {
throw new IllegalArgumentException("Boundary events are supported only on StateBasedNode, found node: " + attachedNode.getClass().getName() + " [" + attachedNode.getMetaData().get("UniqueId") + "]");
}
if (type.startsWith("Escalation")) {
linkBoundaryEscalationEvent(nodeContainer, node, attachedTo, attachedNode);
} else if (type.startsWith("Error-")) {
linkBoundaryErrorEvent(nodeContainer, node, attachedTo, attachedNode);
} else if (type.startsWith("Timer-")) {
linkBoundaryTimerEvent(nodeContainer, node, attachedTo, attachedNode);
} else if (type.equals("Compensation")) {
linkBoundaryCompensationEvent(nodeContainer, node, attachedTo, attachedNode);
} else if (node.getMetaData().get("SignalName") != null || type.startsWith("Message-")) {
linkBoundarySignalEvent(nodeContainer, node, attachedTo, attachedNode);
} else if (type.startsWith("Condition-")) {
linkBoundaryConditionEvent(nodeContainer, node, attachedTo, attachedNode);
}
}
}
}
}
}
use of org.jbpm.process.core.event.EventFilter 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);
}
}
}
Aggregations