Search in sources :

Example 31 with HistoricTaskInstance

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

the class TaskEventResource method getEvent.

@RequestMapping(value = "/runtime/tasks/{taskId}/events/{eventId}", method = RequestMethod.GET, produces = "application/json")
public EventResponse getEvent(@PathVariable("taskId") String taskId, @PathVariable("eventId") String eventId, HttpServletRequest request) {
    HistoricTaskInstance task = getHistoricTaskFromRequest(taskId);
    Event event = taskService.getEvent(eventId);
    if (event == null || !task.getId().equals(event.getTaskId())) {
        throw new ActivitiObjectNotFoundException("Task '" + task.getId() + "' doesn't have an event with id '" + eventId + "'.", Event.class);
    }
    return restResponseFactory.createEventResponse(event);
}
Also used : HistoricTaskInstance(org.activiti.engine.history.HistoricTaskInstance) Event(org.activiti.engine.task.Event) ActivitiObjectNotFoundException(org.activiti.engine.ActivitiObjectNotFoundException) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 32 with HistoricTaskInstance

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

the class TaskServiceTest method testDeleteTaskWithDeleteReason.

public void testDeleteTaskWithDeleteReason() {
    // ACT-900: deleteReason can be manually specified - can only be validated when historyLevel > ACTIVITY
    if (processEngineConfiguration.getHistoryLevel().isAtLeast(HistoryLevel.ACTIVITY)) {
        Task task = taskService.newTask();
        task.setName("test task");
        taskService.saveTask(task);
        assertNotNull(task.getId());
        taskService.deleteTask(task.getId(), "deleted for testing purposes");
        HistoricTaskInstance historicTaskInstance = historyService.createHistoricTaskInstanceQuery().taskId(task.getId()).singleResult();
        assertNotNull(historicTaskInstance);
        assertEquals("deleted for testing purposes", historicTaskInstance.getDeleteReason());
        // Delete historic task that is left behind, will not be cleaned up because this is not part of a process
        taskService.deleteTask(task.getId(), true);
    }
}
Also used : Task(org.activiti.engine.task.Task) HistoricTaskInstance(org.activiti.engine.history.HistoricTaskInstance)

Example 33 with HistoricTaskInstance

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

the class AdminCompletedInstancesPanel method addTasks.

protected void addTasks(HistoricProcessInstance processInstance) {
    if (tasksHeader != null) {
        mainPanel.removeComponent(tasksHeader);
        mainPanel.removeComponent(tasksEmptyHeader);
    }
    if (noTasksLabel != null) {
        mainPanel.removeComponent(noTasksLabel);
    }
    tasksHeader = new Label(i18nManager.getMessage(Messages.PROCESS_INSTANCE_HEADER_TASKS));
    tasksHeader.addStyleName(ExplorerLayout.STYLE_H3);
    tasksHeader.addStyleName(ExplorerLayout.STYLE_DETAIL_BLOCK);
    tasksHeader.addStyleName(ExplorerLayout.STYLE_NO_LINE);
    addDetailComponent(tasksHeader);
    tasksEmptyHeader = new Label(" ", Label.CONTENT_XHTML);
    addDetailComponent(tasksEmptyHeader);
    if (taskTable != null) {
        mainPanel.removeComponent(taskTable);
    }
    taskTable = new Table();
    taskTable.addStyleName(ExplorerLayout.STYLE_PROCESS_INSTANCE_TASK_LIST);
    taskTable.setWidth(100, UNITS_PERCENTAGE);
    taskTable.setHeight(250, UNITS_PIXELS);
    // 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, i18nManager.getMessage(Messages.ADMIN_FINISHED), 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);
        addDetailComponent(taskTable);
        for (HistoricTaskInstance task : tasks) {
            addTaskItem(task, taskTable);
        }
        taskTable.setPageLength(taskTable.size());
    } else {
        // No tasks
        noTasksLabel = new Label(i18nManager.getMessage(Messages.PROCESS_INSTANCE_NO_TASKS));
        addDetailComponent(noTasksLabel);
    }
}
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)

