use of org.camunda.bpm.engine.history.HistoricTaskInstanceQuery in project camunda-bpm-platform by camunda.
the class HistoricTaskInstanceRestServiceImpl method queryHistoricTaskInstances.
@Override
public List<HistoricTaskInstanceDto> queryHistoricTaskInstances(HistoricTaskInstanceQueryDto queryDto, Integer firstResult, Integer maxResults) {
queryDto.setObjectMapper(objectMapper);
HistoricTaskInstanceQuery query = queryDto.toQuery(processEngine);
List<HistoricTaskInstance> match;
if (firstResult != null || maxResults != null) {
match = executePaginatedQuery(query, firstResult, maxResults);
} else {
match = query.list();
}
List<HistoricTaskInstanceDto> result = new ArrayList<HistoricTaskInstanceDto>();
for (HistoricTaskInstance taskInstance : match) {
HistoricTaskInstanceDto taskInstanceDto = HistoricTaskInstanceDto.fromHistoricTaskInstance(taskInstance);
result.add(taskInstanceDto);
}
return result;
}
use of org.camunda.bpm.engine.history.HistoricTaskInstanceQuery in project camunda-bpm-platform by camunda.
the class HistoricTaskInstanceRestServiceImpl method queryHistoricTaskInstancesCount.
@Override
public CountResultDto queryHistoricTaskInstancesCount(HistoricTaskInstanceQueryDto queryDto) {
queryDto.setObjectMapper(objectMapper);
HistoricTaskInstanceQuery query = queryDto.toQuery(processEngine);
long count = query.count();
CountResultDto result = new CountResultDto();
result.setCount(count);
return result;
}
use of org.camunda.bpm.engine.history.HistoricTaskInstanceQuery in project camunda-bpm-platform by camunda.
the class MigrationHistoricTaskInstanceTest method testMigrateHistoryUserTaskInstance.
@Test
@RequiredHistoryLevel(ProcessEngineConfiguration.HISTORY_ACTIVITY)
public void testMigrateHistoryUserTaskInstance() {
// given
ProcessDefinition sourceProcessDefinition = testHelper.deployAndGetDefinition(ProcessModels.ONE_TASK_PROCESS);
ProcessDefinition targetProcessDefinition = testHelper.deployAndGetDefinition(modify(ProcessModels.ONE_TASK_PROCESS).changeElementId("Process", "Process2").changeElementId("userTask", "userTask2"));
MigrationPlan migrationPlan = runtimeService.createMigrationPlan(sourceProcessDefinition.getId(), targetProcessDefinition.getId()).mapActivities("userTask", "userTask2").build();
ProcessInstance processInstance = runtimeService.startProcessInstanceById(sourceProcessDefinition.getId());
HistoricTaskInstanceQuery sourceHistoryTaskInstanceQuery = historyService.createHistoricTaskInstanceQuery().processDefinitionId(sourceProcessDefinition.getId());
HistoricTaskInstanceQuery targetHistoryTaskInstanceQuery = historyService.createHistoricTaskInstanceQuery().processDefinitionId(targetProcessDefinition.getId());
ActivityInstance activityInstance = runtimeService.getActivityInstance(processInstance.getId());
// when
assertEquals(1, sourceHistoryTaskInstanceQuery.count());
assertEquals(0, targetHistoryTaskInstanceQuery.count());
ProcessInstanceQuery sourceProcessInstanceQuery = runtimeService.createProcessInstanceQuery().processDefinitionId(sourceProcessDefinition.getId());
runtimeService.newMigration(migrationPlan).processInstanceQuery(sourceProcessInstanceQuery).execute();
// then
assertEquals(0, sourceHistoryTaskInstanceQuery.count());
assertEquals(1, targetHistoryTaskInstanceQuery.count());
HistoricTaskInstance instance = targetHistoryTaskInstanceQuery.singleResult();
assertEquals(targetProcessDefinition.getKey(), instance.getProcessDefinitionKey());
assertEquals(targetProcessDefinition.getId(), instance.getProcessDefinitionId());
assertEquals("userTask2", instance.getTaskDefinitionKey());
assertEquals(activityInstance.getActivityInstances("userTask")[0].getId(), instance.getActivityInstanceId());
}
use of org.camunda.bpm.engine.history.HistoricTaskInstanceQuery in project camunda-bpm-platform by camunda.
the class HistoricTaskInstanceQueryTest method testGroupTaskQuery.
@RequiredHistoryLevel(ProcessEngineConfiguration.HISTORY_FULL)
@Deployment(resources = { "org/camunda/bpm/engine/test/api/runtime/oneTaskProcess.bpmn20.xml" })
public void testGroupTaskQuery() {
// given
runtimeService.startProcessInstanceByKey("oneTaskProcess");
String taskId = taskService.createTaskQuery().singleResult().getId();
// if
identityService.setAuthenticatedUserId("aAssignerId");
taskService.addCandidateUser(taskId, "aUserId");
taskService.addCandidateGroup(taskId, "aGroupId");
taskService.addCandidateGroup(taskId, "bGroupId");
Task taskOne = taskService.newTask("taskOne");
taskOne.setAssignee("aUserId");
taskService.saveTask(taskOne);
Task taskTwo = taskService.newTask("taskTwo");
taskTwo.setAssignee("aUserId");
taskService.saveTask(taskTwo);
Task taskThree = taskService.newTask("taskThree");
taskThree.setOwner("aUserId");
taskService.saveTask(taskThree);
taskService.deleteCandidateGroup(taskId, "aGroupId");
taskService.deleteCandidateGroup(taskId, "bGroupId");
historyService.createHistoricTaskInstanceQuery();
// Query test
HistoricTaskInstanceQuery query = historyService.createHistoricTaskInstanceQuery();
assertEquals(4, query.taskInvolvedUser("aUserId").count());
query = historyService.createHistoricTaskInstanceQuery();
assertEquals(1, query.taskHadCandidateUser("aUserId").count());
query = historyService.createHistoricTaskInstanceQuery();
assertEquals(1, query.taskHadCandidateGroup("aGroupId").count());
assertEquals(1, query.taskHadCandidateGroup("bGroupId").count());
assertEquals(0, query.taskInvolvedUser("aUserId").count());
query = historyService.createHistoricTaskInstanceQuery();
assertEquals(4, query.taskInvolvedUser("aUserId").count());
assertEquals(1, query.taskHadCandidateUser("aUserId").count());
assertEquals(1, query.taskInvolvedUser("aUserId").count());
// delete task
taskService.deleteTask("taskOne", true);
taskService.deleteTask("taskTwo", true);
taskService.deleteTask("taskThree", true);
}
use of org.camunda.bpm.engine.history.HistoricTaskInstanceQuery in project camunda-bpm-platform by camunda.
the class HistoricTaskInstanceAuthorizationTest method testSimpleQueryWithReadHistoryPermissionOnAnyProcessDefinition.
public void testSimpleQueryWithReadHistoryPermissionOnAnyProcessDefinition() {
// given
startProcessInstanceByKey(PROCESS_KEY);
createGrantAuthorization(PROCESS_DEFINITION, ANY, userId, READ_HISTORY);
// when
HistoricTaskInstanceQuery query = historyService.createHistoricTaskInstanceQuery();
// then
verifyQueryResults(query, 1);
}
Aggregations