]> git.aero2k.de Git - tmp/jakarta-migration.git/commitdiff
CSPACE-4406 - added support for refObjs for vocabulary service items, so that termLis...
authorPatrick Schmitz <pschmitz@berkeley.edu>
Wed, 26 Oct 2011 00:09:00 +0000 (00:09 +0000)
committerPatrick Schmitz <pschmitz@berkeley.edu>
Wed, 26 Oct 2011 00:09:00 +0000 (00:09 +0000)
services/IntegrationTests/src/test/resources/test-data/xmlreplay/vocabulary/vocabulary.xml
services/authority/service/src/main/java/org/collectionspace/services/common/vocabulary/AuthorityResource.java
services/authority/service/src/main/java/org/collectionspace/services/common/vocabulary/RefNameServiceUtils.java
services/common/src/main/cspace/config/services/tenants/tenant-bindings-proto.xml
services/common/src/main/java/org/collectionspace/services/common/context/ServiceBindingUtils.java
services/vocabulary/service/src/main/java/org/collectionspace/services/vocabulary/VocabularyResource.java

index a4839170f6851eed54060da7b460c8db1c412d9e..64aa09f3e331db1a34b0c1a76dfac9fd0ae07ed3 100644 (file)
@@ -6,7 +6,7 @@
                <auth ID="testAdministator">YWRtaW5AY29sbGVjdGlvbnNwYWNlLm9yZzpBZG1pbmlzdHJhdG9y</auth>
        </auths>
        <testGroup ID="TestOrder" autoDeletePOSTS="true">
-        <!-- The purpose of this testGroup is to test the new "order" field
+               <!-- The purpose of this testGroup is to test the new "order" field
              that was added in http://issues.collectionspace.org/browse/CSPACE-573
              and to ensure that this order field is returned in list results, 
              and that duplicate values for the order field is accepted.
                                <var ID="displayName">TestOrder item ${itemID} order ${order}</var>
                        </vars>
                </test>
-               
+
                <test ID="GetVocabularies" auth="admin@core.collectionspace.org">
-            <method>GET</method>
-            <uri>/cspace-services/vocabularies/</uri>
-        </test>
-        
-        <test ID="GetVocabularyItems" auth="admin@core.collectionspace.org">
-            <method>GET</method>
-            <uri>/cspace-services/vocabularies/${Vocabulary1.CSID}/items/</uri>
-            <response>
-                <expected level="ADDOK" />
-                <filename>vocabulary/res/GetVocabularyItems.res.xml</filename>
-                <vars>
+                       <method>GET</method>
+                       <uri>/cspace-services/vocabularies/</uri>
+               </test>
+
+               <test ID="GetVocabularyItems" auth="admin@core.collectionspace.org">
+                       <method>GET</method>
+                       <uri>/cspace-services/vocabularies/${Vocabulary1.CSID}/items/</uri>
+                       <response>
+                               <expected level="ADDOK"/>
+                               <filename>vocabulary/res/GetVocabularyItems.res.xml</filename>
+                               <vars>
                                        <var ID="I3displayName">${Item3DupeOrder.displayName}</var>
                                </vars>
-                <!--<startElement>//vocabulary-list-item[./exitNumber='checkList-1234']</startElement>-->
-             </response>
-        </test>
-               
+                               <!--<startElement>//vocabulary-list-item[./exitNumber='checkList-1234']</startElement>-->
+                       </response>
+               </test>
+
+               <test ID="GetVocabularyItem" auth="admin@core.collectionspace.org">
+                       <method>GET</method>
+                       <uri>/cspace-services/vocabularies/${Vocabulary1.CSID}/items/${Item1.CSID}</uri>
+               </test>
+
+               <test ID="GetVocabularyItemRefObjs" auth="admin@core.collectionspace.org">
+                       <method>GET</method>
+                       <uri>/cspace-services/vocabularies/${Vocabulary1.CSID}/items/${Item1.CSID}/refObjs</uri>
+               </test>
+
        </testGroup>
 </xmlReplay>
-
index 96d887e650ab977f44cfe0a8612b01a688aa64c8..2764731c50e9fc522305f16ef0ee171079bc0dbd 100644 (file)
@@ -87,6 +87,18 @@ import java.util.List;
 /**
  * The Class AuthorityResource.
  */
