chemistry-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j...@apache.org
Subject svn commit: r956661 - in /incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src: main/java/org/apache/chemistry/opencmis/inmemory/query/ test/java/org/apache/chemistry/opencmis/inmemory/
Date Mon, 21 Jun 2010 18:22:36 GMT
Author: jens
Date: Mon Jun 21 18:22:35 2010
New Revision: 956661

URL: http://svn.apache.org/viewvc?rev=956661&view=rev
Log:
CMIS-216
small bug fix in paging

Modified:
    incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/query/InMemoryQueryProcessor.java
    incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/DiscoveryServiceTest.java

Modified: incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/query/InMemoryQueryProcessor.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/query/InMemoryQueryProcessor.java?rev=956661&r1=956660&r2=956661&view=diff
==============================================================================
--- incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/query/InMemoryQueryProcessor.java
(original)
+++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/query/InMemoryQueryProcessor.java
Mon Jun 21 18:22:35 2010
@@ -176,15 +176,15 @@ public class InMemoryQueryProcessor impl
         ObjectListImpl res = new ObjectListImpl();
         res.setNumItems(BigInteger.valueOf(matches.size()));
         int start = 0;
-        if (maxItems != null) 
-            start = (int)maxItems.longValue();
+        if (skipCount != null) 
+            start = (int)skipCount.longValue();
         if (start < 0)
             start = 0;
         if (start > matches.size())
             start = matches.size();
         int stop = 0;
-        if (skipCount != null) 
-            stop = (int)skipCount.longValue();
+        if (maxItems != null) 
+            stop = start + (int)maxItems.longValue();
         if (stop <= 0 || stop > matches.size())
             stop = matches.size();
         res.setHasMoreItems(stop < matches.size());

Modified: incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/DiscoveryServiceTest.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/DiscoveryServiceTest.java?rev=956661&r1=956660&r2=956661&view=diff
==============================================================================
--- incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/DiscoveryServiceTest.java
(original)
+++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/DiscoveryServiceTest.java
Mon Jun 21 18:22:35 2010
@@ -91,6 +91,7 @@ public class DiscoveryServiceTest extend
         // root + 2 at level 1 + 2*2 at level 2 = 7
         assertEquals(7, res.getObjects().size());
 
+
         /*        
         assertEquals(BigInteger.valueOf(9), res.getNumItems());
 
@@ -114,4 +115,48 @@ public class DiscoveryServiceTest extend
         log.info("... testQuery() finished.");
     }
 
+    @Test
+    public void testQueryPaging() throws Exception {
+        log.info("starting testQuery() ...");
+
+        String statement;
+        ObjectList res;
+        ObjectGenerator gen = new ObjectGenerator(fFactory, fNavSvc, fObjSvc, fRepositoryId);
+        gen.setNumberOfDocumentsToCreatePerFolder(3);
+        gen.setDocumentTypeId(TEST_DOCUMENT_TYPE_ID);
+        gen.setFolderTypeId(TEST_FOLDER_TYPE_ID);
+
+        List<String> propsToSet = new ArrayList<String>();
+        propsToSet.add(TEST_DOCUMENT_STRING_PROP_ID);
+        gen.setDocumentPropertiesToGenerate(propsToSet);
+
+        propsToSet = new ArrayList<String>();
+        propsToSet.add(TEST_FOLDER_STRING_PROP_ID);
+        gen.setFolderPropertiesToGenerate(propsToSet);
+
+        gen.createFolderHierachy(2, 2, fRootFolderId);
+
+        Boolean searchAllVersions = Boolean.FALSE;
+        Boolean includeAllowableActions = Boolean.FALSE;
+        IncludeRelationships includeRelationships = IncludeRelationships.NONE;
+        String renditionFilter = null;
+        BigInteger skipCount = BigInteger.valueOf(0);
+        BigInteger maxItems = BigInteger.valueOf(3);
+
+        int count = 0;
+        boolean hasMoreItems = true;
+        statement = "SELECT * FROM cmis:document";
+        while (hasMoreItems) {
+            res = fDiscSvc.query(fRepositoryId, statement, searchAllVersions, includeAllowableActions,
+                    includeRelationships, renditionFilter, maxItems, skipCount, null);
+            hasMoreItems = res.hasMoreItems();
+            assertEquals(3, res.getObjects().size());
+            if (res.getNumItems() != null)
+                assertEquals(9L, res.getNumItems().longValue());
+            skipCount = skipCount.add(maxItems);
+            ++count;
+        }
+        assertEquals(3, count);
+    }
+
 }



Mime
View raw message