From 6604ae091914d67655819854f16d818a733629ca Mon Sep 17 00:00:00 2001 From: Aron Roberts Date: Fri, 23 Jul 2010 22:42:02 +0000 Subject: [PATCH] CSPACE-2535: Made five fields repeatable in Organization records (records of items within an OrgAuthority), in the services layer: contactName, group, function, subBody, and historyNote (formerly history). Changes the relevant Nuxeo document type schema, and as such requires an 'ant deploy' and a 2-server restart. --- .../main/config/services/tenant-bindings.xml | 8 +- .../resources/OSGI-INF/layouts-contrib.xml | 19 +++-- .../schemas/organizations_common.xsd | 40 ++++++++-- .../client/OrgAuthorityClientUtils.java | 79 +++++++++++++++---- .../client/test/OrgAuthorityAuthRefsTest.java | 19 +++-- .../client/test/OrgAuthorityServiceTest.java | 22 +++++- .../services/OrganizationJAXBSchema.java | 28 ++++--- .../main/resources/organization_common.xsd | 42 ++++++++-- 8 files changed, 201 insertions(+), 56 deletions(-) diff --git a/services/common/src/main/config/services/tenant-bindings.xml b/services/common/src/main/config/services/tenant-bindings.xml index dac7ad089..75c95ae47 100644 --- a/services/common/src/main/config/services/tenant-bindings.xml +++ b/services/common/src/main/config/services/tenant-bindings.xml @@ -488,8 +488,8 @@ versionable="true" auditable="false" label="organizations_common" updated="" order="1"> - authRefcontactName - authRefsubBody + authRefcontactNames + authRefsubBodies @@ -1538,8 +1538,8 @@ versionable="true" auditable="false" label="organizations_common" updated="" order="1"> - authRefcontactName - authRefsubBody + authRefcontactNames + authRefsubBodies diff --git a/services/organization/3rdparty/nuxeo-platform-cs-organization/src/main/resources/OSGI-INF/layouts-contrib.xml b/services/organization/3rdparty/nuxeo-platform-cs-organization/src/main/resources/OSGI-INF/layouts-contrib.xml index c6194dd4d..401746487 100644 --- a/services/organization/3rdparty/nuxeo-platform-cs-organization/src/main/resources/OSGI-INF/layouts-contrib.xml +++ b/services/organization/3rdparty/nuxeo-platform-cs-organization/src/main/resources/OSGI-INF/layouts-contrib.xml @@ -86,14 +86,16 @@ shortName longName nameAdditions - contactName + + + foundingDate dissolutionDate foundingPlace - group - function - subBody - history + + + + termStatus @@ -149,7 +151,8 @@ - @@ -253,6 +258,7 @@ + diff --git a/services/organization/3rdparty/nuxeo-platform-cs-organization/src/main/resources/schemas/organizations_common.xsd b/services/organization/3rdparty/nuxeo-platform-cs-organization/src/main/resources/schemas/organizations_common.xsd index 8c10c5452..6427008d9 100644 --- a/services/organization/3rdparty/nuxeo-platform-cs-organization/src/main/resources/schemas/organizations_common.xsd +++ b/services/organization/3rdparty/nuxeo-platform-cs-organization/src/main/resources/schemas/organizations_common.xsd @@ -32,14 +32,44 @@ - + + + + + + + - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/services/organization/client/src/main/java/org/collectionspace/services/client/OrgAuthorityClientUtils.java b/services/organization/client/src/main/java/org/collectionspace/services/client/OrgAuthorityClientUtils.java index 4f7411fb5..c0e19b4f7 100644 --- a/services/organization/client/src/main/java/org/collectionspace/services/client/OrgAuthorityClientUtils.java +++ b/services/organization/client/src/main/java/org/collectionspace/services/client/OrgAuthorityClientUtils.java @@ -27,6 +27,8 @@ package org.collectionspace.services.client; import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; import java.util.Map; import javax.ws.rs.core.MediaType; @@ -34,9 +36,15 @@ import javax.ws.rs.core.MultivaluedMap; import javax.ws.rs.core.Response; import org.collectionspace.services.OrganizationJAXBSchema; +import org.collectionspace.services.client.test.BaseServiceTest; import org.collectionspace.services.client.test.ServiceRequestType; +import org.collectionspace.services.organization.ContactNameList; +import org.collectionspace.services.organization.FunctionList; +import org.collectionspace.services.organization.GroupList; +import org.collectionspace.services.organization.HistoryNoteList; import org.collectionspace.services.organization.OrganizationsCommon; import org.collectionspace.services.organization.OrgauthoritiesCommon; +import org.collectionspace.services.organization.SubBodyList; import org.collectionspace.services.person.PersonauthoritiesCommon; import org.collectionspace.services.person.PersonsCommon; import org.jboss.resteasy.client.ClientResponse; @@ -144,8 +152,8 @@ public class OrgAuthorityClientUtils { commonPart.getHeaders().add("label", headerLabel); if(logger.isDebugEnabled()){ - logger.debug("to be created, orgAuthority common ", - orgAuthority, OrgauthoritiesCommon.class); + logger.debug("to be created, orgAuthority common ", + orgAuthority, OrgauthoritiesCommon.class); } return multipart; @@ -162,7 +170,7 @@ public class OrgAuthorityClientUtils { */ public static String createItemInAuthority(String inAuthority, String orgAuthorityRefName, Map orgInfo, - OrgAuthorityClient client) { + Map> orgRepeatablesInfo, OrgAuthorityClient client) { // Expected status code: 201 Created int EXPECTED_STATUS_CODE = Response.Status.CREATED.getStatusCode(); // Type of service request being tested @@ -175,7 +183,8 @@ public class OrgAuthorityClientUtils { } MultipartOutput multipart = createOrganizationInstance(inAuthority, orgAuthorityRefName, - orgInfo, client.getItemCommonPartName()); + orgInfo, orgRepeatablesInfo, client.getItemCommonPartName()); + ClientResponse res = client.createItem(inAuthority, multipart); String result; try { @@ -210,6 +219,27 @@ public class OrgAuthorityClientUtils { */ public static MultipartOutput createOrganizationInstance(String inAuthority, String orgAuthRefName, Map orgInfo, String headerLabel){ + final Map> EMPTY_ORG_REPEATABLES_INFO = + new HashMap>(); + return createOrganizationInstance(inAuthority, orgAuthRefName, + orgInfo, EMPTY_ORG_REPEATABLES_INFO, headerLabel); + } + + + /** + * Creates the organization instance. + * + * @param inAuthority the in authority + * @param orgAuthRefName the owning Authority ref name + * @param orgInfo the org info + * @param orgRepeatablesInfo names and values of repeatable scalar + * fields in the Organization record + * @param headerLabel the header label + * @return the multipart output + */ + public static MultipartOutput createOrganizationInstance(String inAuthority, + String orgAuthRefName, Map orgInfo, + Map> orgRepeatablesInfo, String headerLabel){ OrganizationsCommon organization = new OrganizationsCommon(); organization.setInAuthority(inAuthority); String shortId = orgInfo.get(OrganizationJAXBSchema.SHORT_IDENTIFIER); @@ -218,6 +248,7 @@ public class OrgAuthorityClientUtils { } organization.setShortIdentifier(shortId); String value = null; + List values = null; value = orgInfo.get(OrganizationJAXBSchema.DISPLAY_NAME_COMPUTED); boolean displayNameComputed = (value==null) || value.equalsIgnoreCase("true"); organization.setDisplayNameComputed(displayNameComputed); @@ -233,22 +264,42 @@ public class OrgAuthorityClientUtils { organization.setLongName(value); if((value = (String)orgInfo.get(OrganizationJAXBSchema.NAME_ADDITIONS))!=null) organization.setNameAdditions(value); - if((value = (String)orgInfo.get(OrganizationJAXBSchema.CONTACT_NAME))!=null) - organization.setContactName(value); + if((values = (List)orgRepeatablesInfo.get(OrganizationJAXBSchema.CONTACT_NAMES))!=null) { + ContactNameList contactsList = new ContactNameList(); + List contactNames = contactsList.getContactName(); + contactNames.addAll(values); + organization.setContactNames(contactsList); + } if((value = (String)orgInfo.get(OrganizationJAXBSchema.FOUNDING_DATE))!=null) organization.setFoundingDate(value); if((value = (String)orgInfo.get(OrganizationJAXBSchema.DISSOLUTION_DATE))!=null) organization.setDissolutionDate(value); if((value = (String)orgInfo.get(OrganizationJAXBSchema.FOUNDING_PLACE))!=null) organization.setFoundingPlace(value); - if((value = (String)orgInfo.get(OrganizationJAXBSchema.GROUP))!=null) - organization.setGroup(value); - if((value = (String)orgInfo.get(OrganizationJAXBSchema.FUNCTION))!=null) - organization.setFunction(value); - if((value = (String)orgInfo.get(OrganizationJAXBSchema.SUB_BODY))!=null) - organization.setSubBody(value); - if((value = (String)orgInfo.get(OrganizationJAXBSchema.HISTORY))!=null) - organization.setHistory(value); + if((values = (List)orgRepeatablesInfo.get(OrganizationJAXBSchema.GROUPS))!=null) { + GroupList groupsList = new GroupList(); + List groups = groupsList.getGroup(); + groups.addAll(values); + organization.setGroups(groupsList); + } + if((values = (List)orgRepeatablesInfo.get(OrganizationJAXBSchema.FUNCTIONS))!=null) { + FunctionList functionsList = new FunctionList(); + List functions = functionsList.getFunction(); + functions.addAll(values); + organization.setFunctions(functionsList); + } + if((values = (List)orgRepeatablesInfo.get(OrganizationJAXBSchema.SUB_BODIES))!=null) { + SubBodyList subBodiesList = new SubBodyList(); + List subbodies = subBodiesList.getSubBody(); + subbodies.addAll(values); + organization.setSubBodies(subBodiesList); + } + if((values = (List)orgRepeatablesInfo.get(OrganizationJAXBSchema.HISTORY_NOTES))!=null) { + HistoryNoteList historyNotesList = new HistoryNoteList(); + List historyNotes = historyNotesList.getHistoryNote(); + historyNotes.addAll(values); + organization.setHistoryNotes(historyNotesList); + } if((value = (String)orgInfo.get(OrganizationJAXBSchema.TERM_STATUS))!=null) organization.setTermStatus(value); MultipartOutput multipart = new MultipartOutput(); diff --git a/services/organization/client/src/test/java/org/collectionspace/services/client/test/OrgAuthorityAuthRefsTest.java b/services/organization/client/src/test/java/org/collectionspace/services/client/test/OrgAuthorityAuthRefsTest.java index 59b5054de..eeb1325f6 100644 --- a/services/organization/client/src/test/java/org/collectionspace/services/client/test/OrgAuthorityAuthRefsTest.java +++ b/services/organization/client/src/test/java/org/collectionspace/services/client/test/OrgAuthorityAuthRefsTest.java @@ -195,13 +195,20 @@ public class OrgAuthorityAuthRefsTest extends BaseServiceTest { "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> testOrgRepeatablesMap = new HashMap>(); + List testOrgContactNames = new ArrayList(); + testOrgContactNames.add(organizationContactPersonRefName); + testOrgRepeatablesMap.put(OrganizationJAXBSchema.CONTACT_NAMES, testOrgContactNames); + List testOrgSubBodies = new ArrayList(); + 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. @@ -353,8 +360,10 @@ public class OrgAuthorityAuthRefsTest extends BaseServiceTest { 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 diff --git a/services/organization/client/src/test/java/org/collectionspace/services/client/test/OrgAuthorityServiceTest.java b/services/organization/client/src/test/java/org/collectionspace/services/client/test/OrgAuthorityServiceTest.java index ad5942210..1f3ffb09a 100644 --- a/services/organization/client/src/test/java/org/collectionspace/services/client/test/OrgAuthorityServiceTest.java +++ b/services/organization/client/src/test/java/org/collectionspace/services/client/test/OrgAuthorityServiceTest.java @@ -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; @@ -229,12 +230,18 @@ public class OrgAuthorityServiceTest extends AbstractServiceTestImpl { 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> testOrgRepeatablesMap = new HashMap>(); + List testOrgContacts = new ArrayList(); + 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){ @@ -659,7 +666,16 @@ public class OrgAuthorityServiceTest extends AbstractServiceTestImpl { 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 contactNames = organization.getContactNames().getContactName(); + Assert.assertTrue(contactNames.size() > 0); + Assert.assertNotNull(contactNames.get(0)); + } finally { res.releaseConnection(); } diff --git a/services/organization/jaxb/src/main/java/org/collectionspace/services/OrganizationJAXBSchema.java b/services/organization/jaxb/src/main/java/org/collectionspace/services/OrganizationJAXBSchema.java index 8dd893c62..54d2c870b 100644 --- a/services/organization/jaxb/src/main/java/org/collectionspace/services/OrganizationJAXBSchema.java +++ b/services/organization/jaxb/src/main/java/org/collectionspace/services/OrganizationJAXBSchema.java @@ -2,6 +2,7 @@ * */ package org.collectionspace.services; + import org.collectionspace.services.common.vocabulary.AuthorityJAXBSchema; /** @@ -9,19 +10,20 @@ import org.collectionspace.services.common.vocabulary.AuthorityJAXBSchema; * */ public interface OrganizationJAXBSchema extends AuthorityJAXBSchema { - final static String ORGANIZATIONS_COMMON="organizations_common"; - final static String DISPLAY_NAME_COMPUTED = "displayNameComputed"; - final static String SHORT_NAME = "shortName"; - final static String LONG_NAME = "longName"; - final static String NAME_ADDITIONS = "nameAdditions"; - final static String CONTACT_NAME = "contactName"; - final static String FOUNDING_DATE = "foundingDate"; - final static String DISSOLUTION_DATE = "dissolutionDate"; - final static String FOUNDING_PLACE = "foundingPlace"; - final static String GROUP = "group"; - final static String FUNCTION = "function"; - final static String SUB_BODY = "subBody"; - final static String HISTORY = "history"; + + final static String ORGANIZATIONS_COMMON = "organizations_common"; + final static String DISPLAY_NAME_COMPUTED = "displayNameComputed"; + final static String SHORT_NAME = "shortName"; + final static String LONG_NAME = "longName"; + final static String NAME_ADDITIONS = "nameAdditions"; + final static String CONTACT_NAMES = "contactNames"; + final static String FOUNDING_DATE = "foundingDate"; + final static String DISSOLUTION_DATE = "dissolutionDate"; + final static String FOUNDING_PLACE = "foundingPlace"; + final static String GROUPS = "groups"; + final static String FUNCTIONS = "functions"; + final static String SUB_BODIES = "subBodies"; + final static String HISTORY_NOTES = "historyNotes"; } diff --git a/services/organization/jaxb/src/main/resources/organization_common.xsd b/services/organization/jaxb/src/main/resources/organization_common.xsd index 5288b135d..314509f7a 100644 --- a/services/organization/jaxb/src/main/resources/organization_common.xsd +++ b/services/organization/jaxb/src/main/resources/organization_common.xsd @@ -21,7 +21,7 @@ - + @@ -29,17 +29,47 @@ - + - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + -- 2.47.3