+/**
+ * @author pschmitz
+ *
+ * @param <AuthCommon>
+ * @param <AuthItemHandler>
+ */
+/**
+ * @author pschmitz
+ *
+ * @param <AuthCommon>
+ * @param <AuthItemHandler>
+ */
 @Consumes("application/xml")
 @Produces("application/xml")
 public abstract class AuthorityResource<AuthCommon, AuthItemHandler>
@@ -677,6 +689,15 @@ public abstract class AuthorityResource<AuthCommon, AuthItemHandler>
         }
     }
 
+    /**
+     * @return the name of the property used to specify references for items in this type of
+     * authority. For most authorities, it is ServiceBindingUtils.AUTH_REF_PROP ("authRef").
+     * Some types (like Vocabulary) use a separate property.
+     */
+    protected String getRefPropName() {
+       return ServiceBindingUtils.AUTH_REF_PROP;
+    }
+    
     /**
      * Gets the entities referencing this Authority item instance. The service type
      * can be passed as a query param "type", and must match a configured type
@@ -723,6 +744,7 @@ public abstract class AuthorityResource<AuthCommon, AuthItemHandler>
                     repoClient,
                     serviceType,
                     refName,
+                    getRefPropName(),
                     myFilter.getPageSize(), myFilter.getStartPage(), true /*computeTotal*/);
         } catch (Exception e) {
             throw bigReThrow(e, ServiceMessages.GET_FAILED);
index 0731d476bd8ab4b7b690a3b130e37e3e66ba6666..56fb517791ec1f7a6162b293f369514b3f801393 100644 (file)
@@ -65,6 +65,7 @@ public class RefNameServiceUtils {
             RepositoryClient repoClient,\r
             String serviceType,\r
             String refName,\r
+            String refPropName,\r
             int pageSize, int pageNum, boolean computeTotal) throws DocumentException, DocumentNotFoundException {\r
         AuthorityRefDocList wrapperList = new AuthorityRefDocList();\r
         AbstractCommonList commonList = (AbstractCommonList) wrapperList;\r
@@ -89,7 +90,7 @@ public class RefNameServiceUtils {
         Map<String, ServiceBindingType> queriedServiceBindings = new HashMap<String, ServiceBindingType>();\r
         Map<String, Map<String, String>> authRefFieldsByService = new HashMap<String, Map<String, String>>();\r
         \r
-        String query = computeWhereClauseForAuthorityRefDocs(escapedRefName, docTypes, servicebindings, \r
+        String query = computeWhereClauseForAuthorityRefDocs(escapedRefName, refPropName, docTypes, servicebindings, \r
                                                                                                queriedServiceBindings, authRefFieldsByService );\r
         if (query == null) { // found no authRef fields - nothing to query\r
             return wrapperList;\r
@@ -112,6 +113,7 @@ public class RefNameServiceUtils {
     \r
     private static String computeWhereClauseForAuthorityRefDocs(\r
                String escapedRefName,\r
+               String refPropName,\r
                ArrayList<String> docTypes,\r
                List<ServiceBindingType> servicebindings,\r
                Map<String, ServiceBindingType> queriedServiceBindings,\r
@@ -124,7 +126,7 @@ public class RefNameServiceUtils {
                // is also the table name, the way that the repository works).\r
             authRefFieldPaths =\r
                     ServiceBindingUtils.getAllPartsPropertyValues(sb,\r
-                    ServiceBindingUtils.AUTH_REF_PROP, ServiceBindingUtils.QUALIFIED_PROP_NAMES);\r
+                               refPropName, ServiceBindingUtils.QUALIFIED_PROP_NAMES);\r
             if (authRefFieldPaths.isEmpty()) {\r
                 continue;\r
             }\r
index e45cb684592399af099eb70892f51ed7ffa43d99..3f3e15214839807bb98bc718bb51851c24efaed8 100644 (file)
               <types:value>fieldCollectors|fieldCollector</types:value>
             </types:item>
             <!-- CSPACE-4457: Identification of term list / controlled vocabulary fields -->
-            <!--
             <types:item xmlns:types="http://collectionspace.org/services/common/types">
               <types:key>termRef</types:key>
               <types:value>responsibleDepartment|responsibleDepartments</types:value>
               <types:key>termRef</types:key>
               <types:value>recordStatus</types:value>
             </types:item>
-            -->
             <!-- Commented out for now, as searching within a field in a complexType breaks searches -->
             <!--
             <types:item xmlns:types="http://collectionspace.org/services/common/types">
             </types:item>
             -->
             <!-- CSPACE-4457: Identification of term list / controlled vocabulary fields -->
-            <!--
             <types:item xmlns:types="http://collectionspace.org/services/common/types">
               <types:key>termRef</types:key>
               <types:value>entryMethods|entryMethod</types:value>
               <types:key>termRef</types:key>
               <types:value>conditionCheckReasons|conditionCheckReason</types:value>
             </types:item>
-            -->
             <!-- Commented out for now, as searching within a field in a complexType breaks searches -->
             <!--
             <types:item xmlns:types="http://collectionspace.org/services/common/types">
               <types:value>lendersContact</types:value>
             </types:item>
             <!-- CSPACE-4457: Identification of term list / controlled vocabulary fields -->
-            <!--
             <types:item xmlns:types="http://collectionspace.org/services/common/types">
               <types:key>termRef</types:key>
               <types:value>loanPurpose</types:value>
             </types:item>
-            -->
             <!-- The following term reference is within a nested complexType / multivalued group of fields -->
             <!--
             <types:item xmlns:types="http://collectionspace.org/services/common/types">
               <types:value>depositor</types:value>
             </types:item>
             <!-- CSPACE-4457: Identification of term list / controlled vocabulary fields -->
-            <!--
             <types:item xmlns:types="http://collectionspace.org/services/common/types">
               <types:key>termRef</types:key>
               <types:value>exitMethods|exitMethod</types:value>
               <types:key>termRef</types:key>
               <types:value>exitReason</types:value>
             </types:item>
-            -->
           </service:properties>
           <service:content contentType="application/xml">
             <service:xmlContent namespaceURI="http://collectionspace.org/services/objectexit" schemaLocation="http://collectionspace.org/services/objectexit http://services.collectionspace.org/objectexit/objectexit_common.xsd" />
               <types:value>owner</types:value>
             </types:item>
             <!-- CSPACE-4457: Identification of term list / controlled vocabulary fields -->
-            <!--
             <types:item xmlns:types="http://collectionspace.org/services/common/types">
               <types:key>termRef</types:key>
               <types:value>responsibleDepartment</types:value>
             </types:item>
-            -->
           </service:properties>
           <service:content contentType="application/xml">
             <service:xmlContent namespaceURI="http://collectionspace.org/services/group" schemaLocation="http://collectionspace.org/services/group http://services.collectionspace.org/group/groups_common.xsd" />
             </types:item>
             -->
             <!-- CSPACE-4457: Identification of term list / controlled vocabulary fields -->
-            <!--
             <types:item xmlns:types="http://collectionspace.org/services/common/types">
               <types:key>termRef</types:key>
-              <types:value>languages|language</types:value>
+              <types:value>languageList|language</types:value>
             </types:item>
             <types:item xmlns:types="http://collectionspace.org/services/common/types">
               <types:key>termRef</types:key>
               <types:value>typeList|type</types:value>
             </types:item>
-            -->
             <!-- The following term references all fall within a nested complexType / multivalued group of fields -->
             <!--
             <types:item xmlns:types="http://collectionspace.org/services/common/types">
               <types:value>movementContact</types:value>
             </types:item>
             <!-- CSPACE-4457: Identification of term list / controlled vocabulary fields -->
-            <!--
             <types:item xmlns:types="http://collectionspace.org/services/common/types">
               <types:key>termRef</types:key>
               <types:value>currentLocationFitness</types:value>
               <types:key>termRef</types:key>
               <types:value>movementMethods|movementMethod</types:value>
             </types:item>
-            -->
           </service:properties>
           <service:content contentType="application/xml">
             <service:xmlContent namespaceURI="http://collectionspace.org/services/movement" schemaLocation="http://collectionspace.org/services/movement http://services.collectionspace.org/movement/movements_common.xsd" />
             </types:item>
             -->
             <!-- CSPACE-4457: Identification of term list / controlled vocabulary fields -->
-            <!--
             <types:item xmlns:types="http://collectionspace.org/services/common/types">
               <types:key>termRef</types:key>
               <types:value>termStatus</types:value>
             </types:item>
-            -->
             <!-- To be added per CSPACE-3939. -->
             <!--
             <types:item xmlns:types="http://collectionspace.org/services/common/types">
           <service:properties xmlns:service="http://collectionspace.org/services/common/service">
           -->
             <!-- CSPACE-4457: Identification of term list / controlled vocabulary fields -->
-            <!--
             <types:item xmlns:types="http://collectionspace.org/services/common/types">
               <types:key>termRef</types:key>
               <types:value>termStatus</types:value>
               <types:key>termRef</types:key>
               <types:value>locationType</types:value>
             </types:item>
-          -->
           <service:content contentType="application/xml">
             <service:xmlContent namespaceURI="http://collectionspace.org/services/location" schemaLocation="http://collectionspace.org/services/location http://services.collectionspace.org/location/locations_common.xsd" />
           </service:content>
             </types:item>
             -->
             <!-- CSPACE-4457: Identification of term list / controlled vocabulary fields -->
-            <!--
             <types:item xmlns:types="http://collectionspace.org/services/common/types">
               <types:key>termRef</types:key>
               <types:value>termStatus</types:value>
               <types:key>termRef</types:key>
               <types:value>taxonNameSource</types:value>
             </types:item>
-            -->
             <!-- The following term reference falls within a nested complexType / multivalued group of fields -->
             <!--
             <types:item xmlns:types="http://collectionspace.org/services/common/types">
             </types:item>
             -->
             <!-- CSPACE-4457: Identification of term list / controlled vocabulary fields -->
-            <!--
             <types:item xmlns:types="http://collectionspace.org/services/common/types">
               <types:key>termRef</types:key>
               <types:value>acquisitionMethod</types:value>
               <types:key>termRef</types:key>
               <types:value>groupPurchasePriceCurrency</types:value>
             </types:item>
-            -->
             <!-- The following term reference falls within a nested complexType / multivalued group of fields -->
             <!--
             <types:item xmlns:types="http://collectionspace.org/services/common/types">
index 051321370d56e88af9a6b2d96b24bb3e42e07ed8..d4b4f0ea2c8702cfec7992436b9d0f97da32c87e 100644 (file)
@@ -18,6 +18,7 @@ public class ServiceBindingUtils {
        public static final boolean QUALIFIED_PROP_NAMES = true;\r
        public static final boolean UNQUALIFIED_PROP_NAMES = false;\r
        public static final String AUTH_REF_PROP = "authRef";\r
+       public static final String TERM_REF_PROP = "termRef";\r
        public static final String OBJ_NUMBER_PROP = "objectNumberProperty";\r
        public static final String OBJ_NAME_PROP = "objectNameProperty";\r
        public static final String SERVICE_TYPE_PROP = "type";\r
index 91fdbaef31de48f232b8f10552bad79445b41001..81f16cf7006dfd9c0d9b67a918447db1ec78d4a0 100644 (file)
@@ -24,6 +24,7 @@
 package org.collectionspace.services.vocabulary;
 
 import org.collectionspace.services.client.VocabularyClient;
+import org.collectionspace.services.common.context.ServiceBindingUtils;
 import org.collectionspace.services.common.vocabulary.AuthorityResource;
 import org.collectionspace.services.vocabulary.nuxeo.VocabularyItemDocumentModelHandler;
 import org.slf4j.Logger;
@@ -64,4 +65,14 @@ public class VocabularyResource extends
                return VocabulariesCommon.class;
        }
 
+    /**
+     * @return the name of the property used to specify references for items in this type of
+     * authority. For most authorities, it is ServiceBindingUtils.AUTH_REF_PROP ("authRef").
+     * Some types (like Vocabulary) use a separate property.
+     */
+       @Override
+    protected String getRefPropName() {
+       return ServiceBindingUtils.TERM_REF_PROP;
+    }
+    
 }