use of io.automatiko.engine.workflow.base.instance.impl.actions.HandleMessageAction in project automatiko-engine by automatiko-io.
the class IntermediateThrowEventHandler method handleMessageNode.
@SuppressWarnings("unchecked")
public void handleMessageNode(final Node node, final Element element, final String uri, final String localName, final ExtensibleXmlParser parser) throws SAXException {
ActionNode actionNode = (ActionNode) node;
org.w3c.dom.Node xmlNode = element.getFirstChild();
while (xmlNode != null) {
String nodeName = xmlNode.getNodeName();
if ("dataInput".equals(nodeName)) {
String id = ((Element) xmlNode).getAttribute("id");
String inputName = ((Element) xmlNode).getAttribute("name");
dataInputs.put(id, inputName);
} else if ("dataInputAssociation".equals(nodeName)) {
readDataInputAssociation(xmlNode, actionNode, parser);
} 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);
}
String variable = (String) actionNode.getMetaData(MAPPING_VARIABLE_KEY);
Variable v = (Variable) ((ProcessBuildData) parser.getData()).getMetaData("Variable");
if (v != null) {
variable = (String) v.getMetaData(variable);
}
actionNode.setMetaData("MessageType", message.getType());
actionNode.setMetaData("TriggerType", "ProduceMessage");
actionNode.setMetaData("TriggerRef", message.getName());
for (Entry<String, Object> entry : message.getMetaData().entrySet()) {
actionNode.setMetaData(entry.getKey(), entry.getValue());
}
ConsequenceAction action = createJavaAction(new HandleMessageAction(message.getType(), variable, (Transformation) actionNode.getMetaData().get(TRANSFORMATION_KEY)));
actionNode.setAction(action);
}
xmlNode = xmlNode.getNextSibling();
}
}
use of io.automatiko.engine.workflow.base.instance.impl.actions.HandleMessageAction in project automatiko-engine by automatiko-io.
the class EndEventHandler method handleMessageNode.
@SuppressWarnings("unchecked")
public void handleMessageNode(final Node node, final Element element, final String uri, final String localName, final ExtensibleXmlParser parser) throws SAXException {
EndNode endNode = (EndNode) node;
org.w3c.dom.Node xmlNode = element.getFirstChild();
while (xmlNode != null) {
String nodeName = xmlNode.getNodeName();
if ("dataInputAssociation".equals(nodeName)) {
readEndDataInputAssociation(xmlNode, endNode);
} 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);
}
String variable = (String) endNode.getMetaData("MappingVariable");
endNode.setMetaData("MessageType", message.getType());
endNode.setMetaData("TriggerType", "ProduceMessage");
endNode.setMetaData("TriggerRef", message.getName());
for (Entry<String, Object> entry : message.getMetaData().entrySet()) {
endNode.setMetaData(entry.getKey(), entry.getValue());
}
List<ProcessAction> actions = new ArrayList<ProcessAction>();
ConsequenceAction action = createJavaAction(new HandleMessageAction(message.getType(), variable));
actions.add(action);
endNode.setActions(EndNode.EVENT_NODE_ENTER, actions);
}
xmlNode = xmlNode.getNextSibling();
}
}
Aggregations