Search in sources :

Example 21 with ModelElementType

use of org.camunda.bpm.model.xml.type.ModelElementType in project camunda-bpmn-model by camunda.

the class QueryTest method testFilterByType.

@Test
public void testFilterByType() {
    ModelElementType taskType = modelInstance.getModel().getType(Task.class);
    ModelElementType gatewayType = modelInstance.getModel().getType(Gateway.class);
    assertThat(startSucceeding.filterByType(taskType).list()).hasSize(1);
    assertThat(startSucceeding.filterByType(gatewayType).list()).hasSize(0);
    assertThat(gateway1Succeeding.filterByType(taskType).list()).hasSize(1);
    assertThat(gateway1Succeeding.filterByType(gatewayType).list()).hasSize(1);
    assertThat(gateway2Succeeding.filterByType(taskType).list()).hasSize(3);
    assertThat(gateway2Succeeding.filterByType(gatewayType).list()).hasSize(0);
}
Also used : ModelElementType(org.camunda.bpm.model.xml.type.ModelElementType) Test(org.junit.Test)

Example 22 with ModelElementType

use of org.camunda.bpm.model.xml.type.ModelElementType in project camunda-bpm-platform by camunda.

the class ItemHandler method initializeActivityType.

protected void initializeActivityType(CmmnElement element, CmmnActivity activity, CmmnHandlerContext context) {
    PlanItemDefinition definition = getDefinition(element);
    String activityType = null;
    if (definition != null) {
        ModelElementType elementType = definition.getElementType();
        if (elementType != null) {
            activityType = elementType.getTypeName();
        }
    }
    activity.setProperty(PROPERTY_ACTIVITY_TYPE, activityType);
}
Also used : ModelElementType(org.camunda.bpm.model.xml.type.ModelElementType) PlanItemDefinition(org.camunda.bpm.model.cmmn.instance.PlanItemDefinition) CamundaString(org.camunda.bpm.model.cmmn.instance.camunda.CamundaString)

Example 23 with ModelElementType

use of org.camunda.bpm.model.xml.type.ModelElementType in project camunda-cmmn-model by camunda.

the class ExtensionElementsImpl method addExtensionElement.

public ModelElementInstance addExtensionElement(String namespaceUri, String localName) {
    ModelElementType extensionElementType = modelInstance.registerGenericType(namespaceUri, localName);
    ModelElementInstance extensionElement = extensionElementType.newInstance(modelInstance);
    addChildElement(extensionElement);
    return extensionElement;
}
Also used : ModelElementType(org.camunda.bpm.model.xml.type.ModelElementType) ModelElementInstance(org.camunda.bpm.model.xml.instance.ModelElementInstance)

Example 24 with ModelElementType

use of org.camunda.bpm.model.xml.type.ModelElementType in project camunda-xml-model by camunda.

the class ModelUtil method getIndexOfElementType.

/**
 * Find the index of the type of a model element in a list of element types
 *
 * @param modelElement the model element which type is searched for
 * @param childElementTypes the list to search the type
 * @return the index of the model element type in the list or -1 if it is not found
 */
public static int getIndexOfElementType(ModelElementInstance modelElement, List<ModelElementType> childElementTypes) {
    for (int index = 0; index < childElementTypes.size(); index++) {
        ModelElementType childElementType = childElementTypes.get(index);
        Class<? extends ModelElementInstance> instanceType = childElementType.getInstanceType();
        if (instanceType.isAssignableFrom(modelElement.getClass())) {
            return index;
        }
    }
    Collection<String> childElementTypeNames = new ArrayList<String>();
    for (ModelElementType childElementType : childElementTypes) {
        childElementTypeNames.add(childElementType.getTypeName());
    }
    throw new ModelException("New child is not a valid child element type: " + modelElement.getElementType().getTypeName() + "; valid types are: " + childElementTypeNames);
}
Also used : ModelElementType(org.camunda.bpm.model.xml.type.ModelElementType) ModelException(org.camunda.bpm.model.xml.ModelException)

Example 25 with ModelElementType

use of org.camunda.bpm.model.xml.type.ModelElementType in project camunda-xml-model by camunda.

the class ModelUtil method calculateAllExtendingTypes.

/**
 * Calculate a collection of all extending types for the given base types
 *
 * @param baseTypes the collection of types to calculate the union of all extending types
 */
public static Collection<ModelElementType> calculateAllExtendingTypes(Model model, Collection<ModelElementType> baseTypes) {
    Set<ModelElementType> allExtendingTypes = new HashSet<ModelElementType>();
    for (ModelElementType baseType : baseTypes) {
        ModelElementTypeImpl modelElementTypeImpl = (ModelElementTypeImpl) model.getType(baseType.getInstanceType());
        modelElementTypeImpl.resolveExtendingTypes(allExtendingTypes);
    }
    return allExtendingTypes;
}
Also used : ModelElementType(org.camunda.bpm.model.xml.type.ModelElementType) ModelElementTypeImpl(org.camunda.bpm.model.xml.impl.type.ModelElementTypeImpl)

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