Search in sources :

Example 6 with DomElement

use of org.camunda.bpm.model.xml.instance.DomElement in project camunda-xml-model by camunda.

the class DomElementImpl method appendChild.

public void appendChild(DomElement childDomElement) {
    synchronized (document) {
        Element childElement = ((DomElementImpl) childDomElement).getElement();
        element.appendChild(childElement);
    }
}
Also used : DomElement(org.camunda.bpm.model.xml.instance.DomElement)

Example 7 with DomElement

use of org.camunda.bpm.model.xml.instance.DomElement in project camunda-xml-model by camunda.

the class ModelElementInstanceImpl method setUniqueChildElementByNameNs.

public void setUniqueChildElementByNameNs(ModelElementInstance newChild) {
    ModelUtil.ensureInstanceOf(newChild, ModelElementInstanceImpl.class);
    ModelElementInstanceImpl newChildElement = (ModelElementInstanceImpl) newChild;
    DomElement childElement = newChildElement.getDomElement();
    ModelElementInstance existingChild = getUniqueChildElementByNameNs(childElement.getNamespaceURI(), childElement.getLocalName());
    if (existingChild == null) {
        addChildElement(newChild);
    } else {
        replaceChildElement(existingChild, newChildElement);
    }
}
Also used : DomElement(org.camunda.bpm.model.xml.instance.DomElement) ModelElementInstance(org.camunda.bpm.model.xml.instance.ModelElementInstance)

Example 8 with DomElement

use of org.camunda.bpm.model.xml.instance.DomElement in project camunda-xml-model by camunda.

the class ModelElementInstanceImpl method findElementToInsertAfter.

/**
 * Returns the element after which the new element should be inserted in the DOM document.
 *
 * @param elementToInsert  the new element to insert
 * @return the element to insert after or null
 */
private ModelElementInstance findElementToInsertAfter(ModelElementInstance elementToInsert) {
    List<ModelElementType> childElementTypes = elementType.getAllChildElementTypes();
    List<DomElement> childDomElements = domElement.getChildElements();
    Collection<ModelElementInstance> childElements = ModelUtil.getModelElementCollection(childDomElements, modelInstance);
    ModelElementInstance insertAfterElement = null;
    int newElementTypeIndex = ModelUtil.getIndexOfElementType(elementToInsert, childElementTypes);
    for (ModelElementInstance childElement : childElements) {
        int childElementTypeIndex = ModelUtil.getIndexOfElementType(childElement, childElementTypes);
        if (newElementTypeIndex >= childElementTypeIndex) {
            insertAfterElement = childElement;
        } else {
            break;
        }
    }
    return insertAfterElement;
}
Also used : ModelElementType(org.camunda.bpm.model.xml.type.ModelElementType) DomElement(org.camunda.bpm.model.xml.instance.DomElement) ModelElementInstance(org.camunda.bpm.model.xml.instance.ModelElementInstance)

Example 9 with DomElement

use of org.camunda.bpm.model.xml.instance.DomElement in project camunda-xml-model by camunda.

the class ModelElementInstanceImpl method getChildElementsByType.

public Collection<ModelElementInstance> getChildElementsByType(ModelElementType childElementType) {
    List<ModelElementInstance> instances = new ArrayList<ModelElementInstance>();
    for (ModelElementType extendingType : childElementType.getExtendingTypes()) {
        instances.addAll(getChildElementsByType(extendingType));
    }
    Model model = modelInstance.getModel();
    String alternativeNamespace = model.getAlternativeNamespace(childElementType.getTypeNamespace());
    List<DomElement> elements = domElement.getChildElementsByNameNs(asSet(childElementType.getTypeNamespace(), alternativeNamespace), childElementType.getTypeName());
    instances.addAll(ModelUtil.getModelElementCollection(elements, modelInstance));
    return instances;
}
Also used : ModelElementType(org.camunda.bpm.model.xml.type.ModelElementType) DomElement(org.camunda.bpm.model.xml.instance.DomElement) ModelElementInstance(org.camunda.bpm.model.xml.instance.ModelElementInstance) ArrayList(java.util.ArrayList) Model(org.camunda.bpm.model.xml.Model)

Example 10 with DomElement

use of org.camunda.bpm.model.xml.instance.DomElement in project camunda-xml-model by camunda.

the class AbstractModelParser method getSchema.

protected Schema getSchema(DomDocument document) {
    DomElement rootElement = document.getRootElement();
    String namespaceURI = rootElement.getNamespaceURI();
    return schemas.get(namespaceURI);
}
Also used : DomElement(org.camunda.bpm.model.xml.instance.DomElement)

Aggregations

DomElement (org.camunda.bpm.model.xml.instance.DomElement)20 ArrayList (java.util.ArrayList)5 DomDocument (org.camunda.bpm.model.xml.instance.DomDocument)5 ModelException (org.camunda.bpm.model.xml.ModelException)4 ModelElementInstance (org.camunda.bpm.model.xml.instance.ModelElementInstance)4 Collection (java.util.Collection)2 Model (org.camunda.bpm.model.xml.Model)2 UnsupportedModelOperationException (org.camunda.bpm.model.xml.UnsupportedModelOperationException)2 ModelInstanceImpl (org.camunda.bpm.model.xml.impl.ModelInstanceImpl)2 ModelElementType (org.camunda.bpm.model.xml.type.ModelElementType)2 Element (org.w3c.dom.Element)2 Iterator (java.util.Iterator)1 CAMUNDA_ELEMENT_LIST (org.camunda.bpm.model.bpmn.impl.BpmnModelConstants.CAMUNDA_ELEMENT_LIST)1 ModelElementInstanceImpl (org.camunda.bpm.model.xml.impl.instance.ModelElementInstanceImpl)1 XmlQName (org.camunda.bpm.model.xml.impl.util.XmlQName)1 ChildElementCollection (org.camunda.bpm.model.xml.type.child.ChildElementCollection)1