DocumentFilter myFilter = handler.getDocumentFilter();
// Need to make the default sort order for authority items
// be on the displayName field
- String sortBy = queryParams.getFirst(IClientQueryParams.SORT_BY_PARAM);
+ String sortBy = queryParams.getFirst(IClientQueryParams.ORDER_BY_PARAM);
if (sortBy == null || sortBy.isEmpty()) {
String qualifiedDisplayNameField = authorityCommonSchemaName + ":"
+ AuthorityItemJAXBSchema.DISPLAY_NAME;
@Produces("application/xml")
public AbstractCommonList getAuthorityItemList(@PathParam("csid") String specifier,
@Context UriInfo ui) {
+ AbstractCommonList result = null;
+
try {
MultivaluedMap<String, String> queryParams = ui.getQueryParameters();
- String partialTerm = queryParams.getFirst(IQueryManager.SEARCH_TYPE_PARTIALTERM);
+ String orderBy = queryParams.getFirst(IClientQueryParams.ORDER_BY_PARAM);
String termStatus = queryParams.getFirst(SEARCH_TYPE_TERMSTATUS);
String keywords = queryParams.getFirst(IQueryManager.SEARCH_TYPE_KEYWORDS_KW);
String advancedSearch = queryParams.getFirst(IQueryManager.SEARCH_TYPE_KEYWORDS_AS);
+ String partialTerm = queryParams.getFirst(IQueryManager.SEARCH_TYPE_PARTIALTERM);
- // Note that docType defaults to the ServiceName, so we're fine with that.
- ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx = null;
-
- String parentcsid = PARENT_WILDCARD.equals(specifier)?null:
- lookupParentCSID(specifier, "getAuthorityItemList", "LIST", queryParams);
-
- ctx = createServiceContext(getItemServiceName(), queryParams);
-
+ ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx = createServiceContext(getItemServiceName(), queryParams);
// For the wildcard case, parentcsid is null, but docHandler will deal with this.
// We omit the parentShortId, only needed when doing a create...
- DocumentHandler<?, AbstractCommonList, DocumentModel, DocumentModelList> handler = createItemDocumentHandler(ctx, parentcsid, null);
+ String parentcsid = PARENT_WILDCARD.equals(specifier) ? null :
+ lookupParentCSID(specifier, "getAuthorityItemList", "LIST", queryParams);
+ DocumentHandler<?, AbstractCommonList, DocumentModel, DocumentModelList> handler =
+ createItemDocumentHandler(ctx, parentcsid, null);
DocumentFilter myFilter = handler.getDocumentFilter();
- // Need to make the default sort order for authority items
- // be on the displayName field
- String sortBy = queryParams.getFirst(IClientQueryParams.SORT_BY_PARAM);
- if (sortBy == null || sortBy.isEmpty()) {
- String orderByField = getOrderByField();
- myFilter.setOrderByClause(orderByField);
- }
-
// If we are not wildcarding the parent, add a restriction
- if(parentcsid!=null) {
+ if (parentcsid != null) {
myFilter.appendWhereClause(authorityItemCommonSchemaName + ":"
+ AuthorityItemJAXBSchema.IN_AUTHORITY + "="
+ "'" + parentcsid + "'",
String tsClause = QueryManager.createWhereClauseToFilterFromStringList(qualifiedTermStatusField, filterTerms, IQueryManager.FILTER_EXCLUDE);
myFilter.appendWhereClause(tsClause, IQueryManager.SEARCH_QUALIFIER_AND);
}
-
- // AND vocabularyitems_common:displayName LIKE '%partialTerm%'
- // NOTE: Partial terms searches are mutually exclusive to keyword and advanced-search, but
- // the PT query param trumps the KW and AS query params.
- if (partialTerm != null && !partialTerm.isEmpty()) {
- String partialTermMatchField = getPartialTermMatchField();
- String ptClause = QueryManager.createWhereClauseForPartialMatch(
- partialTermMatchField, partialTerm);
- myFilter.appendWhereClause(ptClause, IQueryManager.SEARCH_QUALIFIER_AND);
- } else if (keywords != null || advancedSearch != null) {
-// String kwdClause = QueryManager.createWhereClauseFromKeywords(keywords);
-// myFilter.appendWhereClause(kwdClause, IQueryManager.SEARCH_QUALIFIER_AND);
- return search(ctx, handler, queryParams, keywords, advancedSearch);
- }
- if (logger.isDebugEnabled()) {
- logger.debug("getAuthorityItemList filtered WHERE clause: "
- + myFilter.getWhereClause()
- + " and ORDER BY clause: " + myFilter.getOrderByClause());
- }
- getRepositoryClient(ctx).getFiltered(ctx, handler);
- return handler.getCommonPartList();
+
+ result = search(ctx, handler, queryParams, orderBy, keywords, advancedSearch, partialTerm);
} catch (Exception e) {
throw bigReThrow(e, ServiceMessages.LIST_FAILED);
}
+
+ return result;
}
/**
@GET\r
@Produces({"application/xml"})\r
ClientResponse<CLT> readList(\r
- @QueryParam(IClientQueryParams.SORT_BY_PARAM) String sortBy,\r
+ @QueryParam(IClientQueryParams.ORDER_BY_PARAM) String sortBy,\r
@QueryParam(IClientQueryParams.PAGE_SIZE_PARAM) Long pageSize,\r
@QueryParam(IClientQueryParams.START_PAGE_PARAM) Long pageNumber); \r
}\r
\r
public static final String PAGE_SIZE_PARAM = "pgSz";\r
public static final String START_PAGE_PARAM = "pgNum";\r
- public static final String SORT_BY_PARAM = "sortBy";\r
+ public static final String ORDER_BY_PARAM = "sortBy";\r
public static final String IMPORT_TIMEOUT_PARAM = "impTimout";\r
\r
}\r
*/\r
package org.collectionspace.services.common;\r
\r
+import org.collectionspace.services.client.IClientQueryParams;\r
import org.collectionspace.services.client.IQueryManager;\r
import org.collectionspace.services.client.PoxPayloadIn;\r
import org.collectionspace.services.client.PoxPayloadOut;\r
@GET\r
public AbstractCommonList getList(@Context UriInfo ui) {\r
MultivaluedMap<String, String> queryParams = ui.getQueryParameters();\r
+ String orderBy = queryParams.getFirst(IClientQueryParams.ORDER_BY_PARAM);\r
String keywords = queryParams.getFirst(IQueryManager.SEARCH_TYPE_KEYWORDS_KW);\r
String advancedSearch = queryParams.getFirst(IQueryManager.SEARCH_TYPE_KEYWORDS_AS);\r
String partialTerm = queryParams.getFirst(IQueryManager.SEARCH_TYPE_PARTIALTERM);\r
\r
AbstractCommonList list;\r
if (keywords != null || advancedSearch != null) {\r
- list = search(queryParams, keywords, advancedSearch);\r
+ list = search(queryParams, orderBy, keywords, advancedSearch, partialTerm);\r
} else {\r
list = getList(queryParams);\r
}\r
}\r
}\r
\r
- protected AbstractCommonList search(ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx,\r
+ protected AbstractCommonList search(\r
+ ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx,\r
DocumentHandler handler, \r
MultivaluedMap<String, String> queryParams,\r
+ String orderBy,\r
String keywords,\r
String advancedSearch,\r
String partialTerm) throws Exception {\r
+ DocumentFilter docFilter = handler.getDocumentFilter(); \r
+ if (orderBy == null || orderBy.isEmpty()) {\r
+ String orderByField = getOrderByField(ctx);\r
+ docFilter.setOrderByClause(orderByField);\r
+ }\r
\r
- DocumentFilter docFilter = handler.getDocumentFilter();\r
+ //\r
+ //NOTE: Partial-term (PT) searches are mutually exclusive to keyword and advanced-search, but\r
+ // the PT query param trumps the keyword search.\r
+ //\r
if (partialTerm != null && !partialTerm.isEmpty()) {\r
- String partialTermMatchField = getPartialTermMatchField();\r
+ String partialTermMatchField = getPartialTermMatchField(ctx);\r
String ptClause = QueryManager.createWhereClauseForPartialMatch(\r
partialTermMatchField, partialTerm);\r
docFilter.appendWhereClause(ptClause, IQueryManager.SEARCH_QUALIFIER_AND);\r
}\r
}\r
}\r
- \r
+ \r
//\r
- // Add an advance search clause if one was specified\r
+ // Add an advance search clause if one was specified -even if PT search was requested?\r
//\r
if (advancedSearch != null && !advancedSearch.isEmpty()) {\r
String whereClause = QueryManager.createWhereClauseFromAdvancedSearch(advancedSearch);\r
logger.debug("The WHERE clause is: " + docFilter.getWhereClause());\r
}\r
}\r
- getRepositoryClient(ctx).getFiltered(ctx, handler);\r
\r
+ getRepositoryClient(ctx).getFiltered(ctx, handler); \r
return (AbstractCommonList) handler.getCommonPartList();\r
}\r
\r
- protected AbstractCommonList search(MultivaluedMap<String, String> queryParams,\r
+ private AbstractCommonList search(\r
+ MultivaluedMap<String, String> queryParams,\r
+ String orderBy,\r
String keywords,\r
String advancedSearch,\r
String partialTerm) {\r
- ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx;\r
- AbstractCommonList result = null;\r
- try {\r
- ctx = createServiceContext(queryParams);\r
- DocumentHandler handler = createDocumentHandler(ctx);\r
- result = search(ctx, handler, queryParams, keywords, advancedSearch, partialTerm);\r
- } catch (Exception e) {\r
- throw bigReThrow(e, ServiceMessages.SEARCH_FAILED);\r
- }\r
- return result;\r
+ AbstractCommonList result = null;\r
+\r
+ ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx;\r
+ try {\r
+ ctx = createServiceContext(queryParams);\r
+ DocumentHandler handler = createDocumentHandler(ctx);\r
+ result = search(ctx, handler, queryParams, orderBy, keywords, advancedSearch, partialTerm);\r
+ } catch (Exception e) {\r
+ throw bigReThrow(e, ServiceMessages.SEARCH_FAILED);\r
+ }\r
+\r
+ return result;\r
}\r
\r
//FIXME: REM - This should not be @Deprecated since we may want to implement this -it has been on the wish list.\r
}\r
// Set the order by clause\r
String orderByStr = null;\r
- List<String> list = theQueryParams.get(IClientQueryParams.SORT_BY_PARAM);\r
+ List<String> list = theQueryParams.get(IClientQueryParams.ORDER_BY_PARAM);\r
if (list != null) {\r
orderByStr = list.get(0);\r
}\r
public String createWhereClauseToFilterFromStringList(String qualifiedField, String[] filterTerms, boolean fExclude) {\r
// Start with the qualified termStatus field\r
StringBuilder filterClause = new StringBuilder(qualifiedField);\r
- if(filterTerms.length == 1) {\r
+ if (filterTerms.length == 1) {\r
filterClause.append(fExclude?" <> '":" = '");\r
filterClause.append(filterTerms[0]);\r
filterClause.append('\''); \r
import org.collectionspace.services.common.ReflectionMapper;\r
import org.collectionspace.services.common.api.GregorianCalendarDateTimeUtils;\r
import org.collectionspace.services.common.api.Tools;\r
+import org.collectionspace.services.common.config.ServiceConfigUtils;\r
import org.collectionspace.services.common.context.AbstractServiceContextImpl;\r
+import org.collectionspace.services.common.context.ServiceContext;\r
import org.collectionspace.services.common.document.DocumentException;\r
import org.collectionspace.services.common.document.DocumentWrapper;\r
import org.collectionspace.services.common.query.QueryContext;\r
*/\r
public AbstractCommonList createAbstractCommonListImpl() throws Exception {\r
// String classname = this.commonList.getClass().getName();\r
- String classname = getDocHandlerParams().getAbstractCommonListClassname();\r
+ ServiceContext ctx = this.getServiceContext();\r
+ String classname = ServiceConfigUtils.getDocHandlerParams(ctx).getAbstractCommonListClassname();\r
if (classname == null){\r
throw new Exception("in createAbstractCommonListImpl. getDocHandlerParams().getAbstractCommonListClassname() is null");\r
}\r
\r
/** DocHandlerBase calls this method with the CSID as id */\r
public Object createItemForCommonList(DocumentModel docModel, String label, String id) throws Exception {\r
- return createItemForCommonList(getDocHandlerParams().getCommonListItemClassname(),\r
+ ServiceContext ctx = this.getServiceContext();\r
+ return createItemForCommonList(ServiceConfigUtils.getDocHandlerParams(ctx).getCommonListItemClassname(),\r
docModel, label, id, true);\r
}\r
\r
public String getSummaryFields(AbstractCommonList theCommonList) throws DocumentException {\r
- return getDocHandlerParams().getSummaryFields();\r
+ ServiceContext ctx = this.getServiceContext();\r
+ return ServiceConfigUtils.getDocHandlerParams(ctx).getSummaryFields();\r
}\r
\r
public void setListItemArrayExtended(boolean isExtended) throws DocumentException {\r
- getDocHandlerParams().getListResultsFields().setExtended(isExtended);\r
+ ServiceContext ctx = this.getServiceContext();\r
+ ServiceConfigUtils.getDocHandlerParams(ctx).getListResultsFields().setExtended(isExtended);\r
}\r
\r
public boolean isListItemArrayExtended() throws DocumentException {\r
- return getDocHandlerParams().getListResultsFields().isExtended();\r
+ ServiceContext ctx = this.getServiceContext();\r
+ return ServiceConfigUtils.getDocHandlerParams(ctx).getListResultsFields().isExtended();\r
}\r
\r
public List<ListResultField> getListItemsArray() throws DocumentException {\r
- return getDocHandlerParams().getListResultsFields().getListResultField();\r
+ ServiceContext ctx = this.getServiceContext();\r
+ return ServiceConfigUtils.getDocHandlerParams(ctx).getListResultsFields().getListResultField();\r
}\r
\r
@Override\r
// TODO - get rid of this if we can - appears to be unused.\r
@Override\r
public String getQProperty(String prop) throws DocumentException {\r
- return getDocHandlerParams().getSchemaName() + ":" + prop;\r
+ ServiceContext ctx = this.getServiceContext();\r
+ return ServiceConfigUtils.getDocHandlerParams(ctx).getSchemaName() + ":" + prop;\r
}\r
\r
//============= dublin core handling =======================================\r
protected void fillDublinCoreObject(DocumentWrapper<DocumentModel> wrapDoc) throws Exception {\r
DocHandlerParams.Params docHandlerParams = null;\r
try {\r
- docHandlerParams = getDocHandlerParams();\r
+ docHandlerParams = ServiceConfigUtils.getDocHandlerParams(getServiceContext());\r
} catch (Exception e) {\r
logger.warn(e.getMessage());\r
}\r
\r
if (docHandlerParams != null) {\r
- String title = getDocHandlerParams().getDublinCoreTitle();\r
+ String title = docHandlerParams.getDublinCoreTitle();\r
if (Tools.isEmpty(title) == false){\r
DocumentModel docModel = wrapDoc.getWrappedObject();\r
docModel.setPropertyValue("dublincore:title", title);\r
* field for you if specified.\r
*/\r
public List createItemsList(AbstractCommonList commonList) throws Exception {\r
+ ServiceContext ctx = this.getServiceContext();\r
return createItemsList(commonList, \r
- getDocHandlerParams().getListResultsItemMethodName());\r
+ ServiceConfigUtils.getDocHandlerParams(ctx).getListResultsItemMethodName());\r
}\r
\r
/** e.g. createItemsList(commonList, "getObjectexitListItem" */\r
DocHandlerParams.Params params = null;
try {
- params = getDocHandlerParams();
+ ServiceContext ctx = this.getServiceContext();
+ params = ServiceConfigUtils.getDocHandlerParams(ctx);
Boolean bool = params.isSupportsHierarchy();
if (bool != null) {
result = bool.booleanValue();
@GET
@Produces({"application/xml"})
ClientResponse<AbstractCommonList> readListSortedBy(
- @QueryParam(IClientQueryParams.SORT_BY_PARAM) String sortFieldName);
+ @QueryParam(IClientQueryParams.ORDER_BY_PARAM) String sortFieldName);
@Override
@GET
@Produces({"application/xml"})
ClientResponse<AbstractCommonList> keywordSearchSortedBy(
@QueryParam(IQueryManager.SEARCH_TYPE_KEYWORDS_KW) String keywords,
- @QueryParam(IClientQueryParams.SORT_BY_PARAM) String sortFieldName);
+ @QueryParam(IClientQueryParams.ORDER_BY_PARAM) String sortFieldName);
}
@QueryParam(IRelationsManager.PREDICATE_QP) String predicate,
@QueryParam(IRelationsManager.OBJECT_QP) String objectCsid,
@QueryParam(IRelationsManager.OBJECT_TYPE_QP) String objectType,
- @QueryParam(IClientQueryParams.SORT_BY_PARAM) String sortBy,
+ @QueryParam(IClientQueryParams.ORDER_BY_PARAM) String sortBy,
@QueryParam(IClientQueryParams.PAGE_SIZE_PARAM) Long pageSize,
@QueryParam(IClientQueryParams.START_PAGE_PARAM) Long pageNumber);
}
*/
package org.collectionspace.services.vocabulary;
+import org.collectionspace.services.client.PoxPayloadIn;
+import org.collectionspace.services.client.PoxPayloadOut;
import org.collectionspace.services.client.VocabularyClient;
import org.collectionspace.services.common.context.ServiceBindingUtils;
+import org.collectionspace.services.common.context.ServiceContext;
//import org.collectionspace.services.common.vocabulary.AuthorityItemJAXBSchema;
import org.collectionspace.services.common.vocabulary.AuthorityResource;
//import org.collectionspace.services.nuxeo.util.NuxeoUtils;
}
@Override
- protected String getOrderByField() {
+ protected String getOrderByField(ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx) {
String result = null;
result = authorityItemCommonSchemaName + ":" + VocabularyItemJAXBSchema.DISPLAY_NAME;
}
@Override
- protected String getPartialTermMatchField() {
- return getOrderByField();
+ protected String getPartialTermMatchField(ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx) {
+ return getOrderByField(ctx);
}
/*