ALF-393: Added "detailed" parameter to task-instances webscript and made Share use "initiator" to decide if an "edit" button/icon shall be displayed

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@21537 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Erik Winlof
2010-08-02 12:03:56 +00:00
parent c7ba8fea8a
commit 04de456146
3 changed files with 12 additions and 5 deletions

View File

@@ -4,7 +4,7 @@
Lists all Workflow Task Instances associated with an authority and of a given State. 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.
</description> </description>
<url>/api/task-instances?authority={authority?}&amp;state={state?}&amp;properties={properties?}</url> <url>/api/task-instances?authority={authority?}&amp;state={state?}&amp;properties={properties?}&amp;detailed={detailed?}</url>
<format default="json"/> <format default="json"/>
<authentication>user</authentication> <authentication>user</authentication>
<transaction allow="readonly">required</transaction> <transaction allow="readonly">required</transaction>

View File

@@ -1,11 +1,11 @@
<#-- List Workflow Task Instances --> <#-- List Workflow Task Instances -->
<#assign detailed=((args.detailed!"false")=="true")>
<#import "task.lib.ftl" as taskLib /> <#import "task.lib.ftl" as taskLib />
{ {
"data": "data":
[ [
<#list taskInstances as task> <#list taskInstances as task>
<@taskLib.taskJSON task=task /> <@taskLib.taskJSON task=task detailed=detailed/>
<#if task_has_next>,</#if> <#if task_has_next>,</#if>
</#list> </#list>
] ]

View File

@@ -43,6 +43,7 @@ public class TaskInstancesGet extends AbstractWorkflowWebscript
public static final String PARAM_AUTHORITY = "authority"; public static final String PARAM_AUTHORITY = "authority";
public static final String PARAM_STATUS= "status"; public static final String PARAM_STATUS= "status";
public static final String PARAM_PROPERTIES= "properties"; public static final String PARAM_PROPERTIES= "properties";
public static final String PARAM_DETAILED= "detailed";
@Override @Override
protected Map<String, Object> buildModel(WorkflowModelBuilder modelBuilder, WebScriptRequest req, Status status, protected Map<String, Object> buildModel(WorkflowModelBuilder modelBuilder, WebScriptRequest req, Status status,
@@ -51,6 +52,7 @@ public class TaskInstancesGet extends AbstractWorkflowWebscript
String authority = getAuthority(req); String authority = getAuthority(req);
WorkflowTaskState state = getState(req); WorkflowTaskState state = getState(req);
List<String> properties = getProperties(req); List<String> properties = getProperties(req);
boolean detailed = "true".equals(req.getParameter(PARAM_DETAILED));
//TODO Handle possible thrown exceptions here? //TODO Handle possible thrown exceptions here?
List<WorkflowTask> tasks = workflowService.getAssignedTasks(authority, state); List<WorkflowTask> tasks = workflowService.getAssignedTasks(authority, state);
@@ -62,10 +64,15 @@ public class TaskInstancesGet extends AbstractWorkflowWebscript
ArrayList<Map<String, Object>> results = new ArrayList<Map<String, Object>>(); ArrayList<Map<String, Object>> results = new ArrayList<Map<String, Object>>();
for (WorkflowTask task : allTasks) for (WorkflowTask task : allTasks)
{ {
results.add(modelBuilder.buildSimple(task, properties)); if (detailed)
{
results.add(modelBuilder.buildDetailed(task));
}
else {
results.add(modelBuilder.buildSimple(task, properties));
}
} }
Map<String, Object> model = new HashMap<String, Object>(); Map<String, Object> model = new HashMap<String, Object>();
model.put("taskInstances", results); model.put("taskInstances", results);
return model; return model;