From d6a66bc6a98e0c37212e62c03192db780aef556a Mon Sep 17 00:00:00 2001 From: Patrick Schmitz Date: Wed, 13 Jan 2010 23:10:49 +0000 Subject: [PATCH] CSPACE-725 - Refactored instance creation methods into a shared utility class. --- services/person/client/.classpath | 2 + .../client/PersonAuthorityClientUtils.java | 236 ++++++++++++++++++ .../test/PersonAuthorityServiceTest.java | 159 ++++-------- services/person/import/.classpath | 1 + services/person/import/.project | 3 + .../nuxeo/PersonDocumentModelHandler.java | 54 ++-- 6 files changed, 336 insertions(+), 119 deletions(-) create mode 100644 services/person/client/src/main/java/org/collectionspace/services/client/PersonAuthorityClientUtils.java diff --git a/services/person/client/.classpath b/services/person/client/.classpath index cec251a43..425cd1620 100644 --- a/services/person/client/.classpath +++ b/services/person/client/.classpath @@ -1,7 +1,9 @@ + + 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 new file mode 100644 index 000000000..3f3a96465 --- /dev/null +++ b/services/person/client/src/main/java/org/collectionspace/services/client/PersonAuthorityClientUtils.java @@ -0,0 +1,236 @@ +package org.collectionspace.services.client; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.Map; + +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.MultivaluedMap; +import javax.ws.rs.core.Response; + +import org.collectionspace.services.PersonJAXBSchema; +import org.collectionspace.services.client.test.ServiceRequestType; +import org.collectionspace.services.person.PersonsCommon; +import org.collectionspace.services.person.PersonauthoritiesCommon; +import org.jboss.resteasy.client.ClientResponse; +import org.jboss.resteasy.plugins.providers.multipart.MultipartOutput; +import org.jboss.resteasy.plugins.providers.multipart.OutputPart; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class PersonAuthorityClientUtils { + private static final Logger logger = + LoggerFactory.getLogger(PersonAuthorityClientUtils.class); + + public static MultipartOutput createPersonAuthorityInstance( + String displayName, String refName, String headerLabel ) { + PersonauthoritiesCommon personAuthority = new PersonauthoritiesCommon(); + personAuthority.setDisplayName(displayName); + personAuthority.setRefName(refName); + personAuthority.setVocabType("PersonAuthority"); + MultipartOutput multipart = new MultipartOutput(); + OutputPart commonPart = multipart.addPart(personAuthority, MediaType.APPLICATION_XML_TYPE); + commonPart.getHeaders().add("label", headerLabel); + + if(logger.isDebugEnabled()){ + logger.debug("to be created, personAuthority common ", + personAuthority, PersonauthoritiesCommon.class); + } + + return multipart; + } + + public static MultipartOutput createPersonInstance(String inAuthority, + String personRefName, Map personInfo, String headerLabel){ + PersonsCommon person = new PersonsCommon(); + person.setInAuthority(inAuthority); + person.setRefName(personRefName); + String value = null; + if((value = (String)personInfo.get(PersonJAXBSchema.FORE_NAME))!=null) + person.setForeName(value); + if((value = (String)personInfo.get(PersonJAXBSchema.MIDDLE_NAME))!=null) + person.setMiddleName(value); + if((value = (String)personInfo.get(PersonJAXBSchema.SUR_NAME))!=null) + person.setSurName(value); + if((value = (String)personInfo.get(PersonJAXBSchema.INITIALS))!=null) + person.setInitials(value); + if((value = (String)personInfo.get(PersonJAXBSchema.SALUTATIONS))!=null) + person.setSalutation(value); + if((value = (String)personInfo.get(PersonJAXBSchema.TITLE))!=null) + 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_PLACE))!=null) + person.setBirthPlace(value); + if((value = (String)personInfo.get(PersonJAXBSchema.DEATH_PLACE))!=null) + person.setDeathPlace(value); + if((value = (String)personInfo.get(PersonJAXBSchema.GROUP))!=null) + person.setGroup(value); + if((value = (String)personInfo.get(PersonJAXBSchema.NATIONALITY))!=null) + person.setNationality(value); + if((value = (String)personInfo.get(PersonJAXBSchema.GENDER))!=null) + person.setGender(value); + if((value = (String)personInfo.get(PersonJAXBSchema.OCCUPATION))!=null) + person.setOccupation(value); + if((value = (String)personInfo.get(PersonJAXBSchema.SCHOOL_OR_STYLE))!=null) + person.setSchoolOrStyle(value); + if((value = (String)personInfo.get(PersonJAXBSchema.BIO_NOTE))!=null) + person.setBioNote(value); + if((value = (String)personInfo.get(PersonJAXBSchema.NAME_NOTE))!=null) + person.setNameNote(value); + MultipartOutput multipart = new MultipartOutput(); + OutputPart commonPart = multipart.addPart(person, + MediaType.APPLICATION_XML_TYPE); + commonPart.getHeaders().add("label", headerLabel); + + if(logger.isDebugEnabled()){ + logger.debug("to be created, person common ", person, PersonsCommon.class); + } + + return multipart; + } + + public static String createItemInAuthority(String vcsid, + String personAuthorityRefName, Map personMap, + PersonAuthorityClient client ) { + // Expected status code: 201 Created + int EXPECTED_STATUS_CODE = Response.Status.CREATED.getStatusCode(); + // Type of service request being tested + ServiceRequestType REQUEST_TYPE = ServiceRequestType.CREATE; + String displayName = + prepareDefaultDisplayName( + personMap.get(PersonJAXBSchema.FORE_NAME), + personMap.get(PersonJAXBSchema.MIDDLE_NAME), + personMap.get(PersonJAXBSchema.SUR_NAME), + personMap.get(PersonJAXBSchema.BIRTH_DATE), + personMap.get(PersonJAXBSchema.DEATH_DATE)); + String refName = createPersonRefName(personAuthorityRefName, + displayName); + + if(logger.isDebugEnabled()){ + logger.debug("Import: Create Item: \""+displayName + +"\" in personAuthorityulary: \"" + personAuthorityRefName +"\""); + } + MultipartOutput multipart = + createPersonInstance( vcsid, refName, + personMap, client.getItemCommonPartName() ); + ClientResponse res = client.createItem(vcsid, multipart); + + int statusCode = res.getStatus(); + + if(!REQUEST_TYPE.isValidStatusCode(statusCode)) { + throw new RuntimeException("Could not create Item: \""+refName + +"\" in personAuthority: \"" + personAuthorityRefName + +"\" "+ invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); + } + if(statusCode != EXPECTED_STATUS_CODE) { + throw new RuntimeException("Unexpected Status when creating Item: \""+refName + +"\" in personAuthority: \"" + personAuthorityRefName +"\", Status:"+ statusCode); + } + + return extractId(res); + } + + public static String createPersonAuthRefName(String personAuthorityName) { + return "urn:cspace:org.collectionspace.demo:personauthority:name(" + +personAuthorityName+")"; + } + + public static String createPersonRefName( + String personAuthRefName, String personName) { + return personAuthRefName+":person:name("+personName+")"; + } + + public static String extractId(ClientResponse res) { + MultivaluedMap mvm = res.getMetadata(); + String uri = (String) ((ArrayList) mvm.get("Location")).get(0); + if(logger.isDebugEnabled()){ + logger.debug("extractId:uri=" + uri); + } + String[] segments = uri.split("/"); + String id = segments[segments.length - 1]; + if(logger.isDebugEnabled()){ + logger.debug("id=" + id); + } + return id; + } + + /** + * Returns an error message indicating that the status code returned by a + * specific call to a service does not fall within a set of valid status + * codes for that service. + * + * @param serviceRequestType A type of service request (e.g. CREATE, DELETE). + * + * @param statusCode The invalid status code that was returned in the response, + * from submitting that type of request to the service. + * + * @return An error message. + */ + public static String invalidStatusCodeMessage(ServiceRequestType requestType, int statusCode) { + return "Status code '" + statusCode + "' in response is NOT within the expected set: " + + requestType.validStatusCodesAsString(); + } + + + + /** + * Produces a default displayName from the basic name and dates fields. + * @see PersonDocumentModelHandler.prepareDefaultDisplayName() which + * duplicates this logic, until we define a service-general utils package + * that is neither client nor service specific. + * @param foreName + * @param middleName + * @param surName + * @param birthDate + * @param deathDate + * @return + */ + public static String prepareDefaultDisplayName( + String foreName, String middleName, String surName, + String birthDate, String deathDate ) { + StringBuilder newStr = new StringBuilder(); + final String sep = " "; + final String dateSep = "-"; + List nameStrings = + Arrays.asList(foreName, middleName, surName); + boolean firstAdded = false; + for(String partStr : nameStrings ){ + if(null != partStr ) { + if(firstAdded) { + newStr.append(sep); + } + newStr.append(partStr); + firstAdded = true; + } + } + // 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); + } + return newStr.toString(); + } + + + +} 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 79c43c779..e449dfdcb 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 @@ -26,15 +26,17 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; + import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; +import org.collectionspace.services.PersonJAXBSchema; import org.collectionspace.services.client.PersonAuthorityClient; +import org.collectionspace.services.client.PersonAuthorityClientUtils; import org.collectionspace.services.person.PersonauthoritiesCommon; import org.collectionspace.services.person.PersonauthoritiesCommonList; import org.collectionspace.services.person.PersonsCommon; import org.collectionspace.services.person.PersonsCommonList; - import org.jboss.resteasy.client.ClientResponse; import org.jboss.resteasy.plugins.providers.multipart.MultipartInput; import org.jboss.resteasy.plugins.providers.multipart.MultipartOutput; @@ -96,11 +98,11 @@ public class PersonAuthorityServiceTest extends AbstractServiceTest { // Submit the request to the service and store the response. String identifier = createIdentifier(); - String displayName = "displayName-" + identifier; + String displayName = "displayName-" + identifier; String refName = createPersonAuthRefName(displayName); - String typeName = "vocabType-" + identifier; MultipartOutput multipart = - createPersonAuthorityInstance(displayName, refName, typeName); + PersonAuthorityClientUtils.createPersonAuthorityInstance( + displayName, refName, client.getCommonPartName()); ClientResponse res = client.create(multipart); int statusCode = res.getStatus(); @@ -121,7 +123,7 @@ public class PersonAuthorityServiceTest extends AbstractServiceTest { // for additional tests below. knownResourceRefName = refName; - lastPersonAuthId = extractId(res); + lastPersonAuthId = PersonAuthorityClientUtils.extractId(res); // Store the ID returned from the first resource created // for additional tests below. if (knownResourceId == null){ @@ -132,7 +134,7 @@ public class PersonAuthorityServiceTest extends AbstractServiceTest { } // Store the IDs from every resource created by tests, // so they can be deleted after tests have been run. - allResourceIdsCreated.add(extractId(res)); + allResourceIdsCreated.add(lastPersonAuthId); } @@ -156,13 +158,26 @@ public class PersonAuthorityServiceTest extends AbstractServiceTest { // Submit the request to the service and store the response. String identifier = createIdentifier(); - String refName = createPersonRefName(authRefName, "Patrick Schmitz"); - MultipartOutput multipart = createPersonInstance(vcsid, refName, - "Patrick","Lee","Schmitz","pls", null, null, null, - "1960", null, "Detroit, MI", null, "Coders", "American", "male", - null, null, null, null ); + Map johnWayneMap = new HashMap(); + johnWayneMap.put(PersonJAXBSchema.FORE_NAME, "John"); + johnWayneMap.put(PersonJAXBSchema.SUR_NAME, "Wayne"); + johnWayneMap.put(PersonJAXBSchema.GENDER, "male"); + johnWayneMap.put(PersonJAXBSchema.BIRTH_DATE, "May 26, 1907"); + johnWayneMap.put(PersonJAXBSchema.BIRTH_PLACE, "Winterset, Iowa"); + johnWayneMap.put(PersonJAXBSchema.DEATH_DATE, "June 11, 1979"); + johnWayneMap.put(PersonJAXBSchema.BIO_NOTE, "born Marion Robert Morrison and better" + + "known by his stage name John Wayne, was an American film actor, director " + + "and producer. He epitomized rugged masculinity and has become an enduring " + + "American icon. He is famous for his distinctive voice, walk and height. " + + "He was also known for his conservative political views and his support in " + + "the 1950s for anti-communist positions."); + String refName = createPersonRefName(authRefName, "John Wayne"); + MultipartOutput multipart = + PersonAuthorityClientUtils.createPersonInstance(vcsid, refName, johnWayneMap, + client.getItemCommonPartName() ); ClientResponse res = client.createItem(vcsid, multipart); int statusCode = res.getStatus(); + String extractedID = PersonAuthorityClientUtils.extractId(res); // Check the status code of the response: does it match // the expected response(s)? @@ -173,10 +188,11 @@ public class PersonAuthorityServiceTest extends AbstractServiceTest { invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE); + // Store the ID returned from the first item resource created // for additional tests below. if (knownItemResourceId == null){ - knownItemResourceId = extractId(res); + knownItemResourceId = extractedID; if (logger.isDebugEnabled()) { logger.debug(testName + ": knownItemResourceId=" + knownItemResourceId); } @@ -188,9 +204,9 @@ public class PersonAuthorityServiceTest extends AbstractServiceTest { // // Item resource IDs are unique, so these are used as keys; // the non-unique IDs of their parents are stored as associated values. - allResourceItemIdsCreated.put(extractId(res), vcsid); + allResourceItemIdsCreated.put(extractedID, vcsid); - return extractId(res); + return extractedID; } @Override @@ -397,6 +413,12 @@ public class PersonAuthorityServiceTest extends AbstractServiceTest { PersonsCommon person = (PersonsCommon) extractPart(input, client.getItemCommonPartName(), PersonsCommon.class); Assert.assertNotNull(person); + boolean showFull = true; + if(showFull && logger.isDebugEnabled()){ + logger.debug(testName + ": returned payload:"); + logger.debug(objectAsXmlString(person, PersonsCommon.class)); + } + Assert.assertEquals(person.getInAuthority(), knownResourceId); } @@ -526,19 +548,21 @@ public class PersonAuthorityServiceTest extends AbstractServiceTest { } Assert.assertEquals( nItemsReturned, nItemsToCreateInList); - // Optionally output additional data about list members for debugging. - boolean iterateThroughList = false; - if (iterateThroughList && logger.isDebugEnabled()) { - int i = 0; - for (PersonsCommonList.PersonListItem item : items) { + int i = 0; + for (PersonsCommonList.PersonListItem item : items) { + Assert.assertTrue((null != item.getRefName()), "Item refName is null!"); + Assert.assertTrue((null != item.getDisplayName()), "Item displayName is null!"); + // Optionally output additional data about list members for debugging. + boolean showDetails = true; + if (showDetails && logger.isDebugEnabled()) { logger.debug(" " + testName + ": list-item[" + i + "] csid=" + item.getCsid()); logger.debug(" " + testName + ": list-item[" + i + "] displayName=" + item.getDisplayName()); logger.debug(" " + testName + ": list-item[" + i + "] URI=" + item.getUri()); - i++; } + i++; } } @@ -804,11 +828,14 @@ public class PersonAuthorityServiceTest extends AbstractServiceTest { // The only relevant ID may be the one used in update(), below. // The only relevant ID may be the one used in update(), below. - MultipartOutput multipart = createPersonInstance(NON_EXISTENT_ID, - createPersonRefName(NON_EXISTENT_ID, NON_EXISTENT_ID), - "Patrick","Lee","Schmitz","pls", null, null, null, - "1960", null, "Detroit, MI", null, "Coders", "American", "male", - null, null, null, null ); + Map nonexMap = new HashMap(); + nonexMap.put(PersonJAXBSchema.FORE_NAME, "John"); + nonexMap.put(PersonJAXBSchema.SUR_NAME, "Wayne"); + nonexMap.put(PersonJAXBSchema.GENDER, "male"); + MultipartOutput multipart = + PersonAuthorityClientUtils.createPersonInstance(NON_EXISTENT_ID, + createPersonRefName(NON_EXISTENT_ID, NON_EXISTENT_ID), nonexMap, + client.getItemCommonPartName() ); ClientResponse res = client.updateItem(knownResourceId, NON_EXISTENT_ID, multipart); int statusCode = res.getStatus(); @@ -1038,85 +1065,9 @@ public class PersonAuthorityServiceTest extends AbstractServiceTest { private MultipartOutput createPersonAuthorityInstance(String identifier) { String displayName = "displayName-" + identifier; String refName = createPersonAuthRefName(displayName); - String typeName = "vocabType-" + identifier; - return createPersonAuthorityInstance( - displayName, refName,typeName ); + return + PersonAuthorityClientUtils.createPersonAuthorityInstance( + displayName, refName, client.getCommonPartName()); } - private MultipartOutput createPersonAuthorityInstance( - String displayName, String refName, String vocabType) { - PersonauthoritiesCommon personAuthority = new PersonauthoritiesCommon(); - personAuthority.setDisplayName(displayName); - if(refName!=null) - personAuthority.setRefName(refName); - personAuthority.setVocabType(vocabType); - MultipartOutput multipart = new MultipartOutput(); - OutputPart commonPart = multipart.addPart(personAuthority, MediaType.APPLICATION_XML_TYPE); - commonPart.getHeaders().add("label", client.getCommonPartName()); - - if(logger.isDebugEnabled()) { - logger.debug("to be created, personAuthority common"); - logger.debug(objectAsXmlString(personAuthority, PersonauthoritiesCommon.class)); - } - return multipart; - } - - private MultipartOutput createPersonInstance(String inAuthority, String refName, - String foreName, String middleName, String surName, - String initials, String salutation, String title, String nameAdditions, - String birthDate, String deathDate, String birthPlace, String deathPlace, - String group, String nationality, String gender, String occupation, - String schoolOrStyle, String bioNote, String nameNote ) { - PersonsCommon person = new PersonsCommon(); - person.setInAuthority(inAuthority); - person.setRefName(refName); - if(foreName!=null) - person.setForeName(foreName); - if(middleName!=null) - person.setMiddleName(middleName); - if(surName!=null) - person.setSurName(surName); - if(initials!=null) - person.setInitials(initials); - if(salutation!=null) - person.setSalutation(salutation); - if(title!=null) - person.setTitle(title); - if(nameAdditions!=null) - person.setNameAdditions(nameAdditions); - if(birthDate!=null) - person.setBirthDate(birthDate); - if(deathDate!=null) - person.setDeathDate(deathDate); - if(birthPlace!=null) - person.setBirthPlace(birthPlace); - if(deathPlace!=null) - person.setDeathPlace(deathPlace); - if(group!=null) - person.setGroup(group); - if(nationality!=null) - person.setNationality(nationality); - if(gender!=null) - person.setGender(gender); - if(occupation!=null) - person.setOccupation(occupation); - if(schoolOrStyle!=null) - person.setSchoolOrStyle(schoolOrStyle); - if(bioNote!=null) - person.setBioNote(bioNote); - if(nameNote!=null) - person.setNameNote(nameNote); - MultipartOutput multipart = new MultipartOutput(); - OutputPart commonPart = multipart.addPart(person, - MediaType.APPLICATION_XML_TYPE); - commonPart.getHeaders().add("label", client.getItemCommonPartName()); - - if(logger.isDebugEnabled()){ - logger.debug("to be created, person common"); - logger.debug(objectAsXmlString(person, - PersonsCommon.class)); - } - - return multipart; - } } diff --git a/services/person/import/.classpath b/services/person/import/.classpath index 83343792e..199bbbbdb 100644 --- a/services/person/import/.classpath +++ b/services/person/import/.classpath @@ -1,6 +1,7 @@ + diff --git a/services/person/import/.project b/services/person/import/.project index 6d98bdb53..ae21be519 100644 --- a/services/person/import/.project +++ b/services/person/import/.project @@ -3,6 +3,9 @@ org.collectionspace.services.person.importer + org.collectionspace.services.client + org.collectionspace.services.common + org.collectionspace.services.person.jaxb 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 e02b5b055..6db5909e7 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 @@ -46,6 +46,10 @@ import org.slf4j.LoggerFactory; * $LastChangedRevision: $ * $LastChangedDate: $ */ +/** + * @author pschmitz + * + */ public class PersonDocumentModelHandler extends RemoteDocumentModelHandler { @@ -95,50 +99,70 @@ public class PersonDocumentModelHandler } private String prepareDefaultDisplayName(DocumentModel docModel) throws Exception { + String commonPartLabel = getServiceContext().getCommonPartLabel("persons"); + return 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 ) + ); + } + + + /** + * Produces a default displayName from the basic name and dates fields. + * @see PersonAuthorityClientUtils.prepareDefaultDisplayName() which + * duplicates this logic, until we define a service-general utils package + * that is neither client nor service specific. + * @param foreName + * @param middleName + * @param surName + * @param birthDate + * @param deathDate + * @return + * @throws Exception + */ + private static String prepareDefaultDisplayName( + String foreName, String middleName, String surName, + String birthDate, String deathDate ) throws Exception { StringBuilder newStr = new StringBuilder(); - String part = null; final String sep = " "; final String dateSep = "-"; List nameStrings = - Arrays.asList(PersonJAXBSchema.FORE_NAME, PersonJAXBSchema.MIDDLE_NAME, - PersonJAXBSchema.SUR_NAME); + Arrays.asList(foreName, middleName, surName); boolean firstAdded = false; for(String partStr : nameStrings ){ - if(null != (part = (String) - docModel.getProperty(getServiceContext().getCommonPartLabel("persons"), partStr ))) { + if(null != partStr ) { if(firstAdded) { newStr.append(sep); } - newStr.append(part); + newStr.append(partStr); firstAdded = true; } } // Now we add the dates. In theory could have dates with no name, but that is their problem. boolean foundBirth = false; - if(null != (part = (String) - docModel.getProperty(getServiceContext().getCommonPartLabel("persons"), - PersonJAXBSchema.BIRTH_DATE ))) { + if(null != birthDate) { if(firstAdded) { newStr.append(sep); } - newStr.append(part); + newStr.append(birthDate); newStr.append(dateSep); // Put this in whether there is a death date or not foundBirth = true; } - if(null != (part = (String) - docModel.getProperty(getServiceContext().getCommonPartLabel("persons"), - PersonJAXBSchema.DEATH_DATE ))) { + if(null != deathDate) { if(!foundBirth) { if(firstAdded) { newStr.append(sep); } newStr.append(dateSep); } - newStr.append(part); + newStr.append(deathDate); } return newStr.toString(); } - + /** * getCommonPart get associated person * @return -- 2.47.3