]> git.aero2k.de Git - tmp/jakarta-migration.git/commitdiff
CSPACE-5138: Add list item support for the term info group in authority items.
authorAron Roberts <aron@socrates.berkeley.edu>
Wed, 2 May 2012 18:58:35 +0000 (11:58 -0700)
committerAron Roberts <aron@socrates.berkeley.edu>
Wed, 2 May 2012 18:58:35 +0000 (11:58 -0700)
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

index f3efe483a4c4216c4ba81b2273af70c04e6fa9f3..506d4a31d0bd2eac0463fe9ef48065946c676671 100644 (file)
@@ -144,7 +144,9 @@ public abstract class AuthorityItemDocumentModelHandler<AICommon>
     public List<ListResultField> getListItemsArray() throws DocumentException {
         List<ListResultField> list = super.getListItemsArray();
         int nFields = list.size();
-        // Ensure some common fields so do not depend upon config for general logic
+        // Ensure that each item in a list of Authority items includes
+        // a set of common fields, so we do not depend upon configuration
+        // for general logic.
         boolean hasDisplayName = false;
         boolean hasShortId = false;
         boolean hasRefName = false;
@@ -166,7 +168,9 @@ public abstract class AuthorityItemDocumentModelHandler<AICommon>
         if (!hasDisplayName) {
             field = new ListResultField();
             field.setElement(AuthorityItemJAXBSchema.TERM_DISPLAY_NAME);
-            field.setXpath(AuthorityItemJAXBSchema.DISPLAY_NAME);
+            field.setXpath(NuxeoUtils.getPrimaryXPathPropertyName(
+                    null, getItemTermInfoGroupXPathBase(), AuthorityItemJAXBSchema.TERM_DISPLAY_NAME));
+            // field.setXpath(AuthorityItemJAXBSchema.DISPLAY_NAME);
             list.add(field);
         }
         if (!hasShortId) {
@@ -184,7 +188,9 @@ public abstract class AuthorityItemDocumentModelHandler<AICommon>
         if (!hasTermStatus) {
             field = new ListResultField();
             field.setElement(AuthorityItemJAXBSchema.TERM_STATUS);
-            field.setXpath(AuthorityItemJAXBSchema.TERM_STATUS);
+            field.setXpath(NuxeoUtils.getPrimaryXPathPropertyName(
+                    null, getItemTermInfoGroupXPathBase(), AuthorityItemJAXBSchema.TERM_STATUS));
+            // field.setXpath(AuthorityItemJAXBSchema.TERM_STATUS);
             list.add(field);
         }
         return list;
@@ -228,7 +234,7 @@ public abstract class AuthorityItemDocumentModelHandler<AICommon>
         //        AuthorityItemJAXBSchema.DISPLAY_NAME);
         oldDisplayNameOnUpdate = (String) getStringValueInPrimaryRepeatingComplexProperty(
                 wrapDoc.getWrappedObject(), authorityItemCommonSchemaName,
-                this.authorityItemTermGroupXPathBase,
+                getItemTermInfoGroupXPathBase(),
                 AuthorityItemJAXBSchema.TERM_DISPLAY_NAME);
         oldRefNameOnUpdate = (String) wrapDoc.getWrappedObject().getProperty(authorityItemCommonSchemaName,
                 AuthorityItemJAXBSchema.REF_NAME);
@@ -321,12 +327,12 @@ public abstract class AuthorityItemDocumentModelHandler<AICommon>
         String termDisplayName =
                 (String) getStringValueInPrimaryRepeatingComplexProperty(
                     docModel, authorityItemCommonSchemaName,
-                    this.authorityItemTermGroupXPathBase,
+                    getItemTermInfoGroupXPathBase(),
                     AuthorityItemJAXBSchema.TERM_DISPLAY_NAME);
         String termName = 
                 (String) getStringValueInPrimaryRepeatingComplexProperty(
                     docModel, authorityItemCommonSchemaName,
-                    this.authorityItemTermGroupXPathBase,
+                    getItemTermInfoGroupXPathBase(),
                     AuthorityItemJAXBSchema.TERM_NAME);
         if (Tools.isEmpty(shortIdentifier)) {
             String generatedShortIdentifier =
@@ -354,7 +360,7 @@ public abstract class AuthorityItemDocumentModelHandler<AICommon>
         String displayName =
                 (String) getStringValueInPrimaryRepeatingComplexProperty(
                     docModel, authorityItemCommonSchemaName,
-                    this.authorityItemTermGroupXPathBase,
+                    getItemTermInfoGroupXPathBase(),
                     AuthorityItemJAXBSchema.TERM_DISPLAY_NAME);
         if (Tools.isEmpty(authorityRefBaseName)) {
             throw new Exception("Could not create the refName for this authority term, because the refName for its authority parent was empty.");
index 46393459e7729185e498398023c373e9f29e2e69..520a4604047daa88920d0652576a2e2f28627570 100644 (file)
@@ -34,6 +34,7 @@ import java.util.regex.PatternSyntaxException;
 import org.collectionspace.services.client.IQueryManager;
 import org.collectionspace.services.client.PoxPayloadIn;
 import org.collectionspace.services.client.PoxPayloadOut;
+import org.collectionspace.services.common.api.Tools;
 import org.collectionspace.services.common.context.ServiceBindingUtils;
 import org.collectionspace.services.common.context.ServiceContext;
 import org.collectionspace.services.common.document.BadRequestException;
@@ -602,6 +603,10 @@ public class NuxeoUtils {
     }
     
     static public String getPrimaryXPathPropertyName(String schema, String complexPropertyName, String fieldName) {
-       return schema + ":" + complexPropertyName + "/[0]/" + fieldName;
+        if (Tools.isBlank(schema)) {
+            return complexPropertyName + "/[0]/" + fieldName;
+        } else {
+           return schema + ":" + complexPropertyName + "/[0]/" + fieldName;
+        }
     }
 }