Search in sources :

Example 16 with ModelElementType

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

the class ProcessBuilderTest method testCreateProcessWithInclusiveGateway.

@Test
public void testCreateProcessWithInclusiveGateway() {
    modelInstance = Bpmn.createProcess().startEvent().userTask().inclusiveGateway().condition("approved", "${approved}").serviceTask().endEvent().moveToLastGateway().condition("not approved", "${!approved}").scriptTask().endEvent().done();
    ModelElementType inclusiveGwType = modelInstance.getModel().getType(InclusiveGateway.class);
    assertThat(modelInstance.getModelElementsByType(eventType)).hasSize(3);
    assertThat(modelInstance.getModelElementsByType(taskType)).hasSize(3);
    assertThat(modelInstance.getModelElementsByType(inclusiveGwType)).hasSize(1);
}
Also used : ModelElementType(org.camunda.bpm.model.xml.type.ModelElementType) Test(org.junit.Test)

Example 17 with ModelElementType

use of org.camunda.bpm.model.xml.type.ModelElementType in project camunda-bpmn-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 18 with ModelElementType

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

the class BaseElementImpl method getIncomingReferencesByType.

@SuppressWarnings("rawtypes")
public Collection<Reference> getIncomingReferencesByType(Class<? extends ModelElementInstance> referenceSourceTypeClass) {
    Collection<Reference> references = new ArrayList<Reference>();
    // we traverse all incoming references in reverse direction
    for (Reference<?> reference : idAttribute.getIncomingReferences()) {
        ModelElementType sourceElementType = reference.getReferenceSourceElementType();
        Class<? extends ModelElementInstance> sourceInstanceType = sourceElementType.getInstanceType();
        // if the referencing element (source element) is a BPMNDI element, dig deeper
        if (referenceSourceTypeClass.isAssignableFrom(sourceInstanceType)) {
            references.add(reference);
        }
    }
    return references;
}
Also used : ModelElementType(org.camunda.bpm.model.xml.type.ModelElementType) Reference(org.camunda.bpm.model.xml.type.reference.Reference) ArrayList(java.util.ArrayList)

Example 19 with ModelElementType

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

the class ModelTest method testBaseTypeCalculation.

@Test
public void testBaseTypeCalculation() {
    BpmnModelInstance bpmnModelInstance = Bpmn.createEmptyModel();
    Model model = bpmnModelInstance.getModel();
    Collection<ModelElementType> allBaseTypes = ModelUtil.calculateAllBaseTypes(model.getType(StartEvent.class));
    assertThat(allBaseTypes).hasSize(5);
    allBaseTypes = ModelUtil.calculateAllBaseTypes(model.getType(MessageEventDefinition.class));
    assertThat(allBaseTypes).hasSize(3);
    allBaseTypes = ModelUtil.calculateAllBaseTypes(model.getType(BaseElement.class));
    assertThat(allBaseTypes).hasSize(0);
}
Also used : ModelElementType(org.camunda.bpm.model.xml.type.ModelElementType) Model(org.camunda.bpm.model.xml.Model) Test(org.junit.Test)

Example 20 with ModelElementType

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

the class ModelTest method testExtendingTypeCalculation.

@Test
public void testExtendingTypeCalculation() {
    BpmnModelInstance bpmnModelInstance = Bpmn.createEmptyModel();
    Model model = bpmnModelInstance.getModel();
    List<ModelElementType> baseInstanceTypes = new ArrayList<ModelElementType>();
    baseInstanceTypes.add(model.getType(Event.class));
    baseInstanceTypes.add(model.getType(CatchEvent.class));
    baseInstanceTypes.add(model.getType(ExtensionElements.class));
    baseInstanceTypes.add(model.getType(EventDefinition.class));
    Collection<ModelElementType> allExtendingTypes = ModelUtil.calculateAllExtendingTypes(bpmnModelInstance.getModel(), baseInstanceTypes);
    assertThat(allExtendingTypes).hasSize(17);
}
Also used : ModelElementType(org.camunda.bpm.model.xml.type.ModelElementType) Model(org.camunda.bpm.model.xml.Model) ArrayList(java.util.ArrayList) Test(org.junit.Test)

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