Search in sources :

Example 1 with BaseChildElementParser

use of org.activiti.bpmn.converter.child.BaseChildElementParser in project Activiti by Activiti.

the class BpmnXMLUtil method parseChildElements.

public static void parseChildElements(String elementName, BaseElement parentElement, XMLStreamReader xtr, Map<String, BaseChildElementParser> childParsers, BpmnModel model) throws Exception {
    Map<String, BaseChildElementParser> localParserMap = new HashMap<String, BaseChildElementParser>(genericChildParserMap);
    if (childParsers != null) {
        localParserMap.putAll(childParsers);
    }
    boolean inExtensionElements = false;
    boolean readyWithChildElements = false;
    while (readyWithChildElements == false && xtr.hasNext()) {
        xtr.next();
        if (xtr.isStartElement()) {
            if (ELEMENT_EXTENSIONS.equals(xtr.getLocalName())) {
                inExtensionElements = true;
            } else if (localParserMap.containsKey(xtr.getLocalName())) {
                BaseChildElementParser childParser = localParserMap.get(xtr.getLocalName());
                //if we're into an extension element but the current element is not accepted by this parentElement then is read as a custom extension element
                if (inExtensionElements && !childParser.accepts(parentElement)) {
                    ExtensionElement extensionElement = BpmnXMLUtil.parseExtensionElement(xtr);
                    parentElement.addExtensionElement(extensionElement);
                    continue;
                }
                localParserMap.get(xtr.getLocalName()).parseChildElement(xtr, parentElement, model);
            } else if (inExtensionElements) {
                ExtensionElement extensionElement = BpmnXMLUtil.parseExtensionElement(xtr);
                parentElement.addExtensionElement(extensionElement);
            }
        } else if (xtr.isEndElement()) {
            if (ELEMENT_EXTENSIONS.equals(xtr.getLocalName())) {
                inExtensionElements = false;
            } else if (elementName.equalsIgnoreCase(xtr.getLocalName())) {
                readyWithChildElements = true;
            }
        }
    }
}
Also used : HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) ExtensionElement(org.activiti.bpmn.model.ExtensionElement) BaseChildElementParser(org.activiti.bpmn.converter.child.BaseChildElementParser)

Aggregations

HashMap (java.util.HashMap)1 LinkedHashMap (java.util.LinkedHashMap)1 BaseChildElementParser (org.activiti.bpmn.converter.child.BaseChildElementParser)1 ExtensionElement (org.activiti.bpmn.model.ExtensionElement)1