mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +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:
@@ -58,6 +58,8 @@ import org.alfresco.service.namespace.NamespaceService;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.alfresco.util.BaseSpringTest;
|
||||
import org.alfresco.util.GUID;
|
||||
import org.alfresco.util.collections.CollectionUtils;
|
||||
import org.alfresco.util.collections.Function;
|
||||
|
||||
/**
|
||||
* @author Nick Smith
|
||||
@@ -781,6 +783,12 @@ public abstract class AbstractWorkflowServiceIntegrationTest extends BaseSpringT
|
||||
checkCompletedWorkflows(defId, instance1);
|
||||
checkWorkflows(defId, instance1, instance2);
|
||||
|
||||
checkWorkflowsContains(workflowService.getActiveWorkflows(), instance2);
|
||||
checkWorkflowsDontContain(workflowService.getActiveWorkflows(), instance1);
|
||||
checkWorkflowsContains(workflowService.getCompletedWorkflows(), instance1);
|
||||
checkWorkflowsDontContain(workflowService.getCompletedWorkflows(), instance2);
|
||||
checkWorkflowsContains(workflowService.getWorkflows(), instance1, instance2);
|
||||
|
||||
// End workflow 2
|
||||
WorkflowTask startTask2 = workflowService.getStartTask(instance2);
|
||||
workflowService.endTask(startTask2.getId(), null);
|
||||
@@ -865,6 +873,28 @@ public abstract class AbstractWorkflowServiceIntegrationTest extends BaseSpringT
|
||||
}
|
||||
}
|
||||
|
||||
private void checkWorkflowsContains(List<WorkflowInstance> workflows, String... expectedIds)
|
||||
{
|
||||
List<String> expIds = Arrays.asList(expectedIds);
|
||||
List<String> workflowIds = CollectionUtils.transform(workflows, new Function<WorkflowInstance, String>()
|
||||
{
|
||||
public String apply(WorkflowInstance workflow)
|
||||
{
|
||||
return workflow.getId();
|
||||
}
|
||||
});
|
||||
assertTrue(workflowIds.containsAll(expIds));
|
||||
}
|
||||
|
||||
private void checkWorkflowsDontContain(List<WorkflowInstance> workflows, String... expectedIds)
|
||||
{
|
||||
List<String> expIds = Arrays.asList(expectedIds);
|
||||
for (WorkflowInstance instance : workflows)
|
||||
{
|
||||
assertFalse(expIds.contains(instance.getId()));
|
||||
}
|
||||
}
|
||||
|
||||
protected void checkTaskNameQuery(QName taskName, List<String> expectedTaskIds, WorkflowTaskState state,
|
||||
String optionalProcessId)
|
||||
{
|
||||
@@ -974,6 +1004,7 @@ public abstract class AbstractWorkflowServiceIntegrationTest extends BaseSpringT
|
||||
checkNoTasksFoundUsingQuery(taskQuery);
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
protected void checkProcessNameQuery(List<String> expectedTaskIds, WorkflowTaskState state)
|
||||
{
|
||||
WorkflowTaskQuery taskQuery = createWorkflowTaskQuery(state);
|
||||
|
@@ -185,6 +185,30 @@ public interface WorkflowComponent
|
||||
*/
|
||||
public List<WorkflowInstance> getWorkflows(String workflowDefinitionId);
|
||||
|
||||
/**
|
||||
* Gets all "in-flight" active workflow instances.
|
||||
*
|
||||
* @return the list of "in-flight" workflow instances
|
||||
* @since 4.0
|
||||
*/
|
||||
public List<WorkflowInstance> getActiveWorkflows();
|
||||
|
||||
/**
|
||||
* Gets all completed workflow instances.
|
||||
*
|
||||
* @return the list of "in-flight" workflow instances
|
||||
* @since 4.0
|
||||
*/
|
||||
public List<WorkflowInstance> getCompletedWorkflows();
|
||||
|
||||
/**
|
||||
* Gets all workflow instances (both active and completed).
|
||||
*
|
||||
* @return the list of "in-flight" workflow instances
|
||||
* @since 4.0
|
||||
*/
|
||||
public List<WorkflowInstance> getWorkflows();
|
||||
|
||||
/**
|
||||
* Gets a specific workflow instances
|
||||
*
|
||||
|
@@ -22,6 +22,7 @@ package org.alfresco.repo.workflow;
|
||||
import java.io.InputStream;
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
@@ -56,6 +57,8 @@ import org.alfresco.service.cmr.workflow.WorkflowTaskQuery;
|
||||
import org.alfresco.service.cmr.workflow.WorkflowTaskState;
|
||||
import org.alfresco.service.cmr.workflow.WorkflowTimer;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.alfresco.util.collections.CollectionUtils;
|
||||
import org.alfresco.util.collections.Function;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
@@ -414,50 +417,99 @@ public class WorkflowServiceImpl implements WorkflowService
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see
|
||||
* org.alfresco.service.cmr.workflow.WorkflowService#getActiveWorkflows(
|
||||
* java.lang.String)
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public List<WorkflowInstance> getActiveWorkflows(String workflowDefinitionId)
|
||||
{
|
||||
if(workflowDefinitionId==null)
|
||||
{
|
||||
return getActiveWorkflows();
|
||||
}
|
||||
String engineId = BPMEngineRegistry.getEngineId(workflowDefinitionId);
|
||||
WorkflowComponent component = getWorkflowComponent(engineId);
|
||||
return component.getActiveWorkflows(workflowDefinitionId);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see
|
||||
* org.alfresco.service.cmr.workflow.WorkflowService#getCompletedWorkflows(
|
||||
* java.lang.String)
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public List<WorkflowInstance> getCompletedWorkflows(String workflowDefinitionId)
|
||||
{
|
||||
if(workflowDefinitionId==null)
|
||||
{
|
||||
return getCompletedWorkflows();
|
||||
}
|
||||
|
||||
String engineId = BPMEngineRegistry.getEngineId(workflowDefinitionId);
|
||||
WorkflowComponent component = getWorkflowComponent(engineId);
|
||||
return component.getCompletedWorkflows(workflowDefinitionId);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see
|
||||
* org.alfresco.service.cmr.workflow.WorkflowService#getWorkflows(
|
||||
* java.lang.String)
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public List<WorkflowInstance> getWorkflows(String workflowDefinitionId)
|
||||
{
|
||||
if(workflowDefinitionId==null)
|
||||
{
|
||||
return getWorkflows();
|
||||
}
|
||||
String engineId = BPMEngineRegistry.getEngineId(workflowDefinitionId);
|
||||
WorkflowComponent component = getWorkflowComponent(engineId);
|
||||
return component.getWorkflows(workflowDefinitionId);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see
|
||||
* org.alfresco.service.cmr.workflow.WorkflowService#getWorkflowById(java
|
||||
* .lang.String)
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public List<WorkflowInstance> getActiveWorkflows()
|
||||
{
|
||||
List<String> ids = Arrays.asList(registry.getWorkflowComponents());
|
||||
return CollectionUtils.transformFlat(ids, new Function<String, Collection<WorkflowInstance>>()
|
||||
{
|
||||
public List<WorkflowInstance> apply(String id)
|
||||
{
|
||||
WorkflowComponent component = registry.getWorkflowComponent(id);
|
||||
return component.getActiveWorkflows();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public List<WorkflowInstance> getCompletedWorkflows()
|
||||
{
|
||||
List<String> ids = Arrays.asList(registry.getWorkflowComponents());
|
||||
return CollectionUtils.transformFlat(ids, new Function<String, Collection<WorkflowInstance>>()
|
||||
{
|
||||
public List<WorkflowInstance> apply(String id)
|
||||
{
|
||||
WorkflowComponent component = registry.getWorkflowComponent(id);
|
||||
return component.getCompletedWorkflows();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public List<WorkflowInstance> getWorkflows()
|
||||
{
|
||||
List<String> ids = Arrays.asList(registry.getWorkflowComponents());
|
||||
return CollectionUtils.transformFlat(ids, new Function<String, Collection<WorkflowInstance>>()
|
||||
{
|
||||
public List<WorkflowInstance> apply(String id)
|
||||
{
|
||||
WorkflowComponent component = registry.getWorkflowComponent(id);
|
||||
return component.getWorkflows();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public WorkflowInstance getWorkflowById(String workflowId)
|
||||
{
|
||||
|
@@ -43,6 +43,7 @@ import org.activiti.engine.RuntimeService;
|
||||
import org.activiti.engine.TaskService;
|
||||
import org.activiti.engine.form.StartFormData;
|
||||
import org.activiti.engine.history.HistoricProcessInstance;
|
||||
import org.activiti.engine.history.HistoricProcessInstanceQuery;
|
||||
import org.activiti.engine.history.HistoricTaskInstance;
|
||||
import org.activiti.engine.history.HistoricTaskInstanceQuery;
|
||||
import org.activiti.engine.impl.RepositoryServiceImpl;
|
||||
@@ -65,6 +66,7 @@ import org.activiti.engine.repository.ProcessDefinition;
|
||||
import org.activiti.engine.runtime.Execution;
|
||||
import org.activiti.engine.runtime.Job;
|
||||
import org.activiti.engine.runtime.ProcessInstance;
|
||||
import org.activiti.engine.runtime.ProcessInstanceQuery;
|
||||
import org.activiti.engine.task.Task;
|
||||
import org.activiti.engine.task.TaskQuery;
|
||||
import org.alfresco.model.ContentModel;
|
||||
@@ -201,6 +203,7 @@ public class ActivitiWorkflowEngine extends BPMEngine implements WorkflowEngine
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@@ -219,7 +222,6 @@ public class ActivitiWorkflowEngine extends BPMEngine implements WorkflowEngine
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public WorkflowInstance cancelWorkflow(String workflowId)
|
||||
{
|
||||
String localId = createLocalId(workflowId);
|
||||
@@ -256,7 +258,6 @@ public class ActivitiWorkflowEngine extends BPMEngine implements WorkflowEngine
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public WorkflowInstance deleteWorkflow(String workflowId)
|
||||
{
|
||||
String localId = createLocalId(workflowId);
|
||||
@@ -292,7 +293,6 @@ public class ActivitiWorkflowEngine extends BPMEngine implements WorkflowEngine
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public WorkflowDeployment deployDefinition(InputStream workflowDefinition, String mimetype)
|
||||
{
|
||||
return deployDefinition(workflowDefinition, mimetype, null);
|
||||
@@ -301,7 +301,6 @@ public class ActivitiWorkflowEngine extends BPMEngine implements WorkflowEngine
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public WorkflowDeployment deployDefinition(InputStream workflowDefinition, String mimetype, String name)
|
||||
{
|
||||
try
|
||||
@@ -326,17 +325,65 @@ public class ActivitiWorkflowEngine extends BPMEngine implements WorkflowEngine
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public WorkflowPath fireEvent(String pathId, String event)
|
||||
{
|
||||
String message = messageService.getMessage(ERR_FIRE_EVENT_NOT_SUPPORTED);
|
||||
throw new WorkflowException(message);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public List<WorkflowInstance> getActiveWorkflows()
|
||||
{
|
||||
try
|
||||
{
|
||||
return getWorkflowInstances(null, true);
|
||||
}
|
||||
catch(ActivitiException ae)
|
||||
{
|
||||
String message = messageService.getMessage(ERR_GET_ACTIVE_WORKFLOW_INSTS, "");
|
||||
throw new WorkflowException(message, ae);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public List<WorkflowInstance> getCompletedWorkflows()
|
||||
{
|
||||
try
|
||||
{
|
||||
return getWorkflowInstances(null, false);
|
||||
}
|
||||
catch(ActivitiException ae)
|
||||
{
|
||||
String message = messageService.getMessage(ERR_GET_COMPLETED_WORKFLOW_INSTS, "");
|
||||
throw new WorkflowException(message, ae);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public List<WorkflowInstance> getWorkflows()
|
||||
{
|
||||
try
|
||||
{
|
||||
return getWorkflowInstances(null, null);
|
||||
}
|
||||
catch(ActivitiException ae)
|
||||
{
|
||||
String message = messageService.getMessage(ERR_GET_WORKFLOW_INSTS, "");
|
||||
throw new WorkflowException(message, ae);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public List<WorkflowInstance> getActiveWorkflows(String workflowDefinitionId)
|
||||
{
|
||||
try
|
||||
@@ -353,7 +400,6 @@ public class ActivitiWorkflowEngine extends BPMEngine implements WorkflowEngine
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public List<WorkflowDefinition> getAllDefinitions()
|
||||
{
|
||||
try
|
||||
@@ -371,7 +417,6 @@ public class ActivitiWorkflowEngine extends BPMEngine implements WorkflowEngine
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public List<WorkflowDefinition> getAllDefinitionsByName(String workflowName)
|
||||
{
|
||||
try
|
||||
@@ -392,7 +437,6 @@ public class ActivitiWorkflowEngine extends BPMEngine implements WorkflowEngine
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public List<WorkflowInstance> getCompletedWorkflows(String workflowDefinitionId)
|
||||
{
|
||||
try
|
||||
@@ -409,7 +453,6 @@ public class ActivitiWorkflowEngine extends BPMEngine implements WorkflowEngine
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public WorkflowDefinition getDefinitionById(String workflowDefinitionId)
|
||||
{
|
||||
try
|
||||
@@ -430,7 +473,6 @@ public class ActivitiWorkflowEngine extends BPMEngine implements WorkflowEngine
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public WorkflowDefinition getDefinitionByName(String workflowName)
|
||||
{
|
||||
try
|
||||
@@ -452,7 +494,6 @@ public class ActivitiWorkflowEngine extends BPMEngine implements WorkflowEngine
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public byte[] getDefinitionImage(String workflowDefinitionId)
|
||||
{
|
||||
try
|
||||
@@ -494,7 +535,6 @@ public class ActivitiWorkflowEngine extends BPMEngine implements WorkflowEngine
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public List<WorkflowDefinition> getDefinitions()
|
||||
{
|
||||
try
|
||||
@@ -514,7 +554,6 @@ public class ActivitiWorkflowEngine extends BPMEngine implements WorkflowEngine
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Map<QName, Serializable> getPathProperties(String pathId)
|
||||
{
|
||||
String executionId = createLocalId(pathId);
|
||||
@@ -524,7 +563,6 @@ public class ActivitiWorkflowEngine extends BPMEngine implements WorkflowEngine
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public List<WorkflowTaskDefinition> getTaskDefinitions(String workflowDefinitionId)
|
||||
{
|
||||
List<WorkflowTaskDefinition> defs = new ArrayList<WorkflowTaskDefinition>();
|
||||
@@ -651,7 +689,7 @@ public class ActivitiWorkflowEngine extends BPMEngine implements WorkflowEngine
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
|
||||
public List<WorkflowTask> getTasksForWorkflowPath(String pathId)
|
||||
{
|
||||
try
|
||||
@@ -716,7 +754,6 @@ public class ActivitiWorkflowEngine extends BPMEngine implements WorkflowEngine
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public List<WorkflowTimer> getTimers(String workflowId)
|
||||
{
|
||||
try
|
||||
@@ -790,7 +827,6 @@ public class ActivitiWorkflowEngine extends BPMEngine implements WorkflowEngine
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public WorkflowInstance getWorkflowById(String workflowId)
|
||||
{
|
||||
try
|
||||
@@ -831,7 +867,6 @@ public class ActivitiWorkflowEngine extends BPMEngine implements WorkflowEngine
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public List<WorkflowPath> getWorkflowPaths(String workflowId)
|
||||
{
|
||||
try
|
||||
@@ -855,7 +890,6 @@ public class ActivitiWorkflowEngine extends BPMEngine implements WorkflowEngine
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public List<WorkflowInstance> getWorkflows(String workflowDefinitionId)
|
||||
{
|
||||
try
|
||||
@@ -872,7 +906,6 @@ public class ActivitiWorkflowEngine extends BPMEngine implements WorkflowEngine
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public boolean isDefinitionDeployed(InputStream workflowDefinition, String mimetype)
|
||||
{
|
||||
String key = null;
|
||||
@@ -930,7 +963,6 @@ public class ActivitiWorkflowEngine extends BPMEngine implements WorkflowEngine
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public WorkflowPath signal(String pathId, String transitionId)
|
||||
{
|
||||
String execId = createLocalId(pathId);
|
||||
@@ -947,7 +979,6 @@ public class ActivitiWorkflowEngine extends BPMEngine implements WorkflowEngine
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public WorkflowPath startWorkflow(String workflowDefinitionId, Map<QName, Serializable> parameters)
|
||||
{
|
||||
try
|
||||
@@ -999,7 +1030,6 @@ public class ActivitiWorkflowEngine extends BPMEngine implements WorkflowEngine
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public void undeployDefinition(String workflowDefinitionId)
|
||||
{
|
||||
try
|
||||
@@ -1026,7 +1056,6 @@ public class ActivitiWorkflowEngine extends BPMEngine implements WorkflowEngine
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public boolean hasWorkflowImage(String workflowInstanceId)
|
||||
{
|
||||
boolean hasImage = false;
|
||||
@@ -1052,7 +1081,6 @@ public class ActivitiWorkflowEngine extends BPMEngine implements WorkflowEngine
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public InputStream getWorkflowImage(String workflowInstanceId)
|
||||
{
|
||||
String processInstanceId = createLocalId(workflowInstanceId);
|
||||
@@ -1262,7 +1290,6 @@ public class ActivitiWorkflowEngine extends BPMEngine implements WorkflowEngine
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public WorkflowTask endTask(String taskId, String transition)
|
||||
{
|
||||
String localTaskId = createLocalId(taskId);
|
||||
@@ -1373,7 +1400,6 @@ public class ActivitiWorkflowEngine extends BPMEngine implements WorkflowEngine
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public List<WorkflowTask> getAssignedTasks(String authority, WorkflowTaskState state)
|
||||
{
|
||||
try
|
||||
@@ -1403,7 +1429,6 @@ public class ActivitiWorkflowEngine extends BPMEngine implements WorkflowEngine
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public List<WorkflowTask> getPooledTasks(List<String> authorities)
|
||||
{
|
||||
try
|
||||
@@ -1482,7 +1507,6 @@ public class ActivitiWorkflowEngine extends BPMEngine implements WorkflowEngine
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public WorkflowTask getTaskById(String taskId)
|
||||
{
|
||||
try
|
||||
@@ -1514,7 +1538,6 @@ public class ActivitiWorkflowEngine extends BPMEngine implements WorkflowEngine
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public List<WorkflowTask> queryTasks(WorkflowTaskQuery query)
|
||||
{
|
||||
ArrayList<WorkflowTask> result = new ArrayList<WorkflowTask>();
|
||||
@@ -2007,7 +2030,6 @@ public class ActivitiWorkflowEngine extends BPMEngine implements WorkflowEngine
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public WorkflowTask getStartTask(String workflowInstanceId)
|
||||
{
|
||||
String instanceId = createLocalId(workflowInstanceId);
|
||||
@@ -2042,7 +2064,6 @@ public class ActivitiWorkflowEngine extends BPMEngine implements WorkflowEngine
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public WorkflowTask startTask(String taskId)
|
||||
{
|
||||
throw new UnsupportedOperationException();
|
||||
@@ -2051,7 +2072,7 @@ public class ActivitiWorkflowEngine extends BPMEngine implements WorkflowEngine
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
|
||||
public WorkflowTask suspendTask(String taskId)
|
||||
{
|
||||
throw new UnsupportedOperationException();
|
||||
@@ -2060,7 +2081,6 @@ public class ActivitiWorkflowEngine extends BPMEngine implements WorkflowEngine
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public WorkflowTask updateTask(String taskId, Map<QName, Serializable> properties, Map<QName, List<NodeRef>> add,
|
||||
Map<QName, List<NodeRef>> remove)
|
||||
{
|
||||
@@ -2094,22 +2114,28 @@ public class ActivitiWorkflowEngine extends BPMEngine implements WorkflowEngine
|
||||
|
||||
private List<WorkflowInstance> getWorkflowInstances(String workflowDefinitionId, Boolean isActive)
|
||||
{
|
||||
String processDefId = createLocalId(workflowDefinitionId);
|
||||
String processDefId = workflowDefinitionId==null ? null : createLocalId(workflowDefinitionId);
|
||||
LinkedList<WorkflowInstance> results = new LinkedList<WorkflowInstance>();
|
||||
if(Boolean.FALSE.equals(isActive)==false)
|
||||
{
|
||||
List<ProcessInstance> activeInstances = runtimeService.createProcessInstanceQuery()
|
||||
.processDefinitionId(processDefId)
|
||||
.list();
|
||||
ProcessInstanceQuery query = runtimeService.createProcessInstanceQuery();
|
||||
if(processDefId!=null)
|
||||
{
|
||||
query = query.processDefinitionId(processDefId);
|
||||
}
|
||||
List<ProcessInstance> activeInstances = query.list();
|
||||
List<WorkflowInstance> activeResults = typeConverter.convert(activeInstances);
|
||||
results.addAll(activeResults);
|
||||
}
|
||||
if(Boolean.TRUE.equals(isActive)==false)
|
||||
{
|
||||
List<HistoricProcessInstance> completedInstances = historyService.createHistoricProcessInstanceQuery()
|
||||
.processDefinitionId(processDefId)
|
||||
.finished()
|
||||
.list();
|
||||
HistoricProcessInstanceQuery query = historyService.createHistoricProcessInstanceQuery()
|
||||
.finished();
|
||||
if(processDefId!=null)
|
||||
{
|
||||
query = query.processDefinitionId(processDefId);
|
||||
}
|
||||
List<HistoricProcessInstance> completedInstances = query.list();
|
||||
List<WorkflowInstance> completedResults = typeConverter.convert(completedInstances);
|
||||
results.addAll(completedResults);
|
||||
}
|
||||
|
@@ -443,6 +443,17 @@ public class JBPMEngine extends AlfrescoBpmEngine implements WorkflowEngine
|
||||
});
|
||||
}
|
||||
|
||||
private List<WorkflowInstance> convertWorkflows(Collection<ProcessInstance> instances)
|
||||
{
|
||||
return CollectionUtils.transform(instances, new Function<ProcessInstance, WorkflowInstance>()
|
||||
{
|
||||
public WorkflowInstance apply(ProcessInstance value)
|
||||
{
|
||||
return createWorkflowInstance(value);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
@@ -772,55 +783,63 @@ public class JBPMEngine extends AlfrescoBpmEngine implements WorkflowEngine
|
||||
return new WorkflowException(msg, e);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.alfresco.repo.workflow.WorkflowComponent#getActiveWorkflows(java.lang.String)
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public List<WorkflowInstance> getActiveWorkflows()
|
||||
{
|
||||
return getWorkflowsInternal(null, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public List<WorkflowInstance> getCompletedWorkflows()
|
||||
{
|
||||
return getWorkflowsInternal(null, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public List<WorkflowInstance> getWorkflows()
|
||||
{
|
||||
return getWorkflowsInternal(null, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public List<WorkflowInstance> getActiveWorkflows(final String workflowDefinitionId)
|
||||
{
|
||||
return getWorkflowsInternal(workflowDefinitionId, true);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.alfresco.repo.workflow.WorkflowComponent#getCompletedWorkflows(java.lang.String)
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public List<WorkflowInstance> getCompletedWorkflows(final String workflowDefinitionId)
|
||||
{
|
||||
return getWorkflowsInternal(workflowDefinitionId, false);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.alfresco.repo.workflow.WorkflowComponent#getWorkflows(java.lang.String)
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public List<WorkflowInstance> getWorkflows(final String workflowDefinitionId)
|
||||
{
|
||||
return getWorkflowsInternal(workflowDefinitionId, null);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private List<WorkflowInstance> getWorkflowsInternal(final String workflowDefinitionId, final Boolean active)
|
||||
private List<WorkflowInstance> getWorkflowsInternal(String workflowDefinitionId, Boolean active)
|
||||
{
|
||||
try
|
||||
{
|
||||
return (List<WorkflowInstance>) jbpmTemplate.execute(new JbpmCallback()
|
||||
{
|
||||
public Object doInJbpm(JbpmContext context)
|
||||
{
|
||||
GraphSession graphSession = context.getGraphSession();
|
||||
List<ProcessInstance> processInstances = graphSession
|
||||
.findProcessInstances(getJbpmId(workflowDefinitionId));
|
||||
List<WorkflowInstance> workflowInstances = new ArrayList<WorkflowInstance>(processInstances.size());
|
||||
for (ProcessInstance processInstance : processInstances)
|
||||
{
|
||||
if ((active == null) || (!active && processInstance.hasEnded())
|
||||
|| (active && !processInstance.hasEnded()))
|
||||
{
|
||||
WorkflowInstance workflowInstance = createWorkflowInstance(processInstance);
|
||||
workflowInstances.add(workflowInstance);
|
||||
}
|
||||
}
|
||||
return workflowInstances;
|
||||
}
|
||||
});
|
||||
final Long processDefId = workflowDefinitionId == null ? null : getJbpmId(workflowDefinitionId);
|
||||
List<ProcessInstance> instances = getProcessInstances(processDefId, active);
|
||||
return convertWorkflows(instances);
|
||||
}
|
||||
catch(JbpmException e)
|
||||
{
|
||||
@@ -829,12 +848,35 @@ public class JBPMEngine extends AlfrescoBpmEngine implements WorkflowEngine
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* org.alfresco.repo.workflow.WorkflowComponent#getWorkflowById(java.lang
|
||||
* .String)
|
||||
@SuppressWarnings("unchecked")
|
||||
private List<ProcessInstance> getProcessInstances(final Long processDefId, final Boolean active)
|
||||
{
|
||||
return (List<ProcessInstance>) jbpmTemplate.execute(new JbpmCallback()
|
||||
{
|
||||
public Object doInJbpm(JbpmContext context)
|
||||
{
|
||||
Session session = context.getSession();
|
||||
Criteria criteria = session.createCriteria(ProcessInstance.class);
|
||||
if(processDefId!=null)
|
||||
{
|
||||
Criteria definitionCriteria = criteria.createCriteria("processDefinition");
|
||||
definitionCriteria.add(Restrictions.eq("id", processDefId));
|
||||
}
|
||||
if(Boolean.TRUE.equals(active))
|
||||
{
|
||||
criteria.add(Restrictions.isNull("end"));
|
||||
}
|
||||
else if(Boolean.FALSE.equals(active))
|
||||
{
|
||||
criteria.add(Restrictions.isNotNull("end"));
|
||||
}
|
||||
return criteria.list();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public WorkflowInstance getWorkflowById(final String workflowId)
|
||||
{
|
||||
@@ -1573,15 +1615,9 @@ public class JBPMEngine extends AlfrescoBpmEngine implements WorkflowEngine
|
||||
{
|
||||
return (List<WorkflowTask>) jbpmTemplate.execute(new JbpmCallback()
|
||||
{
|
||||
@SuppressWarnings("deprecation")
|
||||
public List<WorkflowTask> doInJbpm(JbpmContext context)
|
||||
{
|
||||
Session session = context.getSession();
|
||||
|
||||
if ((query.getProcessName() != null) && (tenantService.isEnabled()))
|
||||
{
|
||||
query.setProcessName(tenantService.getName(query.getProcessName()));
|
||||
}
|
||||
Criteria criteria = createTaskQueryCriteria(session, query);
|
||||
List<TaskInstance> tasks = criteria.list();
|
||||
return getWorkflowTasks(tasks);
|
||||
|
@@ -24,7 +24,6 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.alfresco.service.Auditable;
|
||||
import org.alfresco.service.PublicService;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
|
||||
@@ -236,6 +235,32 @@ public interface WorkflowService
|
||||
@Auditable(parameters = {"workflowDefinitionId"})
|
||||
public List<WorkflowInstance> getWorkflows(String workflowDefinitionId);
|
||||
|
||||
/**
|
||||
* Gets all active workflow instances.
|
||||
*
|
||||
* @return the list of "in-flight" workflow instances
|
||||
* @since4.0
|
||||
*/
|
||||
@Auditable
|
||||
public List<WorkflowInstance> getActiveWorkflows();
|
||||
|
||||
/**
|
||||
* Gets all completed workflow instances.
|
||||
*
|
||||
* @return the list of "in-flight" workflow instances
|
||||
* @since 4.0
|
||||
*/
|
||||
@Auditable
|
||||
public List<WorkflowInstance> getCompletedWorkflows();
|
||||
|
||||
/**
|
||||
* Gets all workflow instances (both active and completed).
|
||||
*
|
||||
* @return the list of "in-flight" workflow instances
|
||||
* @since 4.0
|
||||
*/
|
||||
public List<WorkflowInstance> getWorkflows();
|
||||
|
||||
/**
|
||||
* Gets a specific workflow instances
|
||||
*
|
||||
|
Reference in New Issue
Block a user