Search in sources :

Example 6 with Model

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

the class ProcessBuilderTest method getElementTypes.

@BeforeClass
public static void getElementTypes() {
    Model model = Bpmn.createEmptyModel().getModel();
    taskType = model.getType(Task.class);
    gatewayType = model.getType(Gateway.class);
    eventType = model.getType(Event.class);
    processType = model.getType(Process.class);
}
Also used : Model(org.camunda.bpm.model.xml.Model) Process(org.camunda.bpm.model.bpmn.instance.Process) BeforeClass(org.junit.BeforeClass)

Example 7 with Model

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

the class ExecutionListenerBpmnModelExecutionContextTest method assertFlowElementIs.

private void assertFlowElementIs(Class<? extends FlowElement> elementClass) {
    BpmnModelInstance modelInstance = ModelExecutionContextExecutionListener.modelInstance;
    assertNotNull(modelInstance);
    Model model = modelInstance.getModel();
    Collection<ModelElementInstance> events = modelInstance.getModelElementsByType(model.getType(Event.class));
    assertEquals(3, events.size());
    Collection<ModelElementInstance> gateways = modelInstance.getModelElementsByType(model.getType(Gateway.class));
    assertEquals(1, gateways.size());
    Collection<ModelElementInstance> tasks = modelInstance.getModelElementsByType(model.getType(Task.class));
    assertEquals(1, tasks.size());
    FlowElement flowElement = ModelExecutionContextExecutionListener.flowElement;
    assertNotNull(flowElement);
    assertTrue(elementClass.isAssignableFrom(flowElement.getClass()));
}
Also used : ModelElementInstance(org.camunda.bpm.model.xml.instance.ModelElementInstance) ParallelGateway(org.camunda.bpm.model.bpmn.instance.ParallelGateway) Model(org.camunda.bpm.model.xml.Model) BpmnModelInstance(org.camunda.bpm.model.bpmn.BpmnModelInstance)

Example 8 with Model

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

the class ServiceTaskBpmnModelExecutionContextTest method testJavaDelegateModelExecutionContext.

public void testJavaDelegateModelExecutionContext() {
    deploy();
    runtimeService.startProcessInstanceByKey(PROCESS_ID);
    BpmnModelInstance modelInstance = ModelExecutionContextServiceTask.modelInstance;
    assertNotNull(modelInstance);
    Model model = modelInstance.getModel();
    Collection<ModelElementInstance> events = modelInstance.getModelElementsByType(model.getType(Event.class));
    assertEquals(2, events.size());
    Collection<ModelElementInstance> tasks = modelInstance.getModelElementsByType(model.getType(Task.class));
    assertEquals(1, tasks.size());
    Process process = (Process) modelInstance.getDefinitions().getRootElements().iterator().next();
    assertEquals(PROCESS_ID, process.getId());
    assertTrue(process.isExecutable());
    ServiceTask serviceTask = ModelExecutionContextServiceTask.serviceTask;
    assertNotNull(serviceTask);
    assertEquals(ModelExecutionContextServiceTask.class.getName(), serviceTask.getCamundaClass());
}
Also used : ServiceTask(org.camunda.bpm.model.bpmn.instance.ServiceTask) Task(org.camunda.bpm.model.bpmn.instance.Task) ServiceTask(org.camunda.bpm.model.bpmn.instance.ServiceTask) ModelElementInstance(org.camunda.bpm.model.xml.instance.ModelElementInstance) Model(org.camunda.bpm.model.xml.Model) Event(org.camunda.bpm.model.bpmn.instance.Event) Process(org.camunda.bpm.model.bpmn.instance.Process) BpmnModelInstance(org.camunda.bpm.model.bpmn.BpmnModelInstance)

Example 9 with Model

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

the class ModelUtil method getModelElement.

protected static ModelElementTypeImpl getModelElement(DomElement domElement, ModelInstanceImpl modelInstance, String namespaceUri) {
    String localName = domElement.getLocalName();
    ModelElementTypeImpl modelType = (ModelElementTypeImpl) modelInstance.getModel().getTypeForName(namespaceUri, localName);
    if (modelType == null) {
        Model model = modelInstance.getModel();
        String actualNamespaceUri = model.getActualNamespace(namespaceUri);
        if (actualNamespaceUri != null) {
            modelType = getModelElement(domElement, modelInstance, actualNamespaceUri);
        } else {
            modelType = (ModelElementTypeImpl) modelInstance.registerGenericType(namespaceUri, localName);
        }
    }
    return modelType;
}
Also used : Model(org.camunda.bpm.model.xml.Model) ModelElementTypeImpl(org.camunda.bpm.model.xml.impl.type.ModelElementTypeImpl)

Example 10 with Model

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

the class ModelElementInstanceImpl method getUniqueChildElementByNameNs.

public ModelElementInstance getUniqueChildElementByNameNs(String namespaceUri, String elementName) {
    Model model = modelInstance.getModel();
    List<DomElement> childElements = domElement.getChildElementsByNameNs(asSet(namespaceUri, model.getAlternativeNamespace(namespaceUri)), elementName);
    if (!childElements.isEmpty()) {
        return ModelUtil.getModelElement(childElements.get(0), modelInstance);
    } else {
        return null;
    }
}
Also used : DomElement(org.camunda.bpm.model.xml.instance.DomElement) Model(org.camunda.bpm.model.xml.Model)

Aggregations

Model (org.camunda.bpm.model.xml.Model)10 ModelElementInstance (org.camunda.bpm.model.xml.instance.ModelElementInstance)3 ModelElementType (org.camunda.bpm.model.xml.type.ModelElementType)3 Test (org.junit.Test)3 ArrayList (java.util.ArrayList)2 BpmnModelInstance (org.camunda.bpm.model.bpmn.BpmnModelInstance)2 Process (org.camunda.bpm.model.bpmn.instance.Process)2 DomElement (org.camunda.bpm.model.xml.instance.DomElement)2 Event (org.camunda.bpm.model.bpmn.instance.Event)1 ParallelGateway (org.camunda.bpm.model.bpmn.instance.ParallelGateway)1 ServiceTask (org.camunda.bpm.model.bpmn.instance.ServiceTask)1 Task (org.camunda.bpm.model.bpmn.instance.Task)1 ModelElementTypeImpl (org.camunda.bpm.model.xml.impl.type.ModelElementTypeImpl)1 BeforeClass (org.junit.BeforeClass)1