]> git.aero2k.de Git - tmp/jakarta-migration.git/commitdiff
CSPACE-2932: Implement the Main Body group of three fields as a repeatable group...
authorAron Roberts <aron@socrates.berkeley.edu>
Mon, 8 Nov 2010 21:38:20 +0000 (21:38 +0000)
committerAron Roberts <aron@socrates.berkeley.edu>
Mon, 8 Nov 2010 21:38:20 +0000 (21:38 +0000)
12 files changed:
services/organization/3rdparty/nuxeo-platform-cs-organization/src/main/resources/schemas/organizations_common.xsd
services/organization/3rdparty/nuxeo-platform-cs-organization/src/main/resources/schemas/orgauthorities_common.xsd
services/organization/client/src/main/java/org/collectionspace/services/client/OrgAuthorityClient.java
services/organization/client/src/main/java/org/collectionspace/services/client/OrgAuthorityClientUtils.java
services/organization/client/src/main/java/org/collectionspace/services/client/OrgAuthorityProxy.java
services/organization/client/src/test/java/org/collectionspace/services/client/test/OrgAuthorityAuthRefsTest.java
services/organization/client/src/test/java/org/collectionspace/services/client/test/OrgAuthorityServiceTest.java
services/organization/jaxb/src/main/java/org/collectionspace/services/OrganizationJAXBSchema.java
services/organization/jaxb/src/main/resources/organization_common.xsd
services/organization/jaxb/src/main/resources/orgauthority_common.xsd
services/organization/service/src/main/java/org/collectionspace/services/organization/nuxeo/OrgAuthorityDocumentModelHandler.java
services/organization/service/src/main/java/org/collectionspace/services/organization/nuxeo/OrganizationDocumentModelHandler.java

index 1fe19f124dbfd2f7c3ca8656b7b53f9b70286605..05d3d2f03245ae61cd075a6f86333c54256d0fe8 100644 (file)
@@ -2,23 +2,23 @@
 
 <!--
     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>
 
index 02b47f2a4eeb8bd976d47bdc07d66a1d8218ed97..d8e3cbda9fbc1974e739dd9c80f002d8e1829d8c 100644 (file)
@@ -7,8 +7,8 @@
     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 
index 696e7f4b2f0bc27ac8c91d238e21a11387604dea..d7ac2b52525f495151cfe3c4d7823cf1d2b366ac 100644 (file)
@@ -6,8 +6,8 @@
  * {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
index 0ff02e4ac3f435430ab14191db2355e45abfd429..7c709609ae10e772a839f067d30450636665da4a 100644 (file)
@@ -6,8 +6,8 @@
  * {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
@@ -42,6 +42,7 @@ import org.collectionspace.services.organization.ContactNameList;
 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
@@ -170,7 +171,7 @@ public class OrgAuthorityClientUtils {
      */\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
@@ -183,7 +184,7 @@ public class OrgAuthorityClientUtils {
        }\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
@@ -220,8 +221,9 @@ public class OrgAuthorityClientUtils {
                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
@@ -237,7 +239,7 @@ public class OrgAuthorityClientUtils {
      */\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
@@ -261,12 +263,10 @@ public class OrgAuthorityClientUtils {
        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
index 3b2f939b277d119226a353d7d28b09cc698fcd8e..d7d30b0954395224f63d2811f1e2146d27b5ef1f 100644 (file)
@@ -23,7 +23,7 @@ import org.jboss.resteasy.plugins.providers.multipart.MultipartInput;
 import org.jboss.resteasy.plugins.providers.multipart.MultipartOutput;
 
 /**
- * @version $Revision:$
+ * @version $Revision$
  */
 @Path("/orgauthorities/")
 @Produces({"multipart/mixed"})
index 435ca0b593b07fb7fe8131b738424df627042e73..9aae6506f1fe6fe8d9a814b1e68f34f054504f19 100644 (file)
@@ -38,6 +38,8 @@ import org.collectionspace.services.client.PersonAuthorityClient;
 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;
@@ -55,8 +57,8 @@ import org.slf4j.LoggerFactory;
  * 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 {
 
@@ -192,9 +194,6 @@ 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>>();
@@ -206,11 +205,18 @@ public class OrgAuthorityAuthRefsTest extends BaseServiceTest {
         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.
index 0aa1b2ad7f5579dda3842cf4a29882803ece2341..b4eabd96c1b8020bf2c57f264ec846a9c97f224c 100644 (file)
@@ -38,6 +38,8 @@ import org.collectionspace.services.contact.ContactsCommonList;
 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;
@@ -57,8 +59,8 @@ import org.testng.annotations.Test;
  * 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 {
 
@@ -238,9 +240,16 @@ 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.
@@ -732,10 +741,18 @@ public class OrgAuthorityServiceTest extends AbstractServiceTestImpl {
         // 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();
@@ -765,8 +782,12 @@ public class OrgAuthorityServiceTest extends AbstractServiceTestImpl {
         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.");
@@ -1371,7 +1392,14 @@ public class OrgAuthorityServiceTest extends AbstractServiceTestImpl {
        
                // 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,
@@ -1402,9 +1430,11 @@ public class OrgAuthorityServiceTest extends AbstractServiceTestImpl {
                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();
            }
index 2191ee0126db4239957784cc78b0be8925a986ce..28e48a7c7b4198403b8584105cd10b538b4f1c3a 100644 (file)
@@ -12,8 +12,9 @@ import org.collectionspace.services.common.vocabulary.AuthorityItemJAXBSchema;
 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
index 20cda416ace9c490a289df20db5706c9e411ca60..ccc8c865cddfdbd2b685f23d43e4034e306ac715 100644 (file)
@@ -7,30 +7,28 @@
     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"/>
@@ -55,7 +67,7 @@
         </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>
@@ -72,7 +84,7 @@
             <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>
 
index 7077ed9cf21e9e54a4b90dc533a36b76f0ed0b04..d727e8f60626f8aeb0669da1a80a1ea3ffdff133 100644 (file)
@@ -7,8 +7,8 @@
     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 
index 5bd2e9e35d79042f43320162e4fc4490ff25ce2e..1867894e0e5ffec39eaf16259b200f4eacb89b65 100644 (file)
@@ -43,8 +43,8 @@ import org.nuxeo.ecm.core.api.DocumentModelList;
 /**
  * OrgAuthorityDocumentModelHandler
  *
- * $LastChangedRevision$
- * $LastChangedDate$
+ * $LastChangedRevision$
+ * $LastChangedDate$
  */
 public class OrgAuthorityDocumentModelHandler
         extends AuthorityDocumentModelHandler<OrgauthoritiesCommon, OrgauthoritiesCommonList> {
index 1989df666908fb049369363985e56c003a8d615a..10d70b1bb981c29161e1cf9c6ba07902970e0694 100644 (file)
@@ -44,8 +44,8 @@ import org.slf4j.LoggerFactory;
 /**
  * OrganizationDocumentModelHandler
  *
- * $LastChangedRevision$
- * $LastChangedDate$
+ * $LastChangedRevision$
+ * $LastChangedDate$
  */
 public class OrganizationDocumentModelHandler
                extends AuthorityItemDocumentModelHandler<OrganizationsCommon, OrganizationsCommonList> {
@@ -98,8 +98,11 @@ public class OrganizationDocumentModelHandler
        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,
@@ -183,5 +186,41 @@ public class OrganizationDocumentModelHandler
     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;
+    }
 }