From 7919edd5e21b1bf310ef2ab3dd88fdd14de72b89 Mon Sep 17 00:00:00 2001 From: Richard Millet Date: Mon, 14 May 2012 14:44:06 -0700 Subject: [PATCH] CSPACE-5133: Updated partial term search query to include all terms' displayName instead of just preferred display name. --- .../common/vocabulary/AuthorityResource.java | 22 ++++++++++++++----- .../AuthorityItemDocumentModelHandler.java | 19 ++++++---------- .../services/nuxeo/util/NuxeoUtils.java | 9 ++++++++ .../vocabulary/VocabularyResource.java | 10 +++++++-- 4 files changed, 40 insertions(+), 20 deletions(-) diff --git a/services/authority/service/src/main/java/org/collectionspace/services/common/vocabulary/AuthorityResource.java b/services/authority/service/src/main/java/org/collectionspace/services/common/vocabulary/AuthorityResource.java index 632600c48..cdf3b4c8b 100644 --- a/services/authority/service/src/main/java/org/collectionspace/services/common/vocabulary/AuthorityResource.java +++ b/services/authority/service/src/main/java/org/collectionspace/services/common/vocabulary/AuthorityResource.java @@ -650,10 +650,10 @@ public abstract class AuthorityResource } /* - * Most of the authority child classes will use this method. However, the Vocabulary service's item schema is + * Most of the authority child classes will/should use this implementation. However, the Vocabulary service's item schema is * different enough that it will have to override this method in it's resource class. */ - protected String getQualifiedDisplayNameField() { + protected String getOrderByField() { String result = null; result = NuxeoUtils.getPrimaryElPathPropertyName( @@ -662,6 +662,16 @@ public abstract class AuthorityResource return result; } + + protected String getPartialTermMatchField() { + String result = null; + + result = NuxeoUtils.getMultiElPathPropertyName( + authorityItemCommonSchemaName, getItemTermInfoGroupXPathBase(), + AuthorityItemJAXBSchema.TERM_DISPLAY_NAME); + + return result; + } /** * Gets the authorityItem list for the specified authority @@ -686,8 +696,6 @@ public abstract class AuthorityResource String keywords = queryParams.getFirst(IQueryManager.SEARCH_TYPE_KEYWORDS_KW); String advancedSearch = queryParams.getFirst(IQueryManager.SEARCH_TYPE_KEYWORDS_AS); - String qualifiedDisplayNameField = getQualifiedDisplayNameField(); - // Note that docType defaults to the ServiceName, so we're fine with that. ServiceContext ctx = null; @@ -705,7 +713,8 @@ public abstract class AuthorityResource // be on the displayName field String sortBy = queryParams.getFirst(IClientQueryParams.SORT_BY_PARAM); if (sortBy == null || sortBy.isEmpty()) { - myFilter.setOrderByClause(qualifiedDisplayNameField); + String orderByField = getOrderByField(); + myFilter.setOrderByClause(orderByField); } // If we are not wildcarding the parent, add a restriction @@ -729,8 +738,9 @@ public abstract class AuthorityResource // 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( - qualifiedDisplayNameField, partialTerm); + partialTermMatchField, partialTerm); myFilter.appendWhereClause(ptClause, IQueryManager.SEARCH_QUALIFIER_AND); } else if (keywords != null || advancedSearch != null) { // String kwdClause = QueryManager.createWhereClauseFromKeywords(keywords); diff --git a/services/authority/service/src/main/java/org/collectionspace/services/common/vocabulary/nuxeo/AuthorityItemDocumentModelHandler.java b/services/authority/service/src/main/java/org/collectionspace/services/common/vocabulary/nuxeo/AuthorityItemDocumentModelHandler.java index c38ade306..dc72d97a6 100644 --- a/services/authority/service/src/main/java/org/collectionspace/services/common/vocabulary/nuxeo/AuthorityItemDocumentModelHandler.java +++ b/services/authority/service/src/main/java/org/collectionspace/services/common/vocabulary/nuxeo/AuthorityItemDocumentModelHandler.java @@ -657,27 +657,22 @@ public abstract class AuthorityItemDocumentModelHandler ctx.addOutputPart(relationsPart); } + @Override public void fillAllParts(DocumentWrapper wrapDoc, Action action) throws Exception { + // + // We currently don't override this method with any AuthorityItemDocumentModelHandler specific functionality, so + // we could remove this method. + // super.fillAllParts(wrapDoc, action); - /* - ServiceContext ctx = getServiceContext(); - PoxPayloadIn input = (PoxPayloadIn) ctx.getInput(); - DocumentModel documentModel = (wrapDoc.getWrappedObject()); - String itemCsid = documentModel.getName(); - - //UPDATE and CREATE will call. Updates relations part - RelationsCommonList relationsCommonList = updateRelations(itemCsid, input, wrapDoc); - - PayloadOutputPart payloadOutputPart = new PayloadOutputPart(RelationClient.SERVICE_COMMON_LIST_NAME, relationsCommonList); - ctx.setProperty(RelationClient.SERVICE_COMMON_LIST_NAME, payloadOutputPart); - */ } + @Override public void completeCreate(DocumentWrapper wrapDoc) throws Exception { super.completeCreate(wrapDoc); handleRelationsPayload(wrapDoc, false); } + @Override public void completeUpdate(DocumentWrapper wrapDoc) throws Exception { super.completeUpdate(wrapDoc); handleRelationsPayload(wrapDoc, true); diff --git a/services/common/src/main/java/org/collectionspace/services/nuxeo/util/NuxeoUtils.java b/services/common/src/main/java/org/collectionspace/services/nuxeo/util/NuxeoUtils.java index 598f970b7..75c42bda8 100644 --- a/services/common/src/main/java/org/collectionspace/services/nuxeo/util/NuxeoUtils.java +++ b/services/common/src/main/java/org/collectionspace/services/nuxeo/util/NuxeoUtils.java @@ -617,4 +617,13 @@ public class NuxeoUtils { return schema + ":" + complexPropertyName + "/0/" + fieldName; } } + + static public String getMultiElPathPropertyName(String schema, String complexPropertyName, String fieldName) { + if (Tools.isBlank(schema)) { + return complexPropertyName + "/*/" + fieldName; + } else { + return schema + ":" + complexPropertyName + "/*/" + fieldName; + } + } + } diff --git a/services/vocabulary/service/src/main/java/org/collectionspace/services/vocabulary/VocabularyResource.java b/services/vocabulary/service/src/main/java/org/collectionspace/services/vocabulary/VocabularyResource.java index 0837b9c7c..002ef8cee 100644 --- a/services/vocabulary/service/src/main/java/org/collectionspace/services/vocabulary/VocabularyResource.java +++ b/services/vocabulary/service/src/main/java/org/collectionspace/services/vocabulary/VocabularyResource.java @@ -77,13 +77,19 @@ public class VocabularyResource extends return ServiceBindingUtils.TERM_REF_PROP; } - protected String getQualifiedDisplayNameField() { + @Override + protected String getOrderByField() { String result = null; result = authorityItemCommonSchemaName + ":" + VocabularyItemJAXBSchema.DISPLAY_NAME; return result; - } + } + + @Override + protected String getPartialTermMatchField() { + return getOrderByField(); + } /* * The item schema for the Vocabulary service does not support a multi-valued term list. Only authorities that support -- 2.47.3