Example 34 with HistoricTaskInstance

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

the class AdminRunningInstancesPanel method addTasks.

protected void addTasks(HistoricProcessInstance processInstance) {
    if (tasksHeader != null) {
        mainPanel.removeComponent(tasksHeader);
        mainPanel.removeComponent(tasksEmptyHeader);
    }
    if (noTasksLabel != null) {
        mainPanel.removeComponent(noTasksLabel);
    }
    tasksHeader = new Label(i18nManager.getMessage(Messages.PROCESS_INSTANCE_HEADER_TASKS));
    tasksHeader.addStyleName(ExplorerLayout.STYLE_H3);
    tasksHeader.addStyleName(ExplorerLayout.STYLE_DETAIL_BLOCK);
    tasksHeader.addStyleName(ExplorerLayout.STYLE_NO_LINE);
    addDetailComponent(tasksHeader);
    tasksEmptyHeader = new Label("&nbsp;", Label.CONTENT_XHTML);
    addDetailComponent(tasksEmptyHeader);
    if (taskTable != null) {
        mainPanel.removeComponent(taskTable);
    }
    taskTable = new Table();
    taskTable.addStyleName(ExplorerLayout.STYLE_PROCESS_INSTANCE_TASK_LIST);
    taskTable.setWidth(100, UNITS_PERCENTAGE);
    taskTable.setHeight(250, UNITS_PIXELS);
    // Fetch all tasks
    List<HistoricTaskInstance> tasks = historyService.createHistoricTaskInstanceQuery().processInstanceId(processInstance.getId()).orderByHistoricTaskInstanceEndTime().desc().orderByTaskCreateTime().desc().list();
    if (!tasks.isEmpty()) {
        // Finished icon
        taskTable.addContainerProperty("finished", Component.class, null, i18nManager.getMessage(Messages.ADMIN_FINISHED), 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);
        addDetailComponent(taskTable);
        for (HistoricTaskInstance task : tasks) {
            addTaskItem(task, taskTable);
        }
        taskTable.setPageLength(taskTable.size());
    } else {
        // No tasks
        noTasksLabel = new Label(i18nManager.getMessage(Messages.PROCESS_INSTANCE_NO_TASKS));
        addDetailComponent(noTasksLabel);
    }
}
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)

Example 35 with HistoricTaskInstance

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

the class DelegateTaskTest method testChangeCategoryInDelegateTask.

@Deployment
public void testChangeCategoryInDelegateTask() {
    // Start process instance
    Map<String, Object> variables = new HashMap<String, Object>();
    //, "gonzo", "mispiggy"));
    variables.put("approvers", Arrays.asList("kermit"));
    ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("delegateTaskTest", variables);
    // Assert there are three tasks with the default category
    List<Task> tasks = taskService.createTaskQuery().processInstanceId(processInstance.getId()).list();
    for (Task task : tasks) {
        assertEquals("approval", task.getCategory());
        Map<String, Object> taskVariables = new HashMap<String, Object>();
        taskVariables.put("outcome", "approve");
        taskService.complete(task.getId(), taskVariables, true);
    }
    // After completion, the task category should be changed in the script listener working on the delegate task
    assertEquals(0, taskService.createTaskQuery().processInstanceId(processInstance.getId()).count());
    for (HistoricTaskInstance historicTaskInstance : historyService.createHistoricTaskInstanceQuery().list()) {
        assertEquals("approved", historicTaskInstance.getCategory());
    }
}
Also used : Task(org.activiti.engine.task.Task) HistoricTaskInstance(org.activiti.engine.history.HistoricTaskInstance) HashMap(java.util.HashMap) ProcessInstance(org.activiti.engine.runtime.ProcessInstance) 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