use of org.jbpm.process.core.event.EventFilter in project jbpm by kiegroup.
the class BoundaryEventHandler method handleCompensationNode.
protected void handleCompensationNode(final Node node, final Element element, final String uri, final String localName, final ExtensibleXmlParser parser, final String attachedTo, final boolean cancelActivity) throws SAXException {
BoundaryEventNode eventNode = (BoundaryEventNode) parser.getCurrent();
super.handleNode(node, element, uri, localName, parser);
NodeList childs = element.getChildNodes();
for (int i = 0; i < childs.getLength(); i++) {
if (childs.item(i) instanceof Element) {
Element el = (Element) childs.item(i);
if ("compensateEventDefinition".equalsIgnoreCase(el.getNodeName())) {
String activityRef = el.getAttribute("activityRef");
if (activityRef != null && activityRef.length() > 0) {
logger.warn("activityRef value [" + activityRef + "] on Boundary Event '" + eventNode.getMetaData("UniqueId") + "' ignored per the BPMN2 specification.");
}
}
}
}
eventNode.setMetaData("AttachedTo", attachedTo);
eventNode.setAttachedToNodeId(attachedTo);
// 1. Find the parent (sub-)process
NodeContainer parentContainer = (NodeContainer) parser.getParent();
// 2. Add the event filter (never fires, purely for dumping purposes)
EventTypeFilter eventFilter = new NonAcceptingEventTypeFilter();
eventFilter.setType("Compensation");
List<EventFilter> eventFilters = new ArrayList<EventFilter>();
eventNode.setEventFilters(eventFilters);
eventFilters.add(eventFilter);
// 3. Add compensation scope (with key/id: attachedTo)
ProcessHandler.addCompensationScope((RuleFlowProcess) parser.getParent(RuleFlowProcess.class), eventNode, parentContainer, attachedTo);
}
use of org.jbpm.process.core.event.EventFilter in project jbpm by kiegroup.
the class BoundaryEventHandler method handleEscalationNode.
@SuppressWarnings("unchecked")
protected void handleEscalationNode(final Node node, final Element element, final String uri, final String localName, final ExtensibleXmlParser parser, final String attachedTo, final boolean cancelActivity) throws SAXException {
super.handleNode(node, element, uri, localName, parser);
BoundaryEventNode eventNode = (BoundaryEventNode) node;
eventNode.setMetaData("AttachedTo", attachedTo);
/**
* TODO: because of how we process bpmn2/xml files, we can't tell
* if the cancelActivity attribute is set to false or not
* (because we override with the xsd settings)
* BPMN2 spec, p. 255, Escalation row:
* "In contrast to an Error, an Escalation by default is assumed to not abort
* the Activity to which the boundary Event is attached."
*/
eventNode.setMetaData("CancelActivity", cancelActivity);
eventNode.setAttachedToNodeId(attachedTo);
org.w3c.dom.Node xmlNode = element.getFirstChild();
while (xmlNode != null) {
String nodeName = xmlNode.getNodeName();
if ("dataOutput".equals(nodeName)) {
String id = ((Element) xmlNode).getAttribute("id");
String outputName = ((Element) xmlNode).getAttribute("name");
dataOutputs.put(id, outputName);
} else if ("dataOutputAssociation".equals(nodeName)) {
readDataOutputAssociation(xmlNode, eventNode);
} else if ("escalationEventDefinition".equals(nodeName)) {
String escalationRef = ((Element) xmlNode).getAttribute("escalationRef");
if (escalationRef != null && escalationRef.trim().length() > 0) {
Map<String, Escalation> escalations = (Map<String, Escalation>) ((ProcessBuildData) parser.getData()).getMetaData(ProcessHandler.ESCALATIONS);
if (escalations == null) {
throw new IllegalArgumentException("No escalations found");
}
Escalation escalation = escalations.get(escalationRef);
if (escalation == null) {
throw new IllegalArgumentException("Could not find escalation " + escalationRef);
}
List<EventFilter> eventFilters = new ArrayList<EventFilter>();
EventTypeFilter eventFilter = new EventTypeFilter();
String type = escalation.getEscalationCode();
eventFilter.setType("Escalation-" + attachedTo + "-" + type);
eventFilters.add(eventFilter);
eventNode.setEventFilters(eventFilters);
eventNode.setMetaData("EscalationEvent", type);
} else {
throw new UnsupportedOperationException("General escalation is not yet supported.");
}
}
xmlNode = xmlNode.getNextSibling();
}
}
use of org.jbpm.process.core.event.EventFilter in project jbpm by kiegroup.
the class BoundaryEventHandler method handleSignalNode.
protected void handleSignalNode(final Node node, final Element element, final String uri, final String localName, final ExtensibleXmlParser parser, final String attachedTo, final boolean cancelActivity) throws SAXException {
super.handleNode(node, element, uri, localName, parser);
BoundaryEventNode eventNode = (BoundaryEventNode) node;
eventNode.setMetaData("AttachedTo", attachedTo);
eventNode.setMetaData("CancelActivity", cancelActivity);
eventNode.setAttachedToNodeId(attachedTo);
org.w3c.dom.Node xmlNode = element.getFirstChild();
while (xmlNode != null) {
String nodeName = xmlNode.getNodeName();
if ("dataOutput".equals(nodeName)) {
String id = ((Element) xmlNode).getAttribute("id");
String outputName = ((Element) xmlNode).getAttribute("name");
dataOutputs.put(id, outputName);
}
if ("dataOutputAssociation".equals(nodeName)) {
readDataOutputAssociation(xmlNode, eventNode);
} else if ("signalEventDefinition".equals(nodeName)) {
String type = ((Element) xmlNode).getAttribute("signalRef");
if (type != null && type.trim().length() > 0) {
type = checkSignalAndConvertToRealSignalNam(parser, type);
List<EventFilter> eventFilters = new ArrayList<EventFilter>();
EventTypeFilter eventFilter = new EventTypeFilter();
eventFilter.setType(type);
eventFilters.add(eventFilter);
eventNode.setEventFilters(eventFilters);
eventNode.setScope("external");
eventNode.setMetaData("SignalName", type);
}
}
xmlNode = xmlNode.getNextSibling();
}
}
use of org.jbpm.process.core.event.EventFilter in project jbpm by kiegroup.
the class BoundaryEventHandler method handleMessageNode.
protected void handleMessageNode(final Node node, final Element element, final String uri, final String localName, final ExtensibleXmlParser parser, final String attachedTo, final boolean cancelActivity) throws SAXException {
super.handleNode(node, element, uri, localName, parser);
BoundaryEventNode eventNode = (BoundaryEventNode) node;
eventNode.setMetaData("AttachedTo", attachedTo);
eventNode.setMetaData("CancelActivity", cancelActivity);
eventNode.setAttachedToNodeId(attachedTo);
org.w3c.dom.Node xmlNode = element.getFirstChild();
while (xmlNode != null) {
String nodeName = xmlNode.getNodeName();
if ("dataOutput".equals(nodeName)) {
String id = ((Element) xmlNode).getAttribute("id");
String outputName = ((Element) xmlNode).getAttribute("name");
dataOutputs.put(id, outputName);
} else if ("dataOutputAssociation".equals(nodeName)) {
readDataOutputAssociation(xmlNode, eventNode);
} else if ("messageEventDefinition".equals(nodeName)) {
String messageRef = ((Element) xmlNode).getAttribute("messageRef");
Map<String, Message> messages = (Map<String, Message>) ((ProcessBuildData) parser.getData()).getMetaData("Messages");
if (messages == null) {
throw new IllegalArgumentException("No messages found");
}
Message message = messages.get(messageRef);
if (message == null) {
throw new IllegalArgumentException("Could not find message " + messageRef);
}
eventNode.setMetaData("MessageType", message.getType());
List<EventFilter> eventFilters = new ArrayList<EventFilter>();
EventTypeFilter eventFilter = new EventTypeFilter();
eventFilter.setType("Message-" + messageRef);
eventFilters.add(eventFilter);
eventNode.setScope("external");
eventNode.setEventFilters(eventFilters);
}
xmlNode = xmlNode.getNextSibling();
}
}
use of org.jbpm.process.core.event.EventFilter in project jbpm by kiegroup.
the class BoundaryEventHandler method handleErrorNode.
@SuppressWarnings("unchecked")
protected void handleErrorNode(final Node node, final Element element, final String uri, final String localName, final ExtensibleXmlParser parser, final String attachedTo, final boolean cancelActivity) throws SAXException {
super.handleNode(node, element, uri, localName, parser);
BoundaryEventNode eventNode = (BoundaryEventNode) node;
eventNode.setMetaData("AttachedTo", attachedTo);
eventNode.setAttachedToNodeId(attachedTo);
org.w3c.dom.Node xmlNode = element.getFirstChild();
while (xmlNode != null) {
String nodeName = xmlNode.getNodeName();
if ("dataOutput".equals(nodeName)) {
String id = ((Element) xmlNode).getAttribute("id");
String outputName = ((Element) xmlNode).getAttribute("name");
dataOutputs.put(id, outputName);
} else if ("dataOutputAssociation".equals(nodeName)) {
readDataOutputAssociation(xmlNode, eventNode);
} else if ("errorEventDefinition".equals(nodeName)) {
String errorRef = ((Element) xmlNode).getAttribute("errorRef");
if (errorRef != null && errorRef.trim().length() > 0) {
List<Error> errors = (List<Error>) ((ProcessBuildData) parser.getData()).getMetaData("Errors");
if (errors == null) {
throw new IllegalArgumentException("No errors found");
}
Error error = null;
for (Error listError : errors) {
if (errorRef.equals(listError.getId())) {
error = listError;
}
}
if (error == null) {
throw new IllegalArgumentException("Could not find error " + errorRef);
}
String type = error.getErrorCode();
boolean hasErrorCode = true;
if (type == null) {
type = error.getId();
hasErrorCode = false;
}
String structureRef = error.getStructureRef();
if (structureRef != null) {
Map<String, ItemDefinition> itemDefs = (Map<String, ItemDefinition>) ((ProcessBuildData) parser.getData()).getMetaData("ItemDefinitions");
if (itemDefs.containsKey(structureRef)) {
structureRef = itemDefs.get(structureRef).getStructureRef();
}
}
List<EventFilter> eventFilters = new ArrayList<EventFilter>();
EventTypeFilter eventFilter = new EventTypeFilter();
eventFilter.setType("Error-" + attachedTo + "-" + type);
eventFilters.add(eventFilter);
eventNode.setEventFilters(eventFilters);
eventNode.setMetaData("ErrorEvent", type);
eventNode.setMetaData("HasErrorEvent", hasErrorCode);
eventNode.setMetaData("ErrorStructureRef", structureRef);
}
}
xmlNode = xmlNode.getNextSibling();
}
}
Aggregations