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;
}
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;
}
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;
}
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);
}
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());
}
Aggregations