use of io.automatiko.engine.workflow.bpmn2.core.Message 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();
}
}
use of io.automatiko.engine.workflow.bpmn2.core.Message in project automatiko-engine by automatiko-io.
the class SendTaskHandler method handleNode.
@SuppressWarnings("unchecked")
protected void handleNode(final Node node, final Element element, final String uri, final String localName, final ExtensibleXmlParser parser) throws SAXException {
super.handleNode(node, element, uri, localName, parser);
WorkItemNode workItemNode = (WorkItemNode) node;
String messageRef = element.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);
}
workItemNode.getWork().setParameter("MessageType", message.getType());
}
Aggregations