use of org.jbpm.process.instance.impl.actions.HandleMessageAction in project kogito-runtimes by kiegroup.
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 ("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 ProcessParsingValidationException("No messages found");
}
Message message = messages.get(messageRef);
if (message == null) {
throw new ProcessParsingValidationException("Could not find message " + messageRef);
}
String variable = (String) endNode.getMetaData(MAPPING_VARIABLE);
endNode.setMetaData(Metadata.EVENT_TYPE, EVENT_TYPE_MESSAGE);
endNode.setMetaData(Metadata.MESSAGE_TYPE, message.getType());
endNode.setMetaData(Metadata.TRIGGER_TYPE, PRODUCE_MESSAGE);
endNode.setMetaData(Metadata.TRIGGER_REF, message.getName());
List<DroolsAction> actions = new ArrayList<>();
DroolsConsequenceAction action = createJavaAction(new HandleMessageAction(message.getType(), variable));
actions.add(action);
endNode.setActions(EndNode.EVENT_NODE_ENTER, actions);
}
xmlNode = xmlNode.getNextSibling();
}
}
use of org.jbpm.process.instance.impl.actions.HandleMessageAction in project kogito-runtimes by kiegroup.
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 ("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 ProcessParsingValidationException("No messages found");
}
Message message = messages.get(messageRef);
if (message == null) {
throw new ProcessParsingValidationException("Could not find message " + messageRef);
}
String variable = (String) actionNode.getMetaData(MAPPING_VARIABLE);
Variable v = (Variable) ((ProcessBuildData) parser.getData()).getMetaData("Variable");
if (v != null) {
variable = (String) v.getMetaData(variable);
}
actionNode.setMetaData(EVENT_TYPE, EVENT_TYPE_MESSAGE);
actionNode.setMetaData(MESSAGE_TYPE, message.getType());
actionNode.setMetaData(TRIGGER_TYPE, PRODUCE_MESSAGE);
actionNode.setMetaData(TRIGGER_REF, message.getName());
DroolsConsequenceAction action = createJavaAction(new HandleMessageAction(message.getType(), variable));
actionNode.setAction(action);
}
xmlNode = xmlNode.getNextSibling();
}
}
Aggregations