From: Aron Roberts Date: Wed, 2 May 2012 00:32:37 +0000 (-0700) Subject: CSPACE-5119,CSPACE-5139,CSPACE-5138: Additional work on authority item base classes... X-Git-Url: https://git.aero2k.de/?a=commitdiff_plain;h=1c12331e19138183f2f38ff4a3cdf10760b24a73;p=tmp%2Fjakarta-migration.git CSPACE-5119,CSPACE-5139,CSPACE-5138: Additional work on authority item base classes (and other framework classes) to reflect term info group changes. More classes compile; some still do not. --- diff --git a/services/authority/jaxb/src/main/java/org/collectionspace/services/common/vocabulary/AuthorityItemJAXBSchema.java b/services/authority/jaxb/src/main/java/org/collectionspace/services/common/vocabulary/AuthorityItemJAXBSchema.java index 70d6e0b07..024eab8bc 100644 --- a/services/authority/jaxb/src/main/java/org/collectionspace/services/common/vocabulary/AuthorityItemJAXBSchema.java +++ b/services/authority/jaxb/src/main/java/org/collectionspace/services/common/vocabulary/AuthorityItemJAXBSchema.java @@ -36,9 +36,6 @@ public interface AuthorityItemJAXBSchema { final static String TERM_DISPLAY_NAME = "termDisplayName"; final static String TERM_NAME = "termName"; final static String TERM_STATUS = "termStatus"; - final static String PREFERRED_TERM_DISPLAY_NAME_XPATH ="termGroupList/0/termDisplayName"; - final static String PREFERRED_TERM_NAME_XPATH ="termGroupList/0/termName"; - final static String PREFERRED_TERM_STATUS_XPATH ="termGroupList/0/termStatus"; // CSPACE-4813 /* final static String DISPLAY_NAME = "displayName"; 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 a5695ce06..946bf848b 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 @@ -82,6 +82,8 @@ import javax.ws.rs.core.UriInfo; import java.util.ArrayList; import java.util.List; +import org.collectionspace.services.client.*; +import org.collectionspace.services.nuxeo.util.NuxeoUtils; /** * The Class AuthorityResource. @@ -180,6 +182,8 @@ public abstract class AuthorityResource } public abstract String getItemServiceName(); + + public abstract String getItemTermInfoGroupXPathBase(); @Override protected String getVersionString() { @@ -223,9 +227,12 @@ public abstract class AuthorityResource docHandler = (AuthorityItemDocumentModelHandler) createDocumentHandler(ctx, ctx.getCommonPartLabel(getItemServiceName()), authCommonClass); + // FIXME - Richard and Aron think the following three lines should + // be in the constructor for the AuthorityItemDocumentModelHandler + // because all three are required fields. docHandler.setInAuthority(inAuthority); docHandler.setAuthorityRefNameBase(authorityRefNameBase); - + docHandler.setItemTermInfoGroupXPathBase(getItemTermInfoGroupXPathBase()); return docHandler; } @@ -427,8 +434,7 @@ public abstract class AuthorityResource if (sortBy == null || sortBy.isEmpty()) { // String qualifiedDisplayNameField = authorityCommonSchemaName + ":" // + AuthorityItemJAXBSchema.DISPLAY_NAME; - String qualifiedDisplayNameField = AuthorityItemJAXBSchema.TERM_INFO_GROUP_SCHEMA_NAME + ":" - + AuthorityItemJAXBSchema.TERM_DISPLAY_NAME; + String qualifiedDisplayNameField = getQualifiedDisplayNameField(); myFilter.setOrderByClause(qualifiedDisplayNameField); } String nameQ = queryParams.getFirst("refName"); @@ -441,6 +447,11 @@ public abstract class AuthorityResource throw bigReThrow(e, ServiceMessages.GET_FAILED); } } + + protected String getQualifiedDisplayNameField() { + return NuxeoUtils.getPrimaryXPathPropertyName(authorityCommonSchemaName, + getItemTermInfoGroupXPathBase(), AuthorityItemJAXBSchema.TERM_DISPLAY_NAME); + } /** * Update authority. @@ -666,8 +677,7 @@ public abstract class AuthorityResource String keywords = queryParams.getFirst(IQueryManager.SEARCH_TYPE_KEYWORDS_KW); String advancedSearch = queryParams.getFirst(IQueryManager.SEARCH_TYPE_KEYWORDS_AS); - String qualifiedDisplayNameField = authorityItemCommonSchemaName + ":" - + AuthorityItemJAXBSchema.DISPLAY_NAME; + String qualifiedDisplayNameField = getQualifiedDisplayNameField(); // Note that docType defaults to the ServiceName, so we're fine with that. ServiceContext ctx = null; 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 45230aa08..f3efe483a 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 @@ -93,6 +93,7 @@ public abstract class AuthorityItemDocumentModelHandler private final Logger logger = LoggerFactory.getLogger(AuthorityItemDocumentModelHandler.class); private String authorityItemCommonSchemaName; + private String authorityItemTermGroupXPathBase; /** * inVocabulary is the parent Authority for this context */ @@ -151,7 +152,7 @@ public abstract class AuthorityItemDocumentModelHandler for (int i = 0; i < nFields; i++) { ListResultField field = list.get(i); String elName = field.getElement(); - if (AuthorityItemJAXBSchema.DISPLAY_NAME.equals(elName)) { + if (AuthorityItemJAXBSchema.TERM_DISPLAY_NAME.equals(elName)) { hasDisplayName = true; } else if (AuthorityItemJAXBSchema.SHORT_IDENTIFIER.equals(elName)) { hasShortId = true; @@ -164,7 +165,7 @@ public abstract class AuthorityItemDocumentModelHandler ListResultField field; if (!hasDisplayName) { field = new ListResultField(); - field.setElement(AuthorityItemJAXBSchema.DISPLAY_NAME); + field.setElement(AuthorityItemJAXBSchema.TERM_DISPLAY_NAME); field.setXpath(AuthorityItemJAXBSchema.DISPLAY_NAME); list.add(field); } @@ -225,16 +226,20 @@ public abstract class AuthorityItemDocumentModelHandler // First, get a copy of the old displayName // oldDisplayNameOnUpdate = (String) wrapDoc.getWrappedObject().getProperty(authorityItemCommonSchemaName, // AuthorityItemJAXBSchema.DISPLAY_NAME); - oldDisplayNameOnUpdate = (String) RemoteDocumentModelHandlerImpl.getXPathStringValue(wrapDoc.getWrappedObject(), - authorityItemCommonSchemaName, AuthorityItemJAXBSchema.PREFERRED_TERM_DISPLAY_NAME_XPATH); + oldDisplayNameOnUpdate = (String) getStringValueInPrimaryRepeatingComplexProperty( + wrapDoc.getWrappedObject(), authorityItemCommonSchemaName, + this.authorityItemTermGroupXPathBase, + AuthorityItemJAXBSchema.TERM_DISPLAY_NAME); oldRefNameOnUpdate = (String) wrapDoc.getWrappedObject().getProperty(authorityItemCommonSchemaName, AuthorityItemJAXBSchema.REF_NAME); super.handleUpdate(wrapDoc); // handleComputedDisplayNames(wrapDoc.getWrappedObject()); // String newDisplayName = (String) wrapDoc.getWrappedObject().getProperty(authorityItemCommonSchemaName, // AuthorityItemJAXBSchema.DISPLAY_NAME); - String newDisplayName = (String) RemoteDocumentModelHandlerImpl.getXPathStringValue(wrapDoc.getWrappedObject(), - authorityItemCommonSchemaName, AuthorityItemJAXBSchema.PREFERRED_TERM_DISPLAY_NAME_XPATH); + String newDisplayName = (String) getStringValueInPrimaryRepeatingComplexProperty( + wrapDoc.getWrappedObject(), authorityItemCommonSchemaName, + this.authorityItemTermGroupXPathBase, + AuthorityItemJAXBSchema.TERM_DISPLAY_NAME); if (newDisplayName != null && !newDisplayName.equals(oldDisplayNameOnUpdate)) { // Need to update the refName, and then fix all references. newRefNameOnUpdate = handleItemRefNameUpdateForDisplayName(wrapDoc.getWrappedObject(), newDisplayName); @@ -314,10 +319,15 @@ public abstract class AuthorityItemDocumentModelHandler private void handleDisplayNameAsShortIdentifier(DocumentModel docModel, String schemaName) throws Exception { String shortIdentifier = (String) docModel.getProperty(schemaName, AuthorityItemJAXBSchema.SHORT_IDENTIFIER); String termDisplayName = - (String) RemoteDocumentModelHandlerImpl.getXPathStringValue(docModel, - schemaName, AuthorityItemJAXBSchema.PREFERRED_TERM_DISPLAY_NAME_XPATH); - String termName = (String) RemoteDocumentModelHandlerImpl.getXPathStringValue(docModel, - schemaName, AuthorityItemJAXBSchema.PREFERRED_TERM_NAME_XPATH); + (String) getStringValueInPrimaryRepeatingComplexProperty( + docModel, authorityItemCommonSchemaName, + this.authorityItemTermGroupXPathBase, + AuthorityItemJAXBSchema.TERM_DISPLAY_NAME); + String termName = + (String) getStringValueInPrimaryRepeatingComplexProperty( + docModel, authorityItemCommonSchemaName, + this.authorityItemTermGroupXPathBase, + AuthorityItemJAXBSchema.TERM_NAME); if (Tools.isEmpty(shortIdentifier)) { String generatedShortIdentifier = AuthorityIdentifierUtils.generateShortIdentifierFromDisplayName(termDisplayName, termName); @@ -342,8 +352,10 @@ public abstract class AuthorityItemDocumentModelHandler DocumentModel docModel = wrapDoc.getWrappedObject(); String shortIdentifier = (String) docModel.getProperty(schemaName, AuthorityItemJAXBSchema.SHORT_IDENTIFIER); String displayName = - RemoteDocumentModelHandlerImpl.getXPathStringValue(docModel, schemaName, - AuthorityItemJAXBSchema.PREFERRED_TERM_DISPLAY_NAME_XPATH); + (String) getStringValueInPrimaryRepeatingComplexProperty( + docModel, authorityItemCommonSchemaName, + this.authorityItemTermGroupXPathBase, + 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."); } @@ -1088,4 +1100,12 @@ public abstract class AuthorityItemDocumentModelHandler return relationsCommonList; } //============================= END TODO refactor ========================== + + public String getItemTermInfoGroupXPathBase() { + return this.authorityItemTermGroupXPathBase; + } + + public void setItemTermInfoGroupXPathBase(String itemTermInfoGroupXPathBase) { + this.authorityItemTermGroupXPathBase = itemTermInfoGroupXPathBase; + } } diff --git a/services/common/src/main/java/org/collectionspace/services/nuxeo/client/java/RemoteDocumentModelHandlerImpl.java b/services/common/src/main/java/org/collectionspace/services/nuxeo/client/java/RemoteDocumentModelHandlerImpl.java index e00c93c71..8717b8af2 100644 --- a/services/common/src/main/java/org/collectionspace/services/nuxeo/client/java/RemoteDocumentModelHandlerImpl.java +++ b/services/common/src/main/java/org/collectionspace/services/nuxeo/client/java/RemoteDocumentModelHandlerImpl.java @@ -60,6 +60,7 @@ import org.collectionspace.services.common.vocabulary.RefNameUtils; import org.collectionspace.services.common.vocabulary.RefNameServiceUtils; import org.collectionspace.services.common.vocabulary.RefNameServiceUtils.AuthRefConfigInfo; import org.collectionspace.services.config.service.ObjectPartType; +import org.collectionspace.services.nuxeo.util.NuxeoUtils; import org.dom4j.Element; import org.nuxeo.ecm.core.api.DocumentModel; @@ -672,7 +673,7 @@ public abstract class RemoteDocumentModelHandlerImpl */ protected String getStringValueInPrimaryRepeatingComplexProperty( DocumentModel docModel, String schema, String complexPropertyName, String fieldName) { - String xpath = "/"+schema+":"+complexPropertyName+"/[0]/"+fieldName; + String xpath = "/" + NuxeoUtils.getPrimaryXPathPropertyName(schema, complexPropertyName, fieldName); try { return (String)docModel.getPropertyValue(xpath); } catch(PropertyException pe) { 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 6daadf926..46393459e 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 @@ -600,4 +600,8 @@ public class NuxeoUtils { return result; } + + static public String getPrimaryXPathPropertyName(String schema, String complexPropertyName, String fieldName) { + return schema + ":" + complexPropertyName + "/[0]/" + fieldName; + } } diff --git a/services/person/client/src/main/java/org/collectionspace/services/client/PersonAuthorityClient.java b/services/person/client/src/main/java/org/collectionspace/services/client/PersonAuthorityClient.java index 7a06e57e3..f5dc8c85e 100644 --- a/services/person/client/src/main/java/org/collectionspace/services/client/PersonAuthorityClient.java +++ b/services/person/client/src/main/java/org/collectionspace/services/client/PersonAuthorityClient.java @@ -36,6 +36,7 @@ public class PersonAuthorityClient extends AuthorityWithContactsClientImpl getCommonPartClass() {