]> git.aero2k.de Git - tmp/jakarta-migration.git/commitdiff
CSPACE-5130: Adding special case code for Vocabulary item since we've decided to...
authorRichard Millet <remillet@berkeley.edu>
Thu, 3 May 2012 19:56:31 +0000 (12:56 -0700)
committerRichard Millet <remillet@berkeley.edu>
Thu, 3 May 2012 19:56:31 +0000 (12:56 -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/client/java/RemoteDocumentModelHandlerImpl.java
services/vocabulary/service/src/main/java/org/collectionspace/services/vocabulary/VocabularyResource.java

index 8f60e0359e68eb8d661f7eae31ce678ebe39e034..0fe7c37d7a0e30341c233c37a115939ecc409e71 100644 (file)
@@ -649,6 +649,20 @@ public abstract class AuthorityResource<AuthCommon, AuthItemHandler>
         return result.getBytes();
     }
 
+    /*
+     * Most of the authority child classes will use this method.  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() {
+               String result = null;
+
+               result = NuxeoUtils.getPrimaryElPathPropertyName(
+                               authorityItemCommonSchemaName, getItemTermInfoGroupXPathBase(),
+                               AuthorityItemJAXBSchema.TERM_DISPLAY_NAME);
+
+               return result;
+       }
+    
     /**
      * Gets the authorityItem list for the specified authority
      * If partialPerm is specified, keywords will be ignored.
@@ -672,9 +686,7 @@ 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 =
-                    NuxeoUtils.getPrimaryElPathPropertyName(authorityItemCommonSchemaName,
-                        getItemTermInfoGroupXPathBase(), AuthorityItemJAXBSchema.TERM_DISPLAY_NAME);
+            String qualifiedDisplayNameField = getQualifiedDisplayNameField();
 
             // Note that docType defaults to the ServiceName, so we're fine with that.
             ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx = null;
index fb58dcd1af884995606e2ae04a163b8570eada43..904a67307beec4dc6549cf62dfe8ef78d19e98a3 100644 (file)
@@ -154,7 +154,7 @@ public abstract class AuthorityItemDocumentModelHandler<AICommon>
         for (int i = 0; i < nFields; i++) {
             ListResultField field = list.get(i);
             String elName = field.getElement();
-            if (AuthorityItemJAXBSchema.TERM_DISPLAY_NAME.equals(elName)) {
+            if (AuthorityItemJAXBSchema.TERM_DISPLAY_NAME.equals(elName)) { //FIXME: Add a special if-case for Vocabulary item's displayName
                 hasDisplayName = true;
             } else if (AuthorityItemJAXBSchema.SHORT_IDENTIFIER.equals(elName)) {
                 hasShortId = true;
@@ -167,7 +167,7 @@ public abstract class AuthorityItemDocumentModelHandler<AICommon>
         ListResultField field;
         if (!hasDisplayName) {
             field = new ListResultField();
-            // Per CSPACE-5132, the name of this element remains 'displayName'
+            // Per CSPACE-5132, the name of this element remains 'displayName' //FIXME: Add a special case again for Vocab item's displayName
             // for backwards compatibility, although its value is obtained
             // from the termDisplayName field.
             //
@@ -238,7 +238,7 @@ public abstract class AuthorityItemDocumentModelHandler<AICommon>
         // First, get a copy of the old displayName
         // oldDisplayNameOnUpdate = (String) wrapDoc.getWrappedObject().getProperty(authorityItemCommonSchemaName,
         //        AuthorityItemJAXBSchema.DISPLAY_NAME);
-        oldDisplayNameOnUpdate = (String) getStringValueInPrimaryRepeatingComplexProperty(
+        oldDisplayNameOnUpdate = (String) getStringValueInPrimaryRepeatingComplexProperty( //FIXME - This won't work for vocabulary items
                 wrapDoc.getWrappedObject(), authorityItemCommonSchemaName,
                 getItemTermInfoGroupXPathBase(),
                 AuthorityItemJAXBSchema.TERM_DISPLAY_NAME);
@@ -248,7 +248,7 @@ public abstract class AuthorityItemDocumentModelHandler<AICommon>
         // handleComputedDisplayNames(wrapDoc.getWrappedObject());
         // String newDisplayName = (String) wrapDoc.getWrappedObject().getProperty(authorityItemCommonSchemaName,
         //        AuthorityItemJAXBSchema.DISPLAY_NAME);
-        String newDisplayName = (String) getStringValueInPrimaryRepeatingComplexProperty(
+        String newDisplayName = (String) getStringValueInPrimaryRepeatingComplexProperty( //FIXME - This won't work for vocabulary items
                 wrapDoc.getWrappedObject(), authorityItemCommonSchemaName,
                 this.authorityItemTermGroupXPathBase,
                 AuthorityItemJAXBSchema.TERM_DISPLAY_NAME);
@@ -268,9 +268,9 @@ public abstract class AuthorityItemDocumentModelHandler<AICommon>
      * @param docModel the doc model
      * @throws Exception the exception
      */
