use of org.camunda.bpm.model.xml.type.ModelElementType in project camunda-xml-model by camunda.
the class ChildElementCollectionTest method testParentElementType.
@Test
public void testParentElementType() {
ModelElementType flyingAnimalType = modelInstance.getModel().getType(FlyingAnimal.class);
assertThat(flightInstructorChild).hasParentElementType(flyingAnimalType);
assertThat(flightPartnerRefCollection).hasParentElementType(flyingAnimalType);
}
use of org.camunda.bpm.model.xml.type.ModelElementType 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.type.ModelElementType 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.type.ModelElementType in project camunda-xml-model by camunda.
the class ModelElementTypeImpl method resolveExtendingTypes.
/**
* Resolve all types recursively which are extending this type
*
* @param allExtendingTypes set of calculated extending types
*/
public void resolveExtendingTypes(Set<ModelElementType> allExtendingTypes) {
for (ModelElementType modelElementType : extendingTypes) {
ModelElementTypeImpl modelElementTypeImpl = (ModelElementTypeImpl) modelElementType;
if (!allExtendingTypes.contains(modelElementTypeImpl)) {
allExtendingTypes.add(modelElementType);
modelElementTypeImpl.resolveExtendingTypes(allExtendingTypes);
}
}
}
use of org.camunda.bpm.model.xml.type.ModelElementType in project camunda-xml-model by camunda.
the class ChildElementCollectionBuilderImpl method performModelBuild.
public void performModelBuild(Model model) {
ModelElementType elementType = model.getType(childElementType);
if (elementType == null) {
throw new ModelException(parentElementType + " declares undefined child element of type " + childElementType + ".");
}
parentElementType.registerChildElementType(elementType);
parentElementType.registerChildElementCollection(collection);
for (ModelBuildOperation modelBuildOperation : modelBuildOperations) {
modelBuildOperation.performModelBuild(model);
}
}
Aggregations