use of org.camunda.bpm.model.xml.instance.ModelElementInstance in project camunda-xml-model by camunda.
the class ModelInstanceImpl method getModelElementsByType.
public Collection<ModelElementInstance> getModelElementsByType(ModelElementType type) {
Collection<ModelElementType> extendingTypes = type.getAllExtendingTypes();
List<ModelElementInstance> instances = new ArrayList<ModelElementInstance>();
for (ModelElementType modelElementType : extendingTypes) {
if (!modelElementType.isAbstract()) {
instances.addAll(modelElementType.getInstances(this));
}
}
return instances;
}
use of org.camunda.bpm.model.xml.instance.ModelElementInstance 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.ModelElementInstance in project camunda-xml-model by camunda.
the class ChildElementImpl method getChild.
@SuppressWarnings("unchecked")
public T getChild(ModelElementInstance element) {
ModelElementInstanceImpl elementInstanceImpl = (ModelElementInstanceImpl) element;
ModelElementInstance childElement = elementInstanceImpl.getUniqueChildElementByType(childElementTypeClass);
if (childElement != null) {
ModelUtil.ensureInstanceOf(childElement, childElementTypeClass);
return (T) childElement;
} else {
return null;
}
}
use of org.camunda.bpm.model.xml.instance.ModelElementInstance in project camunda-xml-model by camunda.
the class ElementReferenceCollectionImpl method removeReference.
@Override
protected void removeReference(ModelElementInstance referenceSourceElement, ModelElementInstance referenceTargetElement) {
ModelElementInstance parentElement = referenceSourceElement.getParentElement();
Collection<Source> childElementCollection = referenceSourceCollection.get(parentElement);
childElementCollection.remove(referenceSourceElement);
}
use of org.camunda.bpm.model.xml.instance.ModelElementInstance in project camunda-xml-model by camunda.
the class ElementReferenceCollectionImpl method performAddOperation.
protected void performAddOperation(ModelElementInstanceImpl referenceSourceParentElement, Target referenceTargetElement) {
ModelInstanceImpl modelInstance = referenceSourceParentElement.getModelInstance();
String referenceTargetIdentifier = referenceTargetAttribute.getValue(referenceTargetElement);
ModelElementInstance existingElement = modelInstance.getModelElementById(referenceTargetIdentifier);
if (existingElement == null || !existingElement.equals(referenceTargetElement)) {
throw new ModelReferenceException("Cannot create reference to model element " + referenceTargetElement + ": element is not part of model. Please connect element to the model first.");
} else {
Collection<Source> referenceSourceElements = referenceSourceCollection.get(referenceSourceParentElement);
Source referenceSourceElement = modelInstance.newInstance(referenceSourceType);
referenceSourceElements.add(referenceSourceElement);
setReferenceIdentifier(referenceSourceElement, referenceTargetIdentifier);
}
}
Aggregations