diff src/main/java/de/mpiwg/itgroup/annotations/restlet/AnnotatorAnnotations.java @ 101:7268c3ca025b

make admin ui view of all annotations scale better.
author casties
date Fri, 13 Feb 2015 18:10:11 +0100
parents cf44d9e1a4a7
children 9140017e8962
line wrap: on
line diff
--- a/src/main/java/de/mpiwg/itgroup/annotations/restlet/AnnotatorAnnotations.java	Wed Feb 11 20:02:56 2015 +0100
+++ b/src/main/java/de/mpiwg/itgroup/annotations/restlet/AnnotatorAnnotations.java	Fri Feb 13 18:10:11 2015 +0100
@@ -84,8 +84,8 @@
         if (id == null) {
             // no id -- send all annotations
             Form form = getRequest().getResourceRef().getQueryAsForm();
-            int limit = getInt(form.getFirstValue("limit"));
-            int offset = getInt(form.getFirstValue("offset"));
+            int limit = getInt(form.getFirstValue("limit", "1000"));
+            int offset = getInt(form.getFirstValue("offset", "0"));
             String sortBy = form.getFirstValue("sortBy");
             return getAllAnnotations(authUser, limit, offset, sortBy);
         }
@@ -112,7 +112,7 @@
         ArrayList<JSONObject> results = new ArrayList<JSONObject>();
 
         // read all annotations
-        List<Annotation> annotations = store.getAnnotations(null, null);
+        List<Annotation> annotations = store.getAnnotations(null, null, 0, 0);
         for (Annotation annotation : annotations) {
             // check permission
             if (!annotation.isActionAllowed("read", authUser, store))
@@ -130,13 +130,12 @@
         // put in JSON list
         JSONArray rows = new JSONArray();
         int cnt = 0;
+        int max = limit + offset;
         for (JSONObject result : results) {
             cnt += 1;
-            if (offset > 0 && cnt < offset)
-                continue;
+            if (cnt < offset) continue;
             rows.put(result);
-            if (limit > 0 && cnt >= limit)
-                break;
+            if (limit > 0 && cnt >= max) break;
         }
 
         // assemble result object