]> git.aero2k.de Git - tmp/jakarta-migration.git/commitdiff
CSPACE-5133: Updated partial term search query to include all terms' displayName...
authorRichard Millet <remillet@berkeley.edu>
Mon, 14 May 2012 21:44:06 +0000 (14:44 -0700)
committerRichard Millet <remillet@berkeley.edu>
Mon, 14 May 2012 21:44:06 +0000 (14:44 -0700)
services/authority/service/src/main/java/org/collectionspace/services/common/vocabulary/AuthorityResource.java
services/authority/service/src/main/java/org/collectionspace/services/common/vocabulary/nuxeo/AuthorityItemDocumentModelHandler.java
services/common/src/main/java/org/collectionspace/services/nuxeo/util/NuxeoUtils.java
services/vocabulary/service/src/main/java/org/collectionspace/services/vocabulary/VocabularyResource.java

index 632600c48e99ca05ad7aae7d68ec0c6d5d330701..cdf3b4c8b579872c7db6aa4f0b3f7b801c4f41cd 100644 (file)
@@ -650,10 +650,10 @@ public abstract class AuthorityResource<AuthCommon, AuthItemHandler>
     }
 
     /*
-     * 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<AuthCommon, AuthItemHandler>
 
                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<AuthCommon, AuthItemHandler>
             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<PoxPayloadIn, PoxPayloadOut> ctx = null;
 
@@ -705,7 +713,8 @@ public abstract class AuthorityResource<AuthCommon, AuthItemHandler>
             // 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<AuthCommon, AuthItemHandler>
             // 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);
index c38ade3062b0090c790bb65262f40e263357723f..dc72d97a67d5ea6ac8c8ab84f77c8d8076249647 100644 (file)
@@ -657,27 +657,22 @@ public abstract class AuthorityItemDocumentModelHandler<AICommon>
         ctx.addOutputPart(relationsPart);
     }
 
+    @Override
     public void fillAllParts(DocumentWrapper<DocumentModel> 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<DocumentModel> wrapDoc) throws Exception {
         super.completeCreate(wrapDoc);
         handleRelationsPayload(wrapDoc, false);
     }
 
+    @Override
     public void completeUpdate(DocumentWrapper<DocumentModel> wrapDoc) throws Exception {
         super.completeUpdate(wrapDoc);
         handleRelationsPayload(wrapDoc, true);
index 598f970b7561947172760f308f8cc6adad575acf..75c42bda8424c4c05a6e02842ce46f3c4441df6b 100644 (file)
@@ -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;
+        }
+    }
+    
 }
index 0837b9c7cf9d3ce5af38bfc7f9fb2b08fa38ed91..002ef8cee0aa4b2e759fb8761dbab3f2df84925c 100644 (file)
@@ -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