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 8596d5430a..59a4afe9bd 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
@@ -2,9 +2,9 @@
List Workflow Tasks
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.
+ The list of returned tasks also includes pooled tasks which the specified authority is eligible to claim.
- /api/task-instances?authority={authority?}&state={state?}&properties={properties?}&detailed={detailed?}
+ /api/task-instances?authority={authority?}&state={state?}&priority={priority?}&dueBefore={dueBefore?}&dueAfter={dueAfter?}&properties={properties?}&detailed={detailed?}
user
required
diff --git a/config/alfresco/templates/webscripts/org/alfresco/repository/workflow/workflow-instances.get.desc.xml b/config/alfresco/templates/webscripts/org/alfresco/repository/workflow/workflow-instances.get.desc.xml
index ac680c6ba3..e28bb7a0a8 100644
--- a/config/alfresco/templates/webscripts/org/alfresco/repository/workflow/workflow-instances.get.desc.xml
+++ b/config/alfresco/templates/webscripts/org/alfresco/repository/workflow/workflow-instances.get.desc.xml
@@ -1,8 +1,8 @@
Get Workflow Instance Collection
Retrieves all workflow instances, the returned list can be optionally filtered by the state of the workflow instance and by the authority that initiated the workflow instance.
- /api/workflow-instances?state={state?}&initiator={initiator?}&priority={priority?}
- /api/workflow-definitions/{workflow_definition_id}/workflow-instances?state={state?}&initiator={initiator?}&date={date?}&priority={priority?}
+ /api/workflow-instances?state={state?}&initiator={initiator?}&priority={priority?}&dueBefore={dueBefore?}&dueAfter={dueAfter?}&startedBefore={startedBefore?}&startedAfter={startedAfter?}&completedBefore={completedBefore?}&completedAfter={completedAfter?}
+ /api/workflow-definitions/{workflow_definition_id}/workflow-instances?state={state?}&initiator={initiator?}&priority={priority?}&dueBefore={dueBefore?}&dueAfter={dueAfter?}&startedBefore={startedBefore?}&startedAfter={startedAfter?}&completedBefore={completedBefore?}&completedAfter={completedAfter?}
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 a7ff117727..8bcda6a916 100644
--- a/source/java/org/alfresco/repo/web/scripts/workflow/TaskInstancesGet.java
+++ b/source/java/org/alfresco/repo/web/scripts/workflow/TaskInstancesGet.java
@@ -18,17 +18,21 @@
*/
package org.alfresco.repo.web.scripts.workflow;
+import java.io.Serializable;
import java.util.ArrayList;
import java.util.Arrays;
+import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletResponse;
-import org.alfresco.repo.security.authentication.AuthenticationUtil;
+import org.alfresco.repo.workflow.WorkflowModel;
import org.alfresco.service.cmr.workflow.WorkflowTask;
+import org.alfresco.service.cmr.workflow.WorkflowTaskQuery;
import org.alfresco.service.cmr.workflow.WorkflowTaskState;
+import org.springframework.extensions.surf.util.ISO8601DateFormat;
import org.springframework.extensions.webscripts.Cache;
import org.springframework.extensions.webscripts.Status;
import org.springframework.extensions.webscripts.WebScriptException;
@@ -41,38 +45,63 @@ import org.springframework.extensions.webscripts.WebScriptRequest;
public class TaskInstancesGet extends AbstractWorkflowWebscript
{
public static final String PARAM_AUTHORITY = "authority";
- public static final String PARAM_STATUS= "status";
- public static final String PARAM_PROPERTIES= "properties";
- public static final String PARAM_DETAILED= "detailed";
-
+ public static final String PARAM_STATE = "state";
+ public static final String PARAM_PRIORITY = "priority";
+ public static final String PARAM_DUE_BEFORE = "dueBefore";
+ public static final String PARAM_DUE_AFTER = "dueAfter";
+ public static final String PARAM_PROPERTIES = "properties";
+ public static final String PARAM_DETAILED = "detailed";
+
@Override
- protected Map buildModel(WorkflowModelBuilder modelBuilder, WebScriptRequest req, Status status,
- Cache cache)
+ protected Map buildModel(WorkflowModelBuilder modelBuilder, WebScriptRequest req, Status status, Cache cache)
{
+ Map filters = new HashMap(4);
+
+ // authority is not included into filters list as it will be taken into account before filtering
String authority = getAuthority(req);
+ // state is also not included into filters list, for the same reason
WorkflowTaskState state = getState(req);
+ filters.put(PARAM_PRIORITY, req.getParameter(PARAM_PRIORITY));
+ filters.put(PARAM_DUE_BEFORE, getDateParameter(req, PARAM_DUE_BEFORE));
+ filters.put(PARAM_DUE_AFTER, getDateParameter(req, PARAM_DUE_AFTER));
+
List properties = getProperties(req);
boolean detailed = "true".equals(req.getParameter(PARAM_DETAILED));
- //TODO Handle possible thrown exceptions here?
- List tasks = workflowService.getAssignedTasks(authority, state);
- List pooledTasks= workflowService.getPooledTasks(authority);
- ArrayList allTasks = new ArrayList(tasks.size() + pooledTasks.size());
- allTasks.addAll(tasks);
- allTasks.addAll(pooledTasks);
-
- ArrayList