Search in sources :

Example 1 with HandleEscalationAction

use of io.automatiko.engine.workflow.base.instance.impl.actions.HandleEscalationAction in project automatiko-engine by automatiko-io.

the class IntermediateThrowEventHandler method handleEscalationNode.

@SuppressWarnings("unchecked")
public void handleEscalationNode(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 ("dataInputAssociation".equals(nodeName)) {
            readDataInputAssociation(xmlNode, actionNode, parser);
        } else if ("escalationEventDefinition".equals(nodeName)) {
            String escalationRef = ((Element) xmlNode).getAttribute("escalationRef");
            if (escalationRef != null && escalationRef.trim().length() > 0) {
                Map<String, Escalation> escalations = (Map<String, Escalation>) ((ProcessBuildData) parser.getData()).getMetaData(ProcessHandler.ESCALATIONS);
                if (escalations == null) {
                    throw new IllegalArgumentException("No escalations found");
                }
                Escalation escalation = escalations.get(escalationRef);
                if (escalation == null) {
                    throw new IllegalArgumentException("Could not find escalation " + escalationRef);
                }
                String faultName = escalation.getEscalationCode();
                String variable = (String) actionNode.getMetaData(MAPPING_VARIABLE_KEY);
                ConsequenceAction action = createJavaAction(new HandleEscalationAction(faultName, variable));
                actionNode.setAction(action);
                actionNode.setMetaData("TriggerType", "Escalation");
            } else {
                throw new IllegalArgumentException("General escalation is not yet supported");
            }
        }
        xmlNode = xmlNode.getNextSibling();
    }
}
Also used : ProcessBuildData(io.automatiko.engine.workflow.compiler.xml.ProcessBuildData) Escalation(io.automatiko.engine.workflow.bpmn2.core.Escalation) ConsequenceAction(io.automatiko.engine.workflow.process.core.impl.ConsequenceAction) ActionNode(io.automatiko.engine.workflow.process.core.node.ActionNode) Map(java.util.Map) NamedNodeMap(org.w3c.dom.NamedNodeMap) HandleEscalationAction(io.automatiko.engine.workflow.base.instance.impl.actions.HandleEscalationAction)

Aggregations

HandleEscalationAction (io.automatiko.engine.workflow.base.instance.impl.actions.HandleEscalationAction)1 Escalation (io.automatiko.engine.workflow.bpmn2.core.Escalation)1 ProcessBuildData (io.automatiko.engine.workflow.compiler.xml.ProcessBuildData)1 ConsequenceAction (io.automatiko.engine.workflow.process.core.impl.ConsequenceAction)1 ActionNode (io.automatiko.engine.workflow.process.core.node.ActionNode)1 Map (java.util.Map)1 NamedNodeMap (org.w3c.dom.NamedNodeMap)1