Search in sources :

Example 6 with HistoricTaskInstance

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

the class HistoryServiceTest method testHistoricTaskInstanceOrQueryByDeploymentId.

@Deployment(resources = { "org/activiti/engine/test/api/oneTaskProcess.bpmn20.xml", "org/activiti/engine/test/api/runtime/oneTaskProcess2.bpmn20.xml" })
public void testHistoricTaskInstanceOrQueryByDeploymentId() {
    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());
    HistoricTaskInstanceQuery taskInstanceQuery = historyService.createHistoricTaskInstanceQuery().or().deploymentId(deployment.getId()).endOr();
    assertEquals(5, taskInstanceQuery.count());
    List<HistoricTaskInstance> taskInstances = taskInstanceQuery.list();
    assertNotNull(taskInstances);
    assertEquals(5, taskInstances.size());
    taskInstanceQuery = historyService.createHistoricTaskInstanceQuery().or().deploymentId("invalid").endOr();
    assertEquals(0, taskInstanceQuery.count());
    taskInstanceQuery = historyService.createHistoricTaskInstanceQuery().or().taskDefinitionKey("theTask").deploymentId("invalid").endOr();
    assertEquals(5, taskInstanceQuery.count());
    taskInstanceQuery = historyService.createHistoricTaskInstanceQuery().taskDefinitionKey("theTask").or().deploymentId("invalid").endOr();
    assertEquals(0, taskInstanceQuery.count());
    taskInstanceQuery = historyService.createHistoricTaskInstanceQuery().or().taskDefinitionKey("theTask").deploymentId("invalid").endOr().or().processDefinitionKey("oneTaskProcess").processDefinitionId("invalid").endOr();
    assertEquals(4, taskInstanceQuery.count());
    taskInstanceQuery = historyService.createHistoricTaskInstanceQuery().or().taskDefinitionKey("theTask").deploymentId("invalid").endOr().or().processDefinitionKey("oneTaskProcess2").processDefinitionId("invalid").endOr();
    assertEquals(1, taskInstanceQuery.count());
    taskInstanceQuery = historyService.createHistoricTaskInstanceQuery().or().taskDefinitionKey("theTask").deploymentId("invalid").endOr().or().processDefinitionKey("oneTaskProcess").processDefinitionId("invalid").endOr().processInstanceBusinessKey("1");
    assertEquals(1, taskInstanceQuery.count());
    taskInstanceQuery = historyService.createHistoricTaskInstanceQuery().or().taskDefinitionKey("theTask").deploymentId("invalid").endOr().or().processDefinitionKey("oneTaskProcess2").processDefinitionId("invalid").endOr().processInstanceBusinessKey("1");
    assertEquals(1, taskInstanceQuery.count());
    taskInstanceQuery = historyService.createHistoricTaskInstanceQuery().or().taskDefinitionKey("theTask").deploymentId("invalid").endOr().or().processDefinitionKey("oneTaskProcess2").processDefinitionId("invalid").endOr().processInstanceBusinessKey("2");
    assertEquals(0, taskInstanceQuery.count());
}
Also used : HistoricTaskInstance(org.activiti.engine.history.HistoricTaskInstance) HistoricTaskInstanceQuery(org.activiti.engine.history.HistoricTaskInstanceQuery) HashSet(java.util.HashSet) Deployment(org.activiti.engine.test.Deployment)

Example 7 with HistoricTaskInstance

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

the class MultiInstanceTest method testSequentialUserTasksHistory.

