mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-14 17:58:59 +00:00
Tidy up of task-instance related REST APIs (path and workflowInstance are now part of simple task response).
Also removed detailed=true parameter from my tasks dashlet so it gets smaller JSON response, everything it needs is now in the simple task response payload. git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@21573 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -11,6 +11,7 @@
|
||||
"description": "${task.description}",
|
||||
"state": "${task.state}",
|
||||
"typeDefinitionTitle": "${task.typeDefinitionTitle}",
|
||||
"path": "${task.path}",
|
||||
"isPooled": ${task.isPooled?string},
|
||||
"owner":
|
||||
<#if task.owner??>
|
||||
@@ -23,10 +24,10 @@
|
||||
null,
|
||||
</#if>
|
||||
"properties":
|
||||
<@propertiesJSON properties=task.properties />
|
||||
<#if detailed>,
|
||||
"path": "${task.path}",
|
||||
"workflowInstance": <@workflowInstanceJSON workflowInstance=task.workflowInstance/>,
|
||||
<@propertiesJSON properties=task.properties />,
|
||||
"workflowInstance":
|
||||
<@workflowInstanceJSON workflowInstance=task.workflowInstance/><#if detailed>,
|
||||
|
||||
"definition":
|
||||
{
|
||||
"id": "${task.definition.id}",
|
||||
@@ -67,8 +68,8 @@
|
||||
<#-- Renders a map of properties -->
|
||||
<#macro propertiesJSON properties>
|
||||
<#escape x as jsonUtils.encodeJSONString(x)>
|
||||
{
|
||||
<#list properties?keys as key>
|
||||
{
|
||||
<#list properties?keys as key>
|
||||
"${key}":
|
||||
<#if properties[key]??>
|
||||
<#assign val=properties[key]>
|
||||
@@ -87,17 +88,16 @@
|
||||
</#if>
|
||||
<#else>
|
||||
null
|
||||
</#if>
|
||||
<#if (key_has_next)>,</#if>
|
||||
</#list>
|
||||
}
|
||||
</#if><#if (key_has_next)>,</#if>
|
||||
</#list>
|
||||
}
|
||||
</#escape>
|
||||
</#macro>
|
||||
|
||||
<#-- Renders a workflow instance. -->
|
||||
<#macro workflowInstanceJSON workflowInstance detailed=false>
|
||||
<#escape x as jsonUtils.encodeJSONString(x)>
|
||||
{
|
||||
{
|
||||
"id": "${workflowInstance.id}",
|
||||
"url": "${workflowInstance.url}",
|
||||
"name": "${workflowInstance.name}",
|
||||
@@ -116,14 +116,14 @@
|
||||
<#else>
|
||||
null,
|
||||
</#if>
|
||||
"definitionUrl": "${workflowInstance.definitionUrl}"
|
||||
<#if detailed>,
|
||||
"definitionUrl": "${workflowInstance.definitionUrl}"<#if detailed>,
|
||||
"dueDate": <#if workflowInstance.dueDate??>"${workflowInstance.dueDate}"<#else>null</#if>,
|
||||
"priority": <#if workflowInstance.priority??>${workflowInstance.priority?c}<#else>null</#if>,
|
||||
"context": <#if workflowInstance.context??>"${workflowInstance.context}"<#else>null</#if>,
|
||||
"package": "${workflowInstance.package}",
|
||||
"startTaskInstanceId": "${workflowInstance.startTaskInstanceId}",
|
||||
"definition": <@worflowDefinitionLib.workflowDefinitionJSON workflowDefinition=workflowInstance.definition detailed=true/>
|
||||
"definition":
|
||||
<@worflowDefinitionLib.workflowDefinitionJSON workflowDefinition=workflowInstance.definition detailed=true/>
|
||||
<#if workflowInstance.tasks??>,
|
||||
"tasks":
|
||||
[
|
||||
@@ -134,6 +134,6 @@
|
||||
]
|
||||
</#if>
|
||||
</#if>
|
||||
}
|
||||
}
|
||||
</#escape>
|
||||
</#macro>
|
@@ -164,12 +164,18 @@ public class WorkflowModelBuilder
|
||||
model.put(TASK_DESCRIPTION, task.getDescription());
|
||||
model.put(TASK_STATE, task.getState().name());
|
||||
model.put(TASK_TYPE_DEFINITION_TITLE, task.getDefinition().getMetadata().getTitle());
|
||||
|
||||
model.put(TASK_PATH, getUrl(task.getPath()));
|
||||
model.put(TASK_IS_POOLED, isPooled(task.getProperties()));
|
||||
|
||||
Serializable owner = task.getProperties().get(ContentModel.PROP_OWNER);
|
||||
model.put(TASK_OWNER, getPersonModel( owner));
|
||||
|
||||
// task properties
|
||||
model.put(TASK_PROPERTIES, buildProperties(task, propertyFilters));
|
||||
|
||||
// workflow instance part
|
||||
model.put(TASK_WORKFLOW_INSTANCE, buildSimple(task.getPath().getInstance()));
|
||||
|
||||
return model;
|
||||
}
|
||||
|
||||
@@ -182,11 +188,6 @@ public class WorkflowModelBuilder
|
||||
{
|
||||
Map<String, Object> model = buildSimple(workflowTask, null);
|
||||
|
||||
model.put(TASK_PATH, getUrl(workflowTask.getPath()));
|
||||
|
||||
// workflow instance part
|
||||
model.put(TASK_WORKFLOW_INSTANCE, buildSimple(workflowTask.getPath().getInstance()));
|
||||
|
||||
// definition part
|
||||
model.put(TASK_DEFINITION, buildTaskDefinition(workflowTask.getDefinition(), workflowTask));
|
||||
|
||||
|
@@ -102,6 +102,14 @@ public class WorkflowModelBuilderTest extends TestCase
|
||||
String dateStr = (String) props.get("test_date");
|
||||
assertEquals(date, ISO8601DateFormat.parse(dateStr));
|
||||
|
||||
Map<String, Object> workflowInstance = (Map<String, Object>)model.get(WorkflowModelBuilder.TASK_WORKFLOW_INSTANCE);
|
||||
assertNotNull(workflowInstance);
|
||||
WorkflowInstance instance = task.getPath().getInstance();
|
||||
assertEquals(instance.getId(), workflowInstance.get(WorkflowModelBuilder.TASK_WORKFLOW_INSTANCE_ID));
|
||||
assertEquals(instance.isActive(), workflowInstance.get(WorkflowModelBuilder.TASK_WORKFLOW_INSTANCE_IS_ACTIVE));
|
||||
String startDateStr = ISO8601DateFormat.format(instance.getStartDate());
|
||||
assertEquals(startDateStr, workflowInstance.get(WorkflowModelBuilder.TASK_WORKFLOW_INSTANCE_START_DATE));
|
||||
|
||||
task.getProperties().put(WorkflowModel.ASSOC_POOLED_ACTORS, new ArrayList<NodeRef>(0));
|
||||
model = builder.buildSimple(task, null);
|
||||
assertEquals(false, model.get(WorkflowModelBuilder.TASK_IS_POOLED));
|
||||
|
@@ -126,9 +126,13 @@ public class WorkflowRestApiTest extends BaseWebScriptTest
|
||||
assertEquals(personManager.getFirstName(USER2), owner.getString("firstName"));
|
||||
assertEquals(personManager.getLastName(USER2), owner.getString("lastName"));
|
||||
|
||||
// JSONObject properties = result.getJSONObject("properties");
|
||||
JSONObject properties = result.getJSONObject("properties");
|
||||
assertNotNull(properties);
|
||||
|
||||
//TODO Add more tests to check property filtering and pooled actors.
|
||||
JSONObject instance = result.getJSONObject("workflowInstance");
|
||||
assertNotNull(instance);
|
||||
|
||||
// TODO: Add more tests to check property filtering and pooled actors.
|
||||
}
|
||||
|
||||
public void testTaskInstanceGet() throws Exception
|
||||
|
Reference in New Issue
Block a user