Search in sources :

Example 1 with StatisticsResultDto

use of org.camunda.bpm.engine.rest.dto.StatisticsResultDto 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 StatisticsResultDto

use of org.camunda.bpm.engine.rest.dto.StatisticsResultDto 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

ArrayList (java.util.ArrayList)2 ManagementService (org.camunda.bpm.engine.ManagementService)2 StatisticsResultDto (org.camunda.bpm.engine.rest.dto.StatisticsResultDto)2 InvalidRequestException (org.camunda.bpm.engine.rest.exception.InvalidRequestException)2 ActivityStatistics (org.camunda.bpm.engine.management.ActivityStatistics)1 ActivityStatisticsQuery (org.camunda.bpm.engine.management.ActivityStatisticsQuery)1 ProcessDefinitionStatistics (org.camunda.bpm.engine.management.ProcessDefinitionStatistics)1 ProcessDefinitionStatisticsQuery (org.camunda.bpm.engine.management.ProcessDefinitionStatisticsQuery)1 ActivityStatisticsResultDto (org.camunda.bpm.engine.rest.dto.repository.ActivityStatisticsResultDto)1 ProcessDefinitionStatisticsResultDto (org.camunda.bpm.engine.rest.dto.repository.ProcessDefinitionStatisticsResultDto)1