Search in sources :

Example 41 with HistoricTaskInstance

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

the class ArchivedPage method createDetailComponent.

@Override
protected Component createDetailComponent(String id) {
    HistoryService historyService = ProcessEngines.getDefaultProcessEngine().getHistoryService();
    HistoricTaskInstance historicTaskInstance = historyService.createHistoricTaskInstanceQuery().taskId(id).singleResult();
    taskEventPanel.setTaskId(historicTaskInstance.getId());
    return new HistoricTaskDetailPanel(historicTaskInstance, this);
}
Also used : HistoricTaskInstance(org.activiti.engine.history.HistoricTaskInstance) HistoryService(org.activiti.engine.HistoryService)

Example 42 with HistoricTaskInstance

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

the class HistoricTaskDetailPanel method initSubTasks.

protected void initSubTasks() {
    subTasksLayout = new VerticalLayout();
    subTasksLayout.addStyleName(ExplorerLayout.STYLE_DETAIL_BLOCK);
    addComponent(subTasksLayout);
    initSubTaskTitle();
    List<HistoricTaskInstance> subTasks = historyService.createHistoricTaskInstanceQuery().taskParentTaskId(historicTask.getId()).list();
    if (!subTasks.isEmpty()) {
        initSubTaskGrid();
        populateSubTasks(subTasks);
    } else {
        initNoSubTasksLabel();
    }
}
Also used : HistoricTaskInstance(org.activiti.engine.history.HistoricTaskInstance) VerticalLayout(com.vaadin.ui.VerticalLayout)

Example 43 with HistoricTaskInstance

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

the class UserTaskTest method testTaskCategory.

@Deployment
public void testTaskCategory() {
    runtimeService.startProcessInstanceByKey("testTaskCategory");
    Task task = taskService.createTaskQuery().singleResult();
    // Test if the property set in the model is shown in the task
    String testCategory = "My Category";
    assertEquals(testCategory, task.getCategory());
    // Test if can be queried by query API
    assertEquals("Task with category", taskService.createTaskQuery().taskCategory(testCategory).singleResult().getName());
    assertTrue(taskService.createTaskQuery().taskCategory("Does not exist").count() == 0);
    if (processEngineConfiguration.getHistoryLevel().isAtLeast(HistoryLevel.AUDIT)) {
        // Check historic task
        HistoricTaskInstance historicTaskInstance = historyService.createHistoricTaskInstanceQuery().taskId(task.getId()).singleResult();
        assertEquals(testCategory, historicTaskInstance.getCategory());
        assertEquals("Task with category", historyService.createHistoricTaskInstanceQuery().taskCategory(testCategory).singleResult().getName());
        assertTrue(historyService.createHistoricTaskInstanceQuery().taskCategory("Does not exist").count() == 0);
        // Update category
        String newCategory = "New Test Category";
        task.setCategory(newCategory);
        taskService.saveTask(task);
        task = taskService.createTaskQuery().singleResult();
        assertEquals(newCategory, task.getCategory());
        assertEquals("Task with category", taskService.createTaskQuery().taskCategory(newCategory).singleResult().getName());
        assertTrue(taskService.createTaskQuery().taskCategory(testCategory).count() == 0);
        // Complete task and verify history
        taskService.complete(task.getId());
        historicTaskInstance = historyService.createHistoricTaskInstanceQuery().taskId(task.getId()).singleResult();
        assertEquals(newCategory, historicTaskInstance.getCategory());
        assertEquals("Task with category", historyService.createHistoricTaskInstanceQuery().taskCategory(newCategory).singleResult().getName());
        assertTrue(historyService.createHistoricTaskInstanceQuery().taskCategory(testCategory).count() == 0);
    }
}
Also used : Task(org.activiti.engine.task.Task) HistoricTaskInstance(org.activiti.engine.history.HistoricTaskInstance) Deployment(org.activiti.engine.test.Deployment)

Example 44 with HistoricTaskInstance

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

the class SubProcessTest method testSimpleSubProcessWithTimer.

