Search in sources :

Example 11 with ModelElementType

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);
}
Also used : ModelElementType(org.camunda.bpm.model.xml.type.ModelElementType) Test(org.junit.Test) TestModelTest(org.camunda.bpm.model.xml.testmodel.TestModelTest)

Example 12 with ModelElementType

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;
}
Also used : ModelElementType(org.camunda.bpm.model.xml.type.ModelElementType) DomElement(org.camunda.bpm.model.xml.instance.DomElement) ModelElementInstance(org.camunda.bpm.model.xml.instance.ModelElementInstance)

Example 13 with ModelElementType

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;
}
Also used : ModelElementType(org.camunda.bpm.model.xml.type.ModelElementType) DomElement(org.camunda.bpm.model.xml.instance.DomElement) ModelElementInstance(org.camunda.bpm.model.xml.instance.ModelElementInstance) ArrayList(java.util.ArrayList) Model(org.camunda.bpm.model.xml.Model)

Example 14 with ModelElementType

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);
        }
    }
}
Also used : ModelElementType(org.camunda.bpm.model.xml.type.ModelElementType)

Example 15 with ModelElementType

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);
    }
}
Also used : ModelElementType(org.camunda.bpm.model.xml.type.ModelElementType) ModelException(org.camunda.bpm.model.xml.ModelException) ModelBuildOperation(org.camunda.bpm.model.xml.impl.ModelBuildOperation)

Aggregations

ModelElementType (org.camunda.bpm.model.xml.type.ModelElementType)34 Test (org.junit.Test)11 ArrayList (java.util.ArrayList)9 ModelElementInstance (org.camunda.bpm.model.xml.instance.ModelElementInstance)8 Model (org.camunda.bpm.model.xml.Model)3 TestModelTest (org.camunda.bpm.model.xml.testmodel.TestModelTest)3 ModelException (org.camunda.bpm.model.xml.ModelException)2 ModelInstanceImpl (org.camunda.bpm.model.xml.impl.ModelInstanceImpl)2 ModelElementTypeImpl (org.camunda.bpm.model.xml.impl.type.ModelElementTypeImpl)2 DomElement (org.camunda.bpm.model.xml.instance.DomElement)2 Before (org.junit.Before)2 PlanItemDefinition (org.camunda.bpm.model.cmmn.instance.PlanItemDefinition)1 CamundaString (org.camunda.bpm.model.cmmn.instance.camunda.CamundaString)1 ModelBuildOperation (org.camunda.bpm.model.xml.impl.ModelBuildOperation)1 QName (org.camunda.bpm.model.xml.impl.util.QName)1 AnimalTest (org.camunda.bpm.model.xml.testmodel.instance.AnimalTest)1 Attribute (org.camunda.bpm.model.xml.type.attribute.Attribute)1 Reference (org.camunda.bpm.model.xml.type.reference.Reference)1