-    protected void handleComputedDisplayNames(DocumentModel docModel) throws Exception {
-        // Do nothing by default.
-    }
+//    protected void handleComputedDisplayNames(DocumentModel docModel) throws Exception {
+//        // Do nothing by default.
+//    }
 
     /**
      * Handle refName updates for changes to display name.
@@ -331,12 +331,12 @@ public abstract class AuthorityItemDocumentModelHandler<AICommon>
     private void handleDisplayNameAsShortIdentifier(DocumentModel docModel, String schemaName) throws Exception {
         String shortIdentifier = (String) docModel.getProperty(schemaName, AuthorityItemJAXBSchema.SHORT_IDENTIFIER);
         String termDisplayName =
-                (String) getStringValueInPrimaryRepeatingComplexProperty(
+                (String) getStringValueInPrimaryRepeatingComplexProperty( //FIXME - This won't work for vocabulary items
                     docModel, authorityItemCommonSchemaName,
                     getItemTermInfoGroupXPathBase(),
                     AuthorityItemJAXBSchema.TERM_DISPLAY_NAME);
         String termName = 
-                (String) getStringValueInPrimaryRepeatingComplexProperty(
+                (String) getStringValueInPrimaryRepeatingComplexProperty( //FIXME - This won't work for vocabulary items
                     docModel, authorityItemCommonSchemaName,
                     getItemTermInfoGroupXPathBase(),
                     AuthorityItemJAXBSchema.TERM_NAME);
@@ -364,7 +364,7 @@ public abstract class AuthorityItemDocumentModelHandler<AICommon>
         DocumentModel docModel = wrapDoc.getWrappedObject();
         String shortIdentifier = (String) docModel.getProperty(schemaName, AuthorityItemJAXBSchema.SHORT_IDENTIFIER);
         String displayName =
-                (String) getStringValueInPrimaryRepeatingComplexProperty(
+                (String) getStringValueInPrimaryRepeatingComplexProperty( //FIXME - This won't work for vocabulary items
                     docModel, authorityItemCommonSchemaName,
                     getItemTermInfoGroupXPathBase(),
                     AuthorityItemJAXBSchema.TERM_DISPLAY_NAME);
index 8717b8af20a54d324628449ef36aa689558a15f4..95d82fb240d4e67742bd5799dbcd08b01d8e7ea1 100644 (file)
@@ -671,7 +671,7 @@ public abstract class   RemoteDocumentModelHandlerImpl<T, TL>
      * @param listName The name of the scalar list property
      * @return first value in list, as a String, or empty string if the list is empty
      */
-    protected String getStringValueInPrimaryRepeatingComplexProperty(
+    protected String getStringValueInPrimaryRepeatingComplexProperty( //FIXME - This won't work for vocabulary items
                DocumentModel docModel, String schema, String complexPropertyName, String fieldName) {
        String xpath = "/" + NuxeoUtils.getPrimaryXPathPropertyName(schema, complexPropertyName, fieldName);
        try {
index cca28407f43c460ff79e1c6f1a3b46d0f14994dc..c2f448da2d39b0ae0b947b85e2a73326ba9420c9 100644 (file)
@@ -25,7 +25,9 @@ package org.collectionspace.services.vocabulary;
 
 import org.collectionspace.services.client.VocabularyClient;
 import org.collectionspace.services.common.context.ServiceBindingUtils;
+import org.collectionspace.services.common.vocabulary.AuthorityItemJAXBSchema;
 import org.collectionspace.services.common.vocabulary.AuthorityResource;
+import org.collectionspace.services.nuxeo.util.NuxeoUtils;
 import org.collectionspace.services.vocabulary.nuxeo.VocabularyItemDocumentModelHandler;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -74,11 +76,21 @@ public class VocabularyResource extends
     protected String getRefPropName() {
        return ServiceBindingUtils.TERM_REF_PROP;
     }
+       
+       protected String getQualifiedDisplayNameField() {
+               String result = null;
 
+               result = authorityItemCommonSchemaName + ":" + VocabularyItemJAXBSchema.DISPLAY_NAME;
+
+               return result;
+       }       
+
+       /*
+        * The item schema for the Vocabulary service does not support a multi-valued term list.  Only authorities that support
+        * term lists need to implement this method.
+        */
        @Override
        public String getItemTermInfoGroupXPathBase() {
-               // TODO Auto-generated method stub
-               return VocabularyClient.TERM_INFO_GROUP_XPATH_BASE;
+               throw new UnsupportedOperationException("operation not relevant for AccountDocumentHandler");
        }
-    
 }