Merged searchapi (5.2.1) to 5.2.N (5.2.1)

130151 gjames: SEARCH-124: Implementing "limits" search api param


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/DEV/5.2.N/root@130307 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Gethin James
2016-09-06 15:39:44 +00:00
parent 9bd1b92cf7
commit 4368afe040
6 changed files with 130 additions and 4 deletions

View File

@@ -32,6 +32,7 @@ import org.alfresco.rest.api.search.model.FacetField;
import org.alfresco.rest.api.search.model.FacetFields;
import org.alfresco.rest.api.search.model.FacetQuery;
import org.alfresco.rest.api.search.model.FilterQuery;
import org.alfresco.rest.api.search.model.Limits;
import org.alfresco.rest.api.search.model.Query;
import org.alfresco.rest.api.search.model.Scope;
import org.alfresco.rest.api.search.model.SearchQuery;
@@ -112,6 +113,7 @@ public class SearchMapper
fromFacetFields(sp, searchQuery.getFacetFields());
fromSpellCheck(sp, searchQuery.getSpellcheck());
fromScope(sp, searchQuery.getScope());
fromLimits(sp, searchQuery.getLimits());
return sp;
}
@@ -429,4 +431,29 @@ public class SearchMapper
}
}
}
/**
* SearchParameters from the Limits object
* @param sp SearchParameters
* @param paging Paging
*/
public void fromLimits(SearchParameters sp, Limits limits)
{
if (limits != null)
{
if (limits.getPermissionEvaluationCount() != null)
{
sp.setMaxItems(-1);
sp.setLimitBy(LimitBy.NUMBER_OF_PERMISSION_EVALUATIONS);
sp.setMaxPermissionChecks(limits.getPermissionEvaluationCount());
}
if (limits.getPermissionEvaluationTime() != null)
{
sp.setMaxItems(-1);
sp.setLimitBy(LimitBy.NUMBER_OF_PERMISSION_EVALUATIONS);
sp.setMaxPermissionCheckTimeMillis(limits.getPermissionEvaluationTime());
}
}
}
}

View File

@@ -0,0 +1,58 @@
/*-
* #%L
* Alfresco Remote API
* %%
* Copyright (C) 2005 - 2016 Alfresco Software Limited
* %%
* This file is part of the Alfresco software.
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
*
* Alfresco is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alfresco is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
* #L%
*/
package org.alfresco.rest.api.search.model;
import org.codehaus.jackson.annotate.JsonCreator;
import org.codehaus.jackson.annotate.JsonProperty;
/**
* POJO class representing the query Limits
**/
public class Limits
{
private final Integer permissionEvaluationTime;
private final Integer permissionEvaluationCount;
@JsonCreator
public Limits(@JsonProperty("permissionEvaluationTime") Integer permissionEvaluationTime,
@JsonProperty("permissionEvaluationCount") Integer permissionEvaluationCount)
{
this.permissionEvaluationTime = permissionEvaluationTime;
this.permissionEvaluationCount = permissionEvaluationCount;
}
public Integer getPermissionEvaluationTime()
{
return permissionEvaluationTime;
}
public Integer getPermissionEvaluationCount()
{
return permissionEvaluationCount;
}
}

View File

@@ -51,8 +51,9 @@ public class SearchQuery
private final FacetFields facetFields;
private final Spelling spellcheck;
private final Scope scope;
private final Limits limits;
public static final SearchQuery EMPTY = new SearchQuery(null, null, null, null, null,null, null, null, null, null, null);
public static final SearchQuery EMPTY = new SearchQuery(null, null, null, null, null,null, null, null,null, null, null, null);
@JsonCreator
public SearchQuery(@JsonProperty("query") Query query,
@@ -65,7 +66,8 @@ public class SearchQuery
@JsonProperty("facetFields") FacetFields facetFields,
@JsonProperty("facetQueries") List<FacetQuery> facetQueries,
@JsonProperty("spellcheck") Spelling spellcheck,
@JsonProperty("scope") Scope scope)
@JsonProperty("scope") Scope scope,
@JsonProperty("limits")Limits limits)
{
this.query = query;
this.paging = paging;
@@ -78,6 +80,7 @@ public class SearchQuery
this.spellcheck = spellcheck;
this.scope = scope;
this.facetFields = facetFields;
this.limits = limits;
}
public Query getQuery()
@@ -132,4 +135,9 @@ public class SearchQuery
{
return facetFields;
}
public Limits getLimits()
{
return limits;
}
}