Search in sources :

Example 26 with HistoricTaskInstanceQuery

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;
}
Also used : HistoricTaskInstanceDto(org.camunda.bpm.engine.rest.dto.history.HistoricTaskInstanceDto) HistoricTaskInstance(org.camunda.bpm.engine.history.HistoricTaskInstance) ArrayList(java.util.ArrayList) HistoricTaskInstanceQuery(org.camunda.bpm.engine.history.HistoricTaskInstanceQuery)

Example 27 with HistoricTaskInstanceQuery

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;
}
Also used : CountResultDto(org.camunda.bpm.engine.rest.dto.CountResultDto) HistoricTaskInstanceQuery(org.camunda.bpm.engine.history.HistoricTaskInstanceQuery)

Example 28 with HistoricTaskInstanceQuery

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());
}
Also used : ProcessInstanceQuery(org.camunda.bpm.engine.runtime.ProcessInstanceQuery) HistoricTaskInstance(org.camunda.bpm.engine.history.HistoricTaskInstance) ActivityInstance(org.camunda.bpm.engine.runtime.ActivityInstance) MigrationPlan(org.camunda.bpm.engine.migration.MigrationPlan) ProcessDefinition(org.camunda.bpm.engine.repository.ProcessDefinition) ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) HistoricTaskInstanceQuery(org.camunda.bpm.engine.history.HistoricTaskInstanceQuery) Test(org.junit.Test) RequiredHistoryLevel(org.camunda.bpm.engine.test.RequiredHistoryLevel)

Example 29 with HistoricTaskInstanceQuery

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);
}
Also used : Task(org.camunda.bpm.engine.task.Task) HistoricTaskInstanceQuery(org.camunda.bpm.engine.history.HistoricTaskInstanceQuery) Deployment(org.camunda.bpm.engine.test.Deployment) RequiredHistoryLevel(org.camunda.bpm.engine.test.RequiredHistoryLevel)

Example 30 with HistoricTaskInstanceQuery

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);
}
Also used : HistoricTaskInstanceQuery(org.camunda.bpm.engine.history.HistoricTaskInstanceQuery)

Aggregations

HistoricTaskInstanceQuery (org.camunda.bpm.engine.history.HistoricTaskInstanceQuery)55 Deployment (org.camunda.bpm.engine.test.Deployment)16 HistoricTaskInstance (org.camunda.bpm.engine.history.HistoricTaskInstance)9 ProcessInstance (org.camunda.bpm.engine.runtime.ProcessInstance)5 Test (org.junit.Test)4 HistoricProcessInstance (org.camunda.bpm.engine.history.HistoricProcessInstance)3 Task (org.camunda.bpm.engine.task.Task)3 ScenarioUnderTest (org.camunda.bpm.qa.upgrade.ScenarioUnderTest)3 ProcessEngineException (org.camunda.bpm.engine.ProcessEngineException)2 RequiredHistoryLevel (org.camunda.bpm.engine.test.RequiredHistoryLevel)2 ArrayList (java.util.ArrayList)1 NotValidException (org.camunda.bpm.engine.exception.NotValidException)1 MigrationPlan (org.camunda.bpm.engine.migration.MigrationPlan)1 CaseDefinition (org.camunda.bpm.engine.repository.CaseDefinition)1 ProcessDefinition (org.camunda.bpm.engine.repository.ProcessDefinition)1 CountResultDto (org.camunda.bpm.engine.rest.dto.CountResultDto)1 HistoricTaskInstanceDto (org.camunda.bpm.engine.rest.dto.history.HistoricTaskInstanceDto)1 ActivityInstance (org.camunda.bpm.engine.runtime.ActivityInstance)1 Job (org.camunda.bpm.engine.runtime.Job)1 ProcessInstanceQuery (org.camunda.bpm.engine.runtime.ProcessInstanceQuery)1