From: Patrick Schmitz Date: Wed, 29 Sep 2010 20:48:01 +0000 (+0000) Subject: CSPACE-2537 and CSPACE-2955. Added support for ShortDisplayName to location, org... X-Git-Url: https://git.aero2k.de/?a=commitdiff_plain;h=c1bbfaf2d2397c58fb811e0badde2f4ec774f6d0;p=tmp%2Fjakarta-migration.git CSPACE-2537 and CSPACE-2955. Added support for ShortDisplayName to location, org, and person authority items. Added shortIdentifier to all authority item list results, and updated the fieldsReturned properties accordingly. --- diff --git a/services/common/src/main/java/org/collectionspace/services/common/vocabulary/AuthorityItemJAXBSchema.java b/services/common/src/main/java/org/collectionspace/services/common/vocabulary/AuthorityItemJAXBSchema.java index 8b71d644e..b6be3b3bf 100644 --- a/services/common/src/main/java/org/collectionspace/services/common/vocabulary/AuthorityItemJAXBSchema.java +++ b/services/common/src/main/java/org/collectionspace/services/common/vocabulary/AuthorityItemJAXBSchema.java @@ -29,10 +29,13 @@ 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 REF_NAME = "refName"; final static String SHORT_IDENTIFIER = "shortIdentifier"; - final static String STATUS = "status"; + final static String TERM_STATUS = "termStatus"; final static String CSID = "csid"; } diff --git a/services/common/src/main/java/org/collectionspace/services/common/vocabulary/AuthorityItemListItemJAXBSchema.java b/services/common/src/main/java/org/collectionspace/services/common/vocabulary/AuthorityItemListItemJAXBSchema.java index f9ccecc77..b5d2f0d81 100644 --- a/services/common/src/main/java/org/collectionspace/services/common/vocabulary/AuthorityItemListItemJAXBSchema.java +++ b/services/common/src/main/java/org/collectionspace/services/common/vocabulary/AuthorityItemListItemJAXBSchema.java @@ -25,6 +25,7 @@ package org.collectionspace.services.common.vocabulary; public interface AuthorityItemListItemJAXBSchema { final static String DISPLAY_NAME = "displayName"; + final static String SHORT_DISPLAY_NAME = "shortDisplayName"; final static String REF_NAME = "refName"; final static String SHORT_IDENTIFIER = "shortIdentifier"; final static String CSID = "csid"; diff --git a/services/common/src/main/java/org/collectionspace/services/common/vocabulary/AuthorityJAXBSchema.java b/services/common/src/main/java/org/collectionspace/services/common/vocabulary/AuthorityJAXBSchema.java index edbe2ef95..456ea65e0 100644 --- a/services/common/src/main/java/org/collectionspace/services/common/vocabulary/AuthorityJAXBSchema.java +++ b/services/common/src/main/java/org/collectionspace/services/common/vocabulary/AuthorityJAXBSchema.java @@ -33,7 +33,6 @@ public interface AuthorityJAXBSchema { final static String REF_NAME = "refName"; final static String VOCAB_TYPE = "vocabType"; final static String CSID = "csid"; - final static String TERM_STATUS = "termStatus"; } diff --git a/services/location/3rdparty/nuxeo-platform-cs-location/src/main/resources/schemas/locations_common.xsd b/services/location/3rdparty/nuxeo-platform-cs-location/src/main/resources/schemas/locations_common.xsd index ed0ffa7e8..62c41681f 100644 --- a/services/location/3rdparty/nuxeo-platform-cs-location/src/main/resources/schemas/locations_common.xsd +++ b/services/location/3rdparty/nuxeo-platform-cs-location/src/main/resources/schemas/locations_common.xsd @@ -28,6 +28,8 @@ + + diff --git a/services/location/jaxb/src/main/java/org/collectionspace/services/LocationJAXBSchema.java b/services/location/jaxb/src/main/java/org/collectionspace/services/LocationJAXBSchema.java index cc073fd62..1621792a5 100644 --- a/services/location/jaxb/src/main/java/org/collectionspace/services/LocationJAXBSchema.java +++ b/services/location/jaxb/src/main/java/org/collectionspace/services/LocationJAXBSchema.java @@ -2,15 +2,14 @@ * */ package org.collectionspace.services; -import org.collectionspace.services.common.vocabulary.AuthorityJAXBSchema; +import org.collectionspace.services.common.vocabulary.AuthorityItemJAXBSchema; /** * @author pschmitz * */ -public interface LocationJAXBSchema extends AuthorityJAXBSchema { +public interface LocationJAXBSchema extends AuthorityItemJAXBSchema { final static String LOCATIONS_COMMON = "locations_common"; - final static String DISPLAY_NAME_COMPUTED = "displayNameComputed"; final static String NAME = "name"; final static String CONDITION_NOTE = "conditionNote"; final static String CONDITION_NOTE_DATE = "conditionNoteDate"; diff --git a/services/location/jaxb/src/main/resources/location_common.xsd b/services/location/jaxb/src/main/resources/location_common.xsd index d66668eff..673c55364 100644 --- a/services/location/jaxb/src/main/resources/location_common.xsd +++ b/services/location/jaxb/src/main/resources/location_common.xsd @@ -27,6 +27,8 @@ + + @@ -57,6 +59,8 @@ + 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 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 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 list = coList.getLocationListItem(); Iterator 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); diff --git a/services/organization/3rdparty/nuxeo-platform-cs-organization/src/main/resources/schemas/organizations_common.xsd b/services/organization/3rdparty/nuxeo-platform-cs-organization/src/main/resources/schemas/organizations_common.xsd index baffa3866..1fe19f124 100644 --- a/services/organization/3rdparty/nuxeo-platform-cs-organization/src/main/resources/schemas/organizations_common.xsd +++ b/services/organization/3rdparty/nuxeo-platform-cs-organization/src/main/resources/schemas/organizations_common.xsd @@ -29,6 +29,8 @@ + + diff --git a/services/organization/client/src/main/java/org/collectionspace/services/client/OrgAuthorityClientUtils.java b/services/organization/client/src/main/java/org/collectionspace/services/client/OrgAuthorityClientUtils.java index cb143100a..0ff02e4ac 100644 --- a/services/organization/client/src/main/java/org/collectionspace/services/client/OrgAuthorityClientUtils.java +++ b/services/organization/client/src/main/java/org/collectionspace/services/client/OrgAuthorityClientUtils.java @@ -252,6 +252,12 @@ public class OrgAuthorityClientUtils { if((value = (String)orgInfo.get(OrganizationJAXBSchema.DISPLAY_NAME))!=null) organization.setDisplayName(value); + value = orgInfo.get(OrganizationJAXBSchema.SHORT_DISPLAY_NAME_COMPUTED); + boolean shortDisplayNameComputed = (value==null) || value.equalsIgnoreCase("true"); + organization.setShortDisplayNameComputed(shortDisplayNameComputed); + if((value = (String)orgInfo.get(OrganizationJAXBSchema.SHORT_DISPLAY_NAME))!=null) + organization.setShortDisplayName(value); + String refName = createOrganizationRefName(orgAuthRefName, shortId, value); organization.setRefName(refName); diff --git a/services/organization/jaxb/src/main/java/org/collectionspace/services/OrganizationJAXBSchema.java b/services/organization/jaxb/src/main/java/org/collectionspace/services/OrganizationJAXBSchema.java index 54d2c870b..2191ee012 100644 --- a/services/organization/jaxb/src/main/java/org/collectionspace/services/OrganizationJAXBSchema.java +++ b/services/organization/jaxb/src/main/java/org/collectionspace/services/OrganizationJAXBSchema.java @@ -3,16 +3,15 @@ */ package org.collectionspace.services; -import org.collectionspace.services.common.vocabulary.AuthorityJAXBSchema; +import org.collectionspace.services.common.vocabulary.AuthorityItemJAXBSchema; /** * @author pschmitz * */ -public interface OrganizationJAXBSchema extends AuthorityJAXBSchema { +public interface OrganizationJAXBSchema extends AuthorityItemJAXBSchema { final static String ORGANIZATIONS_COMMON = "organizations_common"; - final static String DISPLAY_NAME_COMPUTED = "displayNameComputed"; final static String SHORT_NAME = "shortName"; final static String LONG_NAME = "longName"; final static String NAME_ADDITIONS = "nameAdditions"; diff --git a/services/organization/jaxb/src/main/resources/organization_common.xsd b/services/organization/jaxb/src/main/resources/organization_common.xsd index 314509f7a..20cda416a 100644 --- a/services/organization/jaxb/src/main/resources/organization_common.xsd +++ b/services/organization/jaxb/src/main/resources/organization_common.xsd @@ -26,6 +26,8 @@ + + @@ -90,6 +92,8 @@ + 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 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 list = coList.getOrganizationListItem(); Iterator 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()); diff --git a/services/person/3rdparty/nuxeo-platform-cs-person/src/main/resources/schemas/persons_common.xsd b/services/person/3rdparty/nuxeo-platform-cs-person/src/main/resources/schemas/persons_common.xsd index ba51601b6..802d28bec 100644 --- a/services/person/3rdparty/nuxeo-platform-cs-person/src/main/resources/schemas/persons_common.xsd +++ b/services/person/3rdparty/nuxeo-platform-cs-person/src/main/resources/schemas/persons_common.xsd @@ -28,6 +28,8 @@ + + diff --git a/services/person/client/src/main/java/org/collectionspace/services/client/PersonAuthorityClientUtils.java b/services/person/client/src/main/java/org/collectionspace/services/client/PersonAuthorityClientUtils.java index f800a0ad9..60f172317 100644 --- a/services/person/client/src/main/java/org/collectionspace/services/client/PersonAuthorityClientUtils.java +++ b/services/person/client/src/main/java/org/collectionspace/services/client/PersonAuthorityClientUtils.java @@ -211,6 +211,20 @@ public class PersonAuthorityClientUtils { if (displayNameComputed == false && displayName == null) { throw new IllegalArgumentException("displayName cannot be null when displayComputed is 'false'"); } + + booleanStr = personInfo.get(PersonJAXBSchema.SHORT_DISPLAY_NAME_COMPUTED); + boolean shortDisplayNameComputed = true; + if (booleanStr != null && booleanStr.length() > 0) { + shortDisplayNameComputed = Boolean.parseBoolean(booleanStr); + } + person.setShortDisplayNameComputed(shortDisplayNameComputed); + + String shortDisplayName = personInfo.get(PersonJAXBSchema.SHORT_DISPLAY_NAME); + person.setShortDisplayName(shortDisplayName); + if (shortDisplayNameComputed == false && shortDisplayName == null) { + throw new IllegalArgumentException("shortDisplayName cannot be null when shortDisplayComputed is 'false'"); + } + String refName = createPersonRefName(personAuthRefName, shortId, displayName); person.setRefName(refName); @@ -315,6 +329,20 @@ public class PersonAuthorityClientUtils { personMap.get(PersonJAXBSchema.DEATH_DATE)); personMap.put(PersonJAXBSchema.DISPLAY_NAME, displayName); } + String shortDisplayName = personMap.get(PersonJAXBSchema.SHORT_DISPLAY_NAME); + String shortDisplayNameComputedStr = personMap.get(PersonJAXBSchema.SHORT_DISPLAY_NAME_COMPUTED); + boolean shortDisplayNameComputed = (shortDisplayNameComputedStr==null) || shortDisplayNameComputedStr.equalsIgnoreCase("true"); + if( shortDisplayName == null ) { + if(!shortDisplayNameComputed) { + throw new RuntimeException( + "CreateItem: Must supply a shortDisplayName if shortDisplayNameComputed is set to false."); + } + shortDisplayName = + prepareDefaultDisplayName( + personMap.get(PersonJAXBSchema.FORE_NAME), null, + personMap.get(PersonJAXBSchema.SUR_NAME),null,null); + personMap.put(PersonJAXBSchema.SHORT_DISPLAY_NAME, shortDisplayName); + } if(logger.isDebugEnabled()){ logger.debug("Import: Create Item: \"" + displayName diff --git a/services/person/client/src/test/java/org/collectionspace/services/client/test/PersonAuthorityServiceTest.java b/services/person/client/src/test/java/org/collectionspace/services/client/test/PersonAuthorityServiceTest.java index e4a298d9f..5efbc897a 100644 --- a/services/person/client/src/test/java/org/collectionspace/services/client/test/PersonAuthorityServiceTest.java +++ b/services/person/client/src/test/java/org/collectionspace/services/client/test/PersonAuthorityServiceTest.java @@ -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()) { diff --git a/services/person/jaxb/src/main/java/org/collectionspace/services/PersonJAXBSchema.java b/services/person/jaxb/src/main/java/org/collectionspace/services/PersonJAXBSchema.java index bc692f032..a9b8ce981 100644 --- a/services/person/jaxb/src/main/java/org/collectionspace/services/PersonJAXBSchema.java +++ b/services/person/jaxb/src/main/java/org/collectionspace/services/PersonJAXBSchema.java @@ -2,15 +2,14 @@ * */ package org.collectionspace.services; -import org.collectionspace.services.common.vocabulary.AuthorityJAXBSchema; +import org.collectionspace.services.common.vocabulary.AuthorityItemJAXBSchema; /** * @author pschmitz * */ -public interface PersonJAXBSchema extends AuthorityJAXBSchema { +public interface PersonJAXBSchema extends AuthorityItemJAXBSchema { final static String PERSONS_COMMON = "persons_common"; - final static String DISPLAY_NAME_COMPUTED = "displayNameComputed"; final static String FORE_NAME = "foreName"; final static String MIDDLE_NAME = "middleName"; final static String SUR_NAME = "surName"; diff --git a/services/person/jaxb/src/main/resources/person_common.xsd b/services/person/jaxb/src/main/resources/person_common.xsd index a9b7f9651..3902d7f0c 100644 --- a/services/person/jaxb/src/main/resources/person_common.xsd +++ b/services/person/jaxb/src/main/resources/person_common.xsd @@ -33,11 +33,13 @@ - + + + @@ -103,6 +105,8 @@ + 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 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 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 list = coList.getPersonListItem(); Iterator 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()); diff --git a/services/vocabulary/jaxb/src/main/resources/vocabulary_common.xsd b/services/vocabulary/jaxb/src/main/resources/vocabulary_common.xsd index ce0b52d58..b9afa8aa0 100644 --- a/services/vocabulary/jaxb/src/main/resources/vocabulary_common.xsd +++ b/services/vocabulary/jaxb/src/main/resources/vocabulary_common.xsd @@ -36,7 +36,7 @@ - + diff --git a/services/vocabulary/jaxb/src/main/resources/vocabularyitem_common.xsd b/services/vocabulary/jaxb/src/main/resources/vocabularyitem_common.xsd index 4e7af77c0..add19438f 100644 --- a/services/vocabulary/jaxb/src/main/resources/vocabularyitem_common.xsd +++ b/services/vocabulary/jaxb/src/main/resources/vocabularyitem_common.xsd @@ -49,6 +49,8 @@ + 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 list = coList.getVocabularyitemListItem(); Iterator 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);