Changing workflow REST API URLs to be plural for consistency with other services and also some minor formatting of FTL

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@21127 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Gavin Cornwell
2010-07-13 13:13:16 +00:00
parent e80119fe6c
commit 53cee95d12
5 changed files with 53 additions and 61 deletions

View File

@@ -4,14 +4,7 @@
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.
</description>
<url>/api/task-instance</url>
<url>/api/task-instance?authority={authority?}</url>
<url>/api/task-instance?state={state?}</url>
<url>/api/task-instance?properties={properties?}</url>
<url>/api/task-instance?authority={authority?}&amp;?state={state?}</url>
<url>/api/task-instance?authority={authority?}&amp;?properties={properties?}</url>
<url>/api/task-instance?state={state?}&amp;?properties={properties?}</url>
<url>/api/task-instance?authority={authority?}&amp;?state={state?}&amp;?properties={properties?}</url>
<url>/api/task-instances?authority={authority?}&amp;state={state?}&amp;properties={properties?}</url>
<format default="json"/>
<authentication>user</authentication>
<transaction allow="readonly">required</transaction>

View File

@@ -2,10 +2,11 @@
<#import "task.lib.ftl" as taskLib />
{
"data": [
<#list taskInstances as task>
<@taskLib.taskJSON task=task />
<#if task_has_next>,</#if>
</#list>
]
"data":
[
<#list taskInstances as task>
<@taskLib.taskJSON task=task />
<#if task_has_next>,</#if>
</#list>
]
}

View File

@@ -1,55 +1,53 @@
<#-- Renders a task instance. -->
<#macro taskJSON task >
{
"id": "${task.id}",
"url": "${task.url}",
"name": "${task.name}",
"title": "${task.title}",
"description": "${task.description}",
"state": "${task.state}",
"typeDefinitionTitle": "${task.typeDefinitionTitle}",
"isPooled": ${task.isPooled?string},
"owner":
<#if task.owner??>
{
"userName": "${task.owner.userName}",
"firstName": "${task.owner.firstName}",
"lastName": "${task.owner.lastName}"
},
<#else>
null,
</#if>
"properties":
<@propertiesJSON properties=task.properties />
}
{
"id": "${task.id}",
"url": "${task.url}",
"name": "${task.name}",
"title": "${task.title}",
"description": "${task.description}",
"state": "${task.state}",
"typeDefinitionTitle": "${task.typeDefinitionTitle}",
"isPooled": ${task.isPooled?string},
"owner":
<#if task.owner??>
{
"userName": "${task.owner.userName}",
"firstName": "${task.owner.firstName}",
"lastName": "${task.owner.lastName}"
},
<#else>
null,
</#if>
"properties":
<@propertiesJSON properties=task.properties />
}
</#macro>
<#-- Renders a map of properties -->
<#macro propertiesJSON properties>
{
<#list properties?keys as key>
"${key}" :
<#if properties[key]??>
<#assign val=properties[key]>
{
<#list properties?keys as key>
"${key}" :
<#if properties[key]??>
<#assign val=properties[key]>
<#if val?is_boolean == true>
${val?string}
${val?string}
<#elseif val?is_number == true>
${val?c}
${val?c}
<#elseif val?is_sequence>
[
<#list val as element>
"${jsonUtils.encodeJSONString(element?string)}"<#if (element_has_next)>,</#if>
</#list>
]
[
<#list val as element>
"${jsonUtils.encodeJSONString(element?string)}"<#if (element_has_next)>,</#if>
</#list>
]
<#else>
"${jsonUtils.encodeJSONString(shortQName(val?string))}"
"${jsonUtils.encodeJSONString(shortQName(val?string))}"
</#if>
<#else>
null
</#if>
<#if (key_has_next)>,</#if>
</#list>
}
<#else>
null
</#if>
<#if (key_has_next)>,</#if>
</#list>
}
</#macro>

View File

@@ -232,12 +232,12 @@ public class WorkflowModelBuilder
private String getUrl(WorkflowTask task)
{
return "api/task-instance/" + task.id;
return "api/task-instances/" + task.id;
}
private String getUrl(WorkflowDefinition workflowDefinition)
{
return "api/workflow-definition/" + workflowDefinition.id;
return "api/workflow-definitions/" + workflowDefinition.id;
}
}

View File

@@ -92,7 +92,7 @@ public class WorkflowModelBuilderTest extends TestCase
Object id = model.get(WorkflowModelBuilder.TASK_ID);
assertEquals(task.id, id);
Object url = model.get(WorkflowModelBuilder.TASK_URL);
assertEquals("api/task-instance/"+task.id, url);
assertEquals("api/task-instances/"+task.id, url);
assertEquals(task.name, model.get(WorkflowModelBuilder.TASK_NAME));
assertEquals(task.title, model.get(WorkflowModelBuilder.TASK_TITLE));
assertEquals(task.description, model.get(WorkflowModelBuilder.TASK_DESCRIPTION));
@@ -143,7 +143,7 @@ public class WorkflowModelBuilderTest extends TestCase
Map<String, Object> model = builder.buildSimple(workflowDefinition);
assertEquals(workflowDefinition.id, model.get(WorkflowModelBuilder.WORKFLOW_DEFINITION_ID));
assertEquals("api/workflow-definition/" + workflowDefinition.id, model.get(WorkflowModelBuilder.WORKFLOW_DEFINITION_URL));
assertEquals("api/workflow-definitions/" + workflowDefinition.id, model.get(WorkflowModelBuilder.WORKFLOW_DEFINITION_URL));
assertEquals(workflowDefinition.name, model.get(WorkflowModelBuilder.WORKFLOW_DEFINITION_NAME));
assertEquals(workflowDefinition.title, model.get(WorkflowModelBuilder.WORKFLOW_DEFINITION_TITLE));
assertEquals(workflowDefinition.description, model.get(WorkflowModelBuilder.WORKFLOW_DEFINITION_DESCRIPTION));