mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-14 17:58:59 +00:00
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:
@@ -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?}&initiator={initiator?}&priority={priority?}&dueBefore={dueBefore?}&dueAfter={dueAfter?}&definitionId={workflow_definition_id?}&startedBefore={startedBefore?}&startedAfter={startedAfter?}&completedBefore={completedBefore?}&completedAfter={completedAfter?}&maxItems={maxItems?}&skipCount={skipCount?}&exclude={exclude?}</url>
|
||||
<url>/api/workflow-instances?state={state?}&initiator={initiator?}&priority={priority?}&dueBefore={dueBefore?}&dueAfter={dueAfter?}&definitionId={definitionId?}&definitionName={definitionName?}&startedBefore={startedBefore?}&startedAfter={startedAfter?}&completedBefore={completedBefore?}&completedAfter={completedAfter?}&maxItems={maxItems?}&skipCount={skipCount?}&exclude={exclude?}</url>
|
||||
<url>/api/workflow-definitions/{workflow_definition_id}/workflow-instances?state={state?}&initiator={initiator?}&priority={priority?}&dueBefore={dueBefore?}&dueAfter={dueAfter?}&startedBefore={startedBefore?}&startedAfter={startedAfter?}&completedBefore={completedBefore?}&completedAfter={completedAfter?}&maxItems={maxItems?}&skipCount={skipCount?}&exclude={exclude?}</url>
|
||||
<format default="json"/>
|
||||
<authentication>user</authentication>
|
||||
|
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -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)
|
||||
|
Reference in New Issue
Block a user