]> git.aero2k.de Git - tmp/jakarta-migration.git/commitdiff
CSPACE-827,CSPACE-2643: Added dimensions as a structured repeatable group of fields...
authorAron Roberts <aron@socrates.berkeley.edu>
Fri, 13 Aug 2010 23:58:42 +0000 (23:58 +0000)
committerAron Roberts <aron@socrates.berkeley.edu>
Fri, 13 Aug 2010 23:58:42 +0000 (23:58 +0000)
services/collectionobject/3rdparty/nuxeo-platform-cs-collectionobject/src/main/resources/schemas/collectionobjects_common.xsd
services/collectionobject/client/src/test/java/org/collectionspace/services/client/test/CollectionObjectServiceTest.java
services/collectionobject/client/src/test/resources/test-data/testCambridge.xml
services/collectionobject/jaxb/src/main/resources/collectionobjects_common.xsd

index bd3efb56570c3fad61071498ea1d8430a2cbea2c..8380828a86234adad38f26311353030844993d3d 100644 (file)
     targetNamespace="http://collectionspace.org/collectionobject/" version="0.1">\r
 \r
     <xs:element name="remNumber" type="ns:otherNumber"/>\r
+\r
     <!-- Object identification information -->\r
     <xs:element name="objectNumber" type="xs:string"/>\r
     <xs:element name="otherNumberList" type="ns:otherNumberList"/>\r
 \r
-    <!-- Remove these two elements when the App/UI layer is using the new repeatable 'otherNumbers' field -->\r
+    <!-- Remove these two elements when the App/UI layer is using -->\r
+    <!-- the new repeatable 'otherNumbers' field: -->\r
     <xs:element name="otherNumber" type="xs:string"/>\r
     <xs:element name="otherNumberType" type="xs:string"/>\r
 \r
@@ -71,8 +73,6 @@
             </xs:sequence>\r
         </xs:complexType>\r
     </xs:element>\r
-\r
-    <!-- Object Description - Content Information -->\r
     <xs:element name="contentActivities">\r
         <xs:complexType>\r
             <xs:sequence>\r
             </xs:sequence>\r
         </xs:complexType>\r
     </xs:element>\r
-\r
     <xs:element name="copyNumber" type="xs:string"/>\r
+    <xs:element name="dimensions" type="ns:dimensionList"/>\r
 \r
-    <!-- Object Description - Dimension Information -->\r
+    <!-- Remove these six elements when the App/UI layer is -->\r
+    <!-- using the new repeatable 'dimensions' field: -->\r
     <xs:element name="dimension" type="xs:string"/>\r
     <xs:element name="dimensionMeasuredPart" type="xs:string"/>\r
     <xs:element name="dimensionMeasurementUnit" type="xs:string"/>\r
 \r
     <!-- Object History and Association Information - Association -->\r
 \r
-    <!-- In the following field names, "assoc" is an abbreviation for "association". -->\r
+    <!-- In the following field names, "assoc" is an abbreviation for "associated". -->\r
     <!-- See the comments to CSPACE-2501 for a discussion of the database identifier -->\r
     <!-- length limit that made this abbreviation necessary. -->\r
     <xs:element name="assocActivity" type="xs:string"/>\r
         </xs:sequence>\r
     </xs:complexType>\r
 \r
+    <xs:complexType name="dimensionList">\r
+        <xs:sequence>\r
+            <xs:element name="dimensionGroup" type="dimensionGroup" minOccurs="0"\r
+                maxOccurs="unbounded"/>\r
+        </xs:sequence>\r
+    </xs:complexType>\r
+\r
+    <xs:complexType name="dimensionGroup">\r
+        <xs:sequence>\r
+            <xs:element name="dimension" type="xs:string"/>\r
+            <xs:element name="measuredPart" type="xs:string"/>\r
+            <xs:element name="measurementUnit" type="xs:string"/>\r
+            <xs:element name="value" type="xs:string"/>\r
+            <xs:element name="valueDate" type="xs:string"/>\r
+            <xs:element name="valueQualifier" type="xs:string"/>\r
+        </xs:sequence>\r
+    </xs:complexType>\r
+\r
     <!-- Object Description Date Information -->\r
     <!-- This appears to be a placeholder structured date -->\r
     <xs:element name="dateAssociation" type="xs:string"/>\r
index 392eed3cd7ba11e7d31f0819616c6137a002721e..544bdbc41bb02242ba28b6e149aa4c40e03f4fb6 100644 (file)
@@ -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<DimensionGroup> 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<ObjectNameGroup> 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<DimensionGroup> 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<ObjectNameGroup> objNameGroups = objNameList.getObjectNameGroup();
+        ObjectNameGroup objectNameGroup = new ObjectNameGroup();
+        objectNameGroup.setObjectName(OBJECT_NAME_VALUE);
+        objNameGroups.add(objectNameGroup);
+        collectionObject.setObjectNameList(objNameList);
+
+        DimensionList dimensionList = new DimensionList();
+        List<DimensionGroup> 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<String> descriptions = descriptionList.getBriefDescription();
         descriptions.add("Papier mache bird cow mask with horns, "
                 + "painted red with black and yellow spots. "
                 + "Puerto Rico. ca. 8&quot; high, 6&quot; wide, projects 10&quot; (with horns).");
