From 4f05557a8bec4ee7ac4f41d2457cf140bf1835db Mon Sep 17 00:00:00 2001 From: Aron Roberts Date: Wed, 2 May 2012 11:58:35 -0700 Subject: [PATCH] CSPACE-5138: Add list item support for the term info group in authority items. --- .../AuthorityItemDocumentModelHandler.java | 20 ++++++++++++------- .../services/nuxeo/util/NuxeoUtils.java | 7 ++++++- 2 files changed, 19 insertions(+), 8 deletions(-) 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 f3efe483a..506d4a31d 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 @@ -144,7 +144,9 @@ public abstract class AuthorityItemDocumentModelHandler public List getListItemsArray() throws DocumentException { List 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 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 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 // 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 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 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."); 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 46393459e..520a46040 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 @@ -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; + } } } -- 2.47.3