Search in sources :

Example 1 with SendMessageAction

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();
    }
}
Also used : SendMessageAction(org.jbpm.bpmn2.handler.SendMessageAction) ProcessBuildData(org.jbpm.compiler.xml.ProcessBuildData) EndNode(org.jbpm.workflow.core.node.EndNode) Message(org.jbpm.bpmn2.core.Message) JavaDroolsAction(org.jbpm.workflow.core.impl.JavaDroolsAction) Map(java.util.Map)

Example 2 with SendMessageAction

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();
    }
}
Also used : SendMessageAction(org.jbpm.bpmn2.handler.SendMessageAction) Message(org.jbpm.bpmn2.core.Message) JavaDroolsAction(org.jbpm.workflow.core.impl.JavaDroolsAction) Element(org.w3c.dom.Element) ActionNode(org.jbpm.workflow.core.node.ActionNode) Map(java.util.Map) NamedNodeMap(org.w3c.dom.NamedNodeMap)

Example 3 with SendMessageAction

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);
    }
}
Also used : SendMessageAction(org.jbpm.bpmn2.handler.SendMessageAction) SendSignalAction(org.jbpm.bpmn2.handler.SendSignalAction)

Aggregations

SendMessageAction (org.jbpm.bpmn2.handler.SendMessageAction)3 Map (java.util.Map)2 Message (org.jbpm.bpmn2.core.Message)2 JavaDroolsAction (org.jbpm.workflow.core.impl.JavaDroolsAction)2 SendSignalAction (org.jbpm.bpmn2.handler.SendSignalAction)1 ProcessBuildData (org.jbpm.compiler.xml.ProcessBuildData)1 ActionNode (org.jbpm.workflow.core.node.ActionNode)1 EndNode (org.jbpm.workflow.core.node.EndNode)1 Element (org.w3c.dom.Element)1 NamedNodeMap (org.w3c.dom.NamedNodeMap)1