@Deployment
public void testSimpleSubProcessWithTimer() {
    Date startTime = new Date();
    // After staring the process, the task in the subprocess should be active
    ProcessInstance pi = runtimeService.startProcessInstanceByKey("simpleSubProcess");
    Task subProcessTask = taskService.createTaskQuery().processInstanceId(pi.getId()).singleResult();
    assertEquals("Task in subprocess", subProcessTask.getName());
    // Setting the clock forward 2 hours 1 second (timer fires in 2 hours) and fire up the job executor 
    processEngineConfiguration.getClock().setCurrentTime(new Date(startTime.getTime() + (2 * 60 * 60 * 1000) + 1000));
    waitForJobExecutorToProcessAllJobs(5000L, 50L);
    // The subprocess should be left, and the escalated task should be active
    Task escalationTask = taskService.createTaskQuery().processInstanceId(pi.getId()).singleResult();
    assertEquals("Fix escalated problem", escalationTask.getName());
    if (processEngineConfiguration.getHistoryLevel().isAtLeast(HistoryLevel.AUDIT)) {
        // Verify history for task that was killed
        HistoricTaskInstance historicTaskInstance = historyService.createHistoricTaskInstanceQuery().taskName("Task in subprocess").singleResult();
        assertNotNull(historicTaskInstance.getEndTime());
        HistoricActivityInstance historicActivityInstance = historyService.createHistoricActivityInstanceQuery().activityId("subProcessTask").singleResult();
        assertNotNull(historicActivityInstance.getEndTime());
    }
}
Also used : Task(org.activiti.engine.task.Task) HistoricTaskInstance(org.activiti.engine.history.HistoricTaskInstance) ProcessInstance(org.activiti.engine.runtime.ProcessInstance) Date(java.util.Date) HistoricActivityInstance(org.activiti.engine.history.HistoricActivityInstance) Deployment(org.activiti.engine.test.Deployment)

Example 45 with HistoricTaskInstance

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

the class MultiInstanceTest method testParallelCallActivityHistory.

@Deployment(resources = { "org/activiti/engine/test/bpmn/multiinstance/MultiInstanceTest.testParallelCallActivity.bpmn20.xml", "org/activiti/engine/test/bpmn/multiinstance/MultiInstanceTest.externalSubProcess.bpmn20.xml" })
public void testParallelCallActivityHistory() {
    runtimeService.startProcessInstanceByKey("miParallelCallActivity");
    List<Task> tasks = taskService.createTaskQuery().list();
    assertEquals(12, tasks.size());
    for (int i = 0; i < tasks.size(); i++) {
        taskService.complete(tasks.get(i).getId());
    }
    if (processEngineConfiguration.getHistoryLevel().isAtLeast(HistoryLevel.ACTIVITY)) {
        // Validate historic processes
        List<HistoricProcessInstance> historicProcessInstances = historyService.createHistoricProcessInstanceQuery().list();
        // 6 subprocesses + main process
        assertEquals(7, historicProcessInstances.size());
        for (HistoricProcessInstance hpi : historicProcessInstances) {
            assertNotNull(hpi.getStartTime());
            assertNotNull(hpi.getEndTime());
        }
        // Validate historic tasks
        List<HistoricTaskInstance> historicTaskInstances = historyService.createHistoricTaskInstanceQuery().list();
        assertEquals(12, historicTaskInstances.size());
        for (HistoricTaskInstance hti : historicTaskInstances) {
            assertNotNull(hti.getStartTime());
            assertNotNull(hti.getEndTime());
            assertNotNull(hti.getAssignee());
            assertEquals("completed", hti.getDeleteReason());
        }
        // Validate historic activities
        List<HistoricActivityInstance> historicActivityInstances = historyService.createHistoricActivityInstanceQuery().activityType("callActivity").list();
        assertEquals(6, historicActivityInstances.size());
        for (HistoricActivityInstance hai : historicActivityInstances) {
            assertNotNull(hai.getStartTime());
            assertNotNull(hai.getEndTime());
        }
    }
}
Also used : Task(org.activiti.engine.task.Task) DelegateTask(org.activiti.engine.delegate.DelegateTask) HistoricTaskInstance(org.activiti.engine.history.HistoricTaskInstance) HistoricProcessInstance(org.activiti.engine.history.HistoricProcessInstance) HistoricActivityInstance(org.activiti.engine.history.HistoricActivityInstance) Deployment(org.activiti.engine.test.Deployment)

Aggregations

HistoricTaskInstance (org.activiti.engine.history.HistoricTaskInstance)65 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)8 HistoricTaskInstanceQuery (org.activiti.engine.history.HistoricTaskInstanceQuery)7 Date (java.util.Date)6 ActivitiObjectNotFoundException (org.activiti.engine.ActivitiObjectNotFoundException)6 HistoricActivityInstance (org.activiti.engine.history.HistoricActivityInstance)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