Merged HEAD-BUG-FIX to HEAD (4.2)

55501: Merged V4.1-BUG-FIX (4.1.7) to HEAD-BUG-FIX (4.2)
      << Had a conflict on merge - think it is okay >>
      55463: Merged V4.1.6 (4.1.6) to V4.1-BUG-FIX (4.1.7)
         55227: MNT-9074: Merged V4.1.6-PATCHES-2013_09_03 to PATCHES/V4.1.6
          55046: MNT-9074 : My Tasks fails to render if tasks quantity is excessive
          Were implemented code for getting definite count of workflow instances and applying them to page. It makes the opening page more quickly.


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@55782 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Alan Davis
2013-09-20 20:49:30 +00:00
parent e5e97719b3
commit 43b8974563
5 changed files with 140 additions and 9 deletions

View File

@@ -194,6 +194,24 @@ public interface WorkflowComponent
*/
public List<WorkflowInstance> getWorkflows(WorkflowInstanceQuery workflowInstanceQuery);
/**
* Gets maxItems "in-flight" workflow instances according to the specified workflowInstanceQuery parameter
*
* @param workflowInstanceQuery
* @param maxItems
* @param skipCount
* @return maxItems workflow instances
*/
public List<WorkflowInstance> getWorkflows(WorkflowInstanceQuery workflowInstanceQuery, int maxItems, int skipCount);
/**
* Get count of workflow instances
*
* @param workflowInstanceQuery
* @return count of workflow instances
*/
public long countWorkflows(WorkflowInstanceQuery workflowInstanceQuery);
/**
* Gets all "in-flight" active workflow instances.
*

View File

@@ -482,7 +482,13 @@ public class WorkflowServiceImpl implements WorkflowService
}
@Override
public List<WorkflowInstance> getWorkflows(final WorkflowInstanceQuery workflowInstanceQuery)
public List<WorkflowInstance> getWorkflows(WorkflowInstanceQuery workflowInstanceQuery)
{
return getWorkflows(workflowInstanceQuery, 0, 0);
}
@Override
public List<WorkflowInstance> getWorkflows(final WorkflowInstanceQuery workflowInstanceQuery, final int maxItems, final int skipCount)
{
if(workflowInstanceQuery.getWorkflowDefinitionId() == null)
{
@@ -492,14 +498,38 @@ public class WorkflowServiceImpl implements WorkflowService
public List<WorkflowInstance> apply(String id)
{
WorkflowComponent component = registry.getWorkflowComponent(id);
return component.getWorkflows(workflowInstanceQuery);
return component.getWorkflows(workflowInstanceQuery, maxItems, skipCount);
}
});
}
String engineId = BPMEngineRegistry.getEngineId(workflowInstanceQuery.getWorkflowDefinitionId());
WorkflowComponent component = getWorkflowComponent(engineId);
return component.getWorkflows(workflowInstanceQuery);
return component.getWorkflows(workflowInstanceQuery, maxItems, skipCount);
}
@Override
public long countWorkflows(final WorkflowInstanceQuery workflowInstanceQuery)
{
// MNT-9074 My Tasks fails to render if tasks quantity is excessive
if (workflowInstanceQuery.getWorkflowDefinitionId() == null)
{
List<String> ids = Arrays.asList(registry.getWorkflowComponents());
long total = 0;
for (String id : ids)
{
WorkflowComponent component = registry.getWorkflowComponent(id);
total += component.countWorkflows(workflowInstanceQuery);
}
return total;
}
String engineId = BPMEngineRegistry.getEngineId(workflowInstanceQuery.getWorkflowDefinitionId());
WorkflowComponent component = getWorkflowComponent(engineId);
return component.countWorkflows(workflowInstanceQuery);
}
/**

View File

@@ -2182,25 +2182,75 @@ public class ActivitiWorkflowEngine extends BPMEngine implements WorkflowEngine
@Override
public List<WorkflowInstance> getWorkflows(WorkflowInstanceQuery workflowInstanceQuery)
{
return getWorkflows(workflowInstanceQuery, 0, 0);
}
@Override
public List<WorkflowInstance> getWorkflows(WorkflowInstanceQuery workflowInstanceQuery, int maxItems, int skipCount)
{
LinkedList<WorkflowInstance> results = new LinkedList<WorkflowInstance>();
if (Boolean.FALSE.equals(workflowInstanceQuery.getActive()) == false)
{
//Add active.
results.addAll(getWorkflowsInternal(workflowInstanceQuery, true));
results.addAll(getWorkflowsInternal(workflowInstanceQuery, true, maxItems, skipCount));
}
if (Boolean.TRUE.equals(workflowInstanceQuery.getActive()) == false)
{
//Add complete
results.addAll(getWorkflowsInternal(workflowInstanceQuery, false));
results.addAll(getWorkflowsInternal(workflowInstanceQuery, false, maxItems, skipCount));
}
return results;
}
@SuppressWarnings("unchecked")
private List<WorkflowInstance> getWorkflowsInternal(WorkflowInstanceQuery workflowInstanceQuery, boolean isActive)
private List<WorkflowInstance> getWorkflowsInternal(WorkflowInstanceQuery workflowInstanceQuery, boolean isActive, int maxItems, int skipCount)
{
// MNT-9074 My Tasks fails to render if tasks quantity is excessive
HistoricProcessInstanceQuery query = createQuery(workflowInstanceQuery, isActive);
LinkedList<WorkflowInstance> results = new LinkedList<WorkflowInstance>();
List<HistoricProcessInstance> completedInstances;
if (maxItems > 0)
{
completedInstances = query.orderByProcessInstanceDuration().desc().listPage(skipCount, maxItems);
}
else
{
completedInstances = query.list();
}
List<WorkflowInstance> completedResults = typeConverter.convert(completedInstances);
results.addAll(completedResults);
return results;
}
@Override
public long countWorkflows(WorkflowInstanceQuery workflowInstanceQuery)
{
// MNT-9074 My Tasks fails to render if tasks quantity is excessive
long total = 0;
if (Boolean.FALSE.equals(workflowInstanceQuery.getActive()) == false)
{
// Add active.
total += createQuery(workflowInstanceQuery, true).count();
}
if (Boolean.TRUE.equals(workflowInstanceQuery.getActive()) == false)
{
// Add complete
total += createQuery(workflowInstanceQuery, false).count();
}
return total;
}
@SuppressWarnings("unchecked")
private HistoricProcessInstanceQuery createQuery(WorkflowInstanceQuery workflowInstanceQuery, boolean isActive)
{
// MNT-9074 My Tasks fails to render if tasks quantity is excessive
String processDefId = workflowInstanceQuery.getWorkflowDefinitionId() == null ? null : createLocalId(workflowInstanceQuery.getWorkflowDefinitionId());
HistoricProcessInstanceQuery query;
@@ -2324,8 +2374,7 @@ public class ActivitiWorkflowEngine extends BPMEngine implements WorkflowEngine
}
}
List<HistoricProcessInstance> completedInstances = query.list();
return typeConverter.convert(completedInstances);
return query;
}
/**

View File

@@ -876,8 +876,16 @@ public class JBPMEngine extends AlfrescoBpmEngine implements WorkflowEngine
}
@Override
public List<WorkflowInstance> getWorkflows(final WorkflowInstanceQuery query)
public List<WorkflowInstance> getWorkflows(WorkflowInstanceQuery workflowInstanceQuery)
{
return getWorkflows(workflowInstanceQuery, 0, 0);
}
@Override
public List<WorkflowInstance> getWorkflows(final WorkflowInstanceQuery query, int maxItems, int skipCount)
{
// MNT-9074 My Tasks fails to render if tasks quantity is excessive
// here don't use maxItems and skipCount
try
{
List<ProcessInstance> instances = getProcessInstances(query);
@@ -891,6 +899,13 @@ public class JBPMEngine extends AlfrescoBpmEngine implements WorkflowEngine
}
}
@Override
public long countWorkflows(WorkflowInstanceQuery workflowInstanceQuery)
{
// MNT-9074 My Tasks fails to render if tasks quantity is excessive
return getWorkflows(workflowInstanceQuery).size();
}
@SuppressWarnings("unchecked")
private List<ProcessInstance> getProcessInstances(final WorkflowInstanceQuery query)
{

View File

@@ -245,6 +245,25 @@ public interface WorkflowService
*/
public List<WorkflowInstance> getWorkflows(WorkflowInstanceQuery workflowInstanceQuery);
/**
* Gets maxItems "in-flight" workflow instances according to the specified workflowInstanceQuery parameter
* Get maxItems and skipCount parameters form request
*
* @param workflowInstanceQuery
* @param maxItems
* @param skipCount
* @return maxItems workflow instances
*/
public List<WorkflowInstance> getWorkflows(WorkflowInstanceQuery workflowInstanceQuery, int maxItems, int skipCount);
/**
* Get count of workflow instances
*
* @param workflowInstanceQuery
* @return count of workflow instances
*/
public long countWorkflows(WorkflowInstanceQuery workflowInstanceQuery);
/**
* Gets all active workflow instances.
*