<!--
Organization schema (XSD)
-
+
Entity : Organization
Part : Common
Used for: Nuxeo EP core document type
-
- $LastChangedRevision: 860 $
- $LastChangedDate: 2009-10-14 14:48:05 -0700 (Wed, 14 Oct 2009) $
+
+ $LastChangedRevision$
+ $LastChangedDate$
-->
<xs:schema
- xmlns:xs="http://www.w3.org/2001/XMLSchema"
- xmlns:ns="http://collectionspace.org/services/organization"
- xmlns="http://collectionspace.org/services/organization"
- targetNamespace="http://collectionspace.org/services/organization"
- version="0.1"
->
-<!-- See http://wiki.collectionspace.org/display/collectionspace/Name+Authority+Schema -->
+ xmlns:xs="http://www.w3.org/2001/XMLSchema"
+ xmlns:ns="http://collectionspace.org/services/organization"
+ xmlns="http://collectionspace.org/services/organization"
+ targetNamespace="http://collectionspace.org/services/organization"
+ version="0.1"
+ >
+ <!-- See http://wiki.collectionspace.org/display/collectionspace/Name+Authority+Schema -->
<!-- See http://wiki.collectionspace.org/display/collectionspace/Organization+Service+Home -->
<!-- Organization Information Group -->
<xs:element name="displayNameComputed" type="xs:boolean"/>
<xs:element name="shortDisplayName" type="xs:string"/>
<xs:element name="shortDisplayNameComputed" type="xs:boolean"/>
-
- <!-- FIXME Start of main body (represented by 'longName' element) repeatable group -->
- <xs:element name="shortName" type="xs:string"/>
- <xs:element name="longName" type="xs:string"/>
- <xs:element name="nameAdditions" type="xs:string"/>
- <!-- FIXME End of main body repeatable group -->
+ <xs:element name="mainBodyGroupList" type="mainBodyGroupList"/>
<xs:element name="contactNames">
<xs:complexType>
</xs:complexType>
</xs:element>
+ <xs:complexType name="mainBodyGroupList">
+ <xs:sequence>
+ <xs:element name="mainBodyGroup" type="mainBodyGroup" minOccurs="0" maxOccurs="unbounded"/>
+ </xs:sequence>
+ </xs:complexType>
+
+ <xs:complexType name="mainBodyGroup">
+ <xs:sequence>
+ <xs:element name="longName" type="xs:string"/>
+ <xs:element name="shortName" type="xs:string"/>
+ <xs:element name="nameAdditions" type="xs:string"/>
+ </xs:sequence>
+ </xs:complexType>
+
</xs:schema>
Part : Common
Used for: Nuxeo EP core document type
- $LastChangedRevision: 928 $
- $LastChangedDate: 2009-11-10 12:25:58 -0800 (Tue, 10 Nov 2009) $
+ $LastChangedRevision$
+ $LastChangedDate$
-->
<xs:schema
* {Other Notes Relating to This Class (Optional)}
*
* $LastChangedBy: $
- * $LastChangedRevision: $
- * $LastChangedDate: $
+ * $LastChangedRevision$
+ * $LastChangedDate$
*
* This document is a part of the source code and related artifacts
* for CollectionSpace, an open source collections management system
* {Other Notes Relating to This Class (Optional)}\r
*\r
* $LastChangedBy: $\r
- * $LastChangedRevision: $\r
- * $LastChangedDate: $\r
+ * $LastChangedRevision$\r
+ * $LastChangedDate$\r
*\r
* This document is a part of the source code and related artifacts\r
* for CollectionSpace, an open source collections management system\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.MainBodyGroupList;\r
import org.collectionspace.services.organization.OrganizationsCommon;\r
import org.collectionspace.services.organization.OrgauthoritiesCommon;\r
import org.collectionspace.services.organization.SubBodyList;\r
*/\r
public static String createItemInAuthority( String inAuthority,\r
String orgAuthorityRefName, Map<String, String> orgInfo,\r
- Map<String, List<String>> orgRepeatablesInfo, OrgAuthorityClient client) {\r
+ Map<String, List<String>> orgRepeatablesInfo, MainBodyGroupList mainBodyList, 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(orgAuthorityRefName, \r
- orgInfo, orgRepeatablesInfo, client.getItemCommonPartName());\r
+ orgInfo, orgRepeatablesInfo, mainBodyList, client.getItemCommonPartName());\r
\r
ClientResponse<Response> res = client.createItem(inAuthority, multipart);\r
String result;\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
+ final MainBodyGroupList EMPTY_MAIN_BODY_LIST = new MainBodyGroupList();\r
return createOrganizationInstance(orgAuthRefName,\r
- orgInfo, EMPTY_ORG_REPEATABLES_INFO, headerLabel);\r
+ orgInfo, EMPTY_ORG_REPEATABLES_INFO, EMPTY_MAIN_BODY_LIST, headerLabel);\r
}\r
\r
\r
*/\r
public static MultipartOutput createOrganizationInstance( \r
String orgAuthRefName, Map<String, String> orgInfo,\r
- Map<String, List<String>> orgRepeatablesInfo, String headerLabel){\r
+ Map<String, List<String>> orgRepeatablesInfo, MainBodyGroupList mainBodyList, String headerLabel){\r
OrganizationsCommon organization = new OrganizationsCommon();\r
String shortId = orgInfo.get(OrganizationJAXBSchema.SHORT_IDENTIFIER);\r
if (shortId == null || shortId.isEmpty()) {\r
String refName = createOrganizationRefName(orgAuthRefName, shortId, value);\r
organization.setRefName(refName);\r
\r
- if((value = (String)orgInfo.get(OrganizationJAXBSchema.SHORT_NAME))!=null)\r
- organization.setShortName(value);\r
- if((value = (String)orgInfo.get(OrganizationJAXBSchema.LONG_NAME))!=null)\r
- organization.setLongName(value);\r
- if((value = (String)orgInfo.get(OrganizationJAXBSchema.NAME_ADDITIONS))!=null)\r
- organization.setNameAdditions(value);\r
+ if (mainBodyList != null) {\r
+ organization.setMainBodyGroupList(mainBodyList);\r
+ }\r
+\r
if((values = (List<String>)orgRepeatablesInfo.get(OrganizationJAXBSchema.CONTACT_NAMES))!=null) {\r
ContactNameList contactsList = new ContactNameList();\r
List<String> contactNames = contactsList.getContactName();\r
import org.jboss.resteasy.plugins.providers.multipart.MultipartOutput;
/**
- * @version $Revision:$
+ * @version $Revision$
*/
@Path("/orgauthorities/")
@Produces({"multipart/mixed"})
import org.collectionspace.services.client.PersonAuthorityClientUtils;
import org.collectionspace.services.common.authorityref.AuthorityRefList;
import org.collectionspace.services.jaxb.AbstractCommonList;
+import org.collectionspace.services.organization.MainBodyGroup;
+import org.collectionspace.services.organization.MainBodyGroupList;
import org.collectionspace.services.organization.OrganizationsCommon;
import org.jboss.resteasy.client.ClientResponse;
* LoaninAuthRefsTest, carries out Authority References tests against a
* deployed and running Loanin (aka Loans In) Service.
*
- * $LastChangedRevision: 1327 $
- * $LastChangedDate: 2010-02-12 10:35:11 -0800 (Fri, 12 Feb 2010) $
+ * $LastChangedRevision$
+ * $LastChangedDate$
*/
public class OrgAuthorityAuthRefsTest extends BaseServiceTest {
// per the initialization(s) below.
Map<String, String> testOrgMap = new HashMap<String,String>();
testOrgMap.put(OrganizationJAXBSchema.SHORT_IDENTIFIER, shortId);
- testOrgMap.put(OrganizationJAXBSchema.SHORT_NAME,
- "Test Organization-" + shortId);
- testOrgMap.put(OrganizationJAXBSchema.LONG_NAME, "Test Organization Name");
testOrgMap.put(OrganizationJAXBSchema.FOUNDING_PLACE, "Anytown, USA");
Map<String, List<String>> testOrgRepeatablesMap = new HashMap<String,List<String>>();
testOrgSubBodies.add(subBodyRefName);
testOrgRepeatablesMap.put(OrganizationJAXBSchema.SUB_BODIES, testOrgSubBodies);
+ MainBodyGroupList mainBodyList = new MainBodyGroupList();
+ List<MainBodyGroup> mainBodyGroups = mainBodyList.getMainBodyGroup();
+ MainBodyGroup mainBodyGroup = new MainBodyGroup();
+ mainBodyGroup.setShortName("Test Organization-" + shortId);
+ mainBodyGroup.setLongName("Test Organization Name");
+ mainBodyGroups.add(mainBodyGroup);
+
// Finishing creating the new Organization item, then
// submit the request to the service and store the response.
knownItemResourceId = OrgAuthorityClientUtils.createItemInAuthority(
knownResourceId, knownResourceRefName, testOrgMap,
- testOrgRepeatablesMap, orgAuthClient);
+ testOrgRepeatablesMap, mainBodyList, orgAuthClient);
// Store the IDs from every item created by tests,
// so they can be deleted after tests have been run.
import org.collectionspace.services.client.OrgAuthorityClient;
import org.collectionspace.services.client.OrgAuthorityClientUtils;
import org.collectionspace.services.jaxb.AbstractCommonList;
+import org.collectionspace.services.organization.MainBodyGroup;
+import org.collectionspace.services.organization.MainBodyGroupList;
import org.collectionspace.services.organization.OrgauthoritiesCommon;
import org.collectionspace.services.organization.OrgauthoritiesCommonList;
import org.collectionspace.services.organization.OrganizationsCommon;
* OrgAuthorityServiceTest, carries out tests against a
* deployed and running OrgAuthority Service.
*
- * $LastChangedRevision: 753 $
- * $LastChangedDate: 2009-09-23 11:03:36 -0700 (Wed, 23 Sep 2009) $
+ * $LastChangedRevision$
+ * $LastChangedDate$
*/
public class OrgAuthorityServiceTest extends AbstractServiceTestImpl {
testOrgContactNames.add("joe@example.org");
testOrgContactNames.add("sally@example.org");
testOrgRepeatablesMap.put(OrganizationJAXBSchema.CONTACT_NAMES, testOrgContactNames);
+
+ MainBodyGroupList mainBodyList = new MainBodyGroupList();
+ List<MainBodyGroup> mainBodyGroups = mainBodyList.getMainBodyGroup();
+ MainBodyGroup mainBodyGroup = new MainBodyGroup();
+ mainBodyGroup.setShortName(TEST_ORG_SHORTNAME);
+ mainBodyGroup.setLongName("The real official test organization");
+ mainBodyGroups.add(mainBodyGroup);
String newID = OrgAuthorityClientUtils.createItemInAuthority(
- vcsid, authRefName, testOrgMap, testOrgRepeatablesMap, client);
+ vcsid, authRefName, testOrgMap, testOrgRepeatablesMap, mainBodyList, client);
// Store the ID returned from the first item resource created
// for additional tests below.
// Update the shortName and verify the computed name is updated.
organization.setCsid(null);
organization.setDisplayNameComputed(true);
- organization.setShortName("updated-" + TEST_ORG_SHORTNAME);
+
+ MainBodyGroupList mainBodyList = organization.getMainBodyGroupList();
+ List<MainBodyGroup> mainBodyGroups = mainBodyList.getMainBodyGroup();
+ MainBodyGroup mainBodyGroup = new MainBodyGroup();
+ String updatedShortName = "updated-" + TEST_ORG_SHORTNAME;
+ mainBodyGroup.setShortName(updatedShortName);
+ mainBodyGroups.add(mainBodyGroup);
+ organization.setMainBodyGroupList(mainBodyList);
+
expectedDisplayName =
OrgAuthorityClientUtils.prepareDefaultDisplayName(
- "updated-" + TEST_ORG_SHORTNAME, TEST_ORG_FOUNDING_PLACE);
+ updatedShortName, TEST_ORG_FOUNDING_PLACE);
// Submit the updated resource to the service and store the response.
MultipartOutput output = new MultipartOutput();
Assert.assertNotNull(updatedOrganization);
// Verify that the updated resource received the correct data.
- Assert.assertEquals(updatedOrganization.getShortName(), organization.getShortName(),
- "Updated ShortName in Organization did not match submitted data.");
+ mainBodyList = organization.getMainBodyGroupList();
+ Assert.assertNotNull(mainBodyList);
+ Assert.assertTrue(mainBodyList.getMainBodyGroup().size() > 0);
+ Assert.assertEquals(updatedOrganization.getMainBodyGroupList().getMainBodyGroup().get(0).getShortName(),
+ updatedShortName, "Updated ShortName in Organization did not match submitted data.");
+
// Verify that the updated resource computes the right displayName.
Assert.assertEquals(updatedOrganization.getDisplayName(), expectedDisplayName,
"Updated ShortName in Organization not reflected in computed DisplayName.");
// Update the contents of this resource.
organization.setCsid(null);
- organization.setShortName("updated-" + organization.getShortName());
+
+ MainBodyGroupList mainBodyList = organization.getMainBodyGroupList();
+ Assert.assertNotNull(mainBodyList);
+ List<MainBodyGroup> mainBodyGroups = mainBodyList.getMainBodyGroup();
+ Assert.assertTrue(mainBodyList.getMainBodyGroup().size() > 0);
+ String updatedShortName = "updated-" + mainBodyGroups.get(0).getShortName();
+ mainBodyGroups.get(0).setShortName(updatedShortName);
+
if(logger.isDebugEnabled()){
logger.debug("to be updated Organization");
logger.debug(objectAsXmlString(organization,
Assert.assertNotNull(updatedOrganization);
// Verify that the updated resource received the correct data.
- Assert.assertEquals(updatedOrganization.getShortName(),
- organization.getShortName(),
- "Data in updated Organization did not match submitted data.");
+ mainBodyList = organization.getMainBodyGroupList();
+ Assert.assertNotNull(mainBodyList);
+ Assert.assertTrue(mainBodyList.getMainBodyGroup().size() > 0);
+ Assert.assertEquals(updatedOrganization.getMainBodyGroupList().getMainBodyGroup().get(0).getShortName(),
+ updatedShortName, "Data in updated Organization did not match submitted data.");
} finally {
res.releaseConnection();
}
public interface OrganizationJAXBSchema extends AuthorityItemJAXBSchema {\r
\r
final static String ORGANIZATIONS_COMMON = "organizations_common";\r
- final static String SHORT_NAME = "shortName";\r
+ final static String MAIN_BODY_GROUP_LIST = "mainBodyGroupList";\r
final static String LONG_NAME = "longName";\r
+ final static String SHORT_NAME = "shortName";\r
final static String NAME_ADDITIONS = "nameAdditions";\r
final static String CONTACT_NAMES = "contactNames";\r
final static String FOUNDING_DATE = "foundingDate";\r
xmlns="http://collectionspace.org/services/organization"
targetNamespace="http://collectionspace.org/services/organization"
version="0.1">
-
+
<!-- avoid XmlRootElement nightnmare, see http://weblogs.java.net/blog/kohsuke/archive/2006/03/why_does_jaxb_p.html-->
-
+
<!-- See http://wiki.collectionspace.org/display/collectionspace/Name+Authority+Schema -->
<!-- See http://wiki.collectionspace.org/display/collectionspace/Organization+Service+Home -->
-
+
<!-- Organization -->
<xs:element name="organizations_common">
<xs:complexType>
<xs:sequence>
<!-- Common identifier -->
- <xs:element name="csid" type="xs:string" />
+ <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="displayNameComputed" type="xs:boolean"/>
<xs:element name="shortDisplayName" type="xs:string"/>
<xs:element name="shortDisplayNameComputed" type="xs:boolean"/>
- <xs:element name="shortName" type="xs:string"/>
- <xs:element name="longName" type="xs:string"/>
- <xs:element name="nameAdditions" type="xs:string"/>
+ <xs:element name="mainBodyGroupList" type="mainBodyGroupList"/>
<xs:element name="contactNames" type="contactNameList"/>
<xs:element name="foundingDate" type="xs:string"/>
<xs:element name="dissolutionDate" type="xs:string"/>
</xs:complexType>
</xs:element>
+ <xs:complexType name="mainBodyGroupList">
+ <xs:sequence>
+ <xs:element name="mainBodyGroup" type="mainBodyGroup" minOccurs="0" maxOccurs="unbounded"/>
+ </xs:sequence>
+ </xs:complexType>
+
+ <xs:complexType name="mainBodyGroup">
+ <xs:sequence>
+ <xs:element name="longName" type="xs:string"/>
+ <xs:element name="shortName" type="xs:string"/>
+ <xs:element name="nameAdditions" type="xs:string"/>
+ </xs:sequence>
+ </xs:complexType>
+
<xs:complexType name="contactNameList">
<xs:sequence>
<xs:element name="contactName" type="xs:string" minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
- <xs:complexType name="functionList">
+ <xs:complexType name="functionList">
<xs:sequence>
<xs:element name="function" type="xs:string" minOccurs="0" maxOccurs="unbounded"/>
</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">
<xs:annotation>
</xs:appinfo>
</xs:annotation>
</xs:complexType>
-
+
<!-- Organization instances, as in nuxeo repository -->
<xs:element name="organizations-common-list">
<xs:complexType>
<xs:complexContent>
- <xs:extension base="abstractCommonListItem">
+ <xs:extension base="abstractCommonListItem">
<xs:sequence>
<xs:element name="organization_list_item" maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<xs:element name="displayName" type="xs:string"
- minOccurs="1" />
- <xs:element name="shortIdentifier" type="xs:string"
- minOccurs="1" />
+ minOccurs="1" />
+ <xs:element name="shortIdentifier" type="xs:string"
+ minOccurs="1" />
<!-- uri to retrieve organization details -->
<xs:element name="uri" type="xs:anyURI"
- minOccurs="1" />
+ minOccurs="1" />
<xs:element name="refName" type="xs:string"
- minOccurs="1" />
+ minOccurs="1" />
<xs:element name="csid" type="xs:string"
- minOccurs="1" />
+ minOccurs="1" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:extension>
- </xs:complexContent>
+ </xs:complexContent>
</xs:complexType>
</xs:element>
-
+
</xs:schema>
Part : Common
Used for: JAXB binding between XML and Java objects
- $LastChangedRevision: 1055 $
- $LastChangedDate: 2009-12-09 12:25:15 -0800 (Wed, 09 Dec 2009) $
+ $LastChangedRevision$
+ $LastChangedDate$
-->
<xs:schema
/**
* OrgAuthorityDocumentModelHandler
*
- * $LastChangedRevision: $
- * $LastChangedDate: $
+ * $LastChangedRevision$
+ * $LastChangedDate$
*/
public class OrgAuthorityDocumentModelHandler
extends AuthorityDocumentModelHandler<OrgauthoritiesCommon, OrgauthoritiesCommonList> {
/**
* OrganizationDocumentModelHandler
*
- * $LastChangedRevision: $
- * $LastChangedDate: $
+ * $LastChangedRevision$
+ * $LastChangedDate$
*/
public class OrganizationDocumentModelHandler
extends AuthorityItemDocumentModelHandler<OrganizationsCommon, OrganizationsCommonList> {
if(shortDisplayNameComputed==null)
shortDisplayNameComputed = true;
if (displayNameComputed || shortDisplayNameComputed) {
- String shortName = (String) docModel.getProperty(commonPartLabel,
- OrganizationJAXBSchema.SHORT_NAME);
+ List<Object> mainBodyGroupList = (List<Object>) docModel.getProperty(commonPartLabel,
+ OrganizationJAXBSchema.MAIN_BODY_GROUP_LIST);
+ // FIXME: Determine how to handle cases where primary short name is null or empty.
+ String shortName = primaryValueFromMultivalue(mainBodyGroupList,
+ OrganizationJAXBSchema.SHORT_NAME);
if(shortDisplayNameComputed) {
String displayName = prepareDefaultDisplayName(shortName, null);
docModel.setProperty(commonPartLabel, OrganizationJAXBSchema.SHORT_DISPLAY_NAME,
public String getQProperty(String prop) {
return OrganizationConstants.NUXEO_SCHEMA_NAME + ":" + prop;
}
+
+ /**
+ * Returns the primary value from a list of values.
+ *
+ * Assumes that the first value is the primary value.
+ * This assumption may change when and if the primary value
+ * is identified explicitly.
+ *
+ * @param values a list of values.
+ * @param propertyName the name of a property through
+ * which the value can be extracted.
+ * @return the primary value.
+ */
+ private String primaryValueFromMultivalue(List<Object> values, String propertyName) {
+ String primaryValue = "";
+ if (values == null || values.size() == 0) {
+ return primaryValue;
+ }
+ Object value = values.get(0);
+ if (value instanceof String) {
+ if (value != null) {
+ primaryValue = (String) value;
+ }
+ // Multivalue group of fields
+ } else if (value instanceof Map) {
+ if (value != null) {
+ Map map = (Map) value;
+ if (map.values().size() > 0) {
+ if (map.get(propertyName) != null) {
+ primaryValue = (String) map.get(propertyName);
+ }
+ }
+ }
+ }
+ return primaryValue;
+ }
}