use of org.camunda.bpm.model.xml.instance.DomElement in project camunda-xml-model by camunda.
the class ModelElementInstanceImpl method getUniqueChildElementByNameNs.
public ModelElementInstance getUniqueChildElementByNameNs(String namespaceUri, String elementName) {
Model model = modelInstance.getModel();
List<DomElement> childElements = domElement.getChildElementsByNameNs(asSet(namespaceUri, model.getAlternativeNamespace(namespaceUri)), elementName);
if (!childElements.isEmpty()) {
return ModelUtil.getModelElement(childElements.get(0), modelInstance);
} else {
return null;
}
}
use of org.camunda.bpm.model.xml.instance.DomElement in project camunda-xml-model by camunda.
the class ModelElementInstanceImpl method replaceChildElement.
public void replaceChildElement(ModelElementInstance existingChild, ModelElementInstance newChild) {
DomElement existingChildDomElement = existingChild.getDomElement();
DomElement newChildDomElement = newChild.getDomElement();
// unlink (remove all references) of child elements
((ModelElementInstanceImpl) existingChild).unlinkAllChildReferences();
// update incoming references from old to new child element
updateIncomingReferences(existingChild, newChild);
// replace the existing child with the new child in the DOM
domElement.replaceChild(newChildDomElement, existingChildDomElement);
// execute after replacement updates
newChild.updateAfterReplacement();
}
use of org.camunda.bpm.model.xml.instance.DomElement in project camunda-xml-model by camunda.
the class ModelElementTypeImpl method newInstance.
public ModelElementInstance newInstance(ModelInstance modelInstance) {
ModelInstanceImpl modelInstanceImpl = (ModelInstanceImpl) modelInstance;
DomDocument document = modelInstanceImpl.getDocument();
DomElement domElement = document.createElement(typeNamespace, typeName);
return newInstance(modelInstanceImpl, domElement);
}
use of org.camunda.bpm.model.xml.instance.DomElement in project camunda-xml-model by camunda.
the class ModelElementTypeImpl method getInstances.
public Collection<ModelElementInstance> getInstances(ModelInstance modelInstance) {
ModelInstanceImpl modelInstanceImpl = (ModelInstanceImpl) modelInstance;
DomDocument document = modelInstanceImpl.getDocument();
List<DomElement> elements = getElementsByNameNs(document, typeNamespace);
List<ModelElementInstance> resultList = new ArrayList<ModelElementInstance>();
for (DomElement element : elements) {
resultList.add(ModelUtil.getModelElement(element, modelInstanceImpl, this));
}
return resultList;
}
use of org.camunda.bpm.model.xml.instance.DomElement in project camunda-xml-model by camunda.
the class ChildElementCollectionImpl method get.
public Collection<T> get(ModelElementInstance element) {
final ModelElementInstanceImpl modelElement = (ModelElementInstanceImpl) element;
return new Collection<T>() {
public boolean contains(Object o) {
if (o == null) {
return false;
} else if (!(o instanceof ModelElementInstanceImpl)) {
return false;
} else {
return getView(modelElement).contains(((ModelElementInstanceImpl) o).getDomElement());
}
}
public boolean containsAll(Collection<?> c) {
for (Object elementToCheck : c) {
if (!contains(elementToCheck)) {
return false;
}
}
return true;
}
public boolean isEmpty() {
return getView(modelElement).isEmpty();
}
public Iterator<T> iterator() {
Collection<T> modelElementCollection = ModelUtil.getModelElementCollection(getView(modelElement), modelElement.getModelInstance());
return modelElementCollection.iterator();
}
public Object[] toArray() {
Collection<T> modelElementCollection = ModelUtil.getModelElementCollection(getView(modelElement), modelElement.getModelInstance());
return modelElementCollection.toArray();
}
public <U> U[] toArray(U[] a) {
Collection<T> modelElementCollection = ModelUtil.getModelElementCollection(getView(modelElement), modelElement.getModelInstance());
return modelElementCollection.toArray(a);
}
public int size() {
return getView(modelElement).size();
}
public boolean add(T e) {
if (!isMutable) {
throw new UnsupportedModelOperationException("add()", "collection is immutable");
}
performAddOperation(modelElement, e);
return true;
}
public boolean addAll(Collection<? extends T> c) {
if (!isMutable) {
throw new UnsupportedModelOperationException("addAll()", "collection is immutable");
}
boolean result = false;
for (T t : c) {
result |= add(t);
}
return result;
}
public void clear() {
if (!isMutable) {
throw new UnsupportedModelOperationException("clear()", "collection is immutable");
}
Collection<DomElement> view = getView(modelElement);
performClearOperation(modelElement, view);
}
public boolean remove(Object e) {
if (!isMutable) {
throw new UnsupportedModelOperationException("remove()", "collection is immutable");
}
ModelUtil.ensureInstanceOf(e, ModelElementInstanceImpl.class);
return performRemoveOperation(modelElement, e);
}
public boolean removeAll(Collection<?> c) {
if (!isMutable) {
throw new UnsupportedModelOperationException("removeAll()", "collection is immutable");
}
boolean result = false;
for (Object t : c) {
result |= remove(t);
}
return result;
}
public boolean retainAll(Collection<?> c) {
throw new UnsupportedModelOperationException("retainAll()", "not implemented");
}
};
}
Aggregations