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>
|
<dir.root>${project.build.directory}/alf_data</dir.root>
|
||||||
<img.exe>convert</img.exe>
|
<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-core.version>7.5.1</dependency.alfresco-core.version>
|
||||||
<dependency.alfresco-data-model.version>8.25.1</dependency.alfresco-data-model.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>
|
<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);
|
Locale locale = new Locale(action);
|
||||||
sparams.addLocale(locale);
|
sparams.addLocale(locale);
|
||||||
});
|
});
|
||||||
|
searchQuery.getFilterQueries().forEach(sparams::addFilterQuery);
|
||||||
|
|
||||||
sparams.setIncludeMetadata(searchQuery.isIncludeMetadata());
|
sparams.setIncludeMetadata(searchQuery.isIncludeMetadata());
|
||||||
return sparams;
|
return sparams;
|
||||||
|
@@ -43,13 +43,15 @@ public class SearchSQLQuery
|
|||||||
private List<String> locales;
|
private List<String> locales;
|
||||||
private boolean includeMetadata;
|
private boolean includeMetadata;
|
||||||
private String timezone;
|
private String timezone;
|
||||||
|
private List<String> filterQueries;
|
||||||
|
|
||||||
public SearchSQLQuery(@JsonProperty("stmt") String stmt,
|
public SearchSQLQuery(@JsonProperty("stmt") String stmt,
|
||||||
@JsonProperty("format") String format,
|
@JsonProperty("format") String format,
|
||||||
@JsonProperty("locales") List<String> locales,
|
@JsonProperty("locales") List<String> locales,
|
||||||
@JsonProperty("limit") Integer itemLimit,
|
@JsonProperty("limit") Integer itemLimit,
|
||||||
@JsonProperty("includeMetadata") boolean includeMetadata,
|
@JsonProperty("includeMetadata") boolean includeMetadata,
|
||||||
@JsonProperty("timezone") String timezone)
|
@JsonProperty("timezone") String timezone,
|
||||||
|
@JsonProperty("filterQueries") List<String> filterQueries)
|
||||||
{
|
{
|
||||||
this.stmt = stmt;
|
this.stmt = stmt;
|
||||||
this.format = format != null ? format : "default";
|
this.format = format != null ? format : "default";
|
||||||
@@ -57,6 +59,7 @@ public class SearchSQLQuery
|
|||||||
this.itemLimit = itemLimit == null || itemLimit < 1 ? new Integer(1000) : itemLimit;
|
this.itemLimit = itemLimit == null || itemLimit < 1 ? new Integer(1000) : itemLimit;
|
||||||
this.includeMetadata = includeMetadata;
|
this.includeMetadata = includeMetadata;
|
||||||
this.timezone = timezone;
|
this.timezone = timezone;
|
||||||
|
this.filterQueries = filterQueries != null ? filterQueries : Collections.emptyList();
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getStmt()
|
public String getStmt()
|
||||||
@@ -88,4 +91,9 @@ public class SearchSQLQuery
|
|||||||
{
|
{
|
||||||
return timezone;
|
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}]}");
|
JSONObject response = new JSONObject("{\"docs\":[{\"SITE\":\"_REPOSITORY_\"},{\"SITE\":\"surf-config\"},{\"SITE\":\"swsdp\"},{\"EOF\":true,\"RESPONSE_TIME\":96}]}");
|
||||||
JSONArray docs = response.getJSONArray("docs");
|
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);
|
CollectionWithPagingInfo<TupleList> info = mapper.toCollectionWithPagingInfo(docs, query);
|
||||||
assertEquals(100, info.getPaging().getMaxItems());
|
assertEquals(100, info.getPaging().getMaxItems());
|
||||||
assertEquals(0, info.getPaging().getSkipCount());
|
assertEquals(0, info.getPaging().getSkipCount());
|
||||||
|
@@ -25,6 +25,8 @@
|
|||||||
*/
|
*/
|
||||||
package org.alfresco.rest.api.search;
|
package org.alfresco.rest.api.search;
|
||||||
|
|
||||||
|
import static java.util.Collections.emptyList;
|
||||||
|
|
||||||
import static junit.framework.TestCase.assertEquals;
|
import static junit.framework.TestCase.assertEquals;
|
||||||
import static junit.framework.TestCase.assertNotNull;
|
import static junit.framework.TestCase.assertNotNull;
|
||||||
|
|
||||||
@@ -47,7 +49,7 @@ public class SearchSQLApiWebscriptTests
|
|||||||
public void testSearchQueryParams() throws Exception
|
public void testSearchQueryParams() throws Exception
|
||||||
{
|
{
|
||||||
String query = "select SITE from alfresco";
|
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);
|
SearchParameters sparams = webscript.buildSearchParameters(searchQuery);
|
||||||
|
|
||||||
assertNotNull(sparams);
|
assertNotNull(sparams);
|
||||||
@@ -61,7 +63,7 @@ public class SearchSQLApiWebscriptTests
|
|||||||
public void testSearchQueryParamsTimezone() throws Exception
|
public void testSearchQueryParamsTimezone() throws Exception
|
||||||
{
|
{
|
||||||
String query = "select SITE from alfresco";
|
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);
|
SearchParameters sparams = webscript.buildSearchParameters(searchQuery);
|
||||||
|
|
||||||
assertNotNull(sparams);
|
assertNotNull(sparams);
|
||||||
@@ -75,7 +77,7 @@ public class SearchSQLApiWebscriptTests
|
|||||||
public void testSearchQueryParamsFormatNull() throws Exception
|
public void testSearchQueryParamsFormatNull() throws Exception
|
||||||
{
|
{
|
||||||
String query = "select SITE from alfresco";
|
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);
|
SearchParameters sparams = webscript.buildSearchParameters(searchQuery);
|
||||||
|
|
||||||
assertNotNull(sparams);
|
assertNotNull(sparams);
|
||||||
@@ -85,7 +87,7 @@ public class SearchSQLApiWebscriptTests
|
|||||||
assertEquals(null, sparams.getExtraParameters().get("format"));
|
assertEquals(null, sparams.getExtraParameters().get("format"));
|
||||||
assertEquals(null, sparams.getTimezone());
|
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);
|
sparams = webscript.buildSearchParameters(searchQuery);
|
||||||
|
|
||||||
assertNotNull(sparams);
|
assertNotNull(sparams);
|
||||||
@@ -98,7 +100,7 @@ public class SearchSQLApiWebscriptTests
|
|||||||
@Test
|
@Test
|
||||||
public void testSearchQueryNullStmt() throws Exception
|
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
|
try
|
||||||
{
|
{
|
||||||
webscript.buildSearchParameters(searchQuery);
|
webscript.buildSearchParameters(searchQuery);
|
||||||
|
Reference in New Issue
Block a user