Search in sources :

Example 1 with HistoricTaskInstance

use of org.activiti.engine.history.HistoricTaskInstance in project Activiti by Activiti.

the class HistoryServiceTest method testHistoricTaskInstanceQueryByDeploymentIdIn.

@Deployment(resources = { "org/activiti/engine/test/api/oneTaskProcess.bpmn20.xml", "org/activiti/engine/test/api/runtime/oneTaskProcess2.bpmn20.xml" })
public void testHistoricTaskInstanceQueryByDeploymentIdIn() {
    org.activiti.engine.repository.Deployment deployment = repositoryService.createDeploymentQuery().singleResult();
    HashSet<String> processInstanceIds = new HashSet<String>();
    for (int i = 0; i < 4; i++) {
        processInstanceIds.add(runtimeService.startProcessInstanceByKey("oneTaskProcess", i + "").getId());
    }
    processInstanceIds.add(runtimeService.startProcessInstanceByKey("oneTaskProcess2", "1").getId());
    List<String> deploymentIds = new ArrayList<String>();
    deploymentIds.add(deployment.getId());
    HistoricTaskInstanceQuery taskInstanceQuery = historyService.createHistoricTaskInstanceQuery().deploymentIdIn(deploymentIds);
    assertEquals(5, taskInstanceQuery.count());
    List<HistoricTaskInstance> taskInstances = taskInstanceQuery.list();
    assertNotNull(taskInstances);
    assertEquals(5, taskInstances.size());
    deploymentIds.add("invalid");
    taskInstanceQuery = historyService.createHistoricTaskInstanceQuery().deploymentIdIn(deploymentIds);
    assertEquals(5, taskInstanceQuery.count());
    deploymentIds = new ArrayList<String>();
    deploymentIds.add("invalid");
    taskInstanceQuery = historyService.createHistoricTaskInstanceQuery().deploymentIdIn(deploymentIds);
    assertEquals(0, taskInstanceQuery.count());
}
Also used : HistoricTaskInstance(org.activiti.engine.history.HistoricTaskInstance) ArrayList(java.util.ArrayList) HistoricTaskInstanceQuery(org.activiti.engine.history.HistoricTaskInstanceQuery) HashSet(java.util.HashSet) Deployment(org.activiti.engine.test.Deployment)

Example 2 with HistoricTaskInstance

use of org.activiti.engine.history.HistoricTaskInstance in project Activiti by Activiti.

the class ProcessInstanceLogQueryTest method testIncludeTasksandComments.

public void testIncludeTasksandComments() {
    ProcessInstanceHistoryLog log = historyService.createProcessInstanceHistoryLogQuery(processInstanceId).includeTasks().includeComments().singleResult();
    List<HistoricData> events = log.getHistoricData();
    assertEquals(5, events.size());
    for (int i = 0; i < 5; i++) {
        HistoricData event = events.get(i);
        if (i < 2) {
            // tasks are created before comments
            assertTrue(event instanceof HistoricTaskInstance);
        } else {
            assertTrue(event instanceof Comment);
        }
    }
}
Also used : Comment(org.activiti.engine.task.Comment) HistoricTaskInstance(org.activiti.engine.history.HistoricTaskInstance) HistoricData(org.activiti.engine.history.HistoricData) ProcessInstanceHistoryLog(org.activiti.engine.history.ProcessInstanceHistoryLog)

Example 3 with HistoricTaskInstance

use of org.activiti.engine.history.HistoricTaskInstance in project Activiti by Activiti.

the class HistoricTaskAndVariablesQueryTest method testQueryWithPagingAndVariables.

public void testQueryWithPagingAndVariables() {
    if (processEngineConfiguration.getHistoryLevel().isAtLeast(HistoryLevel.AUDIT)) {
        List<HistoricTaskInstance> tasks = historyService.createHistoricTaskInstanceQuery().includeProcessVariables().includeTaskLocalVariables().orderByTaskPriority().desc().listPage(0, 1);
        assertEquals(1, tasks.size());
        HistoricTaskInstance task = tasks.get(0);
        Map<String, Object> variableMap = task.getTaskLocalVariables();
        assertEquals(2, variableMap.size());
        assertEquals("someVariable", variableMap.get("testVar"));
        assertEquals(123, variableMap.get("testVar2"));
        tasks = historyService.createHistoricTaskInstanceQuery().includeProcessVariables().includeTaskLocalVariables().orderByTaskPriority().asc().listPage(1, 2);
        assertEquals(2, tasks.size());
        task = tasks.get(1);
        variableMap = task.getTaskLocalVariables();
        assertEquals(2, variableMap.size());
        assertEquals("someVariable", variableMap.get("testVar"));
        assertEquals(123, variableMap.get("testVar2"));
        tasks = historyService.createHistoricTaskInstanceQuery().includeProcessVariables().includeTaskLocalVariables().orderByTaskPriority().asc().listPage(2, 4);
        assertEquals(1, tasks.size());
        task = tasks.get(0);
        variableMap = task.getTaskLocalVariables();
        assertEquals(2, variableMap.size());
        assertEquals("someVariable", variableMap.get("testVar"));
        assertEquals(123, variableMap.get("testVar2"));
        tasks = historyService.createHistoricTaskInstanceQuery().includeProcessVariables().includeTaskLocalVariables().orderByTaskPriority().asc().listPage(4, 2);
        assertEquals(0, tasks.size());
    }
}
Also used : HistoricTaskInstance(org.activiti.engine.history.HistoricTaskInstance)

Example 4 with HistoricTaskInstance

use of org.activiti.engine.history.HistoricTaskInstance in project Activiti by Activiti.

