Search in sources :

Example 11 with Escalation

use of io.automatiko.engine.workflow.bpmn2.core.Escalation in project jbpm by kiegroup.

the class BoundaryEventHandler method handleEscalationNode.

@SuppressWarnings("unchecked")
protected void handleEscalationNode(final Node node, final Element element, final String uri, final String localName, final ExtensibleXmlParser parser, final String attachedTo, final boolean cancelActivity) throws SAXException {
    super.handleNode(node, element, uri, localName, parser);
    BoundaryEventNode eventNode = (BoundaryEventNode) node;
    eventNode.setMetaData("AttachedTo", attachedTo);
    /**
     * TODO: because of how we process bpmn2/xml files, we can't tell
     *       if the cancelActivity attribute is set to false or not
     *       (because we override with the xsd settings)
     * BPMN2 spec, p. 255, Escalation row:
     * "In contrast to an Error, an Escalation by default is assumed to not abort
     * the Activity to which the boundary Event is attached."
     */
    eventNode.setMetaData("CancelActivity", cancelActivity);
    eventNode.setAttachedToNodeId(attachedTo);
    org.w3c.dom.Node xmlNode = element.getFirstChild();
    while (xmlNode != null) {
        String nodeName = xmlNode.getNodeName();
        if ("dataOutput".equals(nodeName)) {
            String id = ((Element) xmlNode).getAttribute("id");
            String outputName = ((Element) xmlNode).getAttribute("name");
            dataOutputs.put(id, outputName);
        } else if ("dataOutputAssociation".equals(nodeName)) {
            ((BoundaryEventNode) parser.getCurrent()).addOutAssociation(DataAssociationFactory.readDataOutputAssociation(xmlNode, dataOutputs));
        } 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);
                }
                List<EventFilter> eventFilters = new ArrayList<EventFilter>();
                EventTypeFilter eventFilter = new EventTypeFilter();
                String type = escalation.getEscalationCode();
                eventFilter.setType("Escalation-" + attachedTo + "-" + type);
                eventFilters.add(eventFilter);
                eventNode.setEventFilters(eventFilters);
                eventNode.setMetaData("EscalationEvent", type);
                eventNode.setMetaData("EscalationStructureRef", escalation.getStructureRef());
            } else {
                throw new UnsupportedOperationException("General escalation is not yet supported.");
            }
        }
        xmlNode = xmlNode.getNextSibling();
    }
}
Also used : Element(org.w3c.dom.Element) Escalation(org.jbpm.bpmn2.core.Escalation) ArrayList(java.util.ArrayList) BoundaryEventNode(org.jbpm.workflow.core.node.BoundaryEventNode) EventFilter(org.jbpm.process.core.event.EventFilter) NonAcceptingEventTypeFilter(org.jbpm.process.core.event.NonAcceptingEventTypeFilter) EventTypeFilter(org.jbpm.process.core.event.EventTypeFilter) Map(java.util.Map)

Example 12 with Escalation

use of io.automatiko.engine.workflow.bpmn2.core.Escalation in project kogito-runtimes by kiegroup.

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 ("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 ProcessParsingValidationException("No escalations found");
                }
                Escalation escalation = escalations.get(escalationRef);
                if (escalation == null) {
                    throw new ProcessParsingValidationException("Could not find escalation " + escalationRef);
                }
                String faultName = escalation.getEscalationCode();
                String variable = (String) actionNode.getMetaData(MAPPING_VARIABLE);
                DroolsConsequenceAction action = createJavaAction(new HandleEscalationAction(faultName, variable));
                actionNode.setAction(action);
            } else {
                throw new ProcessParsingValidationException("General escalation is not yet supported");
            }
        }
        xmlNode = xmlNode.getNextSibling();
    }
}
Also used : DroolsConsequenceAction(org.jbpm.workflow.core.impl.DroolsConsequenceAction) Element(org.w3c.dom.Element) Escalation(org.jbpm.bpmn2.core.Escalation) ActionNode(org.jbpm.workflow.core.node.ActionNode) Map(java.util.Map) NamedNodeMap(org.w3c.dom.NamedNodeMap) HandleEscalationAction(org.jbpm.process.instance.impl.actions.HandleEscalationAction)

Example 13 with Escalation

use of io.automatiko.engine.workflow.bpmn2.core.Escalation in project kogito-runtimes by kiegroup.

the class EndEventHandler method handleEscalationNode.

