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);
}
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);
}
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;
}
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);
}
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;
}
Aggregations