Search in sources :

Example 26 with CaseDefinitionQuery

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

the class CaseDefinitionRestServiceImpl method getCaseDefinitionsCount.

@Override
public CountResultDto getCaseDefinitionsCount(UriInfo uriInfo) {
    CaseDefinitionQueryDto queryDto = new CaseDefinitionQueryDto(getObjectMapper(), uriInfo.getQueryParameters());
    ProcessEngine engine = getProcessEngine();
    CaseDefinitionQuery query = queryDto.toQuery(engine);
    long count = query.count();
    CountResultDto result = new CountResultDto();
    result.setCount(count);
    return result;
}
Also used : CaseDefinitionQueryDto(org.camunda.bpm.engine.rest.dto.repository.CaseDefinitionQueryDto) CountResultDto(org.camunda.bpm.engine.rest.dto.CountResultDto) ProcessEngine(org.camunda.bpm.engine.ProcessEngine) CaseDefinitionQuery(org.camunda.bpm.engine.repository.CaseDefinitionQuery)

Example 27 with CaseDefinitionQuery

use of org.camunda.bpm.engine.repository.CaseDefinitionQuery 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 28 with CaseDefinitionQuery

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

the class MultiTenancyCaseDefinitionQueryTest method testQueryAuthenticatedTenant.

public void testQueryAuthenticatedTenant() {
    identityService.setAuthentication("user", null, Arrays.asList(TENANT_ONE));
    CaseDefinitionQuery query = repositoryService.createCaseDefinitionQuery();
    assertThat(query.count(), is(2L));
    assertThat(query.tenantIdIn(TENANT_ONE).count(), is(1L));
    assertThat(query.tenantIdIn(TENANT_TWO).count(), is(0L));
    assertThat(query.tenantIdIn(TENANT_ONE, TENANT_TWO).includeCaseDefinitionsWithoutTenantId().count(), is(2L));
}
Also used : CaseDefinitionQuery(org.camunda.bpm.engine.repository.CaseDefinitionQuery)

Example 29 with CaseDefinitionQuery

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

the class MultiTenancyCaseDefinitionQueryTest method testQueryNoTenantIdSet.

public void testQueryNoTenantIdSet() {
    CaseDefinitionQuery query = repositoryService.createCaseDefinitionQuery();
    assertThat(query.count(), is(3L));
}
Also used : CaseDefinitionQuery(org.camunda.bpm.engine.repository.CaseDefinitionQuery)

Example 30 with CaseDefinitionQuery

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

the class MultiTenancyCaseDefinitionQueryTest method testQueryByLatestWithoutTenantId.

public void testQueryByLatestWithoutTenantId() {
    // deploy a second version without tenant id
    deployment(CMMN);
    CaseDefinitionQuery query = repositoryService.createCaseDefinitionQuery().caseDefinitionKey(CASE_DEFINITION_KEY).latestVersion().withoutTenantId();
    assertThat(query.count(), is(1L));
    CaseDefinition cDefinition = query.singleResult();
    assertThat(cDefinition.getTenantId(), is(nullValue()));
    assertThat(cDefinition.getVersion(), is(2));
}
Also used : CaseDefinition(org.camunda.bpm.engine.repository.CaseDefinition) CaseDefinitionQuery(org.camunda.bpm.engine.repository.CaseDefinitionQuery)

Aggregations

CaseDefinitionQuery (org.camunda.bpm.engine.repository.CaseDefinitionQuery)47 CaseDefinition (org.camunda.bpm.engine.repository.CaseDefinition)12 NotValidException (org.camunda.bpm.engine.exception.NotValidException)10 Response (com.jayway.restassured.response.Response)2 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 Map (java.util.Map)2 ProcessEngine (org.camunda.bpm.engine.ProcessEngine)2 User (org.camunda.bpm.engine.identity.User)2 UserQuery (org.camunda.bpm.engine.identity.UserQuery)2 ProcessDefinition (org.camunda.bpm.engine.repository.ProcessDefinition)2 ProcessDefinitionQuery (org.camunda.bpm.engine.repository.ProcessDefinitionQuery)2 CaseDefinitionQueryDto (org.camunda.bpm.engine.rest.dto.repository.CaseDefinitionQueryDto)2 Deployment (org.camunda.bpm.engine.test.Deployment)2 Test (org.junit.Test)2 Matchers.anyString (org.mockito.Matchers.anyString)2 InputStream (java.io.InputStream)1 LinkedHashMap (java.util.LinkedHashMap)1 ProcessApplicationService (org.camunda.bpm.ProcessApplicationService)1 ProcessApplicationInfo (org.camunda.bpm.application.ProcessApplicationInfo)1