Search in sources :

Example 1 with ProcessDefinitionStatisticsQuery

use of org.camunda.bpm.engine.management.ProcessDefinitionStatisticsQuery in project camunda-bpm-platform by camunda.

the class MultiTenancyStatisticsQueryTest method testQueryNoAuthenticatedTenantsForProcessDefinitionStatistics.

public void testQueryNoAuthenticatedTenantsForProcessDefinitionStatistics() {
    identityService.setAuthentication("user", null, null);
    ProcessDefinitionStatisticsQuery query = managementService.createProcessDefinitionStatisticsQuery();
    assertThat(query.count(), is(1L));
    Set<String> tenantIds = collectDefinitionTenantIds(query.list());
    assertThat(tenantIds.size(), is(1));
    assertThat(tenantIds.iterator().next(), is(nullValue()));
}
Also used : ProcessDefinitionStatisticsQuery(org.camunda.bpm.engine.management.ProcessDefinitionStatisticsQuery)

Example 2 with ProcessDefinitionStatisticsQuery

use of org.camunda.bpm.engine.management.ProcessDefinitionStatisticsQuery in project camunda-bpm-platform by camunda.

the class MultiTenancyStatisticsQueryTest method testQueryAuthenticatedTenantsForProcessDefinitionStatistics.

public void testQueryAuthenticatedTenantsForProcessDefinitionStatistics() {
    identityService.setAuthentication("user", null, Arrays.asList(TENANT_ONE, TENANT_TWO));
    ProcessDefinitionStatisticsQuery query = managementService.createProcessDefinitionStatisticsQuery();
    assertThat(query.count(), is(3L));
    Set<String> tenantIds = collectDefinitionTenantIds(query.list());
    assertThat(tenantIds.size(), is(3));
    assertThat(tenantIds, hasItems(null, TENANT_ONE, TENANT_TWO));
}
Also used : ProcessDefinitionStatisticsQuery(org.camunda.bpm.engine.management.ProcessDefinitionStatisticsQuery)

Example 3 with ProcessDefinitionStatisticsQuery

use of org.camunda.bpm.engine.management.ProcessDefinitionStatisticsQuery in project camunda-bpm-platform by camunda.

the class ProcessDefinitionStatisticsAuthorizationTest method testQueryWithMultiple.

public void testQueryWithMultiple() {
    // given
    createGrantAuthorization(PROCESS_DEFINITION, ONE_TASK_PROCESS_KEY, userId, READ);
    createGrantAuthorization(PROCESS_DEFINITION, ANY, userId, READ);
    // when
    ProcessDefinitionStatisticsQuery query = managementService.createProcessDefinitionStatisticsQuery();
    // then
    verifyQueryResults(query, 2);
}
Also used : ProcessDefinitionStatisticsQuery(org.camunda.bpm.engine.management.ProcessDefinitionStatisticsQuery)

Example 4 with ProcessDefinitionStatisticsQuery

use of org.camunda.bpm.engine.management.ProcessDefinitionStatisticsQuery in project camunda-bpm-platform by camunda.

the class ProcessDefinitionStatisticsAuthorizationTest method testQueryWithReadPermissionOnOneTaskProcess.

public void testQueryWithReadPermissionOnOneTaskProcess() {
    // given
    createGrantAuthorization(PROCESS_DEFINITION, ONE_TASK_PROCESS_KEY, userId, READ);
    // when
    ProcessDefinitionStatisticsQuery query = managementService.createProcessDefinitionStatisticsQuery();
    // then
    verifyQueryResults(query, 1);
    ProcessDefinitionStatistics statistics = query.singleResult();
    assertEquals(ONE_TASK_PROCESS_KEY, statistics.getKey());
    assertEquals(0, statistics.getInstances());
    assertEquals(0, statistics.getFailedJobs());
    assertTrue(statistics.getIncidentStatistics().isEmpty());
}
Also used : ProcessDefinitionStatistics(org.camunda.bpm.engine.management.ProcessDefinitionStatistics) ProcessDefinitionStatisticsQuery(org.camunda.bpm.engine.management.ProcessDefinitionStatisticsQuery)

Example 5 with ProcessDefinitionStatisticsQuery

use of org.camunda.bpm.engine.management.ProcessDefinitionStatisticsQuery in project camunda-bpm-platform by camunda.

the class ProcessDefinitionRestServiceImpl method getStatistics.

@Override
public List<StatisticsResultDto> getStatistics(Boolean includeFailedJobs, Boolean includeRootIncidents, Boolean includeIncidents, String includeIncidentsForType) {
    if (includeIncidents != null && includeIncidentsForType != null) {
        throw new InvalidRequestException(Status.BAD_REQUEST, "Only one of the query parameter includeIncidents or includeIncidentsForType can be set.");
    }
    if (includeIncidents != null && includeRootIncidents != null) {
        throw new InvalidRequestException(Status.BAD_REQUEST, "Only one of the query parameter includeIncidents or includeRootIncidents can be set.");
    }
    if (includeRootIncidents != null && includeIncidentsForType != null) {
        throw new InvalidRequestException(Status.BAD_REQUEST, "Only one of the query parameter includeRootIncidents or includeIncidentsForType can be set.");
    }
    ManagementService mgmtService = getProcessEngine().getManagementService();
    ProcessDefinitionStatisticsQuery query = mgmtService.createProcessDefinitionStatisticsQuery();
    if (includeFailedJobs != null && includeFailedJobs) {
        query.includeFailedJobs();
    }
    if (includeIncidents != null && includeIncidents) {
        query.includeIncidents();
    } else if (includeIncidentsForType != null) {
        query.includeIncidentsForType(includeIncidentsForType);
    } else if (includeRootIncidents != null && includeRootIncidents) {
        query.includeRootIncidents();
    }
    List<ProcessDefinitionStatistics> queryResults = query.list();
    List<StatisticsResultDto> results = new ArrayList<StatisticsResultDto>();
    for (ProcessDefinitionStatistics queryResult : queryResults) {
        StatisticsResultDto dto = ProcessDefinitionStatisticsResultDto.fromProcessDefinitionStatistics(queryResult);
        results.add(dto);
    }
    return results;
}
Also used : ProcessDefinitionStatistics(org.camunda.bpm.engine.management.ProcessDefinitionStatistics) ManagementService(org.camunda.bpm.engine.ManagementService) ArrayList(java.util.ArrayList) StatisticsResultDto(org.camunda.bpm.engine.rest.dto.StatisticsResultDto) ProcessDefinitionStatisticsResultDto(org.camunda.bpm.engine.rest.dto.repository.ProcessDefinitionStatisticsResultDto) InvalidRequestException(org.camunda.bpm.engine.rest.exception.InvalidRequestException) ProcessDefinitionStatisticsQuery(org.camunda.bpm.engine.management.ProcessDefinitionStatisticsQuery)

Aggregations

ProcessDefinitionStatisticsQuery (org.camunda.bpm.engine.management.ProcessDefinitionStatisticsQuery)9 ProcessDefinitionStatistics (org.camunda.bpm.engine.management.ProcessDefinitionStatistics)3 ArrayList (java.util.ArrayList)1 ManagementService (org.camunda.bpm.engine.ManagementService)1 StatisticsResultDto (org.camunda.bpm.engine.rest.dto.StatisticsResultDto)1 ProcessDefinitionStatisticsResultDto (org.camunda.bpm.engine.rest.dto.repository.ProcessDefinitionStatisticsResultDto)1 InvalidRequestException (org.camunda.bpm.engine.rest.exception.InvalidRequestException)1