Search in sources :

Example 1 with IncidentQuery

use of org.camunda.bpm.engine.runtime.IncidentQuery in project camunda-bpm-platform by camunda.

the class IncidentRestServiceImpl method getIncidentsCount.

@Override
public CountResultDto getIncidentsCount(UriInfo uriInfo) {
    IncidentQueryDto queryDto = new IncidentQueryDto(getObjectMapper(), uriInfo.getQueryParameters());
    IncidentQuery query = queryDto.toQuery(processEngine);
    long count = query.count();
    CountResultDto result = new CountResultDto();
    result.setCount(count);
    return result;
}
Also used : IncidentQuery(org.camunda.bpm.engine.runtime.IncidentQuery) CountResultDto(org.camunda.bpm.engine.rest.dto.CountResultDto) IncidentQueryDto(org.camunda.bpm.engine.rest.dto.runtime.IncidentQueryDto)

Example 2 with IncidentQuery

use of org.camunda.bpm.engine.runtime.IncidentQuery in project camunda-bpm-platform by camunda.

the class IncidentRestServiceImpl method getIncidents.

@Override
public List<IncidentDto> getIncidents(UriInfo uriInfo, Integer firstResult, Integer maxResults) {
    IncidentQueryDto queryDto = new IncidentQueryDto(getObjectMapper(), uriInfo.getQueryParameters());
    IncidentQuery query = queryDto.toQuery(processEngine);
    List<Incident> queryResult;
    if (firstResult != null || maxResults != null) {
        queryResult = executePaginatedQuery(query, firstResult, maxResults);
    } else {
        queryResult = query.list();
    }
    List<IncidentDto> result = new ArrayList<IncidentDto>();
    for (Incident incident : queryResult) {
        IncidentDto dto = IncidentDto.fromIncident(incident);
        result.add(dto);
    }
    return result;
}
Also used : IncidentQuery(org.camunda.bpm.engine.runtime.IncidentQuery) ArrayList(java.util.ArrayList) IncidentDto(org.camunda.bpm.engine.rest.dto.runtime.IncidentDto) IncidentQueryDto(org.camunda.bpm.engine.rest.dto.runtime.IncidentQueryDto) Incident(org.camunda.bpm.engine.runtime.Incident)

Example 3 with IncidentQuery

use of org.camunda.bpm.engine.runtime.IncidentQuery in project camunda-bpm-platform by camunda.

the class IncidentRestServiceQueryTest method setupMockIncidentQuery.

private IncidentQuery setupMockIncidentQuery(List<Incident> incidents) {
    IncidentQuery sampleQuery = mock(IncidentQuery.class);
    when(sampleQuery.list()).thenReturn(incidents);
    when(sampleQuery.count()).thenReturn((long) incidents.size());
    when(processEngine.getRuntimeService().createIncidentQuery()).thenReturn(sampleQuery);
    return sampleQuery;
}
Also used : IncidentQuery(org.camunda.bpm.engine.runtime.IncidentQuery)

Example 4 with IncidentQuery

use of org.camunda.bpm.engine.runtime.IncidentQuery in project camunda-bpm-platform by camunda.

the class IncidentAuthorizationTest method testQueryWithReadInstancesPermissionOnAnyProcessDefinition.

public void testQueryWithReadInstancesPermissionOnAnyProcessDefinition() {
    // given
    startProcessAndExecuteJob(ONE_INCIDENT_PROCESS_KEY);
    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);
    startProcessAndExecuteJob(ANOTHER_ONE_INCIDENT_PROCESS_KEY);
    createGrantAuthorization(PROCESS_DEFINITION, ANY, userId, READ_INSTANCE);
    // when
    IncidentQuery query = runtimeService.createIncidentQuery();
    // then
    verifyQueryResults(query, 7);
}
Also used : IncidentQuery(org.camunda.bpm.engine.runtime.IncidentQuery)

Example 5 with IncidentQuery

use of org.camunda.bpm.engine.runtime.IncidentQuery in project camunda-bpm-platform by camunda.

the class IncidentAuthorizationTest method testSimpleQueryWithReadPermissionOnAnyProcessInstance.

public void testSimpleQueryWithReadPermissionOnAnyProcessInstance() {
    // given
    String processInstanceId = startProcessAndExecuteJob(ONE_INCIDENT_PROCESS_KEY).getId();
    createGrantAuthorization(PROCESS_INSTANCE, ANY, userId, READ);
    // when
    IncidentQuery query = runtimeService.createIncidentQuery();
    // then
    verifyQueryResults(query, 1);
    Incident incident = query.singleResult();
    assertNotNull(incident);
    assertEquals(processInstanceId, incident.getProcessInstanceId());
}
Also used : IncidentQuery(org.camunda.bpm.engine.runtime.IncidentQuery) HistoricIncident(org.camunda.bpm.engine.history.HistoricIncident) Incident(org.camunda.bpm.engine.runtime.Incident)

Aggregations

IncidentQuery (org.camunda.bpm.engine.runtime.IncidentQuery)55 Incident (org.camunda.bpm.engine.runtime.Incident)34 Test (org.junit.Test)21 HistoricIncident (org.camunda.bpm.engine.history.HistoricIncident)7 ProcessInstance (org.camunda.bpm.engine.runtime.ProcessInstance)3 Deployment (org.camunda.bpm.engine.test.Deployment)3 IncidentQueryDto (org.camunda.bpm.engine.rest.dto.runtime.IncidentQueryDto)2 ArrayList (java.util.ArrayList)1 Date (java.util.Date)1 ProcessEngineException (org.camunda.bpm.engine.ProcessEngineException)1 HistoricIncidentQuery (org.camunda.bpm.engine.history.HistoricIncidentQuery)1 RuntimeServiceImpl (org.camunda.bpm.engine.impl.RuntimeServiceImpl)1 JobDefinition (org.camunda.bpm.engine.management.JobDefinition)1 CountResultDto (org.camunda.bpm.engine.rest.dto.CountResultDto)1 IncidentDto (org.camunda.bpm.engine.rest.dto.runtime.IncidentDto)1 Execution (org.camunda.bpm.engine.runtime.Execution)1 Job (org.camunda.bpm.engine.runtime.Job)1