mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-14 17:58:59 +00:00
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:
@@ -18,6 +18,7 @@
|
|||||||
*/
|
*/
|
||||||
package org.alfresco.repo.web.scripts.workflow;
|
package org.alfresco.repo.web.scripts.workflow;
|
||||||
|
|
||||||
|
import java.lang.reflect.Field;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
@@ -227,7 +228,17 @@ public abstract class AbstractWorkflowWebscript extends DeclarativeWebScript
|
|||||||
protected Map<String, Object> createResultModel(WebScriptRequest req, String dataPropertyName,
|
protected Map<String, Object> createResultModel(WebScriptRequest req, String dataPropertyName,
|
||||||
List<Map<String, Object>> results)
|
List<Map<String, Object>> results)
|
||||||
{
|
{
|
||||||
int totalItems = results.size();
|
// MNT-9074 My Tasks fails to render if tasks quantity is excessive
|
||||||
|
int totalItems = 0;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
totalItems = getCapacity(results);
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
totalItems = results.size();
|
||||||
|
}
|
||||||
|
|
||||||
int maxItems = getIntParameter(req, PARAM_MAX_ITEMS, DEFAULT_MAX_ITEMS);
|
int maxItems = getIntParameter(req, PARAM_MAX_ITEMS, DEFAULT_MAX_ITEMS);
|
||||||
int skipCount = getIntParameter(req, PARAM_SKIP_COUNT, DEFAULT_SKIP_COUNT);
|
int skipCount = getIntParameter(req, PARAM_SKIP_COUNT, DEFAULT_SKIP_COUNT);
|
||||||
|
|
||||||
@@ -243,6 +254,19 @@ public abstract class AbstractWorkflowWebscript extends DeclarativeWebScript
|
|||||||
return model;
|
return model;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get capacity instaead of size of list
|
||||||
|
* MNT-9074 My Tasks fails to render if tasks quantity is excessive
|
||||||
|
* @param list
|
||||||
|
* @return capacity of list
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
private int getCapacity(List<?> list) throws Exception {
|
||||||
|
Field dataField = ArrayList.class.getDeclaredField("elementData");
|
||||||
|
dataField.setAccessible(true);
|
||||||
|
return ((Object[]) dataField.get(list)).length;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Make the pagination for given list of objects
|
* Make the pagination for given list of objects
|
||||||
*
|
*
|
||||||
|
@@ -149,16 +149,26 @@ public class WorkflowInstancesGet extends AbstractWorkflowWebscript
|
|||||||
{
|
{
|
||||||
workflowInstanceQuery.setWorkflowDefinitionId(workflowDefinitionId);
|
workflowInstanceQuery.setWorkflowDefinitionId(workflowDefinitionId);
|
||||||
}
|
}
|
||||||
workflows.addAll(workflowService.getWorkflows(workflowInstanceQuery));
|
|
||||||
|
|
||||||
// sort workflows by due date
|
// MNT-9074 My Tasks fails to render if tasks quantity is excessive
|
||||||
Collections.sort(workflows, workflowComparator);
|
int maxItems = getIntParameter(req, PARAM_MAX_ITEMS, DEFAULT_MAX_ITEMS);
|
||||||
|
int skipCount = getIntParameter(req, PARAM_SKIP_COUNT, DEFAULT_SKIP_COUNT);
|
||||||
|
|
||||||
List<Map<String, Object>> results = new ArrayList<Map<String, Object>>(workflows.size());
|
workflows.addAll(workflowService.getWorkflows(workflowInstanceQuery, maxItems, skipCount));
|
||||||
|
|
||||||
|
int total = (int) workflowService.countWorkflows(workflowInstanceQuery);
|
||||||
|
|
||||||
|
List<Map<String, Object>> results = new ArrayList<Map<String, Object>>(total);
|
||||||
|
|
||||||
|
// init empty list
|
||||||
|
results.addAll(Arrays.asList((Map<String, Object>[]) new Map[total]));
|
||||||
|
|
||||||
for (WorkflowInstance workflow : workflows)
|
for (WorkflowInstance workflow : workflows)
|
||||||
{
|
{
|
||||||
results.add(modelBuilder.buildSimple(workflow));
|
// set to special index
|
||||||
|
results.set(skipCount, modelBuilder.buildSimple(workflow));
|
||||||
|
|
||||||
|
skipCount++;
|
||||||
}
|
}
|
||||||
|
|
||||||
// create and return results, paginated if necessary
|
// create and return results, paginated if necessary
|
||||||
|
Reference in New Issue
Block a user