@Deployment(resources = { "org/activiti/engine/test/bpmn/multiinstance/MultiInstanceTest.sequentialUserTasks.bpmn20.xml" })
public void testSequentialUserTasksHistory() {
    runtimeService.startProcessInstanceByKey("miSequentialUserTasks", CollectionUtil.singletonMap("nrOfLoops", 4)).getId();
    for (int i = 0; i < 4; i++) {
        taskService.complete(taskService.createTaskQuery().singleResult().getId());
    }
    if (processEngineConfiguration.getHistoryLevel().isAtLeast(HistoryLevel.ACTIVITY)) {
        List<HistoricTaskInstance> historicTaskInstances = historyService.createHistoricTaskInstanceQuery().list();
        assertEquals(4, historicTaskInstances.size());
        for (HistoricTaskInstance ht : historicTaskInstances) {
            assertNotNull(ht.getAssignee());
            assertNotNull(ht.getStartTime());
            assertNotNull(ht.getEndTime());
        }
        List<HistoricActivityInstance> historicActivityInstances = historyService.createHistoricActivityInstanceQuery().activityType("userTask").list();
        assertEquals(4, historicActivityInstances.size());
        for (HistoricActivityInstance hai : historicActivityInstances) {
            assertNotNull(hai.getActivityId());
            assertNotNull(hai.getActivityName());
            assertNotNull(hai.getStartTime());
            assertNotNull(hai.getEndTime());
            assertNotNull(hai.getAssignee());
        }
    }
}
Also used : HistoricTaskInstance(org.activiti.engine.history.HistoricTaskInstance) HistoricActivityInstance(org.activiti.engine.history.HistoricActivityInstance) Deployment(org.activiti.engine.test.Deployment)

Example 8 with HistoricTaskInstance

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

the class ArchivedListQuery method loadItems.

public List<Item> loadItems(int start, int count) {
    List<HistoricTaskInstance> historicTaskInstances = createQuery().listPage(start, count);
    List<Item> items = new ArrayList<Item>();
    for (HistoricTaskInstance historicTaskInstance : historicTaskInstances) {
        items.add(new TaskListItem(historicTaskInstance));
    }
    return items;
}
Also used : Item(com.vaadin.data.Item) HistoricTaskInstance(org.activiti.engine.history.HistoricTaskInstance) ArrayList(java.util.ArrayList)

Example 9 with HistoricTaskInstance

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

the class SubTaskComponent method populateSubTasks.

protected void populateSubTasks(List<HistoricTaskInstance> subTasks) {
    if (!subTasks.isEmpty()) {
        for (final HistoricTaskInstance subTask : subTasks) {
            // icon
            Embedded icon = null;
            if (subTask.getEndTime() != null) {
                icon = new Embedded(null, Images.TASK_FINISHED_22);
            } else {
                icon = new Embedded(null, Images.TASK_22);
            }
            icon.setWidth(22, UNITS_PIXELS);
            icon.setWidth(22, UNITS_PIXELS);
            subTaskLayout.addComponent(icon);
            // Link to subtask
            Button subTaskLink = new Button(subTask.getName());
            subTaskLink.addStyleName(Reindeer.BUTTON_LINK);
            subTaskLink.addListener(new ClickListener() {

                public void buttonClick(ClickEvent event) {
                    ExplorerApp.get().getViewManager().showTaskPage(subTask.getId());
                }
            });
            subTaskLayout.addComponent(subTaskLink);
            subTaskLayout.setComponentAlignment(subTaskLink, Alignment.MIDDLE_LEFT);
            if (subTask.getEndTime() == null) {
                // Delete icon only appears when task is not finished yet
                Embedded deleteIcon = new Embedded(null, Images.DELETE);
                deleteIcon.addStyleName(ExplorerLayout.STYLE_CLICKABLE);
                deleteIcon.addListener(new DeleteSubTaskClickListener(subTask, this));
                subTaskLayout.addComponent(deleteIcon);
                subTaskLayout.setComponentAlignment(deleteIcon, Alignment.MIDDLE_RIGHT);
            } else {
                // Next line of grid
                subTaskLayout.newLine();
            }
        }
    } else {
        Label noSubTasksLabel = new Label(i18nManager.getMessage(Messages.TASK_NO_SUBTASKS));
        noSubTasksLabel.setSizeUndefined();
        noSubTasksLabel.addStyleName(Reindeer.LABEL_SMALL);
        subTaskLayout.addComponent(noSubTasksLabel);
    }
}
Also used : HistoricTaskInstance(org.activiti.engine.history.HistoricTaskInstance) Button(com.vaadin.ui.Button) ClickEvent(com.vaadin.ui.Button.ClickEvent) Label(com.vaadin.ui.Label) DeleteSubTaskClickListener(org.activiti.explorer.ui.task.listener.DeleteSubTaskClickListener) Embedded(com.vaadin.ui.Embedded) ClickListener(com.vaadin.ui.Button.ClickListener) DeleteSubTaskClickListener(org.activiti.explorer.ui.task.listener.DeleteSubTaskClickListener)