-        descriptions.add("Papier mache bird cow mask with horns, "
-                + "painted red with black and yellow spots. "
-                + "Puerto Rico. ca. 8&quot; high, 6&quot; wide, projects 10&quot; (with horns).");
+        descriptions.add("Acrylic rabbit mask with wings, "
+                + "painted red with green and aquamarine spots. "
+                + "Puerto Rico. ca. 8&quot; high, 6&quot; wide, projects 10&quot; (with wings).");
+        collectionObject.setBriefDescriptions(descriptionList);
 
         ResponsibleDepartmentList deptList = new ResponsibleDepartmentList();
         List<String> 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<OtherNumber> 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<ObjectNameGroup> 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;
     }
index 61a0799d10c9a36058005b783cd8537b821a1454..5929799ec558359bf6585ad99ae6023874845d55 100644 (file)
   <contentPosition>contentPosition</contentPosition>
   <contentScript>XXX</contentScript>
   <copyNumber>copyNumber</copyNumber>
-  <dimension>dimension</dimension>
-  <dimensionMeasuredPart>dimensionMeasuredPart</dimensionMeasuredPart>
-
-<dimensionMeasurementUnit>dimensionMeasurementUnit</dimensionMeasurementUnit>
-  <dimensionValue>dimensionValue</dimensionValue>
-  <dimensionValueDate>XXX</dimensionValueDate>
-
-<dimensionValueQualifier>dimensionValueQualifier</dimensionValueQualifier>
   <editionNumber>editionNumber</editionNumber>
   <form>form</form>
  <inscriptionContent>inscriptionContent</inscriptionContent>
index 9ebf9ba1da01b5faa61c6e182128ecfe03f08cb8..60ff83fb78194119decbb387d9dc71364b53b721 100644 (file)
                 <xs:element name="csid" type="xs:string"/>
                 
                 <xs:element name="remNumber" type="ns:otherNumber"/>
+
                 <!-- Object Identification Information -->
+
                 <xs:element name="objectNumber" type="xs:string"/>
                 <xs:element name="otherNumberList" type="otherNumberList"/>
-                
+
                 <!-- Remove these two elements when the App/UI layer is -->
-                <!-- using the new repeatable 'otherNumbers' field -->
+                <!-- using the new repeatable 'otherNumbers' field: -->
                 <xs:element name="otherNumber" type="xs:string"/>
                 <xs:element name="otherNumberType" type="xs:string"/>
 
                 <xs:element name="briefDescriptions" type="briefDescriptionList"/>
-
                 <xs:element name="comments" type="commentList"/>
                 <xs:element name="distinguishingFeatures" type="xs:string"/>
                 <xs:element name="numberOfObjects" type="xs:string"/>
                 <xs:element name="contentPlaces" type="contentPlaceList"/>
                 <xs:element name="contentPosition" type="xs:string"/>
                 <xs:element name="contentScripts" type="contentScriptList"/>
-
                 <xs:element name="copyNumber" type="xs:string"/>
+                <xs:element name="dimensions" type="ns:dimensionList"/>
 
-                <!-- Object Description - Dimension Information -->
+                <!-- Remove these six elements when the App/UI layer is -->
+                <!-- using the new repeatable 'dimensions' field: -->
                 <xs:element name="dimension" type="xs:string"/>
                 <xs:element name="dimensionMeasuredPart" type="xs:string"/>
                 <xs:element name="dimensionMeasurementUnit" type="xs:string"/>
 
                 <!-- Object History and Association Information - Association -->
 
-                <!-- In the following field names, "assoc" is an abbreviation for "association". -->
+                <!-- In the following field names, "assoc" is an abbreviation for "associated". -->
                 <!-- See the comments to CSPACE-2501 for a discussion of the database identifier -->
                 <!-- length limit that made this abbreviation necessary. -->
                 <xs:element name="assocActivity" type="xs:string"/>
             <xs:element name="contentScript" type="xs:string" minOccurs="0" maxOccurs="unbounded"/>
         </xs:sequence>
     </xs:complexType>
+    
+    <xs:complexType name="dimensionList">
+        <xs:sequence>
+            <xs:element name="dimensionGroup" type="dimensionGroup" minOccurs="0"
+                maxOccurs="unbounded"/>
+        </xs:sequence>
+    </xs:complexType>
+
+    <xs:complexType name="dimensionGroup">
+        <xs:sequence>
+            <xs:element name="dimension" type="xs:string"/>
+            <xs:element name="measuredPart" type="xs:string"/>
+            <xs:element name="measurementUnit" type="xs:string"/>
+            <xs:element name="value" type="xs:string"/>
+            <xs:element name="valueDate" type="xs:string"/>
+            <xs:element name="valueQualifier" type="xs:string"/>
+        </xs:sequence>
+    </xs:complexType>
 
     <xs:complexType name="formList">
         <xs:sequence>