this(ctx);\r
whereClause = theWhereClause;\r
}\r
+ \r
+ /**\r
+ * Instantiates a new query context.\r
+ *\r
+ * @param ctx the ctx\r
+ * @param theWhereClause the where clause\r
+ * @param theOrderByClause the order by clause\r
+ * @throws DocumentNotFoundException the document not found exception\r
+ * @throws DocumentException the document exception\r
+ */\r
+ public QueryContext(ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx,\r
+ String theWhereClause, String theOrderByClause) throws DocumentNotFoundException, DocumentException {\r
+ this(ctx);\r
+ whereClause = theWhereClause;\r
+ orderByClause = theOrderByClause;\r
+ }\r
\r
/**\r
* Instantiates a new query context.\r
return refNameServiceTypes;\r
}\r
// Seems like a good value - no real data to set this well.\r
- // private static final int N_OBJS_TO_UPDATE_PER_LOOP = 100;\r
- // FIXME: This value is set to 3 during debugging; needs to be set higher during production - ADR 2012-07-10\r
- private static final int N_OBJS_TO_UPDATE_PER_LOOP = 3;\r
+ // Note: can set this value lower; e.g. to 3 during debugging; - ADR 2012-07-10\r
+ private static final int N_OBJS_TO_UPDATE_PER_LOOP = 100;\r
\r
public static int updateAuthorityRefDocs(\r
ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx,\r
// Now we have to issue the search\r
RepositoryJavaClientImpl nuxeoRepoClient = (RepositoryJavaClientImpl) repoClient;\r
DocumentWrapper<DocumentModelList> docListWrapper = nuxeoRepoClient.findDocs(ctx, repoSession,\r
- docTypes, query, pageSize, pageNum, computeTotal);\r
+ docTypes, query, orderByClause, pageSize, pageNum, computeTotal);\r
// Now we gather the info for each document into the list and return\r
DocumentModelList docList = docListWrapper.getWrappedObject();\r
return docList;\r
RepositoryInstance repoSession,
List<String> docTypes,
String whereClause,
- int pageSize, int pageNum, boolean computeTotal)
+ String orderByClause,
+ int pageSize,
+ int pageNum,
+ boolean computeTotal)
throws DocumentNotFoundException, DocumentException {
DocumentWrapper<DocumentModelList> wrapDoc = null;
"The findDocs() method must specify at least one DocumentType.");
}
DocumentModelList docList = null;
- QueryContext queryContext = new QueryContext(ctx, whereClause);
+ QueryContext queryContext = new QueryContext(ctx, whereClause, orderByClause);
String query = NuxeoUtils.buildNXQLQuery(docTypes, queryContext);
if (logger.isDebugEnabled()) {
logger.debug("findDocs() NXQL: "+query);
try {
repoSession = getRepositorySession(ctx);
- wrapDoc = findDocs(ctx, repoSession, docTypes, whereClause,
+ wrapDoc = findDocs(ctx, repoSession, docTypes, whereClause, null,
pageSize, pageNum, computeTotal);
} catch (IllegalArgumentException iae) {
throw iae;
query.append(docType);
}
appendNXQLWhere(query, queryContext);
- // For a set of DocTypes, there is no sensible ordering other than by updatedAt
- appendNXQLOrderBy(query, DocumentFilter.ORDER_BY_LAST_UPDATED, null);
+ if (Tools.notBlank(queryContext.getOrderByClause())) {
+ appendNXQLOrderBy(query, queryContext.getOrderByClause(), null);
+ } else {
+ // Across a set of mixed DocTypes, updatedAt is the most sensible default ordering
+ appendNXQLOrderBy(query, DocumentFilter.ORDER_BY_LAST_UPDATED, null);
+ }
// FIXME add 'order by' clause here, if appropriate
return query.toString();
}