Search in sources :

Example 36 with Message

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();
    }
}
Also used : ProcessAction(io.automatiko.engine.workflow.process.core.ProcessAction) Message(io.automatiko.engine.workflow.bpmn2.core.Message) ConsequenceAction(io.automatiko.engine.workflow.process.core.impl.ConsequenceAction) HandleMessageAction(io.automatiko.engine.workflow.base.instance.impl.actions.HandleMessageAction) Entry(java.util.Map.Entry) ProcessBuildData(io.automatiko.engine.workflow.compiler.xml.ProcessBuildData) EndNode(io.automatiko.engine.workflow.process.core.node.EndNode) NodeList(org.w3c.dom.NodeList) ArrayList(java.util.ArrayList) List(java.util.List) Map(java.util.Map)

Example 37 with Message

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());
}
Also used : Message(io.automatiko.engine.workflow.bpmn2.core.Message) WorkItemNode(io.automatiko.engine.workflow.process.core.node.WorkItemNode) Map(java.util.Map)

Aggregations

Map (java.util.Map)28 Message (org.jbpm.bpmn2.core.Message)27 Element (org.w3c.dom.Element)16 ArrayList (java.util.ArrayList)14 Message (io.automatiko.engine.workflow.bpmn2.core.Message)9 Test (org.junit.Test)9 List (java.util.List)7 EventFilter (org.jbpm.process.core.event.EventFilter)7 EventTypeFilter (org.jbpm.process.core.event.EventTypeFilter)7 WorkItemNode (org.jbpm.workflow.core.node.WorkItemNode)6 Signal (org.jbpm.bpmn2.core.Signal)5 ProcessBuildData (org.jbpm.compiler.xml.ProcessBuildData)5 DroolsConsequenceAction (org.jbpm.workflow.core.impl.DroolsConsequenceAction)5 StartNode (org.jbpm.workflow.core.node.StartNode)5 HashMap (java.util.HashMap)4 Error (org.jbpm.bpmn2.core.Error)4 Escalation (org.jbpm.bpmn2.core.Escalation)4 ConstraintTrigger (org.jbpm.workflow.core.node.ConstraintTrigger)4 EventNode (org.jbpm.workflow.core.node.EventNode)4 Node (org.kie.api.definition.process.Node)4