diff --git a/source/java/org/alfresco/util/ModelUtil.java b/source/java/org/alfresco/util/ModelUtil.java index 77fd4e55bb..f22e27a22d 100644 --- a/source/java/org/alfresco/util/ModelUtil.java +++ b/source/java/org/alfresco/util/ModelUtil.java @@ -39,9 +39,11 @@ public class ModelUtil private static final String SHARE = "Share"; private static final String TEAM = "Team"; - public static final String PAGING_TOTAL_ITEMS = "totalItems"; public static final String PAGING_MAX_ITEMS = "maxItems"; public static final String PAGING_SKIP_COUNT = "skipCount"; + public static final String PAGING_TOTAL_ITEMS = "totalItems"; + public static final String PAGING_TOTAL_ITEMS_RANGE_END = "totalItemsRangeEnd"; + public static final String PAGING_CONFIDENCE = "confidence"; /** * Returns the name of the product currently running, determined @@ -67,6 +69,34 @@ public class ModelUtil return productName; } + /** + * Returns representation of paging object + * + * @param totalItems all count of object + * @param maxItems max count of object that should be returned + * @param skipCount count of skipped objects + * @param confidence the confidence in the total, default is exact + * @param totalItemsRangeEnd if the total is a range, what is the upper end of it + * @return A model map of the details + */ + public static Map buildPaging(int totalItems, int maxItems, int skipCount, + ScriptPagingDetails.ItemsSizeConfidence confidence, int totalItemsRangeEnd) + { + HashMap model = new HashMap(); + if(confidence == null) + { + confidence = ScriptPagingDetails.ItemsSizeConfidence.EXACT; + } + + model.put(PAGING_MAX_ITEMS, maxItems); + model.put(PAGING_SKIP_COUNT, skipCount); + model.put(PAGING_TOTAL_ITEMS, totalItems); + model.put(PAGING_TOTAL_ITEMS_RANGE_END, totalItemsRangeEnd); + model.put(PAGING_CONFIDENCE, confidence); + + return model; + } + /** * Returns representation of paging object * @@ -77,13 +107,7 @@ public class ModelUtil */ public static Map buildPaging(int totalItems, int maxItems, int skipCount) { - HashMap model = new HashMap(); - - model.put(PAGING_TOTAL_ITEMS, totalItems); - model.put(PAGING_MAX_ITEMS, maxItems); - model.put(PAGING_SKIP_COUNT, skipCount); - - return model; + return buildPaging(totalItems, maxItems, skipCount, null, -1); } /** @@ -96,7 +120,9 @@ public class ModelUtil return buildPaging( paging.getTotalItems(), paging.getMaxItems(), - paging.getSkipCount() + paging.getSkipCount(), + paging.getConfidence(), + paging.getTotalItemsRangeMax() ); }