]> git.aero2k.de Git - tmp/jakarta-migration.git/commitdiff
CSPACE-2537 and CSPACE-2955. Added support for ShortDisplayName to location, org...
authorPatrick Schmitz <pschmitz@berkeley.edu>
Wed, 29 Sep 2010 20:48:01 +0000 (20:48 +0000)
committerPatrick Schmitz <pschmitz@berkeley.edu>
Wed, 29 Sep 2010 20:48:01 +0000 (20:48 +0000)
21 files changed:
services/common/src/main/java/org/collectionspace/services/common/vocabulary/AuthorityItemJAXBSchema.java
services/common/src/main/java/org/collectionspace/services/common/vocabulary/AuthorityItemListItemJAXBSchema.java
services/common/src/main/java/org/collectionspace/services/common/vocabulary/AuthorityJAXBSchema.java
services/location/3rdparty/nuxeo-platform-cs-location/src/main/resources/schemas/locations_common.xsd
services/location/jaxb/src/main/java/org/collectionspace/services/LocationJAXBSchema.java
services/location/jaxb/src/main/resources/location_common.xsd
services/location/service/src/main/java/org/collectionspace/services/location/nuxeo/LocationDocumentModelHandler.java
services/organization/3rdparty/nuxeo-platform-cs-organization/src/main/resources/schemas/organizations_common.xsd
services/organization/client/src/main/java/org/collectionspace/services/client/OrgAuthorityClientUtils.java
services/organization/jaxb/src/main/java/org/collectionspace/services/OrganizationJAXBSchema.java
services/organization/jaxb/src/main/resources/organization_common.xsd
services/organization/service/src/main/java/org/collectionspace/services/organization/nuxeo/OrganizationDocumentModelHandler.java
services/person/3rdparty/nuxeo-platform-cs-person/src/main/resources/schemas/persons_common.xsd
services/person/client/src/main/java/org/collectionspace/services/client/PersonAuthorityClientUtils.java
services/person/client/src/test/java/org/collectionspace/services/client/test/PersonAuthorityServiceTest.java
services/person/jaxb/src/main/java/org/collectionspace/services/PersonJAXBSchema.java
services/person/jaxb/src/main/resources/person_common.xsd
services/person/service/src/main/java/org/collectionspace/services/person/nuxeo/PersonDocumentModelHandler.java
services/vocabulary/jaxb/src/main/resources/vocabulary_common.xsd
services/vocabulary/jaxb/src/main/resources/vocabularyitem_common.xsd
services/vocabulary/service/src/main/java/org/collectionspace/services/vocabulary/nuxeo/VocabularyItemDocumentModelHandler.java

index 8b71d644e3f248808435b1bad0bb2a87c07757f7..b6be3b3bfcab6a697753aa9a868219e5e352b5de 100644 (file)
@@ -29,10 +29,13 @@ package org.collectionspace.services.common.vocabulary;
  */\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 REF_NAME = "refName";\r
        final static String SHORT_IDENTIFIER = "shortIdentifier";\r
-       final static String STATUS = "status";\r
+       final static String TERM_STATUS = "termStatus";\r
        final static String CSID = "csid";\r
 }\r
 \r
