From ef66cc42e2394fbf8d4162d8bd3a3ac994c68878 Mon Sep 17 00:00:00 2001 From: Aron Roberts Date: Tue, 1 May 2012 15:06:30 -0700 Subject: [PATCH] CSPACE-5119,CSPACE-5139,CSPACE-5138: Initial foray into authority item base classes to reflect term info group changes. These classes do not yet compile. --- .../vocabulary/AuthorityItemJAXBSchema.java | 22 +++++++--- .../common/vocabulary/AuthorityResource.java | 6 ++- .../AuthorityItemDocumentModelHandler.java | 44 ++++++++++++------- .../nuxeo/PersonDocumentModelHandler.java | 6 +++ 4 files changed, 53 insertions(+), 25 deletions(-) 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 05689825d..70d6e0b07 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 @@ -28,16 +28,26 @@ package org.collectionspace.services.common.vocabulary; * */ public interface AuthorityItemJAXBSchema { - final static String DISPLAY_NAME = "displayName"; - final static String DISPLAY_NAME_COMPUTED = "displayNameComputed"; - final static String SHORT_DISPLAY_NAME = "shortDisplayName"; - final static String SHORT_DISPLAY_NAME_COMPUTED = "shortDisplayNameComputed"; - final static String IN_AUTHORITY = "inAuthority"; + final static String IN_AUTHORITY = "inAuthority"; final static String REF_NAME = "refName"; final static String ORDER = "order"; final static String SHORT_IDENTIFIER = "shortIdentifier"; - final static String TERM_STATUS = "termStatus"; final static String CSID = "csid"; + 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"; + final static String DISPLAY_NAME_COMPUTED = "displayNameComputed"; + final static String SHORT_DISPLAY_NAME = "shortDisplayName"; + final static String SHORT_DISPLAY_NAME_COMPUTED = "shortDisplayNameComputed"; + final static String TERM_STATUS = "termStatus"; + * + */ } 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 8ea47ae13..a5695ce06 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 @@ -425,8 +425,10 @@ public abstract class AuthorityResource // be on the displayName field String sortBy = queryParams.getFirst(IClientQueryParams.SORT_BY_PARAM); if (sortBy == null || sortBy.isEmpty()) { - String qualifiedDisplayNameField = authorityCommonSchemaName + ":" - + AuthorityItemJAXBSchema.DISPLAY_NAME; + // String qualifiedDisplayNameField = authorityCommonSchemaName + ":" + // + AuthorityItemJAXBSchema.DISPLAY_NAME; + String qualifiedDisplayNameField = AuthorityItemJAXBSchema.TERM_INFO_GROUP_SCHEMA_NAME + ":" + + AuthorityItemJAXBSchema.TERM_DISPLAY_NAME; myFilter.setOrderByClause(qualifiedDisplayNameField); } String nameQ = queryParams.getFirst("refName"); 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 e439c38b3..45230aa08 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 @@ -51,6 +51,7 @@ import org.collectionspace.services.common.vocabulary.RefNameServiceUtils; import org.collectionspace.services.config.service.ListResultField; import org.collectionspace.services.config.service.ObjectPartType; import org.collectionspace.services.nuxeo.client.java.DocHandlerBase; +import org.collectionspace.services.nuxeo.client.java.RemoteDocumentModelHandlerImpl; import org.collectionspace.services.nuxeo.client.java.RepositoryJavaClientImpl; import org.collectionspace.services.nuxeo.util.NuxeoUtils; import org.collectionspace.services.relation.RelationResource; @@ -78,6 +79,7 @@ import java.util.List; import java.util.Map; import java.util.regex.Matcher; import java.util.regex.Pattern; +import org.collectionspace.services.nuxeo.client.java.DocumentModelHandler; //import org.collectionspace.services.common.authority.AuthorityItemRelations; /** @@ -199,14 +201,18 @@ public abstract class AuthorityItemDocumentModelHandler // Ensure we have required fields set properly handleInAuthority(wrapDoc.getWrappedObject()); + // CSPACE-4813 + /* handleComputedDisplayNames(wrapDoc.getWrappedObject()); String displayName = (String) wrapDoc.getWrappedObject().getProperty(authorityItemCommonSchemaName, AuthorityItemJAXBSchema.DISPLAY_NAME); if (Tools.isEmpty(displayName)) { logger.warn("Creating Authority Item with no displayName!"); } + * + */ // CSPACE-3178: - handleDisplayNameAsShortIdentifier(wrapDoc.getWrappedObject(), authorityItemCommonSchemaName); + // handleDisplayNameAsShortIdentifier(wrapDoc.getWrappedObject(), authorityItemCommonSchemaName); // refName includes displayName, so we force a correct value here. updateRefnameForAuthorityItem(wrapDoc, authorityItemCommonSchemaName, getAuthorityRefNameBase()); } @@ -217,14 +223,18 @@ public abstract class AuthorityItemDocumentModelHandler @Override public void handleUpdate(DocumentWrapper wrapDoc) throws Exception { // First, get a copy of the old displayName - oldDisplayNameOnUpdate = (String) wrapDoc.getWrappedObject().getProperty(authorityItemCommonSchemaName, - AuthorityItemJAXBSchema.DISPLAY_NAME); + // oldDisplayNameOnUpdate = (String) wrapDoc.getWrappedObject().getProperty(authorityItemCommonSchemaName, + // AuthorityItemJAXBSchema.DISPLAY_NAME); + oldDisplayNameOnUpdate = (String) RemoteDocumentModelHandlerImpl.getXPathStringValue(wrapDoc.getWrappedObject(), + authorityItemCommonSchemaName, AuthorityItemJAXBSchema.PREFERRED_TERM_DISPLAY_NAME_XPATH); 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); + // 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); if (newDisplayName != null && !newDisplayName.equals(oldDisplayNameOnUpdate)) { // Need to update the refName, and then fix all references. newRefNameOnUpdate = handleItemRefNameUpdateForDisplayName(wrapDoc.getWrappedObject(), newDisplayName); @@ -298,21 +308,19 @@ public abstract class AuthorityItemDocumentModelHandler } /** - * If no short identifier was provided in the input payload, - * generate a short identifier from the display name. + * If no short identifier was provided in the input payload, generate a + * short identifier from the preferred term display name or term name. */ private void handleDisplayNameAsShortIdentifier(DocumentModel docModel, String schemaName) throws Exception { String shortIdentifier = (String) docModel.getProperty(schemaName, AuthorityItemJAXBSchema.SHORT_IDENTIFIER); - String displayName = (String) docModel.getProperty(schemaName, AuthorityItemJAXBSchema.DISPLAY_NAME); - String shortDisplayName = ""; - try { - shortDisplayName = (String) docModel.getProperty(schemaName, AuthorityItemJAXBSchema.SHORT_DISPLAY_NAME); - } catch (PropertyNotFoundException pnfe) { - // Do nothing on exception. Some vocabulary schemas may not include a short display name. - } + 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); if (Tools.isEmpty(shortIdentifier)) { String generatedShortIdentifier = - AuthorityIdentifierUtils.generateShortIdentifierFromDisplayName(displayName, shortDisplayName); + AuthorityIdentifierUtils.generateShortIdentifierFromDisplayName(termDisplayName, termName); docModel.setProperty(schemaName, AuthorityItemJAXBSchema.SHORT_IDENTIFIER, generatedShortIdentifier); } } @@ -333,7 +341,9 @@ public abstract class AuthorityItemDocumentModelHandler String authorityRefBaseName) throws Exception { DocumentModel docModel = wrapDoc.getWrappedObject(); String shortIdentifier = (String) docModel.getProperty(schemaName, AuthorityItemJAXBSchema.SHORT_IDENTIFIER); - String displayName = (String) docModel.getProperty(schemaName, AuthorityItemJAXBSchema.DISPLAY_NAME); + String displayName = + RemoteDocumentModelHandlerImpl.getXPathStringValue(docModel, schemaName, + AuthorityItemJAXBSchema.PREFERRED_TERM_DISPLAY_NAME_XPATH); 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/person/service/src/main/java/org/collectionspace/services/person/nuxeo/PersonDocumentModelHandler.java b/services/person/service/src/main/java/org/collectionspace/services/person/nuxeo/PersonDocumentModelHandler.java index ea7f32757..8b703b125 100644 --- a/services/person/service/src/main/java/org/collectionspace/services/person/nuxeo/PersonDocumentModelHandler.java +++ b/services/person/service/src/main/java/org/collectionspace/services/person/nuxeo/PersonDocumentModelHandler.java @@ -67,6 +67,7 @@ public class PersonDocumentModelHandler * @param docModel the doc model * @throws Exception the exception */ + /* @Override protected void handleComputedDisplayNames(DocumentModel docModel) throws Exception { String commonPartLabel = getServiceContext().getCommonPartLabel("persons"); @@ -103,6 +104,8 @@ public class PersonDocumentModelHandler } } } + * + */ /** @@ -118,6 +121,7 @@ public class PersonDocumentModelHandler * @return * @throws Exception */ + /* private static String prepareDefaultDisplayName( String foreName, String middleName, String surName, String birthDate, String deathDate ) throws Exception { @@ -159,6 +163,8 @@ public class PersonDocumentModelHandler return newStr.toString(); } + * + */ /** * getQProperty converts the given property to qualified schema property -- 2.47.3