Search in sources :

Example 6 with BoundaryEventNode

use of org.jbpm.workflow.core.node.BoundaryEventNode in project jbpm by kiegroup.

the class BoundaryEventHandler method handleConditionNode.

protected void handleConditionNode(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);
    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)) {
            readDataOutputAssociation(xmlNode, eventNode);
        } else if ("conditionalEventDefinition".equals(nodeName)) {
            org.w3c.dom.Node subNode = xmlNode.getFirstChild();
            while (subNode != null) {
                String subnodeName = subNode.getNodeName();
                if ("condition".equals(subnodeName)) {
                    eventNode.setMetaData("Condition", xmlNode.getTextContent());
                    List<EventFilter> eventFilters = new ArrayList<EventFilter>();
                    EventTypeFilter eventFilter = new EventTypeFilter();
                    eventFilter.setType("Condition-" + attachedTo);
                    eventFilters.add(eventFilter);
                    eventNode.setScope("external");
                    eventNode.setEventFilters(eventFilters);
                    break;
                }
                subNode = subNode.getNextSibling();
            }
        }
        xmlNode = xmlNode.getNextSibling();
    }
}
Also used : NonAcceptingEventTypeFilter(org.jbpm.process.core.event.NonAcceptingEventTypeFilter) EventTypeFilter(org.jbpm.process.core.event.EventTypeFilter) Element(org.w3c.dom.Element) ArrayList(java.util.ArrayList) BoundaryEventNode(org.jbpm.workflow.core.node.BoundaryEventNode) EventFilter(org.jbpm.process.core.event.EventFilter)

Example 7 with BoundaryEventNode

use of org.jbpm.workflow.core.node.BoundaryEventNode in project jbpm by kiegroup.

the class BoundaryEventHandler method handleTimerNode.

protected void handleTimerNode(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);
    eventNode.setMetaData("CancelActivity", cancelActivity);
    eventNode.setAttachedToNodeId(attachedTo);
    org.w3c.dom.Node xmlNode = element.getFirstChild();
    while (xmlNode != null) {
        String nodeName = xmlNode.getNodeName();
        if ("timerEventDefinition".equals(nodeName)) {
            String timeDuration = null;
            String timeCycle = null;
            String timeDate = null;
            String language = "";
            org.w3c.dom.Node subNode = xmlNode.getFirstChild();
            while (subNode instanceof Element) {
                String subNodeName = subNode.getNodeName();
                if ("timeDuration".equals(subNodeName)) {
                    timeDuration = subNode.getTextContent();
                    break;
                } else if ("timeCycle".equals(subNodeName)) {
                    timeCycle = subNode.getTextContent();
                    language = ((Element) subNode).getAttribute("language");
                    break;
                } else if ("timeDate".equals(subNodeName)) {
                    timeDate = subNode.getTextContent();
                    break;
                }
                subNode = subNode.getNextSibling();
            }
            if (timeDuration != null && timeDuration.trim().length() > 0) {
                List<EventFilter> eventFilters = new ArrayList<EventFilter>();
                EventTypeFilter eventFilter = new EventTypeFilter();
                eventFilter.setType("Timer-" + attachedTo + "-" + timeDuration + "-" + eventNode.getId());
                eventFilters.add(eventFilter);
                eventNode.setEventFilters(eventFilters);
                eventNode.setMetaData("TimeDuration", timeDuration);
            } else if (timeCycle != null && timeCycle.trim().length() > 0) {
                List<EventFilter> eventFilters = new ArrayList<EventFilter>();
                EventTypeFilter eventFilter = new EventTypeFilter();
                eventFilter.setType("Timer-" + attachedTo + "-" + timeCycle + "-" + eventNode.getId());
                eventFilters.add(eventFilter);
                eventNode.setEventFilters(eventFilters);
                eventNode.setMetaData("TimeCycle", timeCycle);
                eventNode.setMetaData("Language", language);
            } else if (timeDate != null && timeDate.trim().length() > 0) {
                List<EventFilter> eventFilters = new ArrayList<EventFilter>();
                EventTypeFilter eventFilter = new EventTypeFilter();
                eventFilter.setType("Timer-" + attachedTo + "-" + timeDate + "-" + eventNode.getId());
                eventFilters.add(eventFilter);
                eventNode.setEventFilters(eventFilters);
                eventNode.setMetaData("TimeDate", timeDate);
            }
        }
        xmlNode = xmlNode.getNextSibling();
    }
}
Also used : NonAcceptingEventTypeFilter(org.jbpm.process.core.event.NonAcceptingEventTypeFilter) EventTypeFilter(org.jbpm.process.core.event.EventTypeFilter) Element(org.w3c.dom.Element) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) NodeList(org.w3c.dom.NodeList) List(java.util.List) BoundaryEventNode(org.jbpm.workflow.core.node.BoundaryEventNode) EventFilter(org.jbpm.process.core.event.EventFilter)

Example 8 with BoundaryEventNode

use of org.jbpm.workflow.core.node.BoundaryEventNode in project jbpm by kiegroup.

the class BoundaryEventHandler method handleCompensationNode.

