versionable="true" auditable="false"
label="organizations_common" updated="" order="1">
<service:properties>
- <types:item><types:key>authRef</types:key><types:value>contactName</types:value></types:item>
- <types:item><types:key>authRef</types:key><types:value>subBody</types:value></types:item>
+ <types:item><types:key>authRef</types:key><types:value>contactNames</types:value></types:item>
+ <types:item><types:key>authRef</types:key><types:value>subBodies</types:value></types:item>
</service:properties>
<service:content contentType="application/xml">
versionable="true" auditable="false"
label="organizations_common" updated="" order="1">
<service:properties>
- <types:item><types:key>authRef</types:key><types:value>contactName</types:value></types:item>
- <types:item><types:key>authRef</types:key><types:value>subBody</types:value></types:item>
+ <types:item><types:key>authRef</types:key><types:value>contactNames</types:value></types:item>
+ <types:item><types:key>authRef</types:key><types:value>subBodies</types:value></types:item>
</service:properties>
<service:content contentType="application/xml">
<row><widget>shortName</widget></row>
<row><widget>longName</widget></row>
<row><widget>nameAdditions</widget></row>
- <row><widget>contactName</widget></row>
+ <!-- Repeatable fields are commented out for now until we -->
+ <!-- identify how to represent these complex types in layouts. -->
+<!-- <row><widget>contactName</widget></row>-->
<row><widget>foundingDate</widget></row>
<row><widget>dissolutionDate</widget></row>
<row><widget>foundingPlace</widget></row>
- <row><widget>group</widget></row>
- <row><widget>function</widget></row>
- <row><widget>subBody</widget></row>
- <row><widget>history</widget></row>
+<!-- <row><widget>group</widget></row> -->
+<!-- <row><widget>function</widget></row> -->
+<!-- <row><widget>subBody</widget></row> -->
+<!-- <row><widget>historyNote</widget></row>-->
<row><widget>termStatus</widget></row>
</rows>
</properties>
</widget>
-<!-- <widget name="displayNameComputed" type="text">
+<!--
+ <widget name="displayNameComputed" type="text">
<labels>
<label mode="any">displayNameComputed</label>
</labels>
</properties>
</widget>
+<!--
<widget name="contactName" type="text">
<labels>
<label mode="any">contactName</label>
<property name="styleClass">dataInputText</property>
</properties>
</widget>
+-->
<widget name="foundingDate" type="text">
<labels>
</properties>
</widget>
+<!--
<widget name="group" type="text">
<labels>
<label mode="any">group</label>
<property name="styleClass">dataInputText</property>
</properties>
</widget>
+-->
<widget name="termStatus" type="text">
<labels>
<xs:element name="shortName" type="xs:string"/>
<xs:element name="longName" type="xs:string"/>
<xs:element name="nameAdditions" type="xs:string"/>
- <xs:element name="contactName" type="xs:string"/>
+ <xs:element name="contactNames">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element name="contactName" type="xs:string" minOccurs="0" maxOccurs="unbounded"/>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
<xs:element name="foundingDate" type="xs:string"/>
<xs:element name="dissolutionDate" type="xs:string"/>
<xs:element name="foundingPlace" type="xs:string"/>
- <xs:element name="group" type="xs:string"/>
- <xs:element name="function" type="xs:string"/>
- <xs:element name="subBody" type="xs:string"/>
- <xs:element name="history" 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="functions">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element name="function" type="xs:string" minOccurs="0" maxOccurs="unbounded"/>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="subBodies">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element name="subBody" type="xs:string" minOccurs="0" maxOccurs="unbounded"/>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="historyNotes">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element name="historyNote" type="xs:string" minOccurs="0" maxOccurs="unbounded"/>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
</xs:schema>
package org.collectionspace.services.client;\r
\r
import java.util.ArrayList;\r
+import java.util.HashMap;\r
+import java.util.List;\r
import java.util.Map;\r
\r
import javax.ws.rs.core.MediaType;\r
import javax.ws.rs.core.Response;\r
\r
import org.collectionspace.services.OrganizationJAXBSchema;\r
+import org.collectionspace.services.client.test.BaseServiceTest;\r
import org.collectionspace.services.client.test.ServiceRequestType;\r
+import org.collectionspace.services.organization.ContactNameList;\r
+import org.collectionspace.services.organization.FunctionList;\r
+import org.collectionspace.services.organization.GroupList;\r
+import org.collectionspace.services.organization.HistoryNoteList;\r
import org.collectionspace.services.organization.OrganizationsCommon;\r
import org.collectionspace.services.organization.OrgauthoritiesCommon;\r
+import org.collectionspace.services.organization.SubBodyList;\r
import org.collectionspace.services.person.PersonauthoritiesCommon;\r
import org.collectionspace.services.person.PersonsCommon;\r
import org.jboss.resteasy.client.ClientResponse;\r
commonPart.getHeaders().add("label", headerLabel);\r
\r
if(logger.isDebugEnabled()){\r
- logger.debug("to be created, orgAuthority common ", \r
- orgAuthority, OrgauthoritiesCommon.class);\r
+ logger.debug("to be created, orgAuthority common ",\r
+ orgAuthority, OrgauthoritiesCommon.class);\r
}\r
\r
return multipart;\r
*/\r
public static String createItemInAuthority(String inAuthority, \r
String orgAuthorityRefName, Map<String, String> orgInfo,\r
- OrgAuthorityClient client) {\r
+ Map<String, List<String>> orgRepeatablesInfo, OrgAuthorityClient 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
createOrganizationInstance(inAuthority, orgAuthorityRefName, \r
- orgInfo, client.getItemCommonPartName());\r
+ orgInfo, orgRepeatablesInfo, client.getItemCommonPartName());\r
+\r
ClientResponse<Response> res = client.createItem(inAuthority, multipart);\r
String result;\r
try { \r
*/\r
public static MultipartOutput createOrganizationInstance(String inAuthority, \r
String orgAuthRefName, Map<String, String> orgInfo, String headerLabel){\r
+ final Map<String, List<String>> EMPTY_ORG_REPEATABLES_INFO =\r
+ new HashMap<String, List<String>>();\r
+ return createOrganizationInstance(inAuthority, orgAuthRefName,\r
+ orgInfo, EMPTY_ORG_REPEATABLES_INFO, headerLabel);\r
+ }\r
+\r
+\r
+ /**\r
+ * Creates the organization instance.\r
+ *\r
+ * @param inAuthority the in authority\r
+ * @param orgAuthRefName the owning Authority ref name\r
+ * @param orgInfo the org info\r
+ * @param orgRepeatablesInfo names and values of repeatable scalar\r
+ * fields in the Organization record\r
+ * @param headerLabel the header label\r
+ * @return the multipart output\r
+ */\r
+ public static MultipartOutput createOrganizationInstance(String inAuthority, \r
+ String orgAuthRefName, Map<String, String> orgInfo,\r
+ Map<String, List<String>> orgRepeatablesInfo, String headerLabel){\r
OrganizationsCommon organization = new OrganizationsCommon();\r
organization.setInAuthority(inAuthority);\r
String shortId = orgInfo.get(OrganizationJAXBSchema.SHORT_IDENTIFIER);\r
} \r
organization.setShortIdentifier(shortId);\r
String value = null;\r
+ List<String> values = null;\r
value = orgInfo.get(OrganizationJAXBSchema.DISPLAY_NAME_COMPUTED);\r
boolean displayNameComputed = (value==null) || value.equalsIgnoreCase("true"); \r
organization.setDisplayNameComputed(displayNameComputed);\r
organization.setLongName(value);\r
if((value = (String)orgInfo.get(OrganizationJAXBSchema.NAME_ADDITIONS))!=null)\r
organization.setNameAdditions(value);\r
- if((value = (String)orgInfo.get(OrganizationJAXBSchema.CONTACT_NAME))!=null)\r
- organization.setContactName(value);\r
+ if((values = (List<String>)orgRepeatablesInfo.get(OrganizationJAXBSchema.CONTACT_NAMES))!=null) {\r
+ ContactNameList contactsList = new ContactNameList();\r
+ List<String> contactNames = contactsList.getContactName();\r
+ contactNames.addAll(values);\r
+ organization.setContactNames(contactsList);\r
+ }\r
if((value = (String)orgInfo.get(OrganizationJAXBSchema.FOUNDING_DATE))!=null)\r
organization.setFoundingDate(value);\r
if((value = (String)orgInfo.get(OrganizationJAXBSchema.DISSOLUTION_DATE))!=null)\r
organization.setDissolutionDate(value);\r
if((value = (String)orgInfo.get(OrganizationJAXBSchema.FOUNDING_PLACE))!=null)\r
organization.setFoundingPlace(value);\r
- if((value = (String)orgInfo.get(OrganizationJAXBSchema.GROUP))!=null)\r
- organization.setGroup(value);\r
- if((value = (String)orgInfo.get(OrganizationJAXBSchema.FUNCTION))!=null)\r
- organization.setFunction(value);\r
- if((value = (String)orgInfo.get(OrganizationJAXBSchema.SUB_BODY))!=null)\r
- organization.setSubBody(value);\r
- if((value = (String)orgInfo.get(OrganizationJAXBSchema.HISTORY))!=null)\r
- organization.setHistory(value);\r
+ if((values = (List<String>)orgRepeatablesInfo.get(OrganizationJAXBSchema.GROUPS))!=null) {\r
+ GroupList groupsList = new GroupList();\r
+ List<String> groups = groupsList.getGroup();\r
+ groups.addAll(values);\r
+ organization.setGroups(groupsList);\r
+ }\r
+ if((values = (List<String>)orgRepeatablesInfo.get(OrganizationJAXBSchema.FUNCTIONS))!=null) {\r
+ FunctionList functionsList = new FunctionList();\r
+ List<String> functions = functionsList.getFunction();\r
+ functions.addAll(values);\r
+ organization.setFunctions(functionsList);\r
+ }\r
+ if((values = (List<String>)orgRepeatablesInfo.get(OrganizationJAXBSchema.SUB_BODIES))!=null) {\r
+ SubBodyList subBodiesList = new SubBodyList();\r
+ List<String> subbodies = subBodiesList.getSubBody();\r
+ subbodies.addAll(values);\r
+ organization.setSubBodies(subBodiesList);\r
+ }\r
+ if((values = (List<String>)orgRepeatablesInfo.get(OrganizationJAXBSchema.HISTORY_NOTES))!=null) {\r
+ HistoryNoteList historyNotesList = new HistoryNoteList();\r
+ List<String> historyNotes = historyNotesList.getHistoryNote();\r
+ historyNotes.addAll(values);\r
+ organization.setHistoryNotes(historyNotesList);\r
+ }\r
if((value = (String)orgInfo.get(OrganizationJAXBSchema.TERM_STATUS))!=null)\r
organization.setTermStatus(value);\r
MultipartOutput multipart = new MultipartOutput();\r
"Test Organization-" + shortId);
testOrgMap.put(OrganizationJAXBSchema.LONG_NAME, "Test Organization Name");
testOrgMap.put(OrganizationJAXBSchema.FOUNDING_PLACE, "Anytown, USA");
- testOrgMap.put(OrganizationJAXBSchema.CONTACT_NAME, organizationContactPersonRefName);
- testOrgMap.put(OrganizationJAXBSchema.SUB_BODY, subBodyRefName);
+
+ Map<String, List<String>> testOrgRepeatablesMap = new HashMap<String,List<String>>();
+ List<String> testOrgContactNames = new ArrayList<String>();
+ testOrgContactNames.add(organizationContactPersonRefName);
+ testOrgRepeatablesMap.put(OrganizationJAXBSchema.CONTACT_NAMES, testOrgContactNames);
+ List<String> testOrgSubBodies = new ArrayList<String>();
+ testOrgSubBodies.add(subBodyRefName);
+ testOrgRepeatablesMap.put(OrganizationJAXBSchema.SUB_BODIES, testOrgSubBodies);
// Finishing creating the new Organization item, then
// submit the request to the service and store the response.
knownItemResourceId = OrgAuthorityClientUtils.createItemInAuthority(
- knownResourceId, knownResourceRefName, testOrgMap, orgAuthClient);
+ knownResourceId, knownResourceRefName, testOrgMap,
+ testOrgRepeatablesMap, orgAuthClient);
// Store the IDs from every item created by tests,
// so they can be deleted after tests have been run.
logger.debug(objectAsXmlString(organization, OrganizationsCommon.class));
}
// Check one or more of the authority fields in the Organization item
- Assert.assertEquals(organization.getContactName(), organizationContactPersonRefName);
- Assert.assertEquals(organization.getSubBody(), subBodyRefName);
+ Assert.assertEquals(organization.getContactNames().getContactName().get(0),
+ organizationContactPersonRefName);
+ Assert.assertEquals(organization.getSubBodies().getSubBody().get(0),
+ subBodyRefName);
// Get the auth refs and check them
// FIXME - need to create this method in the client
*/
package org.collectionspace.services.client.test;
+import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
testOrgMap.put(OrganizationJAXBSchema.SHORT_IDENTIFIER, shortId);
testOrgMap.put(OrganizationJAXBSchema.SHORT_NAME, TEST_ORG_SHORTNAME);
testOrgMap.put(OrganizationJAXBSchema.LONG_NAME, "The real official test organization");
- testOrgMap.put(OrganizationJAXBSchema.CONTACT_NAME, "joe@test.org");
testOrgMap.put(OrganizationJAXBSchema.FOUNDING_DATE, "May 26, 1907");
testOrgMap.put(OrganizationJAXBSchema.FOUNDING_PLACE, TEST_ORG_FOUNDING_PLACE);
- testOrgMap.put(OrganizationJAXBSchema.FUNCTION, "For testing");
+
+ Map<String, List<String>> testOrgRepeatablesMap = new HashMap<String,List<String>>();
+ List<String> testOrgContacts = new ArrayList<String>();
+ testOrgContacts.add("joe@example.org");
+ testOrgContacts.add("sally@example.org");
+ testOrgRepeatablesMap.put(OrganizationJAXBSchema.CONTACT_NAMES, testOrgContacts);
+
String newID = OrgAuthorityClientUtils.createItemInAuthority(
- vcsid, authRefName, testOrgMap, client);
+ vcsid, authRefName, testOrgMap, testOrgRepeatablesMap, client);
+
// Store the ID returned from the first item resource created
// for additional tests below.
if (knownItemResourceId == null){
logger.debug(testName + ": returned payload:");
logger.debug(objectAsXmlString(organization, OrganizationsCommon.class));
}
+
+ // Check that the organization item is within the expected OrgAuthority.
Assert.assertEquals(organization.getInAuthority(), knownResourceId);
+
+ // Verify the number and contents of values in a repeatable field,
+ // as created in the instance record used for testing.
+ List<String> contactNames = organization.getContactNames().getContactName();
+ Assert.assertTrue(contactNames.size() > 0);
+ Assert.assertNotNull(contactNames.get(0));
+
} finally {
res.releaseConnection();
}
* \r
*/\r
package org.collectionspace.services;\r
+\r
import org.collectionspace.services.common.vocabulary.AuthorityJAXBSchema;\r
\r
/**\r
*\r
*/\r
public interface OrganizationJAXBSchema extends AuthorityJAXBSchema {\r
- final static String ORGANIZATIONS_COMMON="organizations_common"; \r
- final static String DISPLAY_NAME_COMPUTED = "displayNameComputed";\r
- final static String SHORT_NAME = "shortName";\r
- final static String LONG_NAME = "longName";\r
- final static String NAME_ADDITIONS = "nameAdditions";\r
- final static String CONTACT_NAME = "contactName";\r
- final static String FOUNDING_DATE = "foundingDate";\r
- final static String DISSOLUTION_DATE = "dissolutionDate";\r
- final static String FOUNDING_PLACE = "foundingPlace";\r
- final static String GROUP = "group";\r
- final static String FUNCTION = "function";\r
- final static String SUB_BODY = "subBody";\r
- final static String HISTORY = "history";\r
+\r
+ final static String ORGANIZATIONS_COMMON = "organizations_common";\r
+ final static String DISPLAY_NAME_COMPUTED = "displayNameComputed";\r
+ final static String SHORT_NAME = "shortName";\r
+ final static String LONG_NAME = "longName";\r
+ final static String NAME_ADDITIONS = "nameAdditions";\r
+ final static String CONTACT_NAMES = "contactNames";\r
+ final static String FOUNDING_DATE = "foundingDate";\r
+ final static String DISSOLUTION_DATE = "dissolutionDate";\r
+ final static String FOUNDING_PLACE = "foundingPlace";\r
+ final static String GROUPS = "groups";\r
+ final static String FUNCTIONS = "functions";\r
+ final static String SUB_BODIES = "subBodies";\r
+ final static String HISTORY_NOTES = "historyNotes";\r
}\r
\r
\r
<xs:element name="csid" type="xs:string" />
<!-- Organization 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="shortName" type="xs:string"/>
<xs:element name="longName" type="xs:string"/>
<xs:element name="nameAdditions" type="xs:string"/>
- <xs:element name="contactName" type="xs:string"/>
+ <xs:element name="contactNames" type="contactNameList"/>
<xs:element name="foundingDate" type="xs:string"/>
<xs:element name="dissolutionDate" type="xs:string"/>
<xs:element name="foundingPlace" type="xs:string"/>
- <xs:element name="group" type="xs:string"/>
- <xs:element name="function" type="xs:string"/>
- <xs:element name="subBody" type="xs:string"/>
- <xs:element name="history" type="xs:string"/>
+ <xs:element name="groups" type="groupList"/>
+ <xs:element name="functions" type="functionList"/>
+ <xs:element name="subBodies" type="subBodyList"/>
+ <xs:element name="historyNotes" type="historyNoteList"/>
</xs:sequence>
</xs:complexType>
</xs:element>
+
+ <xs:complexType name="contactNameList">
+ <xs:sequence>
+ <xs:element name="contactName" type="xs:string" minOccurs="0" maxOccurs="unbounded"/>
+ </xs:sequence>
+ </xs:complexType>
+
+ <xs:complexType name="groupList">
+ <xs:sequence>
+ <xs:element name="group" type="xs:string" minOccurs="0" maxOccurs="unbounded"/>
+ </xs:sequence>
+ </xs:complexType>
+
+ <xs:complexType name="functionList">
+ <xs:sequence>
+ <xs:element name="function" type="xs:string" minOccurs="0" maxOccurs="unbounded"/>
+ </xs:sequence>
+ </xs:complexType>
+
+ <xs:complexType name="subBodyList">
+ <xs:sequence>
+ <xs:element name="subBody" type="xs:string" minOccurs="0" maxOccurs="unbounded"/>
+ </xs:sequence>
+ </xs:complexType>
+
+ <xs:complexType name="historyNoteList">
+ <xs:sequence>
+ <xs:element name="historyNote" type="xs:string" minOccurs="0" maxOccurs="unbounded"/>
+ </xs:sequence>
+ </xs:complexType>
<!-- This is the base class for paginated lists -->
<xs:complexType name="abstractCommonListItem">