Search in sources :

Example 1 with ActivityStatisticsQuery

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

the class ProcessDefinitionResourceImpl method getActivityStatistics.

@Override
public List<StatisticsResultDto> getActivityStatistics(Boolean includeFailedJobs, 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.");
    }
    ManagementService mgmtService = engine.getManagementService();
    ActivityStatisticsQuery query = mgmtService.createActivityStatisticsQuery(processDefinitionId);
    if (includeFailedJobs != null && includeFailedJobs) {
        query.includeFailedJobs();
    }
    if (includeIncidents != null && includeIncidents) {
        query.includeIncidents();
    } else if (includeIncidentsForType != null) {
        query.includeIncidentsForType(includeIncidentsForType);
    }
    List<ActivityStatistics> queryResults = query.list();
    List<StatisticsResultDto> results = new ArrayList<StatisticsResultDto>();
    for (ActivityStatistics queryResult : queryResults) {
        StatisticsResultDto dto = ActivityStatisticsResultDto.fromActivityStatistics(queryResult);
        results.add(dto);
    }
    return results;
}
Also used : ActivityStatistics(org.camunda.bpm.engine.management.ActivityStatistics) ManagementService(org.camunda.bpm.engine.ManagementService) ArrayList(java.util.ArrayList) ActivityStatisticsResultDto(org.camunda.bpm.engine.rest.dto.repository.ActivityStatisticsResultDto) StatisticsResultDto(org.camunda.bpm.engine.rest.dto.StatisticsResultDto) InvalidRequestException(org.camunda.bpm.engine.rest.exception.InvalidRequestException) ActivityStatisticsQuery(org.camunda.bpm.engine.management.ActivityStatisticsQuery)

Example 2 with ActivityStatisticsQuery

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

the class MultiTenancyStatisticsQueryTest method testQueryNoAuthenticatedTenantForActivityStatistics.

public void testQueryNoAuthenticatedTenantForActivityStatistics() {
    ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("SingleTaskProcess");
    identityService.setAuthentication("user", null);
    ActivityStatisticsQuery query = managementService.createActivityStatisticsQuery(processInstance.getProcessDefinitionId());
    assertThat(query.count(), is(0L));
}
Also used : ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) ActivityStatisticsQuery(org.camunda.bpm.engine.management.ActivityStatisticsQuery)

Example 3 with ActivityStatisticsQuery

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

the class MultiTenancyStatisticsQueryTest method testQueryDisabledTenantCheckForActivityStatistics.

public void testQueryDisabledTenantCheckForActivityStatistics() {
    ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("SingleTaskProcess");
    identityService.setAuthentication("user", null);
    processEngineConfiguration.setTenantCheckEnabled(false);
    ActivityStatisticsQuery query = managementService.createActivityStatisticsQuery(processInstance.getProcessDefinitionId());
    assertThat(query.count(), is(1L));
}
Also used : ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) ActivityStatisticsQuery(org.camunda.bpm.engine.management.ActivityStatisticsQuery)

Example 4 with ActivityStatisticsQuery

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

the class MultiTenancyStatisticsQueryTest method testQueryAuthenticatedTenantForActivityStatistics.

public void testQueryAuthenticatedTenantForActivityStatistics() {
    identityService.setAuthentication("user", null, Arrays.asList(TENANT_ONE));
    ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("SingleTaskProcess");
    ActivityStatisticsQuery query = managementService.createActivityStatisticsQuery(processInstance.getProcessDefinitionId());
    assertThat(query.count(), is(1L));
}
Also used : ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) ActivityStatisticsQuery(org.camunda.bpm.engine.management.ActivityStatisticsQuery)

Example 5 with ActivityStatisticsQuery

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

the class MultiTenancyStatisticsQueryTest method testActivityStatistics.

public void testActivityStatistics() {
    ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("SingleTaskProcess");
    ActivityStatisticsQuery query = managementService.createActivityStatisticsQuery(processInstance.getProcessDefinitionId());
    assertThat(query.count(), is(1L));
}
Also used : ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) ActivityStatisticsQuery(org.camunda.bpm.engine.management.ActivityStatisticsQuery)

Aggregations

ActivityStatisticsQuery (org.camunda.bpm.engine.management.ActivityStatisticsQuery)6 ProcessInstance (org.camunda.bpm.engine.runtime.ProcessInstance)4 ArrayList (java.util.ArrayList)1 ManagementService (org.camunda.bpm.engine.ManagementService)1 ActivityStatistics (org.camunda.bpm.engine.management.ActivityStatistics)1 StatisticsResultDto (org.camunda.bpm.engine.rest.dto.StatisticsResultDto)1 ActivityStatisticsResultDto (org.camunda.bpm.engine.rest.dto.repository.ActivityStatisticsResultDto)1 InvalidRequestException (org.camunda.bpm.engine.rest.exception.InvalidRequestException)1