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