Search in sources :

Example 1 with DomElement

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

the class ElementReferenceCollectionImpl method getView.

protected Collection<DomElement> getView(ModelElementInstanceImpl referenceSourceParentElement) {
    DomDocument document = referenceSourceParentElement.getModelInstance().getDocument();
    Collection<Source> referenceSourceElements = referenceSourceCollection.get(referenceSourceParentElement);
    Collection<DomElement> referenceTargetElements = new ArrayList<DomElement>();
    for (Source referenceSourceElement : referenceSourceElements) {
        String identifier = getReferenceIdentifier(referenceSourceElement);
        DomElement referenceTargetElement = document.getElementById(identifier);
        if (referenceTargetElement != null) {
            referenceTargetElements.add(referenceTargetElement);
        } else {
            throw new ModelException("Unable to find a model element instance for id " + identifier);
        }
    }
    return referenceTargetElements;
}
Also used : DomElement(org.camunda.bpm.model.xml.instance.DomElement) ModelException(org.camunda.bpm.model.xml.ModelException) ArrayList(java.util.ArrayList) DomDocument(org.camunda.bpm.model.xml.instance.DomDocument)

Example 2 with DomElement

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

the class IdsElementReferenceCollectionImpl method getView.

@Override
protected Collection<DomElement> getView(ModelElementInstanceImpl referenceSourceParentElement) {
    DomDocument document = referenceSourceParentElement.getModelInstance().getDocument();
    Collection<Source> referenceSourceElements = getReferenceSourceCollection().get(referenceSourceParentElement);
    Collection<DomElement> referenceTargetElements = new ArrayList<DomElement>();
    for (Source referenceSourceElement : referenceSourceElements) {
        List<String> identifiers = getReferenceIdentifiers(referenceSourceElement);
        for (String identifier : identifiers) {
            DomElement referenceTargetElement = document.getElementById(identifier);
            if (referenceTargetElement != null) {
                referenceTargetElements.add(referenceTargetElement);
            } else {
                throw new ModelException("Unable to find a model element instance for id " + identifier);
            }
        }
    }
    return referenceTargetElements;
}
Also used : DomElement(org.camunda.bpm.model.xml.instance.DomElement) ModelException(org.camunda.bpm.model.xml.ModelException) ArrayList(java.util.ArrayList) DomDocument(org.camunda.bpm.model.xml.instance.DomDocument)

Example 3 with DomElement

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

the class ModelInstanceImpl method setDocumentElement.

public void setDocumentElement(ModelElementInstance modelElement) {
    ModelUtil.ensureInstanceOf(modelElement, ModelElementInstanceImpl.class);
    DomElement domElement = modelElement.getDomElement();
    document.setRootElement(domElement);
}
Also used : DomElement(org.camunda.bpm.model.xml.instance.DomElement)

Example 4 with DomElement

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

the class DomElementImpl method insertChildElementAfter.

public void insertChildElementAfter(DomElement elementToInsert, DomElement insertAfter) {
    synchronized (document) {
        Element newElement = ((DomElementImpl) elementToInsert).getElement();
        // find node to insert before
        Node insertBeforeNode;
        if (insertAfter == null) {
            insertBeforeNode = element.getFirstChild();
        } else {
            insertBeforeNode = ((DomElementImpl) insertAfter).getElement().getNextSibling();
        }
        // insert before node or append if no node was found
        if (insertBeforeNode != null) {
            element.insertBefore(newElement, insertBeforeNode);
        } else {
            element.appendChild(newElement);
        }
    }
}
Also used : DomElement(org.camunda.bpm.model.xml.instance.DomElement)

Example 5 with DomElement

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

the class DomElementImpl method replaceChild.

public void replaceChild(DomElement newChildDomElement, DomElement existingChildDomElement) {
    synchronized (document) {
        Element newElement = ((DomElementImpl) newChildDomElement).getElement();
        Element existingElement = ((DomElementImpl) existingChildDomElement).getElement();
        try {
            element.replaceChild(newElement, existingElement);
        } catch (DOMException e) {
            throw new ModelException("Unable to replace child <" + existingElement + "> of element <" + element + "> with element <" + newElement + ">", e);
        }
    }
}
Also used : ModelException(org.camunda.bpm.model.xml.ModelException) 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