the class HistoricTaskAndVariablesQueryTest method testQueryWithIncludeTaskVariableAndTaskCategory.

// Unit test for https://activiti.atlassian.net/browse/ACT-4152
public void testQueryWithIncludeTaskVariableAndTaskCategory() {
    List<HistoricTaskInstance> tasks = historyService.createHistoricTaskInstanceQuery().taskAssignee("gonzo").list();
    for (HistoricTaskInstance task : tasks) {
        assertNotNull(task.getCategory());
        assertEquals("testCategory", task.getCategory());
    }
    tasks = historyService.createHistoricTaskInstanceQuery().taskAssignee("gonzo").includeTaskLocalVariables().list();
    for (HistoricTaskInstance task : tasks) {
        assertNotNull(task.getCategory());
        assertEquals("testCategory", task.getCategory());
    }
    tasks = historyService.createHistoricTaskInstanceQuery().taskAssignee("gonzo").includeProcessVariables().list();
    for (HistoricTaskInstance task : tasks) {
        assertNotNull(task.getCategory());
        assertEquals("testCategory", task.getCategory());
    }
}
Also used : HistoricTaskInstance(org.activiti.engine.history.HistoricTaskInstance)

Example 5 with HistoricTaskInstance

use of org.activiti.engine.history.HistoricTaskInstance in project Activiti by Activiti.

the class HistoryServiceTest method testLocalizeTasks.

@Deployment(resources = { "org/activiti/engine/test/api/oneTaskProcess.bpmn20.xml" })
public void testLocalizeTasks() throws Exception {
    ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("oneTaskProcess");
    List<HistoricTaskInstance> tasks = historyService.createHistoricTaskInstanceQuery().processDefinitionId(processInstance.getProcessDefinitionId()).list();
    assertEquals(1, tasks.size());
    assertEquals("my task", tasks.get(0).getName());
    assertNull(tasks.get(0).getDescription());
    ObjectNode infoNode = dynamicBpmnService.changeLocalizationName("en-GB", "theTask", "My localized name");
    dynamicBpmnService.changeLocalizationDescription("en-GB".toString(), "theTask", "My localized description", infoNode);
    dynamicBpmnService.saveProcessDefinitionInfo(processInstance.getProcessDefinitionId(), infoNode);
    tasks = historyService.createHistoricTaskInstanceQuery().processDefinitionId(processInstance.getProcessDefinitionId()).list();
    assertEquals(1, tasks.size());
    assertEquals("my task", tasks.get(0).getName());
    assertNull(tasks.get(0).getDescription());
    tasks = historyService.createHistoricTaskInstanceQuery().processDefinitionId(processInstance.getProcessDefinitionId()).locale("en-GB").list();
    assertEquals(1, tasks.size());
    assertEquals("My localized name", tasks.get(0).getName());
    assertEquals("My localized description", tasks.get(0).getDescription());
    tasks = historyService.createHistoricTaskInstanceQuery().processDefinitionId(processInstance.getProcessDefinitionId()).listPage(0, 10);
    assertEquals(1, tasks.size());
    assertEquals("my task", tasks.get(0).getName());
    assertNull(tasks.get(0).getDescription());
    tasks = historyService.createHistoricTaskInstanceQuery().processDefinitionId(processInstance.getProcessDefinitionId()).locale("en-GB").listPage(0, 10);
    assertEquals(1, tasks.size());
    assertEquals("My localized name", tasks.get(0).getName());
    assertEquals("My localized description", tasks.get(0).getDescription());
    HistoricTaskInstance task = historyService.createHistoricTaskInstanceQuery().processDefinitionId(processInstance.getProcessDefinitionId()).singleResult();
    assertEquals("my task", task.getName());
    assertNull(task.getDescription());
    task = historyService.createHistoricTaskInstanceQuery().processDefinitionId(processInstance.getProcessDefinitionId()).locale("en-GB").singleResult();
    assertEquals("My localized name", task.getName());
    assertEquals("My localized description", task.getDescription());
    task = historyService.createHistoricTaskInstanceQuery().processDefinitionId(processInstance.getProcessDefinitionId()).singleResult();
    assertEquals("my task", task.getName());
    assertNull(task.getDescription());
}
Also used : HistoricTaskInstance(org.activiti.engine.history.HistoricTaskInstance) ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) HistoricProcessInstance(org.activiti.engine.history.HistoricProcessInstance) ProcessInstance(org.activiti.engine.runtime.ProcessInstance) Deployment(org.activiti.engine.test.Deployment)

Aggregations

HistoricTaskInstance (org.activiti.engine.history.HistoricTaskInstance)64 Task (org.activiti.engine.task.Task)27 Deployment (org.activiti.engine.test.Deployment)26 ProcessInstance (org.activiti.engine.runtime.ProcessInstance)16 HistoricProcessInstance (org.activiti.engine.history.HistoricProcessInstance)9 ArrayList (java.util.ArrayList)7 Date (java.util.Date)6 ActivitiObjectNotFoundException (org.activiti.engine.ActivitiObjectNotFoundException)6 HistoricActivityInstance (org.activiti.engine.history.HistoricActivityInstance)6 HistoricTaskInstanceQuery (org.activiti.engine.history.HistoricTaskInstanceQuery)6 HashMap (java.util.HashMap)5 HashSet (java.util.HashSet)5 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)5 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)4 Label (com.vaadin.ui.Label)4 SimpleDateFormat (java.text.SimpleDateFormat)4 Attachment (org.activiti.engine.task.Attachment)4 Button (com.vaadin.ui.Button)3 ClickEvent (com.vaadin.ui.Button.ClickEvent)3 ClickListener (com.vaadin.ui.Button.ClickListener)3