]> git.aero2k.de Git - tmp/jakarta-migration.git/commitdiff
CSPACE-2534: Made four fields repeatable in Person records (records of items within...
authorAron Roberts <aron@socrates.berkeley.edu>
Fri, 23 Jul 2010 00:10:29 +0000 (00:10 +0000)
committerAron Roberts <aron@socrates.berkeley.edu>
Fri, 23 Jul 2010 00:10:29 +0000 (00:10 +0000)
services/person/3rdparty/nuxeo-platform-cs-person/src/main/resources/schemas/persons_common.xsd
services/person/client/src/main/java/org/collectionspace/services/client/PersonAuthorityClientUtils.java
services/person/client/src/test/java/org/collectionspace/services/client/test/PersonAuthoritySearchTest.java
services/person/client/src/test/java/org/collectionspace/services/client/test/PersonAuthorityServicePerfTest.java
services/person/client/src/test/java/org/collectionspace/services/client/test/PersonAuthorityServiceTest.java
services/person/jaxb/src/main/java/org/collectionspace/services/PersonJAXBSchema.java
services/person/jaxb/src/main/resources/person_common.xsd

index 6be3d6b637e16517e015af030d7d9ea44dc16815..c53bc976d544efad21a97777d57939e4dad8414e 100644 (file)
@@ -23,7 +23,7 @@
     <!--  Person Information Group -->
     <!--  inAuthority is the csid of the owning PersonAuthority -->
     <xs:element name="inAuthority" type="xs:string" />
-               <xs:element name="shortIdentifier" type="xs:string"/>
+    <xs:element name="shortIdentifier" type="xs:string"/>
     <xs:element name="refName" type="xs:string"/>
     <xs:element name="termStatus" type="xs:string"/>
     <xs:element name="displayName" type="xs:string"/>
     <xs:element name="deathDate" type="xs:string"/>
     <xs:element name="birthPlace" type="xs:string"/>
     <xs:element name="deathPlace" type="xs:string"/>
-    <xs:element name="group" type="xs:string"/>
-    <xs:element name="nationality" type="xs:string"/>
+    <xs:element name="groups">
+        <xs:complexType>
+            <xs:sequence>
+                <xs:element name="group" type="xs:string" minOccurs="0" maxOccurs="unbounded"/>
+            </xs:sequence>
+        </xs:complexType>
+    </xs:element>
+    <xs:element name="nationalities">
+        <xs:complexType>
+            <xs:sequence>
+                <xs:element name="nationality" type="xs:string" minOccurs="0" maxOccurs="unbounded"/>
+            </xs:sequence>
+        </xs:complexType>
+    </xs:element>
     <xs:element name="gender" type="xs:string"/>
-    <xs:element name="occupation" type="xs:string"/>
-    <xs:element name="schoolOrStyle" type="xs:string"/>
+    <xs:element name="occupations">
+        <xs:complexType>
+            <xs:sequence>
+                <xs:element name="occupation" type="xs:string" minOccurs="0" maxOccurs="unbounded"/>
+            </xs:sequence>
+        </xs:complexType>
+    </xs:element>
+    <xs:element name="schoolsOrStyles">
+        <xs:complexType>
+            <xs:sequence>
+                <xs:element name="schoolOrStyle" type="xs:string" minOccurs="0" maxOccurs="unbounded"/>
+            </xs:sequence>
+        </xs:complexType>
+    </xs:element>
     <xs:element name="bioNote" type="xs:string"/>
     <xs:element name="nameNote" type="xs:string"/>
 
index a734425a3e46d54c69fb68e6a07fe4b1649b4633..f800a0ad9d437baa267cb3b612eb7f4d3f087e1e 100644 (file)
@@ -28,6 +28,7 @@ package org.collectionspace.services.client;
 \r
 import java.util.ArrayList;\r
 import java.util.Arrays;\r
+import java.util.HashMap;\r
 import java.util.List;\r
 import java.util.Map;\r
 \r
@@ -37,8 +38,12 @@ import javax.ws.rs.core.Response;
 \r
 import org.collectionspace.services.PersonJAXBSchema;\r
 import org.collectionspace.services.client.test.ServiceRequestType;\r
+import org.collectionspace.services.person.GroupList;\r
+import org.collectionspace.services.person.NationalityList;\r
+import org.collectionspace.services.person.OccupationList;\r
 import org.collectionspace.services.person.PersonsCommon;\r
 import org.collectionspace.services.person.PersonauthoritiesCommon;\r
+import org.collectionspace.services.person.SchoolOrStyleList;\r
 import org.jboss.resteasy.client.ClientResponse;\r
 import org.jboss.resteasy.plugins.providers.multipart.MultipartInput;\r
 import org.jboss.resteasy.plugins.providers.multipart.MultipartOutput;\r
@@ -151,7 +156,7 @@ public class PersonAuthorityClientUtils {
     }\r
 \r
     /**\r
-     * Creates the person instance.\r
+     * Creates a person instance.\r
      *\r
      * @param inAuthority the owning authority\r
      * @param personAuthRefName the owning Authority ref name\r
@@ -159,8 +164,28 @@ public class PersonAuthorityClientUtils {
      * @param headerLabel the header label\r
      * @return the multipart output\r
      */\r
+    public static MultipartOutput createPersonInstance(String inAuthority,\r
+               String personAuthRefName, Map<String, String> personInfo,\r
+                String headerLabel){\r
+        final Map<String, List<String>> EMPTY_PERSON_REPEATABLES_INFO =\r
+                new HashMap<String, List<String>>();\r
+        return createPersonInstance(inAuthority, personAuthRefName, personInfo,\r
+                EMPTY_PERSON_REPEATABLES_INFO, headerLabel);\r
+    }\r
+\r
+    /**\r
+     * Creates a person instance.\r
+     *\r
+     * @param inAuthority the owning authority\r
+     * @param personAuthRefName the owning Authority ref name\r
+     * @param personInfo the person info\r
+     * @param personRepeatablesInfo names and values of repeatable scalar fields in the Person record\r
+     * @param headerLabel the header label\r
+     * @return the multipart output\r
+     */\r
     public static MultipartOutput createPersonInstance(String inAuthority, \r
-               String personAuthRefName, Map<String, String> personInfo, String headerLabel){\r
+               String personAuthRefName, Map<String, String> personInfo,\r
+                Map<String, List<String>> personRepeatablesInfo, String headerLabel){\r
         PersonsCommon person = new PersonsCommon();\r
         person.setInAuthority(inAuthority);\r
        String shortId = personInfo.get(PersonJAXBSchema.SHORT_IDENTIFIER);\r
@@ -190,6 +215,7 @@ public class PersonAuthorityClientUtils {
                person.setRefName(refName);\r
        \r
        String value;\r
+        List<String> values = null;\r
         if((value = (String)personInfo.get(PersonJAXBSchema.FORE_NAME))!=null) //FIXME: REM - I don't think we need to check for null -null is a valid value and won't cause any problems. \r
                person.setForeName(value);\r
         if((value = (String)personInfo.get(PersonJAXBSchema.MIDDLE_NAME))!=null)\r
@@ -212,16 +238,32 @@ public class PersonAuthorityClientUtils {
                person.setBirthPlace(value);\r
         if((value = (String)personInfo.get(PersonJAXBSchema.DEATH_PLACE))!=null)\r
                person.setDeathPlace(value);\r
-        if((value = (String)personInfo.get(PersonJAXBSchema.GROUP))!=null)\r
-               person.setGroup(value);\r
-        if((value = (String)personInfo.get(PersonJAXBSchema.NATIONALITY))!=null)\r
-               person.setNationality(value);\r
+        if((values = (List<String>)personRepeatablesInfo.get(PersonJAXBSchema.GROUPS))!=null) {\r
+                GroupList groupsList = new GroupList();\r
+                List<String> groups = groupsList.getGroup();\r
+               groups.addAll(values);\r
+                person.setGroups(groupsList);\r
+        }\r
+        if((values = (List<String>)personRepeatablesInfo.get(PersonJAXBSchema.NATIONALITIES))!=null) {\r
+                NationalityList nationalitiesList = new NationalityList();\r
+                List<String> nationalities = nationalitiesList.getNationality();\r
+               nationalities.addAll(values);\r
+                person.setNationalities(nationalitiesList);\r
+        }\r
         if((value = (String)personInfo.get(PersonJAXBSchema.GENDER))!=null)\r
                person.setGender(value);\r
-        if((value = (String)personInfo.get(PersonJAXBSchema.OCCUPATION))!=null)\r
-               person.setOccupation(value);\r
-        if((value = (String)personInfo.get(PersonJAXBSchema.SCHOOL_OR_STYLE))!=null)\r
-               person.setSchoolOrStyle(value);\r
+        if((values = (List<String>)personRepeatablesInfo.get(PersonJAXBSchema.OCCUPATIONS))!=null) {\r
+                OccupationList occupationsList = new OccupationList();\r
+                List<String> occupations = occupationsList.getOccupation();\r
+               occupations.addAll(values);\r
+                person.setOccupations(occupationsList);\r
+        }\r
+        if((values = (List<String>)personRepeatablesInfo.get(PersonJAXBSchema.SCHOOLS_OR_STYLES))!=null) {\r
+                SchoolOrStyleList schoolOrStyleList = new SchoolOrStyleList();\r
+                List<String> schoolsOrStyles = schoolOrStyleList.getSchoolOrStyle();\r
+               schoolsOrStyles.addAll(values);\r
+                person.setSchoolsOrStyles(schoolOrStyleList);\r
+        }\r
         if((value = (String)personInfo.get(PersonJAXBSchema.BIO_NOTE))!=null)\r
                person.setBioNote(value);\r
         if((value = (String)personInfo.get(PersonJAXBSchema.NAME_NOTE))!=null)\r
@@ -250,7 +292,7 @@ public class PersonAuthorityClientUtils {
      */\r
     public static String createItemInAuthority(String vcsid, \r
                String personAuthorityRefName, Map<String,String> personMap,\r
-               PersonAuthorityClient client ) {\r
+               Map<String, List<String>> personRepeatablesMap, PersonAuthorityClient client ) {\r
        // Expected status code: 201 Created\r
        int EXPECTED_STATUS_CODE = Response.Status.CREATED.getStatusCode();\r
        // Type of service request being tested\r
@@ -280,7 +322,7 @@ public class PersonAuthorityClientUtils {
        }\r
        MultipartOutput multipart = \r
                createPersonInstance(vcsid, personAuthorityRefName,\r
-                       personMap, client.getItemCommonPartName());\r
+                       personMap, personRepeatablesMap, client.getItemCommonPartName());\r
        \r
        String result = null;\r
        ClientResponse<Response> res = client.createItem(vcsid, multipart);\r
index a8928158a3efcaa09766d24032d0ff0a69f17200..fa0105bb488d5e58e95657da66fd9596dcc1d8fa 100644 (file)
@@ -566,9 +566,12 @@ public class PersonAuthoritySearchTest extends BaseServiceTest {
         partialTermPersonMap.put(PersonJAXBSchema.SUR_NAME, TEST_PARTIAL_TERM_SUR_NAME);
         partialTermPersonMap.put(PersonJAXBSchema.BIRTH_PLACE, TEST_KWD_BIRTH_PLACE);
         partialTermPersonMap.put(PersonJAXBSchema.GENDER, "male");
+
+        Map<String, List<String>> partialTermRepeatablesMap = new HashMap<String, List<String>>();
+
         MultipartOutput multipart =
-            PersonAuthorityClientUtils.createPersonInstance(authorityCsid, authRefName, partialTermPersonMap,
-                client.getItemCommonPartName() );
+            PersonAuthorityClientUtils.createPersonInstance(authorityCsid, authRefName, 
+                partialTermPersonMap, partialTermRepeatablesMap, client.getItemCommonPartName() );
 
         String newID = null;
         ClientResponse<Response> res = client.createItem(authorityCsid, multipart);
index 7fcb806ad4fbf237aa935d397c86c75ca5c4b933..7f5f60aeaae71cec18d5b1b2b32c4d99a074ab79 100644 (file)
@@ -200,9 +200,10 @@ public class PersonAuthorityServicePerfTest extends BaseServiceTest {
         personMap.put(PersonJAXBSchema.DISPLAY_NAME_COMPUTED, "true");
         personMap.put(PersonJAXBSchema.FORE_NAME, firstName);
         personMap.put(PersonJAXBSchema.SUR_NAME, lastName);
+        Map<String, List<String>> personRepeatablesMap = new HashMap<String, List<String>>();
         MultipartOutput multipart =
             PersonAuthorityClientUtils.createPersonInstance(authId, authRefName, 
-                       personMap, client.getItemCommonPartName() );
+                       personMap, personRepeatablesMap, client.getItemCommonPartName() );
 
         String newID = null;
         ClientResponse<Response> res = client.createItem(authId, multipart);
index 6e14845c0a08aac5b0956c57c217e8c5732f8400..e93c4460fba7928414fbc67cfb9a94f426cff601 100644 (file)
@@ -22,6 +22,7 @@
  */
 package org.collectionspace.services.client.test;
 
+import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -259,9 +260,16 @@ public class PersonAuthorityServiceTest extends AbstractServiceTestImpl {
             "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.");
+
+        Map<String, List<String>> johnWayneRepeatablesMap = new HashMap<String,List<String>>();
+        List<String> johnWayneGroups = new ArrayList<String>();
+        johnWayneGroups.add("Irish");
+        johnWayneGroups.add("Scottish");
+        johnWayneRepeatablesMap.put(PersonJAXBSchema.GROUPS, johnWayneGroups);
+
         MultipartOutput multipart = 
             PersonAuthorityClientUtils.createPersonInstance(vcsid, authRefName, johnWayneMap,
-                client.getItemCommonPartName() );
+                johnWayneRepeatablesMap, client.getItemCommonPartName() );
 
         String newID = null;
         ClientResponse<Response> res = client.createItem(vcsid, multipart);
@@ -715,7 +723,16 @@ public class PersonAuthorityServiceTest extends AbstractServiceTestImpl {
                    logger.debug(testName + ": returned payload:");
                    logger.debug(objectAsXmlString(person, PersonsCommon.class));
                }
+
+                // Check that the person item is within the expected Person Authority.
                Assert.assertEquals(person.getInAuthority(), knownResourceId);
+
+                // Verify the number and contents of values in a repeatable field,
+                // as created in the instance record used for testing.
+                List<String> groups = person.getGroups().getGroup();
+                Assert.assertTrue(groups.size() > 0);
+                Assert.assertNotNull(groups.get(0));
+
         } finally {
                res.releaseConnection();
         }
@@ -1742,10 +1759,11 @@ public class PersonAuthorityServiceTest extends AbstractServiceTestImpl {
         nonexMap.put(PersonJAXBSchema.FORE_NAME, "John");
         nonexMap.put(PersonJAXBSchema.SUR_NAME, "Wayne");
         nonexMap.put(PersonJAXBSchema.GENDER, "male");
+        Map<String, List<String>> nonexRepeatablesMap = new HashMap<String, List<String>>();
         MultipartOutput multipart = 
        PersonAuthorityClientUtils.createPersonInstance(NON_EXISTENT_ID, 
                        PersonAuthorityClientUtils.createPersonAuthRefName(NON_EXISTENT_ID, null),
-                       nonexMap, client.getItemCommonPartName() );
+                       nonexMap, nonexRepeatablesMap, client.getItemCommonPartName() );
         ClientResponse<MultipartInput> res =
                 client.updateItem(knownResourceId, NON_EXISTENT_ID, multipart);
         try {
index 7653c917e1b9e496a373232801e55e0b5a9f97d3..bc692f032a89b9f2e463e6bc78698085cca3e66c 100644 (file)
@@ -22,11 +22,11 @@ public interface PersonJAXBSchema extends AuthorityJAXBSchema {
        final static String DEATH_DATE = "deathDate";\r
        final static String BIRTH_PLACE = "birthPlace";\r
        final static String DEATH_PLACE = "deathPlace";\r
-       final static String GROUP = "group";\r
-       final static String NATIONALITY = "nationality";\r
+       final static String GROUPS = "groups";\r
+       final static String NATIONALITIES = "nationalities";\r
        final static String GENDER = "gender";\r
-       final static String OCCUPATION = "occupation";\r
-       final static String SCHOOL_OR_STYLE = "schoolOrStyle";\r
+       final static String OCCUPATIONS = "occupations";\r
+       final static String SCHOOLS_OR_STYLES = "schoolsOrStyles";\r
        final static String BIO_NOTE = "bioNote";\r
        final static String NAME_NOTE = "nameNote";\r
 }\r
index b095c30fcb046d4d7077f7caf571ea22e05d30ed..a9b7f965165dd1f540695864928bc73d7eabc969 100644 (file)
@@ -33,7 +33,7 @@
                 
                 <!--  Person Information Group -->
                 <xs:element name="inAuthority" type="xs:string" />
-                                                               <xs:element name="shortIdentifier" type="xs:string"/>
+               <xs:element name="shortIdentifier" type="xs:string"/>
                 <xs:element name="refName" type="xs:string" />
                 <xs:element name="termStatus" type="xs:string"/>
                 <xs:element name="displayName" type="xs:string"/>
                 <xs:element name="deathDate" type="xs:string"/>
                 <xs:element name="birthPlace" type="xs:string"/>
                 <xs:element name="deathPlace" type="xs:string"/>
-                <xs:element name="group" type="xs:string"/>
-                <xs:element name="nationality" type="xs:string"/>
+                <xs:element name="groups" type="groupList"/>
+                <xs:element name="nationalities" type="nationalityList"/>
                 <xs:element name="gender" type="xs:string"/>
-                <xs:element name="occupation" type="xs:string"/>
-                <xs:element name="schoolOrStyle" type="xs:string"/>
+                <xs:element name="occupations" type="occupationList"/>
+                <xs:element name="schoolsOrStyles" type="schoolOrStyleList"/>
                 <xs:element name="bioNote" type="xs:string"/>
                 <xs:element name="nameNote" type="xs:string"/>
             </xs:sequence>
         </xs:complexType>
     </xs:element>
+
+    <xs:complexType name="groupList">
+        <xs:sequence>
+            <xs:element name="group" type="xs:string" minOccurs="0" maxOccurs="unbounded"/>
+        </xs:sequence>
+    </xs:complexType>
+
+    <xs:complexType name="nationalityList">
+        <xs:sequence>
+            <xs:element name="nationality" type="xs:string" minOccurs="0" maxOccurs="unbounded"/>
+        </xs:sequence>
+    </xs:complexType>
+
+    <xs:complexType name="occupationList">
+        <xs:sequence>
+            <xs:element name="occupation" type="xs:string" minOccurs="0" maxOccurs="unbounded"/>
+        </xs:sequence>
+    </xs:complexType>
+
+    <xs:complexType name="schoolOrStyleList">
+        <xs:sequence>
+            <xs:element name="schoolOrStyle" type="xs:string" minOccurs="0" maxOccurs="unbounded"/>
+        </xs:sequence>
+    </xs:complexType>
     
     <!-- This is the base class for paginated lists -->
     <xs:complexType name="abstractCommonListItem">