mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-14 17:58:59 +00:00
ALF-10084, ALF-10242. Fixed issues and added WorkflowService methods to get workflow instances without filtering by definition id.
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@30699 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -948,6 +948,9 @@ public abstract class AbstractWorkflowRestApiTest extends BaseWebScriptTest
|
|||||||
|
|
||||||
public void testWorkflowInstancesGet() throws Exception
|
public void testWorkflowInstancesGet() throws Exception
|
||||||
{
|
{
|
||||||
|
// Should work even with definitions hidden.
|
||||||
|
wfTestHelper.setVisible(false);
|
||||||
|
|
||||||
//Start workflow as USER1 and assign task to USER2.
|
//Start workflow as USER1 and assign task to USER2.
|
||||||
personManager.setUser(USER1);
|
personManager.setUser(USER1);
|
||||||
WorkflowDefinition adhocDef = workflowService.getDefinitionByName(getAdhocWorkflowDefinitionName());
|
WorkflowDefinition adhocDef = workflowService.getDefinitionByName(getAdhocWorkflowDefinitionName());
|
||||||
|
@@ -30,7 +30,6 @@ import javax.servlet.http.HttpServletResponse;
|
|||||||
|
|
||||||
import org.alfresco.model.ContentModel;
|
import org.alfresco.model.ContentModel;
|
||||||
import org.alfresco.service.cmr.repository.NodeRef;
|
import org.alfresco.service.cmr.repository.NodeRef;
|
||||||
import org.alfresco.service.cmr.workflow.WorkflowDefinition;
|
|
||||||
import org.alfresco.service.cmr.workflow.WorkflowInstance;
|
import org.alfresco.service.cmr.workflow.WorkflowInstance;
|
||||||
import org.springframework.extensions.webscripts.Cache;
|
import org.springframework.extensions.webscripts.Cache;
|
||||||
import org.springframework.extensions.webscripts.Status;
|
import org.springframework.extensions.webscripts.Status;
|
||||||
@@ -95,42 +94,20 @@ public class WorkflowInstancesGet extends AbstractWorkflowWebscript
|
|||||||
workflowDefinitionId = req.getParameter(PARAM_DEFINITION_ID);
|
workflowDefinitionId = req.getParameter(PARAM_DEFINITION_ID);
|
||||||
}
|
}
|
||||||
|
|
||||||
// default workflow state to ACTIVE if not supplied
|
List<WorkflowInstance> workflows;
|
||||||
|
|
||||||
|
// list workflows for specified workflow definition
|
||||||
if(state == null)
|
if(state == null)
|
||||||
{
|
{
|
||||||
state = WorkflowState.ACTIVE;
|
workflows = workflowService.getWorkflows(workflowDefinitionId);
|
||||||
}
|
}
|
||||||
|
else if (state == WorkflowState.ACTIVE)
|
||||||
List<WorkflowInstance> workflows = new ArrayList<WorkflowInstance>();
|
|
||||||
|
|
||||||
if (workflowDefinitionId != null)
|
|
||||||
{
|
{
|
||||||
// list workflows for specified workflow definition
|
workflows = workflowService.getActiveWorkflows(workflowDefinitionId);
|
||||||
if (state == WorkflowState.ACTIVE)
|
|
||||||
{
|
|
||||||
workflows.addAll(workflowService.getActiveWorkflows(workflowDefinitionId));
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
workflows.addAll(workflowService.getCompletedWorkflows(workflowDefinitionId));
|
workflows = workflowService.getCompletedWorkflows(workflowDefinitionId);
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
List<WorkflowDefinition> workflowDefinitions = workflowService.getAllDefinitions();
|
|
||||||
|
|
||||||
// list workflows for all definitions
|
|
||||||
for (WorkflowDefinition workflowDefinition : workflowDefinitions)
|
|
||||||
{
|
|
||||||
if (state == WorkflowState.ACTIVE)
|
|
||||||
{
|
|
||||||
workflows.addAll(workflowService.getActiveWorkflows(workflowDefinition.getId()));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
workflows.addAll(workflowService.getCompletedWorkflows(workflowDefinition.getId()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// sort workflows by due date
|
// sort workflows by due date
|
||||||
|
Reference in New Issue
Block a user