From 1138a6ae224ed510465ecbc6e806f8c9fe830fe2 Mon Sep 17 00:00:00 2001 From: Aron Roberts Date: Fri, 25 Jun 2010 21:47:26 +0000 Subject: [PATCH] CSPACE-2242: All value instances in a repeatable list are now persisted, even when the first value instance is blank. --- .../test/CollectionObjectServiceTest.java | 2 +- .../common/document/DocumentUtils.java | 39 +++++++++++-------- 2 files changed, 24 insertions(+), 17 deletions(-) diff --git a/services/collectionobject/client/src/test/java/org/collectionspace/services/client/test/CollectionObjectServiceTest.java b/services/collectionobject/client/src/test/java/org/collectionspace/services/client/test/CollectionObjectServiceTest.java index 4c503d82b..70d459ede 100644 --- a/services/collectionobject/client/src/test/java/org/collectionspace/services/client/test/CollectionObjectServiceTest.java +++ b/services/collectionobject/client/src/test/java/org/collectionspace/services/client/test/CollectionObjectServiceTest.java @@ -204,7 +204,7 @@ public class CollectionObjectServiceTest extends AbstractServiceTestImpl { // Verify that at least one value instance of the repeatable field was successfully persisted. BriefDescriptionList descriptionList = collectionObject.getBriefDescriptions(); List descriptions = descriptionList.getBriefDescription(); - // Assert.assertTrue(descriptions.size() > 0); + Assert.assertTrue(descriptions.size() > 0); } /** diff --git a/services/common/src/main/java/org/collectionspace/services/common/document/DocumentUtils.java b/services/common/src/main/java/org/collectionspace/services/common/document/DocumentUtils.java index a5dc9a5f7..cb0e77ff6 100644 --- a/services/common/src/main/java/org/collectionspace/services/common/document/DocumentUtils.java +++ b/services/common/src/main/java/org/collectionspace/services/common/document/DocumentUtils.java @@ -314,22 +314,29 @@ public class DocumentUtils { private static Object getMultiValues(Node node) throws Exception { Object result = null; - Node child = removeTextNodes(node).getFirstChild(); - Node grandChild = child.getFirstChild(); - - if (grandChild != null) { - if (grandChild.getNodeType() == Node.TEXT_NODE) { - result = getMultiStringValues(node); - } else { - ArrayList> values = new ArrayList>(); - NodeList nodeChildren = node.getChildNodes(); - for (int i = 0; i < nodeChildren.getLength(); i++) { - Node nodeChild = nodeChildren.item(i); - Map hashMap = parseProperties(nodeChild); - values.add(hashMap); - } - result = values; - } + Node child = removeTextNodes(node); + NodeList grandChildren = child.getChildNodes(); + for (int j = 0; j < grandChildren.getLength(); j++) { + + Node grandChild = grandChildren.item(j).getFirstChild(); + + // If any grandchild is non-null, return values for all grandchildren. + if (grandChild != null) { + if (grandChild.getNodeType() == Node.TEXT_NODE) { + result = getMultiStringValues(node); + } else { + ArrayList> values = new ArrayList>(); + NodeList nodeChildren = node.getChildNodes(); + for (int i = 0; i < nodeChildren.getLength(); i++) { + Node nodeChild = nodeChildren.item(i); + Map hashMap = parseProperties(nodeChild); + values.add(hashMap); + } + result = values; + } + break; + } + } return result; -- 2.47.3