index f9ccecc7786db99b32bd94c5975e93e9f856bd22..b5d2f0d81e3e27d4d5cbd5cdf396b4379d3a07c1 100644 (file)
@@ -25,6 +25,7 @@ package org.collectionspace.services.common.vocabulary;
 \r
 public interface AuthorityItemListItemJAXBSchema {\r
        final static String DISPLAY_NAME = "displayName";\r
+       final static String SHORT_DISPLAY_NAME = "shortDisplayName";\r
        final static String REF_NAME = "refName";\r
        final static String SHORT_IDENTIFIER = "shortIdentifier";\r
        final static String CSID = "csid";\r
index edbe2ef95dd18cf42dea0a9d7adee24911781f0c..456ea65e03467e299fd63e97f529dafc4d71ae63 100644 (file)
@@ -33,7 +33,6 @@ public interface AuthorityJAXBSchema {
        final static String REF_NAME = "refName";\r
        final static String VOCAB_TYPE = "vocabType";\r
        final static String CSID = "csid";\r
-    final static String TERM_STATUS = "termStatus";\r
 }\r
 \r
 \r
index ed0ffa7e83697dc516ca21527188b523ea4c3e73..62c41681fbfab6ac080c08a8ea6d696b9bb67597 100644 (file)
@@ -28,6 +28,8 @@
     <xs:element name="termStatus" type="xs:string"/>
     <xs:element name="displayName" type="xs:string"/>
     <xs:element name="displayNameComputed" type="xs:boolean"/>
+    <xs:element name="shortDisplayName" type="xs:string"/>
+    <xs:element name="shortDisplayNameComputed" type="xs:boolean"/>
     <xs:element name="name" type="xs:string"/>
     <xs:element name="conditionNote" type="xs:string"/>
     <xs:element name="conditionNoteDate" type="xs:string"/>
index cc073fd62840947bb8a134df1f73662172f17064..1621792a5971ccfa5dc38162fc01e1adefb0f189 100644 (file)
@@ -2,15 +2,14 @@
  * \r
  */\r
 package org.collectionspace.services;\r
-import org.collectionspace.services.common.vocabulary.AuthorityJAXBSchema;\r
+import org.collectionspace.services.common.vocabulary.AuthorityItemJAXBSchema;\r
 \r
 /**\r
  * @author pschmitz\r
  *\r
  */\r
-public interface LocationJAXBSchema extends AuthorityJAXBSchema {\r
+public interface LocationJAXBSchema extends AuthorityItemJAXBSchema {\r
        final static String LOCATIONS_COMMON = "locations_common";\r
-       final static String DISPLAY_NAME_COMPUTED = "displayNameComputed";\r
        final static String NAME = "name";\r
        final static String CONDITION_NOTE = "conditionNote";\r
        final static String CONDITION_NOTE_DATE = "conditionNoteDate";\r
index d66668eff54559df6a74fd7801bc3aeb67cc083c..673c55364914e18305ac3f209034f4fc2b55d662 100644 (file)
@@ -27,6 +27,8 @@
                                                                <xs:element name="termStatus" type="xs:string"/>
                                                                <xs:element name="displayName" type="xs:string"/>
                                                                <xs:element name="displayNameComputed" type="xs:boolean"/>
+                                                           <xs:element name="shortDisplayName" type="xs:string"/>
+                                                           <xs:element name="shortDisplayNameComputed" type="xs:boolean"/>
                                                                <xs:element name="name" type="xs:string"/>
                                                                <xs:element name="conditionNote" type="xs:string"/>
                                                                <xs:element name="conditionNoteDate" type="xs:string"/>
@@ -57,6 +59,8 @@
                             <xs:complexType>
                                 <xs:sequence>
                                     <xs:element name="displayName" type="xs:string"
+                                        minOccurs="1" />
+                                                                       <xs:element name="shortIdentifier" type="xs:string"
                                         minOccurs="1" />
                                     <!-- uri to retrieve location details -->
                                     <xs:element name="uri" type="xs:anyURI"
index 752aff356c67c823b1052970d112c47dcb04bd8e..72c7f2085f39870ab8d7485dcba068906e6704ba 100644 (file)
@@ -33,6 +33,7 @@ import org.collectionspace.services.LocationJAXBSchema;
 import org.collectionspace.services.common.document.DocumentFilter;
 import org.collectionspace.services.common.document.DocumentWrapper;
 import org.collectionspace.services.common.service.ObjectPartType;
+import org.collectionspace.services.common.vocabulary.AuthorityItemJAXBSchema;
 import org.collectionspace.services.common.vocabulary.nuxeo.AuthorityItemDocumentModelHandler;
 import org.collectionspace.services.nuxeo.client.java.RemoteDocumentModelHandlerImpl;
 import org.collectionspace.services.nuxeo.util.NuxeoUtils;
@@ -76,7 +77,7 @@ public class LocationDocumentModelHandler
     public void handleCreate(DocumentWrapper<DocumentModel> wrapDoc) throws Exception {
        // first fill all the parts of the document
        super.handleCreate(wrapDoc);            
-       handleDisplayName(wrapDoc.getWrappedObject());
+       handleDisplayNames(wrapDoc.getWrappedObject());
     }
     
     /* (non-Javadoc)
@@ -85,7 +86,7 @@ public class LocationDocumentModelHandler
     @Override
     public void handleUpdate(DocumentWrapper<DocumentModel> wrapDoc) throws Exception {
        super.handleUpdate(wrapDoc);
-       handleDisplayName(wrapDoc.getWrappedObject());
+       handleDisplayNames(wrapDoc.getWrappedObject());
     }
 
     /**
@@ -94,15 +95,27 @@ public class LocationDocumentModelHandler
      * @param docModel the doc model
      * @throws Exception the exception
      */
-    private void handleDisplayName(DocumentModel docModel) throws Exception {
+    private void handleDisplayNames(DocumentModel docModel) throws Exception {
        String commonPartLabel = getServiceContext().getCommonPartLabel("locations");
        Boolean displayNameComputed = (Boolean) docModel.getProperty(commonPartLabel,
                        LocationJAXBSchema.DISPLAY_NAME_COMPUTED);
-       if (displayNameComputed) {
+       Boolean shortDisplayNameComputed = (Boolean) docModel.getProperty(commonPartLabel,
+                       LocationJAXBSchema.SHORT_DISPLAY_NAME_COMPUTED);
+       if(displayNameComputed==null)
+               displayNameComputed = true;
+       if(shortDisplayNameComputed==null)
+               shortDisplayNameComputed = true;
+       if (displayNameComputed || shortDisplayNameComputed) {
                String displayName = prepareDefaultDisplayName(
                        (String)docModel.getProperty(commonPartLabel, LocationJAXBSchema.NAME ));
-                       docModel.setProperty(commonPartLabel, LocationJAXBSchema.DISPLAY_NAME,
-                                       displayName);
+               if (displayNameComputed) {
+                       docModel.setProperty(commonPartLabel, LocationJAXBSchema.DISPLAY_NAME,
+                                       displayName);
+               }
+               if (shortDisplayNameComputed) {
+                       docModel.setProperty(commonPartLabel, LocationJAXBSchema.SHORT_DISPLAY_NAME,
+                                       displayName);
+               }
        }
     }
        
@@ -134,7 +147,7 @@ public class LocationDocumentModelHandler
                        DocumentWrapper<DocumentModelList> wrapDoc) throws Exception {
                LocationsCommonList coList = extractPagingInfo(new LocationsCommonList(), wrapDoc);
         AbstractCommonList commonList = (AbstractCommonList) coList;
-        commonList.setFieldsReturned("displayName|refName|uri|csid");
+        commonList.setFieldsReturned("displayName|refName|shortIdentifier|uri|csid");
                List<LocationsCommonList.LocationListItem> list = coList.getLocationListItem();
                Iterator<DocumentModel> iter = wrapDoc.getWrappedObject().iterator();
                String commonPartLabel = getServiceContext().getCommonPartLabel(
@@ -143,9 +156,11 @@ public class LocationDocumentModelHandler
                        DocumentModel docModel = iter.next();
                        LocationListItem ilistItem = new LocationListItem();
                        ilistItem.setDisplayName((String) docModel.getProperty(
-                                       commonPartLabel, LocationJAXBSchema.DISPLAY_NAME));
+                                       commonPartLabel, AuthorityItemJAXBSchema.DISPLAY_NAME));
+                       ilistItem.setShortIdentifier((String) docModel.getProperty(commonPartLabel,
+                                       AuthorityItemJAXBSchema.SHORT_IDENTIFIER));
                        ilistItem.setRefName((String) docModel.getProperty(commonPartLabel,
-                                       LocationJAXBSchema.REF_NAME));
+                                       AuthorityItemJAXBSchema.REF_NAME));
                        String id = NuxeoUtils.extractId(docModel.getPathAsString());
                        ilistItem.setUri("/locationauthorities/" + inAuthority + "/items/"
                                        + id);
index baffa38660d30ed9517dc6b2111bb4d0fe570d58..1fe19f124dbfd2f7c3ca8656b7b53f9b70286605 100644 (file)
@@ -29,6 +29,8 @@
     <xs:element name="termStatus" type="xs:string"/>
     <xs:element name="displayName" type="xs:string"/>
     <xs:element name="displayNameComputed" type="xs:boolean"/>
+    <xs:element name="shortDisplayName" type="xs:string"/>
+    <xs:element name="shortDisplayNameComputed" type="xs:boolean"/>
 
     <!-- FIXME Start of main body (represented by 'longName' element) repeatable group -->
     <xs:element name="shortName" type="xs:string"/>
index cb143100a3a70b4a85c98b25d8e1b5c5bcd9a8b7..0ff02e4ac3f435430ab14191db2355e45abfd429 100644 (file)
@@ -252,6 +252,12 @@ public class OrgAuthorityClientUtils {
                if((value = (String)orgInfo.get(OrganizationJAXBSchema.DISPLAY_NAME))!=null)\r
                organization.setDisplayName(value);\r
                \r
+       value = orgInfo.get(OrganizationJAXBSchema.SHORT_DISPLAY_NAME_COMPUTED);\r
+       boolean shortDisplayNameComputed = (value==null) || value.equalsIgnoreCase("true"); \r
+               organization.setShortDisplayNameComputed(shortDisplayNameComputed);\r
+               if((value = (String)orgInfo.get(OrganizationJAXBSchema.SHORT_DISPLAY_NAME))!=null)\r
+               organization.setShortDisplayName(value);\r
+               \r
        String refName = createOrganizationRefName(orgAuthRefName, shortId, value);\r
        organization.setRefName(refName);\r
 \r
index 54d2c870bbaec5570a0c0f7fcc2154588c2b448e..2191ee0126db4239957784cc78b0be8925a986ce 100644 (file)
@@ -3,16 +3,15 @@
  */\r
 package org.collectionspace.services;\r
 \r
-import org.collectionspace.services.common.vocabulary.AuthorityJAXBSchema;\r
+import org.collectionspace.services.common.vocabulary.AuthorityItemJAXBSchema;\r
 \r
 /**\r
  * @author pschmitz\r
  *\r
  */\r
-public interface OrganizationJAXBSchema extends AuthorityJAXBSchema {\r
+public interface OrganizationJAXBSchema extends AuthorityItemJAXBSchema {\r
 \r
     final static String ORGANIZATIONS_COMMON = "organizations_common";\r
-    final static String DISPLAY_NAME_COMPUTED = "displayNameComputed";\r
     final static String SHORT_NAME = "shortName";\r
     final static String LONG_NAME = "longName";\r
     final static String NAME_ADDITIONS = "nameAdditions";\r
index 314509f7a31254d65a134fa1890ac88fbd65fc26..20cda416ace9c490a289df20db5706c9e411ca60 100644 (file)
@@ -26,6 +26,8 @@
                 <xs:element name="termStatus" type="xs:string"/>
                 <xs:element name="displayName" type="xs:string"/>
                 <xs:element name="displayNameComputed" type="xs:boolean"/>
+                <xs:element name="shortDisplayName" type="xs:string"/>
+                <xs:element name="shortDisplayNameComputed" type="xs:boolean"/>
                 <xs:element name="shortName" type="xs:string"/>
                 <xs:element name="longName" type="xs:string"/>
                 <xs:element name="nameAdditions" type="xs:string"/>
@@ -90,6 +92,8 @@
                             <xs:complexType>
                                 <xs:sequence>
                                     <xs:element name="displayName" type="xs:string"
+                                        minOccurs="1" />
+                                                                       <xs:element name="shortIdentifier" type="xs:string"
                                         minOccurs="1" />
                                     <!-- uri to retrieve organization details -->
                                     <xs:element name="uri" type="xs:anyURI"
index d11dc16b5e81a22759dd0bf52ba42337a2f95cd7..1989df666908fb049369363985e56c003a8d615a 100644 (file)
@@ -68,7 +68,7 @@ public class OrganizationDocumentModelHandler
     public void handleCreate(DocumentWrapper<DocumentModel> wrapDoc) throws Exception {
        // first fill all the parts of the document
        super.handleCreate(wrapDoc);            
-       handleDisplayName(wrapDoc.getWrappedObject());
+       handleDisplayNames(wrapDoc.getWrappedObject());
     }
     
     /* (non-Javadoc)
@@ -77,7 +77,7 @@ public class OrganizationDocumentModelHandler
     @Override
     public void handleUpdate(DocumentWrapper<DocumentModel> wrapDoc) throws Exception {
        super.handleUpdate(wrapDoc);
-       handleDisplayName(wrapDoc.getWrappedObject());
+       handleDisplayNames(wrapDoc.getWrappedObject());
     }
 
     /**
@@ -87,16 +87,31 @@ public class OrganizationDocumentModelHandler
      * 
      * @throws Exception the exception
      */
-    private void handleDisplayName(DocumentModel docModel) throws Exception {
+    private void handleDisplayNames(DocumentModel docModel) throws Exception {
        String commonPartLabel = getServiceContext().getCommonPartLabel("organizations");
        Boolean displayNameComputed = (Boolean) docModel.getProperty(commonPartLabel,
                        OrganizationJAXBSchema.DISPLAY_NAME_COMPUTED);
-       if (displayNameComputed) {
-               String displayName = prepareDefaultDisplayName(
-                               (String) docModel.getProperty(commonPartLabel,OrganizationJAXBSchema.SHORT_NAME),
-                               (String) docModel.getProperty(commonPartLabel,OrganizationJAXBSchema.FOUNDING_PLACE));
-                       docModel.setProperty(commonPartLabel, OrganizationJAXBSchema.DISPLAY_NAME,
-                                               displayName);
+       Boolean shortDisplayNameComputed = (Boolean) docModel.getProperty(commonPartLabel,
+                       OrganizationJAXBSchema.SHORT_DISPLAY_NAME_COMPUTED);
+       if(displayNameComputed==null)
+               displayNameComputed = true;
+       if(shortDisplayNameComputed==null)
+               shortDisplayNameComputed = true;
+       if (displayNameComputed || shortDisplayNameComputed) {
+               String shortName = (String) docModel.getProperty(commonPartLabel,
+                                                                       OrganizationJAXBSchema.SHORT_NAME);
+               if(shortDisplayNameComputed) {
+                       String displayName = prepareDefaultDisplayName(shortName, null);
+                       docModel.setProperty(commonPartLabel, OrganizationJAXBSchema.SHORT_DISPLAY_NAME,
+                                       displayName);
+               }
+               if(displayNameComputed) {
+               String foundingPlace = (String) docModel.getProperty(commonPartLabel,
+                                               OrganizationJAXBSchema.FOUNDING_PLACE);
+                       String displayName = prepareDefaultDisplayName(shortName, foundingPlace);
+                               docModel.setProperty(commonPartLabel, OrganizationJAXBSchema.DISPLAY_NAME,
+                                                       displayName);
+               }
        }
     }
 
@@ -137,7 +152,7 @@ public class OrganizationDocumentModelHandler
                throws Exception {
         OrganizationsCommonList coList = this.extractPagingInfo(new OrganizationsCommonList(), wrapDoc);
         AbstractCommonList commonList = (AbstractCommonList) coList;
-        commonList.setFieldsReturned("displayName|refName|uri|csid");
+        commonList.setFieldsReturned("displayName|refName|shortIdentifier|uri|csid");
         List<OrganizationsCommonList.OrganizationListItem> list = coList.getOrganizationListItem();
         Iterator<DocumentModel> iter = wrapDoc.getWrappedObject().iterator();
         String commonPartLabel = getServiceContext().getCommonPartLabel("organizations");
@@ -146,6 +161,8 @@ public class OrganizationDocumentModelHandler
             OrganizationListItem ilistItem = new OrganizationListItem();
             ilistItem.setDisplayName((String)
                        docModel.getProperty(commonPartLabel,OrganizationJAXBSchema.DISPLAY_NAME ));
+                       ilistItem.setShortIdentifier((String) docModel.getProperty(commonPartLabel,
+                                       OrganizationJAXBSchema.SHORT_IDENTIFIER));
                        ilistItem.setRefName((String) 
                                        docModel.getProperty(commonPartLabel, OrganizationJAXBSchema.REF_NAME));
                        String id = NuxeoUtils.extractId(docModel.getPathAsString());
index ba51601b64ee8cb457ea9492e46244e5334e9597..802d28becc62cbee99f40751383cebdf8adc5eba 100644 (file)
@@ -28,6 +28,8 @@
     <xs:element name="termStatus" type="xs:string"/>
     <xs:element name="displayName" type="xs:string"/>
     <xs:element name="displayNameComputed" type="xs:boolean"/>
+    <xs:element name="shortDisplayName" type="xs:string"/>
+    <xs:element name="shortDisplayNameComputed" type="xs:boolean"/>
 
     <!-- FIXME: Currently marked in repeatability spreadsheet as a -->
     <!-- repeatable group.  However, multiple personal names for the -->
index f800a0ad9d437baa267cb3b612eb7f4d3f087e1e..60f1723176b9557d62f30a33b2bd7ab48a3b38b6 100644 (file)
@@ -211,6 +211,20 @@ public class PersonAuthorityClientUtils {
        if (displayNameComputed == false && displayName == null) {\r
                throw new IllegalArgumentException("displayName cannot be null when displayComputed is 'false'");\r
        }       \r
+\r
+       booleanStr = personInfo.get(PersonJAXBSchema.SHORT_DISPLAY_NAME_COMPUTED);\r
+       boolean shortDisplayNameComputed = true;\r
+       if (booleanStr != null && booleanStr.length() > 0) {\r
+               shortDisplayNameComputed = Boolean.parseBoolean(booleanStr);\r
+       }\r
+       person.setShortDisplayNameComputed(shortDisplayNameComputed);\r
+\r
+               String shortDisplayName = personInfo.get(PersonJAXBSchema.SHORT_DISPLAY_NAME);\r
+               person.setShortDisplayName(shortDisplayName);\r
+       if (shortDisplayNameComputed == false && shortDisplayName == null) {\r
+               throw new IllegalArgumentException("shortDisplayName cannot be null when shortDisplayComputed is 'false'");\r
+       }       \r
+\r
        String refName = createPersonRefName(personAuthRefName, shortId, displayName);\r
                person.setRefName(refName);\r
        \r
@@ -315,6 +329,20 @@ public class PersonAuthorityClientUtils {
                        personMap.get(PersonJAXBSchema.DEATH_DATE));\r
                personMap.put(PersonJAXBSchema.DISPLAY_NAME, displayName);\r
        }\r
+       String shortDisplayName = personMap.get(PersonJAXBSchema.SHORT_DISPLAY_NAME);\r
+       String shortDisplayNameComputedStr = personMap.get(PersonJAXBSchema.SHORT_DISPLAY_NAME_COMPUTED);\r
+       boolean shortDisplayNameComputed = (shortDisplayNameComputedStr==null) || shortDisplayNameComputedStr.equalsIgnoreCase("true");\r
+       if( shortDisplayName == null ) {\r
+               if(!shortDisplayNameComputed) {\r
+                       throw new RuntimeException(\r
+                       "CreateItem: Must supply a shortDisplayName if shortDisplayNameComputed is set to false.");\r
+               }\r
+               shortDisplayName = \r
+                       prepareDefaultDisplayName(\r
+                       personMap.get(PersonJAXBSchema.FORE_NAME), null,\r
+                       personMap.get(PersonJAXBSchema.SUR_NAME),null,null);\r
+               personMap.put(PersonJAXBSchema.SHORT_DISPLAY_NAME, shortDisplayName);\r
+       }\r
        \r
        if(logger.isDebugEnabled()){\r
                logger.debug("Import: Create Item: \"" + displayName\r
index e4a298d9f42514e3b8490b5c899bf4ce481b0a7a..5efbc897a502c03f7c5339f4a4c2d0774e356adf 100644 (file)
@@ -246,6 +246,8 @@ public class PersonAuthorityServiceTest extends AbstractServiceTestImpl {
         String shortId = "johnWayneActor";
         johnWayneMap.put(PersonJAXBSchema.DISPLAY_NAME_COMPUTED, "false");
         johnWayneMap.put(PersonJAXBSchema.DISPLAY_NAME, "John Wayne");
+        johnWayneMap.put(PersonJAXBSchema.SHORT_DISPLAY_NAME_COMPUTED, "false");
+        johnWayneMap.put(PersonJAXBSchema.SHORT_DISPLAY_NAME, "JohnWayne");
         johnWayneMap.put(PersonJAXBSchema.SHORT_IDENTIFIER, shortId);
         
         johnWayneMap.put(PersonJAXBSchema.FORE_NAME, TEST_FORE_NAME);
@@ -746,7 +748,7 @@ public class PersonAuthorityServiceTest extends AbstractServiceTestImpl {
      */
     @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
                groups = {"update"}, dependsOnMethods = {"updateItem"})
-    public void verifyItemDisplayName(String testName) throws Exception {
+    public void verifyItemDisplayNames(String testName) throws Exception {
         
          if (logger.isDebugEnabled()) {
             logger.debug(testBanner(testName, CLASS_NAME));
@@ -785,16 +787,27 @@ public class PersonAuthorityServiceTest extends AbstractServiceTestImpl {
             PersonAuthorityClientUtils.prepareDefaultDisplayName(
                TEST_FORE_NAME, null, TEST_SUR_NAME,
                TEST_BIRTH_DATE, TEST_DEATH_DATE);
-        Assert.assertNotNull(displayName, expectedDisplayName);
+        Assert.assertFalse(displayName.equals(expectedDisplayName));
     
-        // Update the shortName and verify the computed name is updated.
+        String shortDisplayName = person.getShortDisplayName();
+        // Make sure displayName matches computed form
+        String expectedShortDisplayName = 
+            PersonAuthorityClientUtils.prepareDefaultDisplayName(
+                       TEST_FORE_NAME, null, TEST_SUR_NAME,null, null);
+        Assert.assertFalse(expectedShortDisplayName.equals(shortDisplayName));
+    
+        // Update the forename and verify the computed name is updated.
         person.setCsid(null);
         person.setDisplayNameComputed(true);
+        person.setShortDisplayNameComputed(true);
         person.setForeName("updated-" + TEST_FORE_NAME);
         expectedDisplayName = 
             PersonAuthorityClientUtils.prepareDefaultDisplayName(
                "updated-" + TEST_FORE_NAME, null, TEST_SUR_NAME, 
                TEST_BIRTH_DATE, TEST_DEATH_DATE);
+        expectedShortDisplayName = 
+            PersonAuthorityClientUtils.prepareDefaultDisplayName(
+                       "updated-" + TEST_FORE_NAME, null, TEST_SUR_NAME,null, null);
 
         // Submit the updated resource to the service and store the response.
         MultipartOutput output = new MultipartOutput();
@@ -829,11 +842,16 @@ public class PersonAuthorityServiceTest extends AbstractServiceTestImpl {
         // Verify that the updated resource computes the right displayName.
         Assert.assertEquals(updatedPerson.getDisplayName(), expectedDisplayName,
             "Updated ForeName in Person not reflected in computed DisplayName.");
+        // Verify that the updated resource computes the right displayName.
+        Assert.assertEquals(updatedPerson.getShortDisplayName(), expectedShortDisplayName,
+            "Updated ForeName in Person not reflected in computed ShortDisplayName.");
 
         // Now Update the displayName, not computed and verify the computed name is overriden.
         person.setDisplayNameComputed(false);
         expectedDisplayName = "TestName";
         person.setDisplayName(expectedDisplayName);
+        person.setShortDisplayNameComputed(false);
+        person.setShortDisplayName(expectedDisplayName);
 
         // Submit the updated resource to the service and store the response.
         output = new MultipartOutput();
@@ -869,6 +887,13 @@ public class PersonAuthorityServiceTest extends AbstractServiceTestImpl {
         Assert.assertEquals(updatedPerson.getDisplayName(),
                        expectedDisplayName,
                 "Updated DisplayName (not computed) in Person not stored.");
+        // Verify that the updated resource received the correct data.
+        Assert.assertEquals(updatedPerson.isShortDisplayNameComputed(), false,
+                "Updated shortDisplayNameComputed in Person did not match submitted data.");
+        // Verify that the updated resource computes the right displayName.
+        Assert.assertEquals(updatedPerson.getShortDisplayName(),
+                       expectedDisplayName,
+                "Updated ShortDisplayName (not computed) in Person not stored.");
     }
 
     /**
@@ -878,7 +903,7 @@ public class PersonAuthorityServiceTest extends AbstractServiceTestImpl {
      * @throws Exception the exception
      */
     @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
-               groups = {"update"}, dependsOnMethods = {"verifyItemDisplayName"})
+               groups = {"update"}, dependsOnMethods = {"verifyItemDisplayNames"})
     public void verifyIllegalItemDisplayName(String testName) throws Exception {
 
         if (logger.isDebugEnabled()) {
index bc692f032a89b9f2e463e6bc78698085cca3e66c..a9b8ce981933c68e70a2f9f90e8ee10091526fd6 100644 (file)
@@ -2,15 +2,14 @@
  * \r
  */\r
 package org.collectionspace.services;\r
-import org.collectionspace.services.common.vocabulary.AuthorityJAXBSchema;\r
+import org.collectionspace.services.common.vocabulary.AuthorityItemJAXBSchema;\r
 \r
 /**\r
  * @author pschmitz\r
  *\r
  */\r
-public interface PersonJAXBSchema extends AuthorityJAXBSchema {\r
+public interface PersonJAXBSchema extends AuthorityItemJAXBSchema {\r
        final static String PERSONS_COMMON = "persons_common";\r
-       final static String DISPLAY_NAME_COMPUTED = "displayNameComputed";\r
        final static String FORE_NAME = "foreName";\r
        final static String MIDDLE_NAME = "middleName";\r
        final static String SUR_NAME = "surName";\r
index a9b7f965165dd1f540695864928bc73d7eabc969..3902d7f0cc90aec37cdf537d53a7ce417e6740fc 100644 (file)
                 
                 <!--  Person Information Group -->
                 <xs:element name="inAuthority" type="xs:string" />
-               <xs:element name="shortIdentifier" type="xs:string"/>
+                               <xs:element name="shortIdentifier" type="xs:string"/>
                 <xs:element name="refName" type="xs:string" />
                 <xs:element name="termStatus" type="xs:string"/>
                 <xs:element name="displayName" type="xs:string"/>
                 <xs:element name="displayNameComputed" type="xs:boolean"/>
+                <xs:element name="shortDisplayName" type="xs:string"/>
+                <xs:element name="shortDisplayNameComputed" type="xs:boolean"/>
                 <xs:element name="foreName" type="xs:string"/>
                 <xs:element name="middleName" type="xs:string"/>
                 <xs:element name="surName" type="xs:string"/>
                             <xs:complexType>
                                 <xs:sequence>
                                     <xs:element name="displayName" type="xs:string"
+                                        minOccurs="1" />
+                                                                       <xs:element name="shortIdentifier" type="xs:string"
                                         minOccurs="1" />
                                     <!-- uri to retrieve person details -->
                                     <xs:element name="uri" type="xs:anyURI"
index b83e0d89df3cb36cb7b7d275f057ee91a235ca43..a9914df603ae99809533a59a9e2a635ff88b066e 100644 (file)
@@ -75,7 +75,7 @@ public class PersonDocumentModelHandler
     public void handleCreate(DocumentWrapper<DocumentModel> wrapDoc) throws Exception {
        // first fill all the parts of the document
        super.handleCreate(wrapDoc);            
-       handleDisplayName(wrapDoc.getWrappedObject());
+       handleDisplayNames(wrapDoc.getWrappedObject());
     }
     
     /* (non-Javadoc)
@@ -84,31 +84,52 @@ public class PersonDocumentModelHandler
     @Override
     public void handleUpdate(DocumentWrapper<DocumentModel> wrapDoc) throws Exception {
        super.handleUpdate(wrapDoc);
-       handleDisplayName(wrapDoc.getWrappedObject());
+       handleDisplayNames(wrapDoc.getWrappedObject());
     }
 
     /**
-     * Handle display name.
+     * Handle display names.
      *
      * @param docModel the doc model
      * @throws Exception the exception
      */
-    private void handleDisplayName(DocumentModel docModel) throws Exception {
+    private void handleDisplayNames(DocumentModel docModel) throws Exception {
        String commonPartLabel = getServiceContext().getCommonPartLabel("persons");
        Boolean displayNameComputed = (Boolean) docModel.getProperty(commonPartLabel,
                        PersonJAXBSchema.DISPLAY_NAME_COMPUTED);
-       if (displayNameComputed == true) {
-               String displayName = prepareDefaultDisplayName(
-                               (String)docModel.getProperty(commonPartLabel, PersonJAXBSchema.FORE_NAME),                      
-                               (String)docModel.getProperty(commonPartLabel, PersonJAXBSchema.MIDDLE_NAME),                            
-                               (String)docModel.getProperty(commonPartLabel, PersonJAXBSchema.SUR_NAME),                       
-                               (String)docModel.getProperty(commonPartLabel, PersonJAXBSchema.BIRTH_DATE),                     
-                               (String)docModel.getProperty(commonPartLabel, PersonJAXBSchema.DEATH_DATE));
-               docModel.setProperty(commonPartLabel, PersonJAXBSchema.DISPLAY_NAME,
-                               displayName);
+       Boolean shortDisplayNameComputed = (Boolean) docModel.getProperty(commonPartLabel,
+                       PersonJAXBSchema.SHORT_DISPLAY_NAME_COMPUTED);
+       if(displayNameComputed==null)
+               displayNameComputed = true;
+       if(shortDisplayNameComputed==null)
+               shortDisplayNameComputed = true;
+       if (displayNameComputed || shortDisplayNameComputed) {
+               String forename = 
+                               (String)docModel.getProperty(commonPartLabel, PersonJAXBSchema.FORE_NAME);
+               String lastname = 
+                               (String)docModel.getProperty(commonPartLabel, PersonJAXBSchema.SUR_NAME);
+               if(shortDisplayNameComputed) {
+                       String displayName = prepareDefaultDisplayName(forename, null, lastname,
+                                       null, null);
+                       docModel.setProperty(commonPartLabel, PersonJAXBSchema.SHORT_DISPLAY_NAME,
+                                       displayName);
+               }
+               if(displayNameComputed) {
+                       String midname = 
+                                       (String)docModel.getProperty(commonPartLabel, PersonJAXBSchema.MIDDLE_NAME);                            
+                       String birthdate = 
+                                       (String)docModel.getProperty(commonPartLabel, PersonJAXBSchema.BIRTH_DATE);
+                       String deathdate = 
+                                       (String)docModel.getProperty(commonPartLabel, PersonJAXBSchema.DEATH_DATE);
+                       String displayName = prepareDefaultDisplayName(forename, midname, lastname,
+                                       birthdate, deathdate);
+                       docModel.setProperty(commonPartLabel, PersonJAXBSchema.DISPLAY_NAME,
+                                       displayName);
+               }
        }
     }
        
+       
     /**
      * Produces a default displayName from the basic name and dates fields.
      * @see PersonAuthorityClientUtils.prepareDefaultDisplayName() which
@@ -190,7 +211,7 @@ public class PersonDocumentModelHandler
                        DocumentWrapper<DocumentModelList> wrapDoc) throws Exception {
                PersonsCommonList coList = extractPagingInfo(new PersonsCommonList(), wrapDoc);
         AbstractCommonList commonList = (AbstractCommonList) coList;
-        commonList.setFieldsReturned("displayName|refName|uri|csid");
+        commonList.setFieldsReturned("displayName|refName|shortIdentifier|uri|csid");
                List<PersonsCommonList.PersonListItem> list = coList.getPersonListItem();
                Iterator<DocumentModel> iter = wrapDoc.getWrappedObject().iterator();
                String commonPartLabel = getServiceContext().getCommonPartLabel(
@@ -200,6 +221,8 @@ public class PersonDocumentModelHandler
                        PersonListItem ilistItem = new PersonListItem();
                        ilistItem.setDisplayName((String) docModel.getProperty(
                                        commonPartLabel, PersonJAXBSchema.DISPLAY_NAME));
+                       ilistItem.setShortIdentifier((String) docModel.getProperty(commonPartLabel,
+                                       PersonJAXBSchema.SHORT_IDENTIFIER));
                        ilistItem.setRefName((String) docModel.getProperty(commonPartLabel,
                                        PersonJAXBSchema.REF_NAME));
                        String id = NuxeoUtils.extractId(docModel.getPathAsString());
index ce0b52d58678985aef2ff9f1758ca580b04f4fd9..b9afa8aa0162aa86012c6d77ffc928b28fc2ba85 100644 (file)
@@ -36,7 +36,7 @@
                 
                 <!--  Vocabulary Information Group -->
                 <xs:element name="displayName" type="xs:string"/>
-                                                               <xs:element name="shortIdentifier" type="xs:string"/>
+                               <xs:element name="shortIdentifier" type="xs:string"/>
                 <xs:element name="refName" type="xs:string"/>
                 <xs:element name="vocabType" type="xs:string"/>                
             </xs:sequence>
index 4e7af77c078b5d21be4d96e7e029e3400e03436a..add19438f709f328a32655812d5280971722d758 100644 (file)
@@ -49,6 +49,8 @@
                             <xs:complexType>
                                 <xs:sequence>
                                     <xs:element name="displayName" type="xs:string"
+                                        minOccurs="1" />
+                                                                       <xs:element name="shortIdentifier" type="xs:string"
                                         minOccurs="1" />
                                     <!-- uri to retrieve vocabularyitem details -->
                                     <xs:element name="uri" type="xs:anyURI"
index 93302aa6d0189175781fe447c083f792b8156394..e54078efbc08573e13ae072fc6dcb934b019b325 100644 (file)
@@ -62,18 +62,19 @@ public class VocabularyItemDocumentModelHandler
                        DocumentWrapper<DocumentModelList> wrapDoc) throws Exception {
                VocabularyitemsCommonList coList = extractPagingInfo(new VocabularyitemsCommonList(), wrapDoc);
         AbstractCommonList commonList = (AbstractCommonList) coList;
-        commonList.setFieldsReturned("displayName|refName|uri|csid");
+        commonList.setFieldsReturned("displayName|refName|shortIdentifier|uri|csid");
                
                List<VocabularyitemsCommonList.VocabularyitemListItem> list = coList.getVocabularyitemListItem();
                Iterator<DocumentModel> iter = wrapDoc.getWrappedObject().iterator();
+               String commonPartLabel = getServiceContext().getCommonPartLabel("vocabularyItems");
                while (iter.hasNext()) {
                        DocumentModel docModel = iter.next();
                        VocabularyitemListItem ilistItem = new VocabularyitemListItem();
-                       ilistItem.setDisplayName((String) docModel.getProperty(
-                                       getServiceContext().getCommonPartLabel("vocabularyItems"),
+                       ilistItem.setDisplayName((String) docModel.getProperty(commonPartLabel, 
                                        AuthorityItemJAXBSchema.DISPLAY_NAME));
-                       ilistItem.setRefName((String) docModel.getProperty(
-                                       getServiceContext().getCommonPartLabel("vocabularyItems"),
+                       ilistItem.setShortIdentifier((String) docModel.getProperty(commonPartLabel,
+                                       AuthorityItemJAXBSchema.SHORT_IDENTIFIER));
+                       ilistItem.setRefName((String) docModel.getProperty(commonPartLabel, 
                                        AuthorityItemJAXBSchema.REF_NAME));
                        String id = NuxeoUtils.extractId(docModel.getPathAsString());
                        ilistItem.setUri("/vocabularies/" + inAuthority + "/items/" + id);