]> git.aero2k.de Git - tmp/jakarta-migration.git/commitdiff
CSPACE-5119,CSPACE-5139,CSPACE-5138: Initial foray into authority item base classes...
authorAron Roberts <aron@socrates.berkeley.edu>
Tue, 1 May 2012 22:06:30 +0000 (15:06 -0700)
committerAron Roberts <aron@socrates.berkeley.edu>
Tue, 1 May 2012 22:06:30 +0000 (15:06 -0700)
services/authority/jaxb/src/main/java/org/collectionspace/services/common/vocabulary/AuthorityItemJAXBSchema.java
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/person/service/src/main/java/org/collectionspace/services/person/nuxeo/PersonDocumentModelHandler.java

index 05689825d6709c0d3286aee53a714a7bd497ebf6..70d6e0b07e4dcfd64dc306830908c13adbbc8d3a 100644 (file)
@@ -28,16 +28,26 @@ package org.collectionspace.services.common.vocabulary;
  *\r
  */\r
 public interface AuthorityItemJAXBSchema {\r
-       final static String DISPLAY_NAME = "displayName";\r
-       final static String DISPLAY_NAME_COMPUTED = "displayNameComputed";\r
-       final static String SHORT_DISPLAY_NAME = "shortDisplayName";\r
-       final static String SHORT_DISPLAY_NAME_COMPUTED = "shortDisplayNameComputed";\r
-       final static String IN_AUTHORITY = "inAuthority";\r
+       final static String IN_AUTHORITY = "inAuthority";\r
        final static String REF_NAME = "refName";\r
        final static String ORDER = "order";\r
        final static String SHORT_IDENTIFIER = "shortIdentifier";\r
-       final static String TERM_STATUS = "termStatus";\r
        final static String CSID = "csid";\r
+        final static String TERM_DISPLAY_NAME = "termDisplayName";\r
+        final static String TERM_NAME = "termName";\r
+        final static String TERM_STATUS = "termStatus";\r
+        final static String PREFERRED_TERM_DISPLAY_NAME_XPATH ="termGroupList/0/termDisplayName";\r
+        final static String PREFERRED_TERM_NAME_XPATH ="termGroupList/0/termName";\r
+        final static String PREFERRED_TERM_STATUS_XPATH ="termGroupList/0/termStatus";\r
+        // CSPACE-4813\r
+        /*\r
+       final static String DISPLAY_NAME = "displayName";\r
+       final static String DISPLAY_NAME_COMPUTED = "displayNameComputed";\r
+       final static String SHORT_DISPLAY_NAME = "shortDisplayName";\r
+       final static String SHORT_DISPLAY_NAME_COMPUTED = "shortDisplayNameComputed";\r
+       final static String TERM_STATUS = "termStatus";\r
+        *\r
+        */\r
 }\r
 \r
 \r
index 8ea47ae13db7e32c1c644a126f994dc645266b47..a5695ce06f915b6e532378eec8c503746fdab968 100644 (file)
@@ -425,8 +425,10 @@ public abstract class AuthorityResource<AuthCommon, AuthItemHandler>
             // 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");
index e439c38b3f774223e48183c9ccaec6f92100c61b..45230aa082b2aada0f5871fc7c3a32d87ceac860 100644 (file)
@@ -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<AICommon>
         // 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<AICommon>
     @Override
     public void handleUpdate(DocumentWrapper<DocumentModel> 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<AICommon>
     }
 
     /**
-     * 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<AICommon>
             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.");
         }
index ea7f3275785c10b3933c8cadd9a24b3b36d4e134..8b703b12540886d7b4ddebf9ad700eb39f39ddd6 100644 (file)
@@ -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