]> git.aero2k.de Git - tmp/jakarta-migration.git/commitdiff
DRYD-239: Make advanced search queries work on GET list request to /vocabularies
authorremillet <remillet@yahoo.com>
Mon, 29 Jan 2018 07:07:26 +0000 (23:07 -0800)
committerremillet <remillet@yahoo.com>
Mon, 29 Jan 2018 07:07:26 +0000 (23:07 -0800)
services/IntegrationTests/src/main/java/org/collectionspace/services/IntegrationTests/xmlreplay/XmlReplay.java
services/IntegrationTests/src/test/resources/test-data/xmlreplay/vocabulary/ShowItems/responses/searchVocabularyAdvancedSearch.res.xml [new file with mode: 0644]
services/IntegrationTests/src/test/resources/test-data/xmlreplay/vocabulary/ShowItems/responses/searchVocabularyItemsAdvancedSearch.res.xml [new file with mode: 0644]
services/IntegrationTests/src/test/resources/test-data/xmlreplay/vocabulary/ShowItems/searchItems-vocab.xml [new file with mode: 0644]
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/vocabulary/service/src/main/java/org/collectionspace/services/vocabulary/VocabularyResource.java

index 1567c6c6adbd981d4a272f90c8fa0fdc5d143fc0..82df0f6595a9820cee35ed9d55c1956b76ae4daa 100644 (file)
@@ -551,7 +551,7 @@ public class XmlReplay {
         evalStruct.jexl = jexl;
 
         for (Node testgroup : testgroupNodes) {
-               String testGroupID = testgroup.valueOf("@autoDeletePOSTS");
+               String testGroupID = testgroup.valueOf("@ID");
             XmlReplayEval.MapContextWKeys jc = new XmlReplayEval.MapContextWKeys();//MapContext();  //Get a new JexlContext for each test group.
             evalStruct.jc = jc;
             autoDeletePOSTS = testgroup.valueOf("@autoDeletePOSTS");
diff --git a/services/IntegrationTests/src/test/resources/test-data/xmlreplay/vocabulary/ShowItems/responses/searchVocabularyAdvancedSearch.res.xml b/services/IntegrationTests/src/test/resources/test-data/xmlreplay/vocabulary/ShowItems/responses/searchVocabularyAdvancedSearch.res.xml
new file mode 100644 (file)
index 0000000..c958558
--- /dev/null
@@ -0,0 +1,16 @@
+<ns2:abstract-common-list xmlns:ns2="http://collectionspace.org/services/jaxb">
+    <pageNum>0</pageNum>
+    <itemsInPage>${itemsInPage}</itemsInPage>
+    <totalItems>${totalItems}</totalItems>
+    <list-item>
+        <csid>${csid}</csid>
+        <uri>/vocabularies/${csid}</uri>
+        <refName>
+            urn:cspace:core.collectionspace.org:vocabularies:name(SearchItemsVocab)'SearchItems Vocabulary'
+        </refName>
+        <workflowState>project</workflowState>
+        <rev>0</rev>
+        <shortIdentifier>SearchItemsVocab</shortIdentifier>
+        <displayName>SearchItems Vocabulary</displayName>
+    </list-item>
+</ns2:abstract-common-list>
\ No newline at end of file
diff --git a/services/IntegrationTests/src/test/resources/test-data/xmlreplay/vocabulary/ShowItems/responses/searchVocabularyItemsAdvancedSearch.res.xml b/services/IntegrationTests/src/test/resources/test-data/xmlreplay/vocabulary/ShowItems/responses/searchVocabularyItemsAdvancedSearch.res.xml
new file mode 100644 (file)
index 0000000..b8253d2
--- /dev/null
@@ -0,0 +1,24 @@
+<ns2:abstract-common-list xmlns:ns2="http://collectionspace.org/services/jaxb">
+    <pageNum>0</pageNum>
+    <itemsInPage>${itemsInPage}</itemsInPage>
+    <totalItems>${totalItems}</totalItems>
+    <list-item>
+        <csid>${createItem2}</csid>
+        <uri>
+            /vocabularies/${csid}/items/${createItem2}
+        </uri>
+        <refName>
+            urn:cspace:core.collectionspace.org:vocabularies:name(ShowItemsVocab):item:name(ShowItemsItem2)'ShowsItems item ShowItemsItem2'
+        </refName>
+        <workflowState>project</workflowState>
+        <rev>0</rev>
+        <sourcePage>The page should match the order:2</sourcePage>
+        <sas>false</sas>
+        <proposed>true</proposed>
+        <description>This is a test vocabulary item</description>
+        <source>Some mythical book</source>
+        <order>2</order>
+        <displayName>ShowsItems item ShowItemsItem2</displayName>
+        <shortIdentifier>ShowItemsItem2</shortIdentifier>
+    </list-item>
+</ns2:abstract-common-list>
\ No newline at end of file
diff --git a/services/IntegrationTests/src/test/resources/test-data/xmlreplay/vocabulary/ShowItems/searchItems-vocab.xml b/services/IntegrationTests/src/test/resources/test-data/xmlreplay/vocabulary/ShowItems/searchItems-vocab.xml
new file mode 100644 (file)
index 0000000..349900e
--- /dev/null
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<document name="vocabularies">
+  <ns3:vocabularies_common xmlns:ns3="http://collectionspace.org/services/vocabulary"
+  xmlns:ns2="http://collectionspace.org/services/jaxb">
+    <displayName>SearchItems Vocabulary</displayName>
+    <shortIdentifier>SearchItemsVocab</shortIdentifier>
+    <description>This is a test vocabulary for the ShowItems XMLReplay test group.</description>
+    <source>XML Replay SearchItems test group.</source>
+ </ns3:vocabularies_common>
+</document>
+
index 740711e3572b63870a96756bae29ca5df1a699e8..00b29687ad38a2a57674de89cac86b8eb92a58d3 100644 (file)
             <uri>/cspace-services/vocabularies/</uri>
             <filename>vocabulary/ShowItems/showItems-vocab.xml</filename>
         </test>
+        <test ID="searchShowItemsVocab">
+            <method>POST</method>
+            <uri>/cspace-services/vocabularies/</uri>
+            <filename>vocabulary/ShowItems/searchItems-vocab.xml</filename>
+        </test>
         <test ID="createItem1">
             <method>POST</method>
             <uri>/cspace-services/vocabularies/${createShowItemsVocab.CSID}/items/</uri>
                 <filename>vocabulary/ShowItems/responses/showVocabWithLastPage.res.xml</filename>
             </response>
         </test>
+        <test ID="SearchVocabulariesAdvancedSearch">
+            <method>GET</method>
+            <uri>/cspace-services/vocabularies?as=(vocabularies_common:displayName+ILIKE+%22%25SearchItems%25%22)</uri>
+            <response>
+                <vars>
+                    <var ID="itemsInPage">1</var>
+                    <var ID="totalItems">1</var>
+                    <var ID="csid">${searchShowItemsVocab.CSID}</var>
+                </vars>
+                <expected level="ADDOK" />
+                <filename>vocabulary/ShowItems/responses/searchVocabularyAdvancedSearch.res.xml</filename>
+            </response>
+        </test>
+        <test ID="SearchVocabularyItemsAdvancedSearch">
+            <method>GET</method>
+            <uri>/cspace-services/vocabularies/${createShowItemsVocab.CSID}/items?as=(vocabularyitems_common:displayName+ILIKE+%22%ShowItemsItem2%25%22)</uri>
+            <response>
+                <vars>
+                    <var ID="itemsInPage">1</var>
+                    <var ID="totalItems">1</var>
+                    <var ID="csid">${createShowItemsVocab.CSID}</var>
+                    <var ID="createItem2">${createItem2.CSID}</var>
+                </vars>
+                <expected level="ADDOK" />
+                <filename>vocabulary/ShowItems/responses/searchVocabularyItemsAdvancedSearch.res.xml</filename>
+            </response>
+        </test>
     </testGroup>
        
     <!--
index c73266f2dd07e30d728f24b386c063d6a8b57400..6edc0e79fd8f0fac3b1e45f74fadfbf81822ca5b 100644 (file)
@@ -517,13 +517,13 @@ public abstract class AuthorityResource<AuthCommon, AuthItemHandler>
        try {
             MultivaluedMap<String, String> queryParams = uriInfo.getQueryParameters();
             ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx = createServiceContext(uriInfo);
-            
+                        
                        DocumentHandler<?, AbstractCommonList, DocumentModel, DocumentModelList> handler = createDocumentHandler(ctx);
             DocumentFilter myFilter = handler.getDocumentFilter();
             // Need to make the default sort order for authority items
             // be on the displayName field
-            String sortBy = queryParams.getFirst(IClientQueryParams.ORDER_BY_PARAM);
-            if (sortBy == null || sortBy.isEmpty()) {
+            String orderBy = queryParams.getFirst(IClientQueryParams.ORDER_BY_PARAM);
+            if (orderBy == null || orderBy.isEmpty()) {
                 String qualifiedDisplayNameField = authorityCommonSchemaName + ":"
                         + AuthorityItemJAXBSchema.DISPLAY_NAME;
                 myFilter.setOrderByClause(qualifiedDisplayNameField);
@@ -532,7 +532,9 @@ public abstract class AuthorityResource<AuthCommon, AuthItemHandler>
             if (nameQ != null) {
                 myFilter.setWhereClause(authorityCommonSchemaName + ":refName='" + nameQ + "'");
             }
-            getRepositoryClient(ctx).getFiltered(ctx, handler);
+            //getRepositoryClient(ctx).getFiltered(ctx, handler); # Something here?
+            String advancedSearch = queryParams.getFirst(IQueryManager.SEARCH_TYPE_KEYWORDS_AS);            
+            result = search(ctx, handler, uriInfo, orderBy, null, advancedSearch, null);
             result = handler.getCommonPartList();
         } catch (Exception e) {
             throw bigReThrow(e, ServiceMessages.GET_FAILED);
index 365ca826175cfce0c05426b9c2df354df20f16a9..1db1bb09c4b6207afa9da415d85f4daced0c3451 100644 (file)
@@ -41,6 +41,7 @@ import org.collectionspace.services.common.document.DocumentException;
 import org.collectionspace.services.common.document.DocumentHandler;
 import org.collectionspace.services.common.document.DocumentNotFoundException;
 import org.collectionspace.services.common.repository.RepositoryClient;
+import org.collectionspace.services.common.vocabulary.AuthorityItemJAXBSchema;
 import org.collectionspace.services.common.vocabulary.AuthorityResource;
 import org.collectionspace.services.common.vocabulary.AuthorityServiceUtils;
 import org.collectionspace.services.common.vocabulary.RefNameServiceUtils;
@@ -620,7 +621,7 @@ public class VocabularyResource extends
        protected String getOrderByField(ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx) {
                String result = null;
 
-               result = authorityItemCommonSchemaName + ":" + VocabularyItemJAXBSchema.DISPLAY_NAME;
+               result = ctx.getCommonPartLabel() + ":" + AuthorityItemJAXBSchema.DISPLAY_NAME;
 
                return result;
        }