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);
}
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);
}
}
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);
}
}
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(" ", 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);
}
}
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());
}
}
Aggregations