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}",
|
"description": "${task.description}",
|
||||||
"state": "${task.state}",
|
"state": "${task.state}",
|
||||||
"typeDefinitionTitle": "${task.typeDefinitionTitle}",
|
"typeDefinitionTitle": "${task.typeDefinitionTitle}",
|
||||||
|
"path": "${task.path}",
|
||||||
"isPooled": ${task.isPooled?string},
|
"isPooled": ${task.isPooled?string},
|
||||||
"owner":
|
"owner":
|
||||||
<#if task.owner??>
|
<#if task.owner??>
|
||||||
@@ -23,10 +24,10 @@
|
|||||||
null,
|
null,
|
||||||
</#if>
|
</#if>
|
||||||
"properties":
|
"properties":
|
||||||
<@propertiesJSON properties=task.properties />
|
<@propertiesJSON properties=task.properties />,
|
||||||
<#if detailed>,
|
"workflowInstance":
|
||||||
"path": "${task.path}",
|
<@workflowInstanceJSON workflowInstance=task.workflowInstance/><#if detailed>,
|
||||||
"workflowInstance": <@workflowInstanceJSON workflowInstance=task.workflowInstance/>,
|
|
||||||
"definition":
|
"definition":
|
||||||
{
|
{
|
||||||
"id": "${task.definition.id}",
|
"id": "${task.definition.id}",
|
||||||
@@ -87,8 +88,7 @@
|
|||||||
</#if>
|
</#if>
|
||||||
<#else>
|
<#else>
|
||||||
null
|
null
|
||||||
</#if>
|
</#if><#if (key_has_next)>,</#if>
|
||||||
<#if (key_has_next)>,</#if>
|
|
||||||
</#list>
|
</#list>
|
||||||
}
|
}
|
||||||
</#escape>
|
</#escape>
|
||||||
@@ -116,14 +116,14 @@
|
|||||||
<#else>
|
<#else>
|
||||||
null,
|
null,
|
||||||
</#if>
|
</#if>
|
||||||
"definitionUrl": "${workflowInstance.definitionUrl}"
|
"definitionUrl": "${workflowInstance.definitionUrl}"<#if detailed>,
|
||||||
<#if detailed>,
|
|
||||||
"dueDate": <#if workflowInstance.dueDate??>"${workflowInstance.dueDate}"<#else>null</#if>,
|
"dueDate": <#if workflowInstance.dueDate??>"${workflowInstance.dueDate}"<#else>null</#if>,
|
||||||
"priority": <#if workflowInstance.priority??>${workflowInstance.priority?c}<#else>null</#if>,
|
"priority": <#if workflowInstance.priority??>${workflowInstance.priority?c}<#else>null</#if>,
|
||||||
"context": <#if workflowInstance.context??>"${workflowInstance.context}"<#else>null</#if>,
|
"context": <#if workflowInstance.context??>"${workflowInstance.context}"<#else>null</#if>,
|
||||||
"package": "${workflowInstance.package}",
|
"package": "${workflowInstance.package}",
|
||||||
"startTaskInstanceId": "${workflowInstance.startTaskInstanceId}",
|
"startTaskInstanceId": "${workflowInstance.startTaskInstanceId}",
|
||||||
"definition": <@worflowDefinitionLib.workflowDefinitionJSON workflowDefinition=workflowInstance.definition detailed=true/>
|
"definition":
|
||||||
|
<@worflowDefinitionLib.workflowDefinitionJSON workflowDefinition=workflowInstance.definition detailed=true/>
|
||||||
<#if workflowInstance.tasks??>,
|
<#if workflowInstance.tasks??>,
|
||||||
"tasks":
|
"tasks":
|
||||||
[
|
[
|
||||||
|
@@ -164,12 +164,18 @@ public class WorkflowModelBuilder
|
|||||||
model.put(TASK_DESCRIPTION, task.getDescription());
|
model.put(TASK_DESCRIPTION, task.getDescription());
|
||||||
model.put(TASK_STATE, task.getState().name());
|
model.put(TASK_STATE, task.getState().name());
|
||||||
model.put(TASK_TYPE_DEFINITION_TITLE, task.getDefinition().getMetadata().getTitle());
|
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()));
|
model.put(TASK_IS_POOLED, isPooled(task.getProperties()));
|
||||||
|
|
||||||
Serializable owner = task.getProperties().get(ContentModel.PROP_OWNER);
|
Serializable owner = task.getProperties().get(ContentModel.PROP_OWNER);
|
||||||
model.put(TASK_OWNER, getPersonModel( owner));
|
model.put(TASK_OWNER, getPersonModel( owner));
|
||||||
|
|
||||||
|
// task properties
|
||||||
model.put(TASK_PROPERTIES, buildProperties(task, propertyFilters));
|
model.put(TASK_PROPERTIES, buildProperties(task, propertyFilters));
|
||||||
|
|
||||||
|
// workflow instance part
|
||||||
|
model.put(TASK_WORKFLOW_INSTANCE, buildSimple(task.getPath().getInstance()));
|
||||||
|
|
||||||
return model;
|
return model;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -182,11 +188,6 @@ public class WorkflowModelBuilder
|
|||||||
{
|
{
|
||||||
Map<String, Object> model = buildSimple(workflowTask, null);
|
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
|
// definition part
|
||||||
model.put(TASK_DEFINITION, buildTaskDefinition(workflowTask.getDefinition(), workflowTask));
|
model.put(TASK_DEFINITION, buildTaskDefinition(workflowTask.getDefinition(), workflowTask));
|
||||||
|
|
||||||
|
@@ -102,6 +102,14 @@ public class WorkflowModelBuilderTest extends TestCase
|
|||||||
String dateStr = (String) props.get("test_date");
|
String dateStr = (String) props.get("test_date");
|
||||||
assertEquals(date, ISO8601DateFormat.parse(dateStr));
|
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));
|
task.getProperties().put(WorkflowModel.ASSOC_POOLED_ACTORS, new ArrayList<NodeRef>(0));
|
||||||
model = builder.buildSimple(task, null);
|
model = builder.buildSimple(task, null);
|
||||||
assertEquals(false, model.get(WorkflowModelBuilder.TASK_IS_POOLED));
|
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.getFirstName(USER2), owner.getString("firstName"));
|
||||||
assertEquals(personManager.getLastName(USER2), owner.getString("lastName"));
|
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
|
public void testTaskInstanceGet() throws Exception
|
||||||
|
Reference in New Issue
Block a user