Search in sources :

Example 31 with CaseDefinition

use of org.camunda.bpm.engine.repository.CaseDefinition in project camunda-bpm-platform by camunda.

the class CaseDefinitionRestServiceQueryTest method testCaseDefinitionTenantIdIncludeDefinitionsWithoutTenantid.

@Test
public void testCaseDefinitionTenantIdIncludeDefinitionsWithoutTenantid() {
    List<CaseDefinition> caseDefinitions = Arrays.asList(MockProvider.mockCaseDefinition().tenantId(null).build(), MockProvider.mockCaseDefinition().tenantId(MockProvider.EXAMPLE_TENANT_ID).build());
    mockedQuery = createMockCaseDefinitionQuery(caseDefinitions);
    Response response = given().queryParam("tenantIdIn", MockProvider.EXAMPLE_TENANT_ID).queryParam("includeCaseDefinitionsWithoutTenantId", true).then().expect().statusCode(Status.OK.getStatusCode()).when().get(CASE_DEFINITION_QUERY_URL);
    verify(mockedQuery).tenantIdIn(MockProvider.EXAMPLE_TENANT_ID);
    verify(mockedQuery).includeCaseDefinitionsWithoutTenantId();
    verify(mockedQuery).list();
    String content = response.asString();
    List<String> definitions = from(content).getList("");
    assertThat(definitions).hasSize(2);
    String returnedTenantId1 = from(content).getString("[0].tenantId");
    String returnedTenantId2 = from(content).getString("[1].tenantId");
    assertThat(returnedTenantId1).isEqualTo(null);
    assertThat(returnedTenantId2).isEqualTo(MockProvider.EXAMPLE_TENANT_ID);
}
Also used : Response(com.jayway.restassured.response.Response) CaseDefinition(org.camunda.bpm.engine.repository.CaseDefinition) Test(org.junit.Test)

Example 32 with CaseDefinition

use of org.camunda.bpm.engine.repository.CaseDefinition in project camunda-bpm-platform by camunda.

the class CaseDefinitionResourceImpl method getCaseDefinitionDiagram.

@Override
public Response getCaseDefinitionDiagram() {
    CaseDefinition definition = engine.getRepositoryService().getCaseDefinition(caseDefinitionId);
    InputStream caseDiagram = engine.getRepositoryService().getCaseDiagram(caseDefinitionId);
    if (caseDiagram == null) {
        return Response.noContent().build();
    } else {
        String fileName = definition.getDiagramResourceName();
        return Response.ok(caseDiagram).header("Content-Disposition", "attachment; filename=" + fileName).type(ProcessDefinitionResourceImpl.getMediaTypeForFileSuffix(fileName)).build();
    }
}
Also used : InputStream(java.io.InputStream) CaseDefinition(org.camunda.bpm.engine.repository.CaseDefinition)

Example 33 with CaseDefinition

use of org.camunda.bpm.engine.repository.CaseDefinition in project camunda-bpm-platform by camunda.

the class CaseDefinitionRestServiceImpl method getCaseDefinitions.

@Override
public List<CaseDefinitionDto> getCaseDefinitions(UriInfo uriInfo, Integer firstResult, Integer maxResults) {
    CaseDefinitionQueryDto queryDto = new CaseDefinitionQueryDto(getObjectMapper(), uriInfo.getQueryParameters());
    List<CaseDefinitionDto> definitions = new ArrayList<CaseDefinitionDto>();
    ProcessEngine engine = getProcessEngine();
    CaseDefinitionQuery query = queryDto.toQuery(engine);
    List<CaseDefinition> matchingDefinitions = null;
    if (firstResult != null || maxResults != null) {
        matchingDefinitions = executePaginatedQuery(query, firstResult, maxResults);
    } else {
        matchingDefinitions = query.list();
    }
    for (CaseDefinition definition : matchingDefinitions) {
        CaseDefinitionDto def = CaseDefinitionDto.fromCaseDefinition(definition);
        definitions.add(def);
    }
    return definitions;
}
Also used : CaseDefinitionQueryDto(org.camunda.bpm.engine.rest.dto.repository.CaseDefinitionQueryDto) CaseDefinition(org.camunda.bpm.engine.repository.CaseDefinition) ArrayList(java.util.ArrayList) CaseDefinitionDto(org.camunda.bpm.engine.rest.dto.repository.CaseDefinitionDto) ProcessEngine(org.camunda.bpm.engine.ProcessEngine) CaseDefinitionQuery(org.camunda.bpm.engine.repository.CaseDefinitionQuery)

