Fixed ALF-4701: Running workflows can disappear from the Workflows I've Started list when using the Workflow Type filter.

Added "definitionName" as a parameter to the GET /api/workflow-instances REST API, UI now uses this parameter to filter workflow types.

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@22445 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Gavin Cornwell
2010-09-13 10:54:43 +00:00
parent 6a868744f5
commit 585a3ffe8c
3 changed files with 49 additions and 34 deletions

View File

@@ -1,7 +1,7 @@
<webscript>
<shortname>Get Workflow Instance Collection</shortname>
<description>Retrieves all workflow instances, the returned list can be optionally filtered by the state of the workflow instance and by the authority that initiated the workflow instance.</description>
<url>/api/workflow-instances?state={state?}&amp;initiator={initiator?}&amp;priority={priority?}&amp;dueBefore={dueBefore?}&amp;dueAfter={dueAfter?}&amp;definitionId={workflow_definition_id?}&amp;startedBefore={startedBefore?}&amp;startedAfter={startedAfter?}&amp;completedBefore={completedBefore?}&amp;completedAfter={completedAfter?}&amp;maxItems={maxItems?}&amp;skipCount={skipCount?}&amp;exclude={exclude?}</url>
<url>/api/workflow-instances?state={state?}&amp;initiator={initiator?}&amp;priority={priority?}&amp;dueBefore={dueBefore?}&amp;dueAfter={dueAfter?}&amp;definitionId={definitionId?}&amp;definitionName={definitionName?}&amp;startedBefore={startedBefore?}&amp;startedAfter={startedAfter?}&amp;completedBefore={completedBefore?}&amp;completedAfter={completedAfter?}&amp;maxItems={maxItems?}&amp;skipCount={skipCount?}&amp;exclude={exclude?}</url>
<url>/api/workflow-definitions/{workflow_definition_id}/workflow-instances?state={state?}&amp;initiator={initiator?}&amp;priority={priority?}&amp;dueBefore={dueBefore?}&amp;dueAfter={dueAfter?}&amp;startedBefore={startedBefore?}&amp;startedAfter={startedAfter?}&amp;completedBefore={completedBefore?}&amp;completedAfter={completedAfter?}&amp;maxItems={maxItems?}&amp;skipCount={skipCount?}&amp;exclude={exclude?}</url>
<format default="json"/>
<authentication>user</authentication>

View File

@@ -51,6 +51,7 @@ public class WorkflowInstancesGet extends AbstractWorkflowWebscript
public static final String PARAM_STARTED_AFTER = "startedAfter";
public static final String PARAM_COMPLETED_BEFORE = "completedBefore";
public static final String PARAM_COMPLETED_AFTER = "completedAfter";
public static final String PARAM_DEFINITION_NAME = "definitionName";
public static final String PARAM_DEFINITION_ID = "definitionId";
public static final String VAR_DEFINITION_ID = "workflow_definition_id";
@@ -66,6 +67,7 @@ public class WorkflowInstancesGet extends AbstractWorkflowWebscript
filters.put(PARAM_STATE, req.getParameter(PARAM_STATE));
filters.put(PARAM_INITIATOR, req.getParameter(PARAM_INITIATOR));
filters.put(PARAM_PRIORITY, req.getParameter(PARAM_PRIORITY));
filters.put(PARAM_DEFINITION_NAME, req.getParameter(PARAM_DEFINITION_NAME));
String excludeParam = req.getParameter(PARAM_EXCLUDE);
if (excludeParam != null && excludeParam.length() > 0)
@@ -154,6 +156,49 @@ public class WorkflowInstancesGet extends AbstractWorkflowWebscript
break;
}
}
else if (key.equals(PARAM_INITIATOR))
{
NodeRef initiator = workflowInstance.getInitiator();
if (initiator == null)
{
result = false;
break;
}
else
{
if (!nodeService.exists(initiator) ||
!filterValue.equals(nodeService.getProperty(workflowInstance.getInitiator(), ContentModel.PROP_USERNAME)))
{
result = false;
break;
}
}
}
else if (key.equals(PARAM_PRIORITY))
{
String priority = "0";
if (workflowInstance.getPriority() != null)
{
priority = workflowInstance.getPriority().toString();
}
if (!filterValue.equals(priority))
{
result = false;
break;
}
}
else if (key.equals(PARAM_DEFINITION_NAME))
{
String definitionName = workflowInstance.getDefinition().getName();
if (!filterValue.equals(definitionName))
{
result = false;
break;
}
}
else if (key.equals(PARAM_STATE))
{
WorkflowState filter = WorkflowState.getState(filterValue.toString());
@@ -228,39 +273,6 @@ public class WorkflowInstancesGet extends AbstractWorkflowWebscript
break;
}
}
else if (key.equals(PARAM_INITIATOR))
{
NodeRef initiator = workflowInstance.getInitiator();
if (initiator == null)
{
result = false;
break;
}
else
{
if (!nodeService.exists(initiator) ||
!filterValue.equals(nodeService.getProperty(workflowInstance.getInitiator(), ContentModel.PROP_USERNAME)))
{
result = false;
break;
}
}
}
else if (key.equals(PARAM_PRIORITY))
{
String priority = "0";
if (workflowInstance.getPriority() != null)
{
priority = workflowInstance.getPriority().toString();
}
if (!filterValue.equals(priority))
{
result = false;
break;
}
}
}
}

View File

@@ -606,6 +606,9 @@ public class WorkflowRestApiTest extends BaseWebScriptTest
// filter by state
checkFiltering(URL_WORKFLOW_INSTANCES + "?state=active");
// filter by definition name
checkFiltering(URL_WORKFLOW_INSTANCES + "?definitionName=jbpm$wf:adhoc");
// paging
int maxItems = 3;
for (int skipCount = 0; skipCount < totalItems; skipCount += maxItems)