Search in sources :

Example 16 with HistoricTaskInstance

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

the class TaskAttachmentResource method getAttachment.

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

Example 17 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 18 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 19 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 20 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)

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