diff --git a/config/alfresco/templates/webscripts/org/alfresco/repository/workflow/task-instances.get.desc.xml b/config/alfresco/templates/webscripts/org/alfresco/repository/workflow/task-instances.get.desc.xml
index 9466fd51e7..82b7ddd462 100644
--- a/config/alfresco/templates/webscripts/org/alfresco/repository/workflow/task-instances.get.desc.xml
+++ b/config/alfresco/templates/webscripts/org/alfresco/repository/workflow/task-instances.get.desc.xml
@@ -4,7 +4,8 @@
Lists all Workflow Task Instances associated with an authority and of a given State.
The list of returned tasks also includes pooled tasks which the specified authority is eligible to claim.
- /api/task-instances?authority={authority?}&state={state?}&priority={priority?}&pooledTasks={pooledTasks?}&dueBefore={dueBefore?}&dueAfter={dueAfter?}&properties={properties?}&detailed={detailed?}&maxItems={maxItems?}&skipCount={skipCount?}&exclude={exclude?}
+ /api/task-instances?authority={authority?}&state={state?}&priority={priority?}&pooledTasks={pooledTasks?}&dueBefore={dueBefore?}&dueAfter={dueAfter?}&properties={properties?}&maxItems={maxItems?}&skipCount={skipCount?}&exclude={exclude?}
+ /api/workflow-instances/{workflow_instance_id}/task-instances?authority={authority?}&state={state?}&priority={priority?}&dueBefore={isoDate?}&dueAfter={isoDate?}&properties={prop1, prop2, prop3...?}&maxItems={maxItems?}&skipCount={skipCount?}&exclude={exclude?}
user
required
diff --git a/source/java/org/alfresco/repo/web/scripts/workflow/TaskInstancesGet.java b/source/java/org/alfresco/repo/web/scripts/workflow/TaskInstancesGet.java
index 766e8c72b9..d0a541026d 100644
--- a/source/java/org/alfresco/repo/web/scripts/workflow/TaskInstancesGet.java
+++ b/source/java/org/alfresco/repo/web/scripts/workflow/TaskInstancesGet.java
@@ -51,11 +51,12 @@ public class TaskInstancesGet extends AbstractWorkflowWebscript
public static final String PARAM_DUE_AFTER = "dueAfter";
public static final String PARAM_PROPERTIES = "properties";
public static final String PARAM_POOLED_TASKS = "pooledTasks";
- public static final String PARAM_DETAILED = "detailed";
+ public static final String VAR_WORKFLOW_INSTANCE_ID = "workflow_instance_id";
@Override
protected Map buildModel(WorkflowModelBuilder modelBuilder, WebScriptRequest req, Status status, Cache cache)
{
+ Map params = req.getServiceMatch().getTemplateVars();
Map filters = new HashMap(4);
// authority is not included into filters list as it will be taken into account before filtering
@@ -64,9 +65,14 @@ public class TaskInstancesGet extends AbstractWorkflowWebscript
// state is also not included into filters list, for the same reason
WorkflowTaskState state = getState(req);
+ // look for a workflow instance id
+ String workflowInstanceId = params.get(VAR_WORKFLOW_INSTANCE_ID);
+
+ // determine if pooledTasks should be included, when appropriate i.e. when an authority is supplied
Boolean pooledTasksOnly = getPooledTasks(req);
+
+ // get list of properties to include in the response
List properties = getProperties(req);
- boolean detailed = "true".equals(req.getParameter(PARAM_DETAILED));
// get filter param values
filters.put(PARAM_PRIORITY, req.getParameter(PARAM_PRIORITY));
@@ -81,56 +87,74 @@ public class TaskInstancesGet extends AbstractWorkflowWebscript
List allTasks;
- if (authority != null)
+ if (workflowInstanceId != null)
{
- List tasks = workflowService.getAssignedTasks(authority, state);
- List pooledTasks = workflowService.getPooledTasks(authority);
- if (pooledTasksOnly != null)
+ // a workflow instance id was provided so query for tasks
+ WorkflowTaskQuery taskQuery = new WorkflowTaskQuery();
+ taskQuery.setActive(null);
+ taskQuery.setProcessId(workflowInstanceId);
+ taskQuery.setTaskState(state);
+
+ if (authority != null)
{
- if (pooledTasksOnly.booleanValue())
+ taskQuery.setActorId(authority);
+ }
+
+ allTasks = workflowService.queryTasks(taskQuery);
+ }
+ else
+ {
+ // default task state to IN_PROGRESS if not supplied
+ if (state == null)
+ {
+ state = WorkflowTaskState.IN_PROGRESS;
+ }
+
+ // no workflow instance id is present so get all tasks
+ if (authority != null)
+ {
+ List tasks = workflowService.getAssignedTasks(authority, state);
+ List pooledTasks = workflowService.getPooledTasks(authority);
+ if (pooledTasksOnly != null)
{
- // only return pooled tasks the user can claim
- allTasks = new ArrayList(pooledTasks.size());
- allTasks.addAll(pooledTasks);
+ if (pooledTasksOnly.booleanValue())
+ {
+ // only return pooled tasks the user can claim
+ allTasks = new ArrayList(pooledTasks.size());
+ allTasks.addAll(pooledTasks);
+ }
+ else
+ {
+ // only return tasks assigned to the user
+ allTasks = new ArrayList(tasks.size());
+ allTasks.addAll(tasks);
+ }
}
else
{
- // only return tasks assigned to the user
- allTasks = new ArrayList(tasks.size());
+ // include both assigned and unassigned tasks
+ allTasks = new ArrayList(tasks.size() + pooledTasks.size());
allTasks.addAll(tasks);
+ allTasks.addAll(pooledTasks);
}
}
else
{
- // include both assigned and unassigned tasks
- allTasks = new ArrayList(tasks.size() + pooledTasks.size());
- allTasks.addAll(tasks);
- allTasks.addAll(pooledTasks);
+ // authority was not provided -> return all active tasks in the system
+ WorkflowTaskQuery taskQuery = new WorkflowTaskQuery();
+ taskQuery.setTaskState(state);
+ taskQuery.setActive(null);
+ allTasks = workflowService.queryTasks(taskQuery);
}
}
- else
- {
- // authority was not provided -> return all active tasks in the system
- WorkflowTaskQuery taskQuery = new WorkflowTaskQuery();
- taskQuery.setTaskState(state);
- taskQuery.setActive(null);
- allTasks = workflowService.queryTasks(taskQuery);
- }
-
+
// filter results
ArrayList