Search in sources :

Example 6 with Process

use of org.camunda.bpm.model.bpmn.instance.Process in project camunda-bpm-platform by camunda.

the class ModifiableBpmnModelInstance method addDocumentation.

public ModifiableBpmnModelInstance addDocumentation(String content) {
    Collection<Process> processes = modelInstance.getModelElementsByType(Process.class);
    Documentation documentation = modelInstance.newInstance(Documentation.class);
    documentation.setTextContent(content);
    for (Process process : processes) {
        process.addChildElement(documentation);
    }
    return this;
}
Also used : Process(org.camunda.bpm.model.bpmn.instance.Process)

Example 7 with Process

use of org.camunda.bpm.model.bpmn.instance.Process in project camunda-bpm-platform by camunda.

the class UserTaskBpmnModelExecutionContextTest method assertModelInstance.

private void assertModelInstance() {
    BpmnModelInstance modelInstance = ModelExecutionContextTaskListener.modelInstance;
    assertNotNull(modelInstance);
    Collection<ModelElementInstance> events = modelInstance.getModelElementsByType(modelInstance.getModel().getType(Event.class));
    assertEquals(2, events.size());
    Collection<ModelElementInstance> tasks = modelInstance.getModelElementsByType(modelInstance.getModel().getType(Task.class));
    assertEquals(1, tasks.size());
    Process process = (Process) modelInstance.getDefinitions().getRootElements().iterator().next();
    assertEquals(PROCESS_ID, process.getId());
    assertTrue(process.isExecutable());
}
Also used : ModelElementInstance(org.camunda.bpm.model.xml.instance.ModelElementInstance) Process(org.camunda.bpm.model.bpmn.instance.Process) BpmnModelInstance(org.camunda.bpm.model.bpmn.BpmnModelInstance)

Example 8 with Process

use of org.camunda.bpm.model.bpmn.instance.Process in project camunda-bpm-platform by camunda.

the class StartProcessInstancesInDirectory method extractProcessDefinitionKeys.

private static List<String> extractProcessDefinitionKeys(List<String> deployableFileNames) {
    ArrayList<String> keys = new ArrayList<String>();
    for (String file : deployableFileNames) {
        if (file.endsWith(".bpmn") || file.endsWith(".bpmn20.xml")) {
            BpmnModelInstance modelInstance = Bpmn.readModelFromFile(new File(file));
            Collection<Process> processes = modelInstance.getModelElementsByType(Process.class);
            for (Process process : processes) {
                if (process.isExecutable()) {
                    keys.add(process.getId());
                }
            }
        }
    }
    return keys;
}
Also used : ArrayList(java.util.ArrayList) Process(org.camunda.bpm.model.bpmn.instance.Process) BpmnModelInstance(org.camunda.bpm.model.bpmn.BpmnModelInstance) File(java.io.File)

Example 9 with Process

use of org.camunda.bpm.model.bpmn.instance.Process in project camunda-bpmn-model by camunda.

the class ProcessTest method shouldImportProcess.

@Test
@BpmnModelResource
public void shouldImportProcess() {
    ModelElementInstance modelElementById = bpmnModelInstance.getModelElementById("exampleProcessId");
    assertThat(modelElementById).isNotNull();
    Collection<RootElement> rootElements = bpmnModelInstance.getDefinitions().getRootElements();
    assertThat(rootElements).hasSize(1);
    org.camunda.bpm.model.bpmn.instance.Process process = (Process) rootElements.iterator().next();
    assertThat(process.getId()).isEqualTo("exampleProcessId");
    assertThat(process.getName()).isNull();
    assertThat(process.getProcessType()).isEqualTo(ProcessType.None);
    assertThat(process.isExecutable()).isFalse();
    assertThat(process.isClosed()).isFalse();
}
Also used : RootElement(org.camunda.bpm.model.bpmn.instance.RootElement) ModelElementInstance(org.camunda.bpm.model.xml.instance.ModelElementInstance) Process(org.camunda.bpm.model.bpmn.instance.Process) Process(org.camunda.bpm.model.bpmn.instance.Process) BpmnModelResource(org.camunda.bpm.model.bpmn.util.BpmnModelResource) Test(org.junit.Test)

Example 10 with Process

use of org.camunda.bpm.model.bpmn.instance.Process in project camunda-bpmn-model by camunda.

the class Bpmn method createProcess.

public static ProcessBuilder createProcess() {
    BpmnModelInstance modelInstance = INSTANCE.doCreateEmptyModel();
    Definitions definitions = modelInstance.newInstance(Definitions.class);
    definitions.setTargetNamespace(BPMN20_NS);
    definitions.getDomElement().registerNamespace("camunda", CAMUNDA_NS);
    modelInstance.setDefinitions(definitions);
    Process process = modelInstance.newInstance(Process.class);
    definitions.addChildElement(process);
    BpmnDiagram bpmnDiagram = modelInstance.newInstance(BpmnDiagram.class);
    BpmnPlane bpmnPlane = modelInstance.newInstance(BpmnPlane.class);
    bpmnPlane.setBpmnElement(process);
    bpmnDiagram.addChildElement(bpmnPlane);
    definitions.addChildElement(bpmnDiagram);
    return process.builder();
}
Also used : BpmnPlane(org.camunda.bpm.model.bpmn.instance.bpmndi.BpmnPlane) Definitions(org.camunda.bpm.model.bpmn.instance.Definitions) Process(org.camunda.bpm.model.bpmn.instance.Process) BpmnDiagram(org.camunda.bpm.model.bpmn.instance.bpmndi.BpmnDiagram)

Aggregations

Process (org.camunda.bpm.model.bpmn.instance.Process)22 Test (org.junit.Test)13 BpmnModelInstance (org.camunda.bpm.model.bpmn.BpmnModelInstance)6 ModelElementInstance (org.camunda.bpm.model.xml.instance.ModelElementInstance)5 ModelValidationException (org.camunda.bpm.model.xml.ModelValidationException)4 Definitions (org.camunda.bpm.model.bpmn.instance.Definitions)3 ArrayList (java.util.ArrayList)2 StartEvent (org.camunda.bpm.model.bpmn.instance.StartEvent)2 UserTask (org.camunda.bpm.model.bpmn.instance.UserTask)2 BpmnModelResource (org.camunda.bpm.model.bpmn.util.BpmnModelResource)2 ByteArrayInputStream (java.io.ByteArrayInputStream)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 File (java.io.File)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 OutputStream (java.io.OutputStream)1 HashSet (java.util.HashSet)1 List (java.util.List)1 Properties (java.util.Properties)1 ProcessEngine (org.camunda.bpm.engine.ProcessEngine)1