<!-- 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"/>
\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
\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
}\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
* @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
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
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
*/\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
}\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
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);
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);
*/
package org.collectionspace.services.client.test;
+import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
"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);
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();
}
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 {
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
<!-- 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">