Example 10 with HistoricTaskInstance

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

the class ProcessInstanceDetailPanel method addTasks.

protected void addTasks() {
    Label header = new Label(i18nManager.getMessage(Messages.PROCESS_INSTANCE_HEADER_TASKS));
    header.addStyleName(ExplorerLayout.STYLE_H3);
    header.addStyleName(ExplorerLayout.STYLE_DETAIL_BLOCK);
    header.addStyleName(ExplorerLayout.STYLE_NO_LINE);
    panelLayout.addComponent(header);
    panelLayout.addComponent(new Label("&nbsp;", Label.CONTENT_XHTML));
    Table taskTable = new Table();
    taskTable.addStyleName(ExplorerLayout.STYLE_PROCESS_INSTANCE_TASK_LIST);
    taskTable.setWidth(100, UNITS_PERCENTAGE);
    // Fetch all tasks
    List<HistoricTaskInstance> tasks = historyService.createHistoricTaskInstanceQuery().processInstanceId(processInstance.getId()).orderByHistoricTaskInstanceEndTime().desc().orderByHistoricTaskInstanceStartTime().desc().list();
    if (!tasks.isEmpty()) {
        // Finished icon
        taskTable.addContainerProperty("finished", Component.class, null, "", null, Table.ALIGN_CENTER);
        taskTable.setColumnWidth("finished", 22);
        taskTable.addContainerProperty("name", String.class, null, i18nManager.getMessage(Messages.TASK_NAME), null, Table.ALIGN_LEFT);
        taskTable.addContainerProperty("priority", Integer.class, null, i18nManager.getMessage(Messages.TASK_PRIORITY), null, Table.ALIGN_LEFT);
        taskTable.addContainerProperty("assignee", Component.class, null, i18nManager.getMessage(Messages.TASK_ASSIGNEE), null, Table.ALIGN_LEFT);
        taskTable.addContainerProperty("dueDate", Component.class, null, i18nManager.getMessage(Messages.TASK_DUEDATE), null, Table.ALIGN_LEFT);
        taskTable.addContainerProperty("startDate", Component.class, null, i18nManager.getMessage(Messages.TASK_CREATE_TIME), null, Table.ALIGN_LEFT);
        taskTable.addContainerProperty("endDate", Component.class, null, i18nManager.getMessage(Messages.TASK_COMPLETE_TIME), null, Table.ALIGN_LEFT);
        panelLayout.addComponent(taskTable);
        panelLayout.setExpandRatio(taskTable, 1.0f);
        for (HistoricTaskInstance task : tasks) {
            addTaskItem(task, taskTable);
        }
        taskTable.setPageLength(taskTable.size());
    } else {
        // No tasks
        Label noTaskLabel = new Label(i18nManager.getMessage(Messages.PROCESS_INSTANCE_NO_TASKS));
        panelLayout.addComponent(noTaskLabel);
    }
}
Also used : Table(com.vaadin.ui.Table) HistoricTaskInstance(org.activiti.engine.history.HistoricTaskInstance) Label(com.vaadin.ui.Label) PrettyTimeLabel(org.activiti.explorer.ui.custom.PrettyTimeLabel)

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