From 576153641903cca5f1f6e7a52c3ee9334fbd5992 Mon Sep 17 00:00:00 2001 From: Aron Roberts Date: Tue, 10 Jul 2012 16:56:27 -0700 Subject: [PATCH] CSPACE-5359: findDocs now accepts an ORDER BY statement, while still defaulting to returning documents in descending order by updatedAt timestamps. When updating display names in authority references, we now obtain documents in ascending order by createdAt timestamps, which should be static for existing records. --- .../services/common/query/QueryContext.java | 16 ++++++++++++++++ .../common/vocabulary/RefNameServiceUtils.java | 7 +++---- .../client/java/RepositoryJavaClientImpl.java | 9 ++++++--- .../services/nuxeo/util/NuxeoUtils.java | 8 ++++++-- 4 files changed, 31 insertions(+), 9 deletions(-) diff --git a/services/common/src/main/java/org/collectionspace/services/common/query/QueryContext.java b/services/common/src/main/java/org/collectionspace/services/common/query/QueryContext.java index f23e1786b..b316d3c1b 100644 --- a/services/common/src/main/java/org/collectionspace/services/common/query/QueryContext.java +++ b/services/common/src/main/java/org/collectionspace/services/common/query/QueryContext.java @@ -68,6 +68,22 @@ public class QueryContext { this(ctx); whereClause = theWhereClause; } + + /** + * Instantiates a new query context. + * + * @param ctx the ctx + * @param theWhereClause the where clause + * @param theOrderByClause the order by clause + * @throws DocumentNotFoundException the document not found exception + * @throws DocumentException the document exception + */ + public QueryContext(ServiceContext ctx, + String theWhereClause, String theOrderByClause) throws DocumentNotFoundException, DocumentException { + this(ctx); + whereClause = theWhereClause; + orderByClause = theOrderByClause; + } /** * Instantiates a new query context. diff --git a/services/common/src/main/java/org/collectionspace/services/common/vocabulary/RefNameServiceUtils.java b/services/common/src/main/java/org/collectionspace/services/common/vocabulary/RefNameServiceUtils.java index 009605de2..1c86715be 100644 --- a/services/common/src/main/java/org/collectionspace/services/common/vocabulary/RefNameServiceUtils.java +++ b/services/common/src/main/java/org/collectionspace/services/common/vocabulary/RefNameServiceUtils.java @@ -291,9 +291,8 @@ public class RefNameServiceUtils { return refNameServiceTypes; } // Seems like a good value - no real data to set this well. - // private static final int N_OBJS_TO_UPDATE_PER_LOOP = 100; - // FIXME: This value is set to 3 during debugging; needs to be set higher during production - ADR 2012-07-10 - private static final int N_OBJS_TO_UPDATE_PER_LOOP = 3; + // Note: can set this value lower; e.g. to 3 during debugging; - ADR 2012-07-10 + private static final int N_OBJS_TO_UPDATE_PER_LOOP = 100; public static int updateAuthorityRefDocs( ServiceContext ctx, @@ -404,7 +403,7 @@ public class RefNameServiceUtils { // Now we have to issue the search RepositoryJavaClientImpl nuxeoRepoClient = (RepositoryJavaClientImpl) repoClient; DocumentWrapper docListWrapper = nuxeoRepoClient.findDocs(ctx, repoSession, - docTypes, query, pageSize, pageNum, computeTotal); + docTypes, query, orderByClause, pageSize, pageNum, computeTotal); // Now we gather the info for each document into the list and return DocumentModelList docList = docListWrapper.getWrappedObject(); return docList; diff --git a/services/common/src/main/java/org/collectionspace/services/nuxeo/client/java/RepositoryJavaClientImpl.java b/services/common/src/main/java/org/collectionspace/services/nuxeo/client/java/RepositoryJavaClientImpl.java index 99d590ee7..349f67636 100644 --- a/services/common/src/main/java/org/collectionspace/services/nuxeo/client/java/RepositoryJavaClientImpl.java +++ b/services/common/src/main/java/org/collectionspace/services/nuxeo/client/java/RepositoryJavaClientImpl.java @@ -475,7 +475,10 @@ public class RepositoryJavaClientImpl implements RepositoryClient docTypes, String whereClause, - int pageSize, int pageNum, boolean computeTotal) + String orderByClause, + int pageSize, + int pageNum, + boolean computeTotal) throws DocumentNotFoundException, DocumentException { DocumentWrapper wrapDoc = null; @@ -485,7 +488,7 @@ public class RepositoryJavaClientImpl implements RepositoryClient