Search in sources :

Example 31 with HistoricIncidentQuery

use of org.camunda.bpm.engine.history.HistoricIncidentQuery in project camunda-bpm-platform by camunda.

the class HistoricIncidentRestServiceImpl method getHistoricIncidentsCount.

@Override
public CountResultDto getHistoricIncidentsCount(UriInfo uriInfo) {
    HistoricIncidentQueryDto queryDto = new HistoricIncidentQueryDto(objectMapper, uriInfo.getQueryParameters());
    HistoricIncidentQuery query = queryDto.toQuery(processEngine);
    long count = query.count();
    CountResultDto result = new CountResultDto();
    result.setCount(count);
    return result;
}
Also used : CountResultDto(org.camunda.bpm.engine.rest.dto.CountResultDto) HistoricIncidentQueryDto(org.camunda.bpm.engine.rest.dto.history.HistoricIncidentQueryDto) HistoricIncidentQuery(org.camunda.bpm.engine.history.HistoricIncidentQuery)

Example 32 with HistoricIncidentQuery

use of org.camunda.bpm.engine.history.HistoricIncidentQuery in project camunda-bpm-platform by camunda.

the class HistoricIncidentRestServiceImpl method getHistoricIncidents.

@Override
public List<HistoricIncidentDto> getHistoricIncidents(UriInfo uriInfo, Integer firstResult, Integer maxResults) {
    HistoricIncidentQueryDto queryDto = new HistoricIncidentQueryDto(objectMapper, uriInfo.getQueryParameters());
    HistoricIncidentQuery query = queryDto.toQuery(processEngine);
    List<HistoricIncident> queryResult;
    if (firstResult != null || maxResults != null) {
        queryResult = executePaginatedQuery(query, firstResult, maxResults);
    } else {
        queryResult = query.list();
    }
    List<HistoricIncidentDto> result = new ArrayList<HistoricIncidentDto>();
    for (HistoricIncident historicIncident : queryResult) {
        HistoricIncidentDto dto = HistoricIncidentDto.fromHistoricIncident(historicIncident);
        result.add(dto);
    }
    return result;
}
Also used : HistoricIncident(org.camunda.bpm.engine.history.HistoricIncident) HistoricIncidentQueryDto(org.camunda.bpm.engine.rest.dto.history.HistoricIncidentQueryDto) ArrayList(java.util.ArrayList) HistoricIncidentDto(org.camunda.bpm.engine.rest.dto.history.HistoricIncidentDto) HistoricIncidentQuery(org.camunda.bpm.engine.history.HistoricIncidentQuery)

Example 33 with HistoricIncidentQuery

use of org.camunda.bpm.engine.history.HistoricIncidentQuery in project camunda-bpm-platform by camunda.

the class HistoricIncidentAuthorizationTest method testStartTimerJobIncidentQueryWithReadInstancePermissionOnAnyProcessDefinition.

public void testStartTimerJobIncidentQueryWithReadInstancePermissionOnAnyProcessDefinition() {
    // given
    disableAuthorization();
    String jobId = managementService.createJobQuery().singleResult().getId();
    managementService.setJobRetries(jobId, 0);
    enableAuthorization();
    createGrantAuthorization(PROCESS_DEFINITION, ANY, userId, READ_HISTORY);
    // when
    HistoricIncidentQuery query = historyService.createHistoricIncidentQuery();
    // then
    verifyQueryResults(query, 1);
}
Also used : HistoricIncidentQuery(org.camunda.bpm.engine.history.HistoricIncidentQuery)

Example 34 with HistoricIncidentQuery

use of org.camunda.bpm.engine.history.HistoricIncidentQuery in project camunda-bpm-platform by camunda.

the class HistoricIncidentAuthorizationTest method testSimpleQueryWithMultiple.

public void testSimpleQueryWithMultiple() {
    // given
    startProcessAndExecuteJob(ONE_INCIDENT_PROCESS_KEY);
    createGrantAuthorization(PROCESS_DEFINITION, ONE_INCIDENT_PROCESS_KEY, userId, READ_HISTORY);
    createGrantAuthorization(PROCESS_DEFINITION, ANY, userId, READ_HISTORY);
    // when
    HistoricIncidentQuery query = historyService.createHistoricIncidentQuery();
    // then
    verifyQueryResults(query, 1);
}
Also used : HistoricIncidentQuery(org.camunda.bpm.engine.history.HistoricIncidentQuery)

Example 35 with HistoricIncidentQuery

use of org.camunda.bpm.engine.history.HistoricIncidentQuery in project camunda-bpm-platform by camunda.

the class HistoricIncidentAuthorizationTest method testQueryWithReadHistoryPermissionOnAnyProcessDefinition.

public void testQueryWithReadHistoryPermissionOnAnyProcessDefinition() {
    // given
    startProcessAndExecuteJob(ONE_INCIDENT_PROCESS_KEY);
    startProcessAndExecuteJob(ONE_INCIDENT_PROCESS_KEY);
    startProcessAndExecuteJob(ANOTHER_ONE_INCIDENT_PROCESS_KEY);
    startProcessAndExecuteJob(ANOTHER_ONE_INCIDENT_PROCESS_KEY);
    startProcessAndExecuteJob(ANOTHER_ONE_INCIDENT_PROCESS_KEY);
    createGrantAuthorization(PROCESS_DEFINITION, ANY, userId, READ_HISTORY);
    // when
    HistoricIncidentQuery query = historyService.createHistoricIncidentQuery();
    // then
    verifyQueryResults(query, 5);
}
Also used : HistoricIncidentQuery(org.camunda.bpm.engine.history.HistoricIncidentQuery)

Aggregations

HistoricIncidentQuery (org.camunda.bpm.engine.history.HistoricIncidentQuery)61 Test (org.junit.Test)29 Deployment (org.camunda.bpm.engine.test.Deployment)20 ProcessEngineException (org.camunda.bpm.engine.ProcessEngineException)13 ProcessInstance (org.camunda.bpm.engine.runtime.ProcessInstance)7 HistoricIncident (org.camunda.bpm.engine.history.HistoricIncident)6 Date (java.util.Date)4 Job (org.camunda.bpm.engine.runtime.Job)4 JobDefinition (org.camunda.bpm.engine.management.JobDefinition)2 HistoricIncidentQueryDto (org.camunda.bpm.engine.rest.dto.history.HistoricIncidentQueryDto)2 Incident (org.camunda.bpm.engine.runtime.Incident)2 ArrayList (java.util.ArrayList)1 CountResultDto (org.camunda.bpm.engine.rest.dto.CountResultDto)1 HistoricIncidentDto (org.camunda.bpm.engine.rest.dto.history.HistoricIncidentDto)1