use of org.jbpm.bpmn2.handler.SendMessageAction in project jbpm 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 ("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);
}
message.addOutgoingNode(node);
String varName = (String) endNode.getMetaData("MappingVariable");
endNode.setMetaData("MessageType", message.getType());
endNode.setActions(EndNode.EVENT_NODE_ENTER, Collections.singletonList(new JavaDroolsAction(new SendMessageAction(varName, message))));
}
xmlNode = xmlNode.getNextSibling();
}
}
use of org.jbpm.bpmn2.handler.SendMessageAction in project jbpm 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 ("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);
} 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);
}
message.addOutgoingNode(node);
String varName = (String) actionNode.getMetaData("MappingVariable");
actionNode.setMetaData("MessageType", message.getType());
actionNode.setAction(new JavaDroolsAction(new SendMessageAction(varName, message)));
}
xmlNode = xmlNode.getNextSibling();
}
}
use of org.jbpm.bpmn2.handler.SendMessageAction in project jbpm by kiegroup.
the class AbstractNodeHandler method writeJavaAction.
protected void writeJavaAction(Node node, JavaAction action, StringBuilder xmlDump) {
if (action instanceof SendSignalAction) {
SendSignalAction signalAction = (SendSignalAction) action;
String variable = signalAction.getVariable();
if (variable != null) {
xmlDump.append(" <dataInput id=\"" + XmlBPMNProcessDumper.getUniqueNodeId(node) + "_Input\" />" + EOL + " <dataInputAssociation>" + EOL + " <sourceRef>" + XmlDumper.replaceIllegalChars(variable) + "</sourceRef>" + EOL + " <targetRef>" + XmlBPMNProcessDumper.getUniqueNodeId(node) + "_Input</targetRef>" + EOL + " </dataInputAssociation>" + EOL + " <inputSet>" + EOL + " <dataInputRefs>" + XmlBPMNProcessDumper.getUniqueNodeId(node) + "_Input</dataInputRefs>" + EOL + " </inputSet>" + EOL);
}
xmlDump.append(" <signalEventDefinition signalRef=\"" + XmlBPMNProcessDumper.replaceIllegalCharsAttribute(signalAction.getSignalName()) + "\"/>" + EOL);
} else if (action instanceof SendMessageAction) {
SendMessageAction signalAction = (SendMessageAction) action;
String variable = signalAction.getVariable();
if (variable != null) {
xmlDump.append(" <dataInput id=\"" + XmlBPMNProcessDumper.getUniqueNodeId(node) + "_Input\" />" + EOL + " <dataInputAssociation>" + EOL + " <sourceRef>" + XmlDumper.replaceIllegalChars(variable) + "</sourceRef>" + EOL + " <targetRef>" + XmlBPMNProcessDumper.getUniqueNodeId(node) + "_Input</targetRef>" + EOL + " </dataInputAssociation>" + EOL + " <inputSet>" + EOL + " <dataInputRefs>" + XmlBPMNProcessDumper.getUniqueNodeId(node) + "_Input</dataInputRefs>" + EOL + " </inputSet>" + EOL);
}
xmlDump.append(" <messageEventDefinition messageRef=\"" + XmlBPMNProcessDumper.getUniqueNodeId(node) + "_Message\"/>" + EOL);
}
}
Aggregations