mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-09-17 14:21:39 +00:00
* SEARCH-1351 Add support for filter queries in SQL requests.
* SEARCH-1351 Update repository version to 7.33.14.
(cherry picked from commit 3aa93f5cf2
)
This commit is contained in:
2
pom.xml
2
pom.xml
@@ -35,7 +35,7 @@
|
||||
<dir.root>${project.build.directory}/alf_data</dir.root>
|
||||
<img.exe>convert</img.exe>
|
||||
|
||||
<dependency.alfresco-repository.version>7.33.12</dependency.alfresco-repository.version>
|
||||
<dependency.alfresco-repository.version>7.33.13</dependency.alfresco-repository.version>
|
||||
<dependency.alfresco-core.version>7.5.1</dependency.alfresco-core.version>
|
||||
<dependency.alfresco-data-model.version>8.25.1</dependency.alfresco-data-model.version>
|
||||
<dependency.alfresco-pdf-renderer.version>1.1</dependency.alfresco-pdf-renderer.version>
|
||||
|
@@ -142,6 +142,7 @@ public class SearchSQLApiWebscript extends AbstractWebScript implements Recogniz
|
||||
Locale locale = new Locale(action);
|
||||
sparams.addLocale(locale);
|
||||
});
|
||||
searchQuery.getFilterQueries().forEach(sparams::addFilterQuery);
|
||||
|
||||
sparams.setIncludeMetadata(searchQuery.isIncludeMetadata());
|
||||
return sparams;
|
||||
|
@@ -43,13 +43,15 @@ public class SearchSQLQuery
|
||||
private List<String> locales;
|
||||
private boolean includeMetadata;
|
||||
private String timezone;
|
||||
private List<String> filterQueries;
|
||||
|
||||
public SearchSQLQuery(@JsonProperty("stmt") String stmt,
|
||||
@JsonProperty("format") String format,
|
||||
@JsonProperty("locales") List<String> locales,
|
||||
@JsonProperty("limit") Integer itemLimit,
|
||||
@JsonProperty("includeMetadata") boolean includeMetadata,
|
||||
@JsonProperty("timezone") String timezone)
|
||||
@JsonProperty("timezone") String timezone,
|
||||
@JsonProperty("filterQueries") List<String> filterQueries)
|
||||
{
|
||||
this.stmt = stmt;
|
||||
this.format = format != null ? format : "default";
|
||||
@@ -57,6 +59,7 @@ public class SearchSQLQuery
|
||||
this.itemLimit = itemLimit == null || itemLimit < 1 ? new Integer(1000) : itemLimit;
|
||||
this.includeMetadata = includeMetadata;
|
||||
this.timezone = timezone;
|
||||
this.filterQueries = filterQueries != null ? filterQueries : Collections.emptyList();
|
||||
}
|
||||
|
||||
public String getStmt()
|
||||
@@ -88,4 +91,9 @@ public class SearchSQLQuery
|
||||
{
|
||||
return timezone;
|
||||
}
|
||||
|
||||
public List<String> getFilterQueries()
|
||||
{
|
||||
return filterQueries;
|
||||
}
|
||||
}
|
||||
|
@@ -853,7 +853,7 @@ public class ResultMapperTests
|
||||
{
|
||||
JSONObject response = new JSONObject("{\"docs\":[{\"SITE\":\"_REPOSITORY_\"},{\"SITE\":\"surf-config\"},{\"SITE\":\"swsdp\"},{\"EOF\":true,\"RESPONSE_TIME\":96}]}");
|
||||
JSONArray docs = response.getJSONArray("docs");
|
||||
SearchSQLQuery query = new SearchSQLQuery("select SITE from alfresco group by SITE", null, null, 100, false, null);
|
||||
SearchSQLQuery query = new SearchSQLQuery("select SITE from alfresco group by SITE", null, null, 100, false, null, null);
|
||||
CollectionWithPagingInfo<TupleList> info = mapper.toCollectionWithPagingInfo(docs, query);
|
||||
assertEquals(100, info.getPaging().getMaxItems());
|
||||
assertEquals(0, info.getPaging().getSkipCount());
|
||||
|
@@ -25,6 +25,8 @@
|
||||
*/
|
||||
package org.alfresco.rest.api.search;
|
||||
|
||||
import static java.util.Collections.emptyList;
|
||||
|
||||
import static junit.framework.TestCase.assertEquals;
|
||||
import static junit.framework.TestCase.assertNotNull;
|
||||
|
||||
@@ -47,7 +49,7 @@ public class SearchSQLApiWebscriptTests
|
||||
public void testSearchQueryParams() throws Exception
|
||||
{
|
||||
String query = "select SITE from alfresco";
|
||||
SearchSQLQuery searchQuery = new SearchSQLQuery(query, "solr", Collections.emptyList(), 1000, false, "");
|
||||
SearchSQLQuery searchQuery = new SearchSQLQuery(query, "solr", emptyList(), 1000, false, "", emptyList());
|
||||
SearchParameters sparams = webscript.buildSearchParameters(searchQuery);
|
||||
|
||||
assertNotNull(sparams);
|
||||
@@ -61,7 +63,7 @@ public class SearchSQLApiWebscriptTests
|
||||
public void testSearchQueryParamsTimezone() throws Exception
|
||||
{
|
||||
String query = "select SITE from alfresco";
|
||||
SearchSQLQuery searchQuery = new SearchSQLQuery(query, "solr", Collections.emptyList(), 1000, false, "Israel");
|
||||
SearchSQLQuery searchQuery = new SearchSQLQuery(query, "solr", emptyList(), 1000, false, "Israel", emptyList());
|
||||
SearchParameters sparams = webscript.buildSearchParameters(searchQuery);
|
||||
|
||||
assertNotNull(sparams);
|
||||
@@ -75,7 +77,7 @@ public class SearchSQLApiWebscriptTests
|
||||
public void testSearchQueryParamsFormatNull() throws Exception
|
||||
{
|
||||
String query = "select SITE from alfresco";
|
||||
SearchSQLQuery searchQuery = new SearchSQLQuery(query, "", Collections.emptyList(), 1000, false, "");
|
||||
SearchSQLQuery searchQuery = new SearchSQLQuery(query, "", emptyList(), 1000, false, "", emptyList());
|
||||
SearchParameters sparams = webscript.buildSearchParameters(searchQuery);
|
||||
|
||||
assertNotNull(sparams);
|
||||
@@ -85,7 +87,7 @@ public class SearchSQLApiWebscriptTests
|
||||
assertEquals(null, sparams.getExtraParameters().get("format"));
|
||||
assertEquals(null, sparams.getTimezone());
|
||||
|
||||
searchQuery = new SearchSQLQuery(query, null, Collections.emptyList(), 1000, true, "");
|
||||
searchQuery = new SearchSQLQuery(query, null, emptyList(), 1000, true, "", emptyList());
|
||||
sparams = webscript.buildSearchParameters(searchQuery);
|
||||
|
||||
assertNotNull(sparams);
|
||||
@@ -98,7 +100,7 @@ public class SearchSQLApiWebscriptTests
|
||||
@Test
|
||||
public void testSearchQueryNullStmt() throws Exception
|
||||
{
|
||||
SearchSQLQuery searchQuery = new SearchSQLQuery(null, "solr", Collections.emptyList(), null, false, null);
|
||||
SearchSQLQuery searchQuery = new SearchSQLQuery(null, "solr", emptyList(), null, false, null, emptyList());
|
||||
try
|
||||
{
|
||||
webscript.buildSearchParameters(searchQuery);
|
||||
|
Reference in New Issue
Block a user