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