diff --git a/userguide/src/en/chapters/ch17-Advanced.xml b/userguide/src/en/chapters/ch17-Advanced.xml index 67c5b6a787b7a50ca4da573eacd075ea059888cb..b3951507b91ec243fa30d0635b0383a1828cf0e3 100644 --- a/userguide/src/en/chapters/ch17-Advanced.xml +++ b/userguide/src/en/chapters/ch17-Advanced.xml @@ -441,6 +441,44 @@ INFO org.activiti.engine.impl.cfg.ProcessEngineConfigurationImpl - class org.a +
+ + Advanced query API: seamless switching between runtime and historic task querying + + + One core component of any BPM user interface is the task list. Typically, end users work on open, runtime tasks, filtering + their inbox with various setting. Often also the historic tasks need to be displayed in those lists, with similar filtering. + To make that code-wise easier, the TaskQuery and HistoricTaskInstanceQuery both have a shared parent interface, + which contains all common operations (and most of the operations are common). + + + + This common interface is the org.activiti.engine.task.TaskInfoQuery class. + Both org.activiti.engine.task.Task and org.activiti.engine.task.HistoricTaskInstance + have a common superclass org.activiti.engine.task.TaskInfo (with common properties) which is returned from eg. the list() method. + However, Java generics are sometimes more harming than helping: if you want to use the TaskInfoQuery type directly, it would look like this: + +TaskInfoQuery<? extends TaskInfoQuery<?,?>, ? extends TaskInfo> taskInfoQuery + Ugh, Right. To 'solve' this, a org.activiti.engine.task.TaskInfoQueryWrapper class that can be used to avoid the generics + (the following code could come from REST code that returns a task list where the user cn switch between open and completed tasks): + +TaskInfoQueryWrapper taskInfoQueryWrapper = null; +if (runtimeQuery) { + taskInfoQueryWrapper = new TaskInfoQueryWrapper(taskService.createTaskQuery()); +} else { + taskInfoQueryWrapper = new TaskInfoQueryWrapper(historyService.createHistoricTaskInstanceQuery()); +} + +List<? extends TaskInfo> taskInfos = taskInfoQueryWrapper.getTaskInfoQuery().or() + .taskNameLike("%k1%") + .taskDueAfter(new Date(now.getTime() + (3 * 24L * 60L * 60L * 1000L))) +.endOr() +.list(); + + + +
+
Enable safe BPMN 2.0 xml