Example 34 with CaseDefinition

use of org.camunda.bpm.engine.repository.CaseDefinition in project camunda-bpm-platform by camunda.

the class ProcessApplicationManager method logCaseDefinitionRegistrations.

protected void logCaseDefinitionRegistrations(StringBuilder builder, List<CaseDefinition> caseDefinitions) {
    if (caseDefinitions.isEmpty()) {
        builder.append("Deployment does not provide any case definitions.");
    } else {
        builder.append("\n");
        builder.append("Will execute case definitions ");
        builder.append("\n");
        for (CaseDefinition caseDefinition : caseDefinitions) {
            builder.append("\n");
            builder.append("        ");
            builder.append(caseDefinition.getKey());
            builder.append("[version: ");
            builder.append(caseDefinition.getVersion());
            builder.append(", id: ");
            builder.append(caseDefinition.getId());
            builder.append("]");
        }
        builder.append("\n");
    }
}
Also used : CaseDefinition(org.camunda.bpm.engine.repository.CaseDefinition)

Example 35 with CaseDefinition

use of org.camunda.bpm.engine.repository.CaseDefinition in project camunda-bpm-platform by camunda.

the class TenantIdProviderTest method providerCalledWithCaseDefinition_SubCaseInstance.

@Test
public void providerCalledWithCaseDefinition_SubCaseInstance() {
    ContextLoggingTenantIdProvider tenantIdProvider = new ContextLoggingTenantIdProvider();
    TestTenantIdProvider.delegate = tenantIdProvider;
    testRule.deploy(CMMN_SUBPROCESS_FILE, CMMN_FILE);
    CaseDefinition deployedCaseDefinition = engineRule.getRepositoryService().createCaseDefinitionQuery().caseDefinitionKey("oneTaskCase").singleResult();
    // if a case instance is created
    engineRule.getCaseService().withCaseDefinitionByKey(CASE_DEFINITION_KEY).create();
    // then the tenant id provider is passed in the case definition
    CaseDefinition passedCaseDefinition = tenantIdProvider.caseParameters.get(1).getCaseDefinition();
    assertThat(passedCaseDefinition, is(notNullValue()));
    assertThat(passedCaseDefinition.getId(), is(deployedCaseDefinition.getId()));
}
Also used : CaseDefinition(org.camunda.bpm.engine.repository.CaseDefinition) Test(org.junit.Test)

Aggregations

CaseDefinition (org.camunda.bpm.engine.repository.CaseDefinition)65 Deployment (org.camunda.bpm.engine.test.Deployment)17 Test (org.junit.Test)14 CaseInstance (org.camunda.bpm.engine.runtime.CaseInstance)13 CaseDefinitionQuery (org.camunda.bpm.engine.repository.CaseDefinitionQuery)12 ArrayList (java.util.ArrayList)8 ProcessDefinition (org.camunda.bpm.engine.repository.ProcessDefinition)5 Response (com.jayway.restassured.response.Response)4 Date (java.util.Date)4 HistoricDecisionInstance (org.camunda.bpm.engine.history.HistoricDecisionInstance)4 BadUserRequestException (org.camunda.bpm.engine.BadUserRequestException)3 HistoricCaseInstance (org.camunda.bpm.engine.history.HistoricCaseInstance)3 CaseInstanceQuery (org.camunda.bpm.engine.runtime.CaseInstanceQuery)3 InputStream (java.io.InputStream)2 HashMap (java.util.HashMap)2 Map (java.util.Map)2 ProcessEngineException (org.camunda.bpm.engine.ProcessEngineException)2 RepositoryService (org.camunda.bpm.engine.RepositoryService)2 HistoricProcessInstance (org.camunda.bpm.engine.history.HistoricProcessInstance)2 User (org.camunda.bpm.engine.identity.User)2