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:
Gavin Cornwell
2010-08-03 15:10:50 +00:00
parent d2ceb3bc73
commit d6914eda7a
4 changed files with 86 additions and 73 deletions

View File

@@ -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));

View File

@@ -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));

View File

@@ -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