From: Aron Roberts Date: Fri, 13 Aug 2010 23:58:42 +0000 (+0000) Subject: CSPACE-827,CSPACE-2643: Added dimensions as a structured repeatable group of fields... X-Git-Url: https://git.aero2k.de/?a=commitdiff_plain;h=99992152a82f26488c6c07b9cd0a4718c9580941;p=tmp%2Fjakarta-migration.git CSPACE-827,CSPACE-2643: Added dimensions as a structured repeatable group of fields to CollectionObject records. Updated client tests to verify update behavior for dimensions groups, as described in the Common Services REST API documentation. Left six existing scalar dimensions fields in place for backwards compatibility, until dimensions are implemented as a repeatable group across all layers. Updates Nuxeo doctype definition, and thus requires 'ant deploy' from services/trunk and a 2-server restart. --- diff --git a/services/collectionobject/3rdparty/nuxeo-platform-cs-collectionobject/src/main/resources/schemas/collectionobjects_common.xsd b/services/collectionobject/3rdparty/nuxeo-platform-cs-collectionobject/src/main/resources/schemas/collectionobjects_common.xsd index bd3efb565..8380828a8 100644 --- a/services/collectionobject/3rdparty/nuxeo-platform-cs-collectionobject/src/main/resources/schemas/collectionobjects_common.xsd +++ b/services/collectionobject/3rdparty/nuxeo-platform-cs-collectionobject/src/main/resources/schemas/collectionobjects_common.xsd @@ -18,11 +18,13 @@ targetNamespace="http://collectionspace.org/collectionobject/" version="0.1"> + - + + @@ -71,8 +73,6 @@ - - @@ -139,10 +139,11 @@ - + - + + @@ -223,7 +224,7 @@ - + @@ -404,6 +405,24 @@ + + + + + + + + + + + + + + + + + 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 392eed3cd..544bdbc41 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 @@ -35,6 +35,8 @@ import org.collectionspace.services.collectionobject.CollectionobjectsCommon; import org.collectionspace.services.collectionobject.domain.naturalhistory.CollectionobjectsNaturalhistory; import org.collectionspace.services.collectionobject.CollectionobjectsCommonList; import org.collectionspace.services.collectionobject.ResponsibleDepartmentList; +import org.collectionspace.services.collectionobject.DimensionGroup; +import org.collectionspace.services.collectionobject.DimensionList; import org.collectionspace.services.collectionobject.ObjectNameGroup; import org.collectionspace.services.collectionobject.ObjectNameList; import org.collectionspace.services.collectionobject.OtherNumber; @@ -70,6 +72,7 @@ public class CollectionObjectServiceTest extends AbstractServiceTestImpl { private String knownResourceId = null; private final String OBJECT_NAME_VALUE = "an object name"; + private final String UPDATED_MEASURED_PART_VALUE = "updated measured part value"; /* (non-Javadoc) * @see org.collectionspace.services.client.test.BaseServiceTest#getServicePathComponent() @@ -558,6 +561,16 @@ public class CollectionObjectServiceTest extends AbstractServiceTestImpl { client.getCommonPartName(), CollectionobjectsCommon.class); Assert.assertNotNull(collectionObject); + // Verify the number and contents of values in repeatable fields, + // as created in the instance record used for testing. + DimensionList dimensionList = collectionObject.getDimensions(); + Assert.assertNotNull(dimensionList); + List dimensionsGroups = dimensionList.getDimensionGroup(); + Assert.assertNotNull(dimensionsGroups); + Assert.assertTrue(dimensionsGroups.size() > 0); + Assert.assertNotNull(dimensionsGroups.get(0)); + Assert.assertNotNull(dimensionsGroups.get(0).getMeasuredPart()); + if (logger.isDebugEnabled()) { logger.debug(testName + ": Reading Natural History part ..."); } @@ -683,8 +696,11 @@ public class CollectionObjectServiceTest extends AbstractServiceTestImpl { Assert.assertNotNull(collectionObject); // Change the content of one or more fields in the common part. + collectionObject.setObjectNumber("updated-" + collectionObject.getObjectNumber()); - + + // Change the object name in the first value instance in the + // object name repeatable group. ObjectNameList objNameList = collectionObject.getObjectNameList(); List objNameGroups = objNameList.getObjectNameGroup(); Assert.assertNotNull(objNameGroups); @@ -695,6 +711,24 @@ public class CollectionObjectServiceTest extends AbstractServiceTestImpl { objNameGroups.get(0).setObjectName(updatedObjectName); collectionObject.setObjectNameList(objNameList); + // Replace the existing value instances in the dimensions repeatable group + // with entirely new value instances, also changing the number of such instances. + DimensionList dimensionList = collectionObject.getDimensions(); + Assert.assertNotNull(dimensionList); + List dimensionGroups = dimensionList.getDimensionGroup(); + Assert.assertNotNull(dimensionGroups); + int originalDimensionGroupSize = dimensionGroups.size(); + Assert.assertTrue(originalDimensionGroupSize >= 1); + + DimensionGroup updatedDimensionGroup = new DimensionGroup(); + updatedDimensionGroup.setMeasuredPart(UPDATED_MEASURED_PART_VALUE); + dimensionGroups.clear(); + dimensionGroups.add(updatedDimensionGroup); + int updatedDimensionGroupSize = dimensionGroups.size(); + Assert.assertTrue(updatedDimensionGroupSize >= 1); + Assert.assertTrue(updatedDimensionGroupSize != originalDimensionGroupSize); + collectionObject.setDimensions(dimensionList); + if (logger.isDebugEnabled()) { logger.debug("sparse update that will be sent in update request:"); logger.debug(objectAsXmlString(collectionObject, @@ -726,6 +760,15 @@ public class CollectionObjectServiceTest extends AbstractServiceTestImpl { Assert.assertEquals(updatedObjectName, objNameGroups.get(0).getObjectName(), "Data in updated object did not match submitted data."); + + dimensionList = collectionObject.getDimensions(); + Assert.assertNotNull(dimensionList); + dimensionGroups = dimensionList.getDimensionGroup(); + Assert.assertNotNull(dimensionGroups); + Assert.assertTrue(dimensionGroups.size() == updatedDimensionGroupSize); + Assert.assertEquals(UPDATED_MEASURED_PART_VALUE, + dimensionGroups.get(0).getMeasuredPart(), + "Data in updated object did not match submitted data."); } @@ -1128,14 +1171,52 @@ public class CollectionObjectServiceTest extends AbstractServiceTestImpl { remNumber.setNumberValue("2271966-" + System.currentTimeMillis()); collectionObject.setRemNumber(remNumber); + // Scalar fields + collectionObject.setTitle("atitle"); + collectionObject.setObjectNumber(objectNumber); + collectionObject.setAge(""); //test for null string + + // FIXME this can be removed when the repeatable other number list + // is supported by the application layers + collectionObject.setOtherNumber("urn:org.walkerart.id:123"); + + // Repeatable structured groups + + ObjectNameList objNameList = new ObjectNameList(); + List objNameGroups = objNameList.getObjectNameGroup(); + ObjectNameGroup objectNameGroup = new ObjectNameGroup(); + objectNameGroup.setObjectName(OBJECT_NAME_VALUE); + objNameGroups.add(objectNameGroup); + collectionObject.setObjectNameList(objNameList); + + DimensionList dimensionList = new DimensionList(); + List dimensionGroups = dimensionList.getDimensionGroup(); + DimensionGroup dimensionGroup1 = new DimensionGroup(); + dimensionGroup1.setMeasuredPart("head"); + dimensionGroup1.setDimension("length"); + dimensionGroup1.setValue("30"); + dimensionGroup1.setMeasurementUnit("cm"); + DimensionGroup dimensionGroup2 = new DimensionGroup(); + dimensionGroup2.setMeasuredPart("leg"); + dimensionGroup2.setDimension("width"); + dimensionGroup2.setValue("2.57"); + dimensionGroup2.setMeasurementUnit("m"); + dimensionGroup2.setValueQualifier(""); // test null string + dimensionGroups.add(dimensionGroup1); + dimensionGroups.add(dimensionGroup2); + collectionObject.setDimensions(dimensionList); + + // Repeatable scalar fields + BriefDescriptionList descriptionList = new BriefDescriptionList(); List descriptions = descriptionList.getBriefDescription(); descriptions.add("Papier mache bird cow mask with horns, " + "painted red with black and yellow spots. " + "Puerto Rico. ca. 8" high, 6" wide, projects 10" (with horns)."); - descriptions.add("Papier mache bird cow mask with horns, " - + "painted red with black and yellow spots. " - + "Puerto Rico. ca. 8" high, 6" wide, projects 10" (with horns)."); + descriptions.add("Acrylic rabbit mask with wings, " + + "painted red with green and aquamarine spots. " + + "Puerto Rico. ca. 8" high, 6" wide, projects 10" (with wings)."); + collectionObject.setBriefDescriptions(descriptionList); ResponsibleDepartmentList deptList = new ResponsibleDepartmentList(); List depts = deptList.getResponsibleDepartment(); @@ -1143,47 +1224,27 @@ public class CollectionObjectServiceTest extends AbstractServiceTestImpl { // in this example test record. The following are mere placeholders. depts.add("urn:org.collectionspace.services.department:Registrar"); depts.add("urn:org.walkerart.department:Fine Art"); + collectionObject.setResponsibleDepartments(deptList); OtherNumberList otherNumList = new OtherNumberList(); List otherNumbers = otherNumList.getOtherNumber(); - OtherNumber otherNumber1 = new OtherNumber(); otherNumber1.setNumberValue("101." + objectName); otherNumber1.setNumberType("integer"); otherNumbers.add(otherNumber1); - OtherNumber otherNumber2 = new OtherNumber(); otherNumber2.setNumberValue("101.502.23.456." + objectName); otherNumber2.setNumberType("ipaddress"); - otherNumbers.add(otherNumber2); - - //FIXME: Title does not need to be set. - collectionObject.setTitle("atitle"); - collectionObject.setResponsibleDepartments(deptList); - collectionObject.setObjectNumber(objectNumber); - + otherNumbers.add(otherNumber2); collectionObject.setOtherNumberList(otherNumList); - // FIXME this can be removed when the repeatable other number list - // is supported by the application layers - collectionObject.setOtherNumber("urn:org.walkerart.id:123"); - - ObjectNameList objNameList = new ObjectNameList(); - List objNameGroups = objNameList.getObjectNameGroup(); - ObjectNameGroup objectNameGroup = new ObjectNameGroup(); - objectNameGroup.setObjectName(OBJECT_NAME_VALUE); - objNameGroups.add(objectNameGroup); - collectionObject.setObjectNameList(objNameList); - - collectionObject.setAge(""); //test for null string - collectionObject.setBriefDescriptions(descriptionList); + // Add instances of fields from an extension schema CollectionobjectsNaturalhistory conh = new CollectionobjectsNaturalhistory(); conh.setNhString("test-string"); conh.setNhInt(999); conh.setNhLong(9999); - MultipartOutput multipart = createCollectionObjectInstance(commonPartName, collectionObject, conh); return multipart; } diff --git a/services/collectionobject/client/src/test/resources/test-data/testCambridge.xml b/services/collectionobject/client/src/test/resources/test-data/testCambridge.xml index 61a0799d1..5929799ec 100644 --- a/services/collectionobject/client/src/test/resources/test-data/testCambridge.xml +++ b/services/collectionobject/client/src/test/resources/test-data/testCambridge.xml @@ -47,14 +47,6 @@ contentPosition XXX copyNumber - dimension - dimensionMeasuredPart - -dimensionMeasurementUnit - dimensionValue - XXX - -dimensionValueQualifier editionNumber
form
inscriptionContent diff --git a/services/collectionobject/jaxb/src/main/resources/collectionobjects_common.xsd b/services/collectionobject/jaxb/src/main/resources/collectionobjects_common.xsd index 9ebf9ba1d..60ff83fb7 100644 --- a/services/collectionobject/jaxb/src/main/resources/collectionobjects_common.xsd +++ b/services/collectionobject/jaxb/src/main/resources/collectionobjects_common.xsd @@ -33,17 +33,18 @@ + + - + - + - @@ -81,10 +82,11 @@ - + - + + @@ -153,7 +155,7 @@ - + @@ -336,6 +338,24 @@ + + + + + + + + + + + + + + + + +