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;
}
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;
}
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);
}
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);
}
}
}
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);
}
}
}
Aggregations