From 3a8eb01e7afe52f3baa4d58fdbb85b7a988a67c7 Mon Sep 17 00:00:00 2001 From: Rick Jaffe Date: Thu, 5 Apr 2012 16:53:21 -0700 Subject: [PATCH] CODE-6: Rename 'name' field in placeNameGroup to 'placeName' to avoid Advanced Search issues, plus related changes to tests, etc. --- .../main/resources/schemas/places_common.xsd | 2 +- .../client/PlaceAuthorityClientUtils.java | 12 ++++---- .../test/PlaceAuthorityServiceTest.java | 30 +++++++++---------- .../services/PlaceJAXBSchema.java | 2 +- .../jaxb/src/main/resources/place_common.xsd | 2 +- .../nuxeo/PlaceDocumentModelHandler.java | 14 ++++----- 6 files changed, 31 insertions(+), 31 deletions(-) diff --git a/services/place/3rdparty/nuxeo-platform-cs-place/src/main/resources/schemas/places_common.xsd b/services/place/3rdparty/nuxeo-platform-cs-place/src/main/resources/schemas/places_common.xsd index a59b671c7..393891143 100644 --- a/services/place/3rdparty/nuxeo-platform-cs-place/src/main/resources/schemas/places_common.xsd +++ b/services/place/3rdparty/nuxeo-platform-cs-place/src/main/resources/schemas/places_common.xsd @@ -68,7 +68,7 @@ - + diff --git a/services/place/client/src/main/java/org/collectionspace/services/client/PlaceAuthorityClientUtils.java b/services/place/client/src/main/java/org/collectionspace/services/client/PlaceAuthorityClientUtils.java index b537e8c16..75a6138a4 100644 --- a/services/place/client/src/main/java/org/collectionspace/services/client/PlaceAuthorityClientUtils.java +++ b/services/place/client/src/main/java/org/collectionspace/services/client/PlaceAuthorityClientUtils.java @@ -80,11 +80,11 @@ public class PlaceAuthorityClientUtils { place.setDisplayNameComputed(displayNameComputed); /* TODO - think about how much to support. This approach to the client * does not scale! We should really favor the document/payload approach. */ - if((value = (String)placeInfo.get(PlaceJAXBSchema.NAME))!=null) { + if((value = (String)placeInfo.get(PlaceJAXBSchema.PLACE_NAME))!=null) { PlaceNameGroupList placeNameGroupList = new PlaceNameGroupList(); List placeNameGroups = placeNameGroupList.getPlaceNameGroup(); PlaceNameGroup placeNameGroup = new PlaceNameGroup(); - placeNameGroup.setName(value); + placeNameGroup.setPlaceName(value); placeNameGroups.add(placeNameGroup); place.setPlaceNameGroupList(placeNameGroupList); } @@ -131,7 +131,7 @@ public class PlaceAuthorityClientUtils { /* Could try to pull name out of first placeNameGroup displayName = prepareDefaultDisplayName( - placeMap.get(PlaceJAXBSchema.NAME)); + placeMap.get(PlaceJAXBSchema.PLACE_NAME)); */ } @@ -295,13 +295,13 @@ public class PlaceAuthorityClientUtils { * @see PlaceAuthorityDocumentModelHandler.prepareDefaultDisplayName() which * duplicates this logic, until we define a service-general utils package * that is neither client nor service specific. - * @param name + * @param placeName * @return a display name */ public static String prepareDefaultDisplayName( - String name ) { + String placeName ) { StringBuilder newStr = new StringBuilder(); - newStr.append(name); + newStr.append(placeName); return newStr.toString(); } diff --git a/services/place/client/src/test/java/org/collectionspace/services/client/test/PlaceAuthorityServiceTest.java b/services/place/client/src/test/java/org/collectionspace/services/client/test/PlaceAuthorityServiceTest.java index 7186f79ba..39cdd1297 100644 --- a/services/place/client/src/test/java/org/collectionspace/services/client/test/PlaceAuthorityServiceTest.java +++ b/services/place/client/src/test/java/org/collectionspace/services/client/test/PlaceAuthorityServiceTest.java @@ -132,7 +132,7 @@ public class PlaceAuthorityServiceTest extends AbstractAuthorityServiceTest placeNameGroups = placeNameGroupList.getPlaceNameGroup(); Assert.assertNotNull(placeNameGroups); Assert.assertTrue(placeNameGroups.size() > 0); - String name = placeNameGroups.get(0).getName(); - Assert.assertNotNull(name); + String placeName = placeNameGroups.get(0).getPlaceName(); + Assert.assertNotNull(placeName); // Update the contents of this resource. final String PLACE_NAME_ADDITION = "verify-item-place-name-updated"; - placeNameGroups.get(0).setName(PLACE_NAME_ADDITION + TEST_NAME); + placeNameGroups.get(0).setPlaceName(PLACE_NAME_ADDITION + TEST_NAME); place.setPlaceNameGroupList(placeNameGroupList); if (logger.isDebugEnabled()) { logger.debug("to be updated Place"); @@ -579,20 +579,20 @@ public class PlaceAuthorityServiceTest extends AbstractAuthorityServiceTest placeNameGroups = placeNameGroupList.getPlaceNameGroup(); Assert.assertNotNull(placeNameGroups); Assert.assertTrue(placeNameGroups.size() > 0); - String originalName = placeNameGroups.get(0).getName(); - Assert.assertNotNull(originalName); + String originalPlaceName = placeNameGroups.get(0).getPlaceName(); + Assert.assertNotNull(originalPlaceName); // Update the contents of the new resource based on original value PlaceNameGroupList updatedPlaceNameGroupList = new PlaceNameGroupList(); List updatedPlaceNameGroups = updatedPlaceNameGroupList.getPlaceNameGroup(); PlaceNameGroup updatedPlaceNameGroup = new PlaceNameGroup(); - updatedPlaceNameGroup.setName("updated-" + originalName); + updatedPlaceNameGroup.setPlaceName("updated-" + originalPlaceName); updatedPlaceNameGroups.add(updatedPlaceNameGroup); PlacesCommon result = new PlacesCommon(); result.setPlaceNameGroupList(updatedPlaceNameGroupList); @@ -606,27 +606,27 @@ public class PlaceAuthorityServiceTest extends AbstractAuthorityServiceTest placeNameGroups = placeNameGroupList.getPlaceNameGroup(); Assert.assertNotNull(placeNameGroups); Assert.assertTrue(placeNameGroups.size() > 0); - String originalName = placeNameGroups.get(0).getName(); - Assert.assertNotNull(originalName); + String originalPlaceName = placeNameGroups.get(0).getPlaceName(); + Assert.assertNotNull(originalPlaceName); PlaceNameGroupList updatedPlaceNameGroupList = updated.getPlaceNameGroupList(); Assert.assertNotNull(updatedPlaceNameGroupList); List updatedPlaceNameGroups = updatedPlaceNameGroupList.getPlaceNameGroup(); Assert.assertNotNull(updatedPlaceNameGroups); Assert.assertTrue(updatedPlaceNameGroups.size() > 0); - String updatedName = updatedPlaceNameGroups.get(0).getName(); - Assert.assertNotNull(updatedName); + String updatedPlaceName = updatedPlaceNameGroups.get(0).getPlaceName(); + Assert.assertNotNull(updatedPlaceName); - Assert.assertEquals(updatedName, originalName, + Assert.assertEquals(updatedPlaceName, originalPlaceName, "Data in updated Place did not match submitted data."); } @@ -641,7 +641,7 @@ public class PlaceAuthorityServiceTest extends AbstractAuthorityServiceTest nonexMap = new HashMap(); - nonexMap.put(PlaceJAXBSchema.NAME, TEST_NAME); + nonexMap.put(PlaceJAXBSchema.PLACE_NAME, TEST_NAME); nonexMap.put(PlaceJAXBSchema.SHORT_IDENTIFIER, "nonEx"); nonexMap.put(PlaceJAXBSchema.PLACE_TYPE, TEST_PLACE_TYPE); nonexMap.put(PlaceJAXBSchema.TERM_STATUS, TEST_STATUS); diff --git a/services/place/jaxb/src/main/java/org/collectionspace/services/PlaceJAXBSchema.java b/services/place/jaxb/src/main/java/org/collectionspace/services/PlaceJAXBSchema.java index 12fd66b2c..7f8b0446c 100644 --- a/services/place/jaxb/src/main/java/org/collectionspace/services/PlaceJAXBSchema.java +++ b/services/place/jaxb/src/main/java/org/collectionspace/services/PlaceJAXBSchema.java @@ -15,7 +15,7 @@ public interface PlaceJAXBSchema extends AuthorityItemJAXBSchema { final static String SHORT_DISPLAY_NAME = "shortDisplayName"; final static String SHORT_DISPLAY_NAME_COMPUTED = "shortDisplayNameComputed"; final static String PLACE_NAME_GROUP_LIST = "placeNameGroupList"; - final static String NAME = "name"; + final static String PLACE_NAME = "placeName"; final static String NOTE = "note"; final static String SOURCE = "source"; final static String SOURCE_PAGE = "sourcePage"; diff --git a/services/place/jaxb/src/main/resources/place_common.xsd b/services/place/jaxb/src/main/resources/place_common.xsd index 55a38cd20..ca9e6219b 100644 --- a/services/place/jaxb/src/main/resources/place_common.xsd +++ b/services/place/jaxb/src/main/resources/place_common.xsd @@ -71,7 +71,7 @@ - + diff --git a/services/place/service/src/main/java/org/collectionspace/services/place/nuxeo/PlaceDocumentModelHandler.java b/services/place/service/src/main/java/org/collectionspace/services/place/nuxeo/PlaceDocumentModelHandler.java index 4163faf9f..db09a5658 100644 --- a/services/place/service/src/main/java/org/collectionspace/services/place/nuxeo/PlaceDocumentModelHandler.java +++ b/services/place/service/src/main/java/org/collectionspace/services/place/nuxeo/PlaceDocumentModelHandler.java @@ -76,10 +76,10 @@ public class PlaceDocumentModelHandler shortDisplayNameComputed = true; if (displayNameComputed || shortDisplayNameComputed) { // Obtain the primary place name from the list of place names, for computing the display name. - String xpathToName = PlaceJAXBSchema.PLACE_NAME_GROUP_LIST - + "/[0]/" + PlaceJAXBSchema.NAME; - String name = getXPathStringValue(docModel, COMMON_PART_LABEL, xpathToName); - String displayName = prepareDefaultDisplayName(name); + String xpathToPlaceName = PlaceJAXBSchema.PLACE_NAME_GROUP_LIST + + "/[0]/" + PlaceJAXBSchema.PLACE_NAME; + String placeName = getXPathStringValue(docModel, COMMON_PART_LABEL, xpathToPlaceName); + String displayName = prepareDefaultDisplayName(placeName); if (displayNameComputed) { docModel.setProperty(commonPartLabel, PlaceJAXBSchema.DISPLAY_NAME, displayName); @@ -96,14 +96,14 @@ public class PlaceDocumentModelHandler * @see PlaceAuthorityClientUtils.prepareDefaultDisplayName() which * duplicates this logic, until we define a service-general utils package * that is neither client nor service specific. - * @param name + * @param placeName * @return the default display name * @throws Exception */ private static String prepareDefaultDisplayName( - String name ) throws Exception { + String placeName ) throws Exception { StringBuilder newStr = new StringBuilder(); - newStr.append(name); + newStr.append(placeName); return newStr.toString(); } -- 2.47.3