@SuppressWarnings("unchecked")
public void handleEscalationNode(final Node node, final Element element, final String uri, final String localName, final ExtensibleXmlParser parser) throws SAXException {
    FaultNode faultNode = (FaultNode) node;
    org.w3c.dom.Node xmlNode = element.getFirstChild();
    while (xmlNode != null) {
        String nodeName = xmlNode.getNodeName();
        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 ProcessParsingValidationException("No escalations found");
                }
                Escalation escalation = escalations.get(escalationRef);
                if (escalation == null) {
                    throw new ProcessParsingValidationException("Could not find escalation " + escalationRef);
                }
                faultNode.setFaultName(escalation.getEscalationCode());
            } else {
                // are _required_ to reference a specific escalation(-code).
                throw new ProcessParsingValidationException("End events throwing an escalation must throw *specific* escalations (and not general ones).");
            }
        }
        xmlNode = xmlNode.getNextSibling();
    }
}
Also used : FaultNode(org.jbpm.workflow.core.node.FaultNode) Element(org.w3c.dom.Element) Escalation(org.jbpm.bpmn2.core.Escalation) Map(java.util.Map)

Example 14 with Escalation

use of io.automatiko.engine.workflow.bpmn2.core.Escalation in project kogito-runtimes by kiegroup.

the class BoundaryEventHandler method handleEscalationNode.

@SuppressWarnings("unchecked")
protected void handleEscalationNode(final Node node, final Element element, final String uri, final String localName, final ExtensibleXmlParser parser, final String attachedTo, final boolean cancelActivity) throws SAXException {
    super.handleNode(node, element, uri, localName, parser);
    BoundaryEventNode eventNode = (BoundaryEventNode) node;
    eventNode.setMetaData("AttachedTo", attachedTo);
    /**
     * TODO: because of how we process bpmn2/xml files, we can't tell
     * if the cancelActivity attribute is set to false or not
     * (because we override with the xsd settings)
     * BPMN2 spec, p. 255, Escalation row:
     * "In contrast to an Error, an Escalation by default is assumed to not abort
     * the Activity to which the boundary Event is attached."
     */
    eventNode.setMetaData("CancelActivity", cancelActivity);
    eventNode.setAttachedToNodeId(attachedTo);
    org.w3c.dom.Node xmlNode = element.getFirstChild();
    while (xmlNode != null) {
        String nodeName = xmlNode.getNodeName();
        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 ProcessParsingValidationException("No escalations found");
                }
                Escalation escalation = escalations.get(escalationRef);
                if (escalation == null) {
                    throw new ProcessParsingValidationException("Could not find escalation " + escalationRef);
                }
                List<EventFilter> eventFilters = new ArrayList<EventFilter>();
                EventTypeFilter eventFilter = new EventTypeFilter();
                String type = escalation.getEscalationCode();
                eventFilter.setType("Escalation-" + attachedTo + "-" + type);
                eventFilters.add(eventFilter);
                eventNode.setEventFilters(eventFilters);
                eventNode.setMetaData("EscalationEvent", type);
            } else {
                throw new UnsupportedOperationException("General escalation is not yet supported.");
            }
        }
        xmlNode = xmlNode.getNextSibling();
    }
}
Also used : Element(org.w3c.dom.Element) Escalation(org.jbpm.bpmn2.core.Escalation) ArrayList(java.util.ArrayList) BoundaryEventNode(org.jbpm.workflow.core.node.BoundaryEventNode) EventFilter(org.jbpm.process.core.event.EventFilter) NonAcceptingEventTypeFilter(org.jbpm.process.core.event.NonAcceptingEventTypeFilter) EventTypeFilter(org.jbpm.process.core.event.EventTypeFilter) Map(java.util.Map)

Aggregations

Map (java.util.Map)14 Escalation (org.jbpm.bpmn2.core.Escalation)8 Element (org.w3c.dom.Element)8 ArrayList (java.util.ArrayList)7 Escalation (io.automatiko.engine.workflow.bpmn2.core.Escalation)6 ProcessBuildData (io.automatiko.engine.workflow.compiler.xml.ProcessBuildData)5 List (java.util.List)4 ProcessBuildData (org.jbpm.compiler.xml.ProcessBuildData)4 EventFilter (org.jbpm.process.core.event.EventFilter)3 EventTypeFilter (org.jbpm.process.core.event.EventTypeFilter)3 NonAcceptingEventTypeFilter (org.jbpm.process.core.event.NonAcceptingEventTypeFilter)3 NamedNodeMap (org.w3c.dom.NamedNodeMap)3 EventFilter (io.automatiko.engine.workflow.base.core.event.EventFilter)2 EventTypeFilter (io.automatiko.engine.workflow.base.core.event.EventTypeFilter)2 Error (io.automatiko.engine.workflow.bpmn2.core.Error)2 ItemDefinition (io.automatiko.engine.workflow.bpmn2.core.ItemDefinition)2 Message (io.automatiko.engine.workflow.bpmn2.core.Message)2 Signal (io.automatiko.engine.workflow.bpmn2.core.Signal)2 ConsequenceAction (io.automatiko.engine.workflow.process.core.impl.ConsequenceAction)2 ActionNode (io.automatiko.engine.workflow.process.core.node.ActionNode)2