protected void handleCompensationNode(final Node node, final Element element, final String uri, final String localName, final ExtensibleXmlParser parser, final String attachedTo, final boolean cancelActivity) throws SAXException {
    BoundaryEventNode eventNode = (BoundaryEventNode) parser.getCurrent();
    super.handleNode(node, element, uri, localName, parser);
    NodeList childs = element.getChildNodes();
    for (int i = 0; i < childs.getLength(); i++) {
        if (childs.item(i) instanceof Element) {
            Element el = (Element) childs.item(i);
            if ("compensateEventDefinition".equalsIgnoreCase(el.getNodeName())) {
                String activityRef = el.getAttribute("activityRef");
                if (activityRef != null && activityRef.length() > 0) {
                    logger.warn("activityRef value [" + activityRef + "] on Boundary Event '" + eventNode.getMetaData("UniqueId") + "' ignored per the BPMN2 specification.");
                }
            }
        }
    }
    eventNode.setMetaData("AttachedTo", attachedTo);
    eventNode.setAttachedToNodeId(attachedTo);
    // 1. Find the parent (sub-)process
    NodeContainer parentContainer = (NodeContainer) parser.getParent();
    // 2. Add the event filter (never fires, purely for dumping purposes)
    EventTypeFilter eventFilter = new NonAcceptingEventTypeFilter();
    eventFilter.setType("Compensation");
    List<EventFilter> eventFilters = new ArrayList<EventFilter>();
    eventNode.setEventFilters(eventFilters);
    eventFilters.add(eventFilter);
    // 3. Add compensation scope (with key/id: attachedTo)
    ProcessHandler.addCompensationScope((RuleFlowProcess) parser.getParent(RuleFlowProcess.class), eventNode, parentContainer, attachedTo);
}
Also used : NonAcceptingEventTypeFilter(org.jbpm.process.core.event.NonAcceptingEventTypeFilter) EventTypeFilter(org.jbpm.process.core.event.EventTypeFilter) NodeList(org.w3c.dom.NodeList) Element(org.w3c.dom.Element) ArrayList(java.util.ArrayList) NonAcceptingEventTypeFilter(org.jbpm.process.core.event.NonAcceptingEventTypeFilter) NodeContainer(org.jbpm.workflow.core.NodeContainer) BoundaryEventNode(org.jbpm.workflow.core.node.BoundaryEventNode) EventFilter(org.jbpm.process.core.event.EventFilter)

Example 9 with BoundaryEventNode

use of org.jbpm.workflow.core.node.BoundaryEventNode 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)) {
            readDataOutputAssociation(xmlNode, eventNode);
        } 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);
            } 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 10 with BoundaryEventNode

use of org.jbpm.workflow.core.node.BoundaryEventNode in project jbpm by kiegroup.

the class BoundaryEventHandler method handleSignalNode.

protected void handleSignalNode(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);
    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);
        }
        if ("dataOutputAssociation".equals(nodeName)) {
            readDataOutputAssociation(xmlNode, eventNode);
        } else if ("signalEventDefinition".equals(nodeName)) {
            String type = ((Element) xmlNode).getAttribute("signalRef");
            if (type != null && type.trim().length() > 0) {
                type = checkSignalAndConvertToRealSignalNam(parser, type);
                List<EventFilter> eventFilters = new ArrayList<EventFilter>();
                EventTypeFilter eventFilter = new EventTypeFilter();
                eventFilter.setType(type);
                eventFilters.add(eventFilter);
                eventNode.setEventFilters(eventFilters);
                eventNode.setScope("external");
                eventNode.setMetaData("SignalName", type);
            }
        }
        xmlNode = xmlNode.getNextSibling();
    }
}
Also used : NonAcceptingEventTypeFilter(org.jbpm.process.core.event.NonAcceptingEventTypeFilter) EventTypeFilter(org.jbpm.process.core.event.EventTypeFilter) Element(org.w3c.dom.Element) ArrayList(java.util.ArrayList) NodeList(org.w3c.dom.NodeList) List(java.util.List) BoundaryEventNode(org.jbpm.workflow.core.node.BoundaryEventNode) EventFilter(org.jbpm.process.core.event.EventFilter)

Aggregations

BoundaryEventNode (org.jbpm.workflow.core.node.BoundaryEventNode)15 ArrayList (java.util.ArrayList)13 EventFilter (org.jbpm.process.core.event.EventFilter)11 EventTypeFilter (org.jbpm.process.core.event.EventTypeFilter)11 NonAcceptingEventTypeFilter (org.jbpm.process.core.event.NonAcceptingEventTypeFilter)8 List (java.util.List)7 Element (org.w3c.dom.Element)7 ActionNode (org.jbpm.workflow.core.node.ActionNode)5 EventSubProcessNode (org.jbpm.workflow.core.node.EventSubProcessNode)5 Node (org.kie.api.definition.process.Node)5 Map (java.util.Map)4 CompositeNode (org.jbpm.workflow.core.node.CompositeNode)4 EndNode (org.jbpm.workflow.core.node.EndNode)4 NodeList (org.w3c.dom.NodeList)4 CompositeContextNode (org.jbpm.workflow.core.node.CompositeContextNode)3 EventNode (org.jbpm.workflow.core.node.EventNode)3 FaultNode (org.jbpm.workflow.core.node.FaultNode)3 StartNode (org.jbpm.workflow.core.node.StartNode)3 WorkItemNode (org.jbpm.workflow.core.node.WorkItemNode)3 HashMap (java.util.HashMap)2