use of io.automatiko.engine.workflow.base.core.event.EventFilter in project automatiko-engine by automatiko-io.
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 io.automatiko.engine.workflow.base.core.event.EventFilter in project automatiko-engine by automatiko-io.
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.getParentContainer();
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).getParentContainer();
}
}
String parentId;
if (nodeParent instanceof ExecutableProcess) {
parentId = ((ExecutableProcess) 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;
}
throwEventNode.setMetaData("CompensationEvent", compensationEvent);
ConsequenceAction compensationAction = new ConsequenceAction("java", "");
compensationAction.setMetaData("Action", new ProcessInstanceCompensationAction(compensationEvent));
if (throwEventNode instanceof ActionNode) {
((ActionNode) throwEventNode).setAction(compensationAction);
} else if (throwEventNode instanceof EndNode) {
List<ProcessAction> actions = new ArrayList<ProcessAction>();
actions.add(compensationAction);
((EndNode) throwEventNode).setActions(EndNode.EVENT_NODE_ENTER, actions);
}
throwEventNode.setMetaData("TriggerType", "Compensation");
}
}
use of io.automatiko.engine.workflow.base.core.event.EventFilter in project automatiko-engine by automatiko-io.
the class IntermediateCatchEventHandler method handleSignalNode.
protected void handleSignalNode(final Node node, final Element element, final String uri, final String localName, final ExtensibleXmlParser parser) throws SAXException {
super.handleNode(node, element, uri, localName, parser);
EventNode eventNode = (EventNode) node;
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);
populateDataOutputs(xmlNode, outputName, parser);
} else 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) {
Signal signal = findSignalByName(parser, type);
if (signal != null) {
eventNode.setMetaData("MessageType", retrieveDataType(signal.getStructureRef(), null, parser));
}
type = checkSignalAndConvertToRealSignalNam(parser, type);
List<EventFilter> eventFilters = new ArrayList<EventFilter>();
EventTypeFilter eventFilter = new EventTypeFilter();
eventFilter.setType(type);
eventFilters.add(eventFilter);
eventNode.setEventFilters(eventFilters);
}
}
xmlNode = xmlNode.getNextSibling();
}
}
use of io.automatiko.engine.workflow.base.core.event.EventFilter in project automatiko-engine by automatiko-io.
the class IntermediateCatchEventHandler method handleMessageNode.
@SuppressWarnings("unchecked")
protected void handleMessageNode(final Node node, final Element element, final String uri, final String localName, final ExtensibleXmlParser parser) throws SAXException {
super.handleNode(node, element, uri, localName, parser);
EventNode eventNode = (EventNode) node;
org.w3c.dom.Node xmlNode = element.getFirstChild();
while (xmlNode != null) {
String nodeName = xmlNode.getNodeName();
String id = ((Element) xmlNode).getAttribute("id");
String name = ((Element) xmlNode).getAttribute("name");
if ("dataOutput".equals(nodeName)) {
dataOutputs.put(id, name);
populateDataOutputs(xmlNode, name, parser);
} 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 MalformedNodeException(id, name, MessageFormat.format("Could not find message \"{0}\"", messageRef));
}
eventNode.setMetaData("MessageType", message.getType());
eventNode.setMetaData("TriggerType", "ConsumeMessage");
eventNode.setMetaData("TriggerRef", message.getName());
eventNode.setMetaData("TriggerCorrelation", message.getCorrelation());
eventNode.setMetaData("TriggerCorrelationExpr", message.getCorrelationExpression());
for (Entry<String, Object> entry : message.getMetaData().entrySet()) {
eventNode.setMetaData(entry.getKey(), entry.getValue());
}
List<EventFilter> eventFilters = new ArrayList<EventFilter>();
EventTypeFilter eventFilter = new EventTypeFilter();
eventFilter.setType("Message-" + message.getName());
eventFilters.add(eventFilter);
eventNode.setEventFilters(eventFilters);
}
xmlNode = xmlNode.getNextSibling();
}
}
use of io.automatiko.engine.workflow.base.core.event.EventFilter in project automatiko-engine by automatiko-io.
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((ExecutableProcess) parser.getParent(ExecutableProcess.class), eventNode, parentContainer, attachedTo);
}
Aggregations