]> git.aero2k.de Git - tmp/jakarta-migration.git/commitdiff
CSPACE-705: Default sorting was still not functioning for ALL services. If the defau...
authorRichard Millet <richard.millet@berkeley.edu>
Tue, 8 Mar 2011 05:54:27 +0000 (05:54 +0000)
committerRichard Millet <richard.millet@berkeley.edu>
Tue, 8 Mar 2011 05:54:27 +0000 (05:54 +0000)
services/common/src/main/java/org/collectionspace/services/common/document/DocumentFilter.java
services/common/src/main/java/org/collectionspace/services/nuxeo/client/java/RepositoryJavaClientImpl.java

index 841204551f790e2b771bf4e3e132b946d822a2f9..1ff4415eaae177a9b7c6473e0e65a53977cf29a1 100644 (file)
@@ -43,6 +43,7 @@ public class DocumentFilter {
     /** The order by clause. */\r
     protected String orderByClause;    // Filtering clause. Omit the "ORDER BY".\r
     public static final String EMPTY_ORDER_BY_CLAUSE = "";\r
+    public static final String ORDER_BY_LAST_UPDATED = "collectionspace_core:updatedAt DESC";\r
     /** The start page. */\r
     protected int startPage;           // Pagination offset for list results\r
     /** The page size. */\r
index 427a8a9a207c9d37349bae95824a4a032388d4d2..a83eac3b6d250a5d8264ad75b33addae8f03a7c6 100644 (file)
@@ -568,6 +568,14 @@ public class RepositoryJavaClientImpl implements RepositoryClient {
             }
         }
     }
+    
+    private boolean isClauseEmpty(String theString) {
+       boolean result = true;
+       if (theString != null && !theString.isEmpty()) {
+               result = false;
+       }
+       return result;
+    }
 
     /**
      * getFiltered get all documents for an entity service from the Document repository,
@@ -581,10 +589,10 @@ public class RepositoryJavaClientImpl implements RepositoryClient {
     public void getFiltered(ServiceContext ctx, DocumentHandler handler)
             throws DocumentNotFoundException, DocumentException {
 
-        DocumentFilter filter =  handler.getDocumentFilter();
+        DocumentFilter filter = handler.getDocumentFilter();
         String oldOrderBy = filter.getOrderByClause();
-        if (oldOrderBy!=null && oldOrderBy.isEmpty()){
-            filter.setOrderByClause("collectionspace_core:updatedAt DESC");  //per http://issues.collectionspace.org/browse/CSPACE-705
+        if (isClauseEmpty(oldOrderBy) == true){
+            filter.setOrderByClause(DocumentFilter.ORDER_BY_LAST_UPDATED);  //per http://issues.collectionspace.org/browse/CSPACE-705
         }
         QueryContext queryContext = new QueryContext(ctx, handler);
         RepositoryInstance repoSession = null;