From df15f4297c622c489edc9aba1a104a579f21cbf8 Mon Sep 17 00:00:00 2001 From: Amy Wieliczka Date: Fri, 11 May 2012 17:09:05 -0700 Subject: [PATCH] CSPACE-5128: Converted Person birthDate and deathDate to structuredDateGroups --- .../resources/OSGI-INF/layouts-contrib.xml | 30 +---------- .../main/resources/schemas/persons_common.xsd | 35 +++++++++++- .../client/PersonAuthorityClientUtils.java | 53 +++++++++++-------- .../jaxb/src/main/resources/person_common.xsd | 36 ++++++++++++- .../services/person/client/sample/Sample.java | 28 ++++++---- 5 files changed, 115 insertions(+), 67 deletions(-) diff --git a/services/person/3rdparty/nuxeo-platform-cs-person/src/main/resources/OSGI-INF/layouts-contrib.xml b/services/person/3rdparty/nuxeo-platform-cs-person/src/main/resources/OSGI-INF/layouts-contrib.xml index f5099c5f7..309e8bb75 100644 --- a/services/person/3rdparty/nuxeo-platform-cs-person/src/main/resources/OSGI-INF/layouts-contrib.xml +++ b/services/person/3rdparty/nuxeo-platform-cs-person/src/main/resources/OSGI-INF/layouts-contrib.xml @@ -89,8 +89,6 @@ salutation title nameAdditions - birthDate - deathDate birthPlace deathPlace @@ -247,33 +245,7 @@ dataInputText - - - - - - true - - birthDate - - - dataInputText - - - - - - - - true - - deathDate - - - dataInputText - - - + 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 56cc99ce3..a5678030b 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 @@ -30,8 +30,8 @@ - - + + @@ -97,6 +97,37 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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 83ccfd6e3..75745ebf7 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 @@ -47,6 +47,7 @@ import org.jboss.resteasy.client.ClientResponse; //import org.jboss.resteasy.plugins.providers.multipart.OutputPart; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import org.collectionspace.services.person.StructuredDateGroup; /** * The Class PersonAuthorityClientUtils. @@ -203,10 +204,16 @@ public class PersonAuthorityClientUtils { String value; List values = null; - if((value = (String)personInfo.get(PersonJAXBSchema.BIRTH_DATE))!=null) - person.setBirthDate(value); - if((value = (String)personInfo.get(PersonJAXBSchema.DEATH_DATE))!=null) - person.setDeathDate(value); + if((value = (String)personInfo.get(PersonJAXBSchema.BIRTH_DATE))!=null) { + StructuredDateGroup birthDate = new StructuredDateGroup(); + birthDate.setDateDisplayDate(value); + person.setBirthDate(birthDate); + } + if((value = (String)personInfo.get(PersonJAXBSchema.DEATH_DATE))!=null) { + StructuredDateGroup deathDate = new StructuredDateGroup(); + deathDate.setDateDisplayDate(value); + person.setDeathDate(deathDate); + } if((value = (String)personInfo.get(PersonJAXBSchema.BIRTH_PLACE))!=null) person.setBirthPlace(value); if((value = (String)personInfo.get(PersonJAXBSchema.DEATH_PLACE))!=null) @@ -409,8 +416,8 @@ public class PersonAuthorityClientUtils { * @return display name */ public static String prepareDefaultDisplayName( - String foreName, String middleName, String surName, - String birthDate, String deathDate ) { + String foreName, String middleName, String surName, + String birthDate, String deathDate) { StringBuilder newStr = new StringBuilder(); final String sep = " "; final String dateSep = "-"; @@ -428,23 +435,23 @@ public class PersonAuthorityClientUtils { } // Now we add the dates. In theory could have dates with no name, but that is their problem. boolean foundBirth = false; - if(null != birthDate) { - if(firstAdded) { - newStr.append(sep); - } - newStr.append(birthDate); - newStr.append(dateSep); // Put this in whether there is a death date or not - foundBirth = true; - } - if(null != deathDate) { - if(!foundBirth) { - if(firstAdded) { - newStr.append(sep); - } - newStr.append(dateSep); - } - newStr.append(deathDate); - } + if(null != birthDate) { + if(firstAdded) { + newStr.append(sep); + } + newStr.append(birthDate); + newStr.append(dateSep); // Put this in whether there is a death date or not + foundBirth = true; + } + if(null != deathDate) { + if(!foundBirth) { + if(firstAdded) { + newStr.append(sep); + } + newStr.append(dateSep); + } + newStr.append(deathDate); + } return newStr.toString(); } diff --git a/services/person/jaxb/src/main/resources/person_common.xsd b/services/person/jaxb/src/main/resources/person_common.xsd index 62402ff70..c09112e52 100644 --- a/services/person/jaxb/src/main/resources/person_common.xsd +++ b/services/person/jaxb/src/main/resources/person_common.xsd @@ -40,8 +40,8 @@ - - + + @@ -111,5 +111,37 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/services/person/sample/sample/src/main/java/org/collectionspace/services/person/client/sample/Sample.java b/services/person/sample/sample/src/main/java/org/collectionspace/services/person/client/sample/Sample.java index 3ff81ae99..105d37431 100644 --- a/services/person/sample/sample/src/main/java/org/collectionspace/services/person/client/sample/Sample.java +++ b/services/person/sample/sample/src/main/java/org/collectionspace/services/person/client/sample/Sample.java @@ -123,8 +123,8 @@ public class Sample { String foreName = personMap.get(PersonJAXBSchema.FORE_NAME); String middleName = personMap.get(PersonJAXBSchema.MIDDLE_NAME); String surName = personMap.get(PersonJAXBSchema.SUR_NAME); - String birthDate = personMap.get(PersonJAXBSchema.BIRTH_DATE); - String deathDate = personMap.get(PersonJAXBSchema.DEATH_DATE); + String birthDate = personMap.get(PersonJAXBSchema.BIRTH_DATE); + String deathDate = personMap.get(PersonJAXBSchema.DEATH_DATE); StringBuilder builtName = new StringBuilder(); if(foreName!=null) builtName.append(foreName); @@ -132,11 +132,11 @@ public class Sample { builtName.append(middleName); if(surName!=null) builtName.append(surName); - if(birthDate!=null) - builtName.append(birthDate); - builtName.append("-"); - if(deathDate!=null) - builtName.append(deathDate); + if(birthDate!=null) + builtName.append(birthDate); + builtName.append("-"); + if(deathDate!=null) + builtName.append(deathDate); String displaySuffix = "displayName-" + System.currentTimeMillis(); //TODO: Laramie20100728 temp fix, made-up displaySuffix. @@ -372,10 +372,16 @@ public class Sample { person.setTitle(value); if((value = (String)personInfo.get(PersonJAXBSchema.NAME_ADDITIONS))!=null) person.setNameAdditions(value); - if((value = (String)personInfo.get(PersonJAXBSchema.BIRTH_DATE))!=null) - person.setBirthDate(value); - if((value = (String)personInfo.get(PersonJAXBSchema.DEATH_DATE))!=null) - person.setDeathDate(value); + if((value = (String)personInfo.get(PersonJAXBSchema.BIRTH_DATE))!=null) { + StructuredDateGroup birthDate = new StructuredDateGroup(); + birthDate.setDateDisplayDate(value); + person.setBirthDate(birthDate); + } + if((value = (String)personInfo.get(PersonJAXBSchema.DEATH_DATE))!=null) { + StructuredDateGroup deathDate = new StructuredDateGroup(); + deathDate.setDateDisplayDate(value); + person.setDeathDate(deathDate); + } if((value = (String)personInfo.get(PersonJAXBSchema.BIRTH_PLACE))!=null) person.setBirthPlace(value); if((value = (String)personInfo.get(PersonJAXBSchema.DEATH_PLACE))!=null) -- 2.47.3