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