Search in sources :

Example 16 with Process

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

the class ProcessBuilderTest method testProcessCamundaExtensions.

@Test
public void testProcessCamundaExtensions() {
    modelInstance = Bpmn.createProcess(PROCESS_ID).camundaJobPriority("${somePriority}").camundaTaskPriority(TEST_PROCESS_TASK_PRIORITY).camundaHistoryTimeToLive(TEST_HISTORY_TIME_TO_LIVE).startEvent().endEvent().done();
    Process process = modelInstance.getModelElementById(PROCESS_ID);
    assertThat(process.getCamundaJobPriority()).isEqualTo("${somePriority}");
    assertThat(process.getCamundaTaskPriority()).isEqualTo(TEST_PROCESS_TASK_PRIORITY);
    assertThat(process.getCamundaHistoryTimeToLive()).isEqualTo(TEST_HISTORY_TIME_TO_LIVE);
}
Also used : Process(org.camunda.bpm.model.bpmn.instance.Process) Test(org.junit.Test)

Example 17 with Process

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

the class ProcessBuilderTest method testCreateEmptyProcess.

@Test
public void testCreateEmptyProcess() {
    modelInstance = Bpmn.createProcess().done();
    Definitions definitions = modelInstance.getDefinitions();
    assertThat(definitions).isNotNull();
    assertThat(definitions.getTargetNamespace()).isEqualTo(BPMN20_NS);
    Collection<ModelElementInstance> processes = modelInstance.getModelElementsByType(processType);
    assertThat(processes).hasSize(1);
    Process process = (Process) processes.iterator().next();
    assertThat(process.getId()).isNotNull();
}
Also used : ModelElementInstance(org.camunda.bpm.model.xml.instance.ModelElementInstance) Process(org.camunda.bpm.model.bpmn.instance.Process) Test(org.junit.Test)

Example 18 with Process

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

the class ProcessBuilderTest method testGetElement.

@Test
public void testGetElement() {
    // Make sure this method is publicly available
    Process process = Bpmn.createProcess().getElement();
    assertThat(process).isNotNull();
}
Also used : Process(org.camunda.bpm.model.bpmn.instance.Process) Test(org.junit.Test)

Example 19 with Process

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

the class ProcessImpl method registerType.

public static void registerType(ModelBuilder modelBuilder) {
    ModelElementTypeBuilder typeBuilder = modelBuilder.defineType(Process.class, BPMN_ELEMENT_PROCESS).namespaceUri(BPMN20_NS).extendsType(CallableElement.class).instanceProvider(new ModelTypeInstanceProvider<Process>() {

        public Process newInstance(ModelTypeInstanceContext instanceContext) {
            return new ProcessImpl(instanceContext);
        }
    });
    processTypeAttribute = typeBuilder.enumAttribute(BPMN_ATTRIBUTE_PROCESS_TYPE, ProcessType.class).defaultValue(ProcessType.None).build();
    isClosedAttribute = typeBuilder.booleanAttribute(BPMN_ATTRIBUTE_IS_CLOSED).defaultValue(false).build();
    isExecutableAttribute = typeBuilder.booleanAttribute(BPMN_ATTRIBUTE_IS_EXECUTABLE).build();
    // TODO: definitionalCollaborationRef
    SequenceBuilder sequenceBuilder = typeBuilder.sequence();
    auditingChild = sequenceBuilder.element(Auditing.class).build();
    monitoringChild = sequenceBuilder.element(Monitoring.class).build();
    propertyCollection = sequenceBuilder.elementCollection(Property.class).build();
    laneSetCollection = sequenceBuilder.elementCollection(LaneSet.class).build();
    flowElementCollection = sequenceBuilder.elementCollection(FlowElement.class).build();
    artifactCollection = sequenceBuilder.elementCollection(Artifact.class).build();
    resourceRoleCollection = sequenceBuilder.elementCollection(ResourceRole.class).build();
    correlationSubscriptionCollection = sequenceBuilder.elementCollection(CorrelationSubscription.class).build();
    supportsCollection = sequenceBuilder.elementCollection(Supports.class).qNameElementReferenceCollection(Process.class).build();
    /**
     * camunda extensions
     */
    camundaCandidateStarterGroupsAttribute = typeBuilder.stringAttribute(CAMUNDA_ATTRIBUTE_CANDIDATE_STARTER_GROUPS).namespace(CAMUNDA_NS).build();
    camundaCandidateStarterUsersAttribute = typeBuilder.stringAttribute(CAMUNDA_ATTRIBUTE_CANDIDATE_STARTER_USERS).namespace(CAMUNDA_NS).build();
    camundaJobPriorityAttribute = typeBuilder.stringAttribute(CAMUNDA_ATTRIBUTE_JOB_PRIORITY).namespace(CAMUNDA_NS).build();
    camundaTaskPriorityAttribute = typeBuilder.stringAttribute(CAMUNDA_ATTRIBUTE_TASK_PRIORITY).namespace(CAMUNDA_NS).build();
    camundaHistoryTimeToLiveAttribute = typeBuilder.stringAttribute(CAMUNDA_ATTRIBUTE_HISTORY_TIME_TO_LIVE).namespace(CAMUNDA_NS).build();
    typeBuilder.build();
}
Also used : ProcessType(org.camunda.bpm.model.bpmn.ProcessType) SequenceBuilder(org.camunda.bpm.model.xml.type.child.SequenceBuilder) ModelElementTypeBuilder(org.camunda.bpm.model.xml.type.ModelElementTypeBuilder) Process(org.camunda.bpm.model.bpmn.instance.Process) ModelTypeInstanceContext(org.camunda.bpm.model.xml.impl.instance.ModelTypeInstanceContext)

Example 20 with Process

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

the class DeployCmd method retrieveProcessKeysFromResources.

protected Set<String> retrieveProcessKeysFromResources(Map<String, ResourceEntity> resources) {
    Set<String> keys = new HashSet<String>();
    for (ResourceEntity resource : resources.values()) {
        if (isBpmnResource(resource)) {
            ByteArrayInputStream byteStream = new ByteArrayInputStream(resource.getBytes());
            BpmnModelInstance model = Bpmn.readModelFromStream(byteStream);
            for (Process process : model.getDefinitions().getChildElementsByType(Process.class)) {
                keys.add(process.getId());
            }
        } else if (isCmmnResource(resource)) {
            ByteArrayInputStream byteStream = new ByteArrayInputStream(resource.getBytes());
            CmmnModelInstance model = Cmmn.readModelFromStream(byteStream);
            for (Case cmmnCase : model.getDefinitions().getCases()) {
                keys.add(cmmnCase.getId());
            }
        }
    }
    return keys;
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) ResourceEntity(org.camunda.bpm.engine.impl.persistence.entity.ResourceEntity) Process(org.camunda.bpm.model.bpmn.instance.Process) BpmnModelInstance(org.camunda.bpm.model.bpmn.BpmnModelInstance) CmmnModelInstance(org.camunda.bpm.model.cmmn.CmmnModelInstance) HashSet(java.util.HashSet) Case(org.camunda.bpm.model.cmmn.instance.Case)

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