mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-14 17:58:59 +00:00
Merged 5.2.N (5.2.1) to HEAD (5.2)
129253 adavis: REPO-1069 Review live search sort order / sort type (sites and also people) - Removal of parameter sortType - we are going to be using the POST_QUERY_SORT - Removal of tests using IN_QUERY_SORT except for the one to do with the default sort. git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@129380 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -67,7 +67,6 @@ public interface Queries
|
||||
static String PARAM_SITE_TITLE = "title";
|
||||
static String PARAM_SITE_DESCRIPTION = "description";
|
||||
static int MIN_TERM_LENGTH_SITES = 2;
|
||||
static String PARAM_SORT_TYPE = "sortType"; // TODO review
|
||||
|
||||
/**
|
||||
* Find Nodes
|
||||
|
@@ -324,24 +324,6 @@ public class QueriesImpl implements Queries, InitializingBean
|
||||
@Override
|
||||
public CollectionWithPagingInfo<Site> findSites(Parameters parameters)
|
||||
{
|
||||
// TODO review
|
||||
AbstractQuery.Sort sortType = IN_QUERY_SORT;
|
||||
String sortTypeStr = parameters.getParameter(PARAM_SORT_TYPE);
|
||||
if (sortTypeStr != null) {
|
||||
if (sortTypeStr.equalsIgnoreCase("in-query"))
|
||||
{
|
||||
sortType = IN_QUERY_SORT;
|
||||
}
|
||||
else if (sortTypeStr.equalsIgnoreCase("post-query"))
|
||||
{
|
||||
sortType = POST_QUERY_SORT;
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new IllegalArgumentException("Unexpected sortType: "+sortTypeStr+" (expected in-query or post-query)");
|
||||
}
|
||||
}
|
||||
|
||||
return new AbstractQuery<Site>(nodeService, searchService)
|
||||
{
|
||||
@Override
|
||||
@@ -380,7 +362,7 @@ public class QueriesImpl implements Queries, InitializingBean
|
||||
}
|
||||
return new Site(siteInfo, role);
|
||||
}
|
||||
}.find(parameters, PARAM_TERM, MIN_TERM_LENGTH_SITES, "_SITE", sortType, SITE_SORT_PARAMS_TO_QNAMES, new SortColumn(PARAM_SITE_TITLE, true));
|
||||
}.find(parameters, PARAM_TERM, MIN_TERM_LENGTH_SITES, "_SITE", POST_QUERY_SORT, SITE_SORT_PARAMS_TO_QNAMES, new SortColumn(PARAM_SITE_TITLE, true));
|
||||
}
|
||||
|
||||
public abstract static class AbstractQuery<T>
|
||||
|
@@ -241,89 +241,27 @@ public class QueriesSitesApiTest extends AbstractSingleNetworkSiteTest
|
||||
|
||||
// test sort order
|
||||
{
|
||||
// default sort order - title asc (note: in-query - using search index, tokenized cm:title)
|
||||
// default sort order - title asc
|
||||
Map<String, String> params = new HashMap<>(1);
|
||||
params.put(Queries.PARAM_TERM, "siAB");
|
||||
HttpResponse response = getAll(URL_QUERIES_LSS, paging, params, 200);
|
||||
List<Site> sites = RestApiUtil.parseRestApiEntries(response.getJsonResponse(), Site.class);
|
||||
assertEquals(sCount, sites.size());
|
||||
assertEquals(Arrays.asList(new String[]{s2, s3, s5, s1, s4}), getSiteIds(sites));
|
||||
|
||||
// sort order - id asc
|
||||
params = new HashMap<>(1);
|
||||
params.put(Queries.PARAM_TERM, "siAB");
|
||||
params.put(Queries.PARAM_ORDERBY, "id asc");
|
||||
params.put("sortType", "in-query");
|
||||
response = getAll(URL_QUERIES_LSS, paging, params, 200);
|
||||
sites = RestApiUtil.parseRestApiEntries(response.getJsonResponse(), Site.class);
|
||||
assertEquals(sCount, sites.size());
|
||||
assertEquals(Arrays.asList(new String[]{s4, s5, s2, s3, s1}), getSiteIds(sites));
|
||||
|
||||
// sort order - id desc
|
||||
params = new HashMap<>(1);
|
||||
params.put(Queries.PARAM_TERM, "siAB");
|
||||
params.put(Queries.PARAM_ORDERBY, "id desc");
|
||||
params.put("sortType", "in-query");
|
||||
response = getAll(URL_QUERIES_LSS, paging, params, 200);
|
||||
sites = RestApiUtil.parseRestApiEntries(response.getJsonResponse(), Site.class);
|
||||
assertEquals(sCount, sites.size());
|
||||
assertEquals(Arrays.asList(new String[]{s1, s3, s2, s5, s4}), getSiteIds(sites));
|
||||
|
||||
// sort order - title asc
|
||||
params = new HashMap<>(1);
|
||||
params.put(Queries.PARAM_TERM, "siAB");
|
||||
params.put(Queries.PARAM_ORDERBY, "title asc");
|
||||
params.put("sortType", "in-query");
|
||||
response = getAll(URL_QUERIES_LSS, paging, params, 200);
|
||||
sites = RestApiUtil.parseRestApiEntries(response.getJsonResponse(), Site.class);
|
||||
assertEquals(sCount, sites.size());
|
||||
assertEquals(Arrays.asList(new String[]{s2, s3, s5, s1, s4}), getSiteIds(sites));
|
||||
assertEquals(Arrays.asList(new String[]{s4, s5, s2, s3, s1}), getSiteIds(sites));
|
||||
|
||||
// sort order - title desc
|
||||
params = new HashMap<>(1);
|
||||
params.put(Queries.PARAM_TERM, "siAB");
|
||||
params.put(Queries.PARAM_ORDERBY, "title desc");
|
||||
params.put("sortType", "in-query");
|
||||
response = getAll(URL_QUERIES_LSS, paging, params, 200);
|
||||
sites = RestApiUtil.parseRestApiEntries(response.getJsonResponse(), Site.class);
|
||||
assertEquals(sCount, sites.size());
|
||||
assertEquals(Arrays.asList(new String[]{s4, s1, s5, s3, s2}), getSiteIds(sites));
|
||||
|
||||
// sort order - title asc (post query - using Alfresco Collator which does not ignore spaces, unlike default RuleBasedCollator)
|
||||
params = new HashMap<>(1);
|
||||
params.put(Queries.PARAM_TERM, "siAB");
|
||||
params.put(Queries.PARAM_ORDERBY, "title asc");
|
||||
params.put("sortType", "post-query");
|
||||
response = getAll(URL_QUERIES_LSS, paging, params, 200);
|
||||
sites = RestApiUtil.parseRestApiEntries(response.getJsonResponse(), Site.class);
|
||||
assertEquals(sCount, sites.size());
|
||||
assertEquals(Arrays.asList(new String[]{s4, s5, s2, s3, s1}), getSiteIds(sites));
|
||||
|
||||
// sort order - title desc (post query - using Alfresco Collator which does not ignore spaces, unlike default RuleBasedCollator)
|
||||
params = new HashMap<>(1);
|
||||
params.put(Queries.PARAM_TERM, "siAB");
|
||||
params.put(Queries.PARAM_ORDERBY, "title desc");
|
||||
params.put("sortType", "post-query");
|
||||
response = getAll(URL_QUERIES_LSS, paging, params, 200);
|
||||
sites = RestApiUtil.parseRestApiEntries(response.getJsonResponse(), Site.class);
|
||||
assertEquals(sCount, sites.size());
|
||||
assertEquals(Arrays.asList(new String[]{s1, s3, s2, s5, s4}), getSiteIds(sites));
|
||||
|
||||
// sort order - description asc
|
||||
params = new HashMap<>(1);
|
||||
params.put(Queries.PARAM_TERM, "siAB");
|
||||
params.put(Queries.PARAM_ORDERBY, "description asc");
|
||||
params.put("sortType", "in-query");
|
||||
response = getAll(URL_QUERIES_LSS, paging, params, 200);
|
||||
sites = RestApiUtil.parseRestApiEntries(response.getJsonResponse(), Site.class);
|
||||
assertEquals(sCount, sites.size());
|
||||
assertEquals(Arrays.asList(new String[]{s4, s5, s2, s3, s1}), getSiteIds(sites));
|
||||
|
||||
// sort order - description desc
|
||||
params = new HashMap<>(1);
|
||||
params.put(Queries.PARAM_TERM, "siAB");
|
||||
params.put(Queries.PARAM_ORDERBY, "description desc");
|
||||
params.put("sortType", "in-query");
|
||||
response = getAll(URL_QUERIES_LSS, paging, params, 200);
|
||||
sites = RestApiUtil.parseRestApiEntries(response.getJsonResponse(), Site.class);
|
||||
assertEquals(sCount, sites.size());
|
||||
@@ -332,50 +270,19 @@ public class QueriesSitesApiTest extends AbstractSingleNetworkSiteTest
|
||||
|
||||
// basic paging tests
|
||||
{
|
||||
// sort order - title desc (in query - using search index, tokenized cm:title)
|
||||
// sort order - title desc
|
||||
|
||||
Map<String, String> params = new HashMap<>(1);
|
||||
params.put(Queries.PARAM_TERM, "siAB");
|
||||
params.put(Queries.PARAM_ORDERBY, "title desc");
|
||||
params.put("sortType", "in-query");
|
||||
HttpResponse response = getAll(URL_QUERIES_LSS, getPaging(0, 2), params, 200);
|
||||
List<Site> sites = RestApiUtil.parseRestApiEntries(response.getJsonResponse(), Site.class);
|
||||
assertEquals(2, sites.size());
|
||||
assertEquals(Arrays.asList(new String[]{s4, s1}), getSiteIds(sites));
|
||||
|
||||
params = new HashMap<>(1);
|
||||
params.put(Queries.PARAM_TERM, "siAB");
|
||||
params.put(Queries.PARAM_ORDERBY, "title desc");
|
||||
params.put("sortType", "in-query");
|
||||
response = getAll(URL_QUERIES_LSS, getPaging(2, 2), params, 200);
|
||||
sites = RestApiUtil.parseRestApiEntries(response.getJsonResponse(), Site.class);
|
||||
assertEquals(2, sites.size());
|
||||
assertEquals(Arrays.asList(new String[]{s5, s3}), getSiteIds(sites));
|
||||
|
||||
params = new HashMap<>(1);
|
||||
params.put(Queries.PARAM_TERM, "siAB");
|
||||
params.put(Queries.PARAM_ORDERBY, "title desc");
|
||||
params.put("sortType", "in-query");
|
||||
response = getAll(URL_QUERIES_LSS, getPaging(4, 2), params, 200);
|
||||
sites = RestApiUtil.parseRestApiEntries(response.getJsonResponse(), Site.class);
|
||||
assertEquals(1, sites.size());
|
||||
assertEquals(Arrays.asList(new String[]{s2}), getSiteIds(sites));
|
||||
|
||||
// sort order - title desc (post query - using Alfresco Collator which does not ignore spaces, unlike default RuleBasedCollator)
|
||||
|
||||
params = new HashMap<>(1);
|
||||
params.put(Queries.PARAM_TERM, "siAB");
|
||||
params.put(Queries.PARAM_ORDERBY, "title desc");
|
||||
params.put("sortType", "post-query");
|
||||
response = getAll(URL_QUERIES_LSS, getPaging(0, 2), params, 200);
|
||||
sites = RestApiUtil.parseRestApiEntries(response.getJsonResponse(), Site.class);
|
||||
assertEquals(2, sites.size());
|
||||
assertEquals(Arrays.asList(new String[]{s1, s3}), getSiteIds(sites));
|
||||
|
||||
params = new HashMap<>(1);
|
||||
params.put(Queries.PARAM_TERM, "siAB");
|
||||
params.put(Queries.PARAM_ORDERBY, "title desc");
|
||||
params.put("sortType", "post-query");
|
||||
response = getAll(URL_QUERIES_LSS, getPaging(2, 2), params, 200);
|
||||
sites = RestApiUtil.parseRestApiEntries(response.getJsonResponse(), Site.class);
|
||||
assertEquals(2, sites.size());
|
||||
@@ -384,7 +291,6 @@ public class QueriesSitesApiTest extends AbstractSingleNetworkSiteTest
|
||||
params = new HashMap<>(1);
|
||||
params.put(Queries.PARAM_TERM, "siAB");
|
||||
params.put(Queries.PARAM_ORDERBY, "title desc");
|
||||
params.put("sortType", "post-query");
|
||||
response = getAll(URL_QUERIES_LSS, getPaging(4, 2), params, 200);
|
||||
sites = RestApiUtil.parseRestApiEntries(response.getJsonResponse(), Site.class);
|
||||
assertEquals(1, sites.size());
|
||||
|
Reference in New Issue
Block a user