mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-21 18:09:20 +00:00
Merged searchapi (5.2.1) to 5.2.N (5.2.1)
130145 gjames: SEARCH-123: Implementing scope for queries git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/DEV/5.2.N/root@130304 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -26,10 +26,12 @@
|
||||
|
||||
package org.alfresco.rest.api.search.impl;
|
||||
|
||||
import org.alfresco.error.AlfrescoRuntimeException;
|
||||
import org.alfresco.rest.api.search.model.Default;
|
||||
import org.alfresco.rest.api.search.model.FacetQuery;
|
||||
import org.alfresco.rest.api.search.model.FilterQuery;
|
||||
import org.alfresco.rest.api.search.model.Query;
|
||||
import org.alfresco.rest.api.search.model.Scope;
|
||||
import org.alfresco.rest.api.search.model.SearchQuery;
|
||||
import org.alfresco.rest.api.search.model.SortDef;
|
||||
import org.alfresco.rest.api.search.model.Spelling;
|
||||
@@ -103,6 +105,7 @@ public class SearchMapper
|
||||
fromFilterQuery(sp, searchQuery.getFilterQueries());
|
||||
fromFacetQuery(sp, searchQuery.getFacetQueries());
|
||||
fromSpellCheck(sp, searchQuery.getSpellcheck());
|
||||
fromScope(sp, searchQuery.getScope());
|
||||
|
||||
return sp;
|
||||
}
|
||||
@@ -111,7 +114,7 @@ public class SearchMapper
|
||||
* Sets the API defaults
|
||||
* @param sp
|
||||
*/
|
||||
protected void setDefaults(SearchParameters sp)
|
||||
public void setDefaults(SearchParameters sp)
|
||||
{
|
||||
//Hardcode workspace store
|
||||
sp.addStore(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE);
|
||||
@@ -331,4 +334,34 @@ public class SearchMapper
|
||||
sp.setSpellCheck(true);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* SearchParameters from Scope object
|
||||
* @param sp SearchParameters
|
||||
* @param Scope scope
|
||||
*/
|
||||
public void fromScope(SearchParameters sp, Scope scope)
|
||||
{
|
||||
if (scope != null)
|
||||
{
|
||||
List<String> stores = scope.getStores();
|
||||
if (stores!= null && !stores.isEmpty())
|
||||
{
|
||||
//First reset the stores then add them.
|
||||
sp.getStores().clear();
|
||||
for (String aStore:stores)
|
||||
{
|
||||
try
|
||||
{
|
||||
sp.addStore(new StoreRef(aStore));
|
||||
}
|
||||
catch (AlfrescoRuntimeException are)
|
||||
{
|
||||
throw new InvalidArgumentException(InvalidArgumentException.DEFAULT_MESSAGE_ID,
|
||||
new Object[] { aStore });
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
52
source/java/org/alfresco/rest/api/search/model/Scope.java
Normal file
52
source/java/org/alfresco/rest/api/search/model/Scope.java
Normal file
@@ -0,0 +1,52 @@
|
||||
/*-
|
||||
* #%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;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* POJO class representing a FilterQuery
|
||||
*
|
||||
* @author Gethin James
|
||||
*/
|
||||
public class Scope
|
||||
{
|
||||
private final List<String> stores;
|
||||
|
||||
@JsonCreator
|
||||
public Scope(@JsonProperty("stores") List<String> stores)
|
||||
{
|
||||
this.stores = stores;
|
||||
}
|
||||
|
||||
public List<String> getStores()
|
||||
{
|
||||
return stores;
|
||||
}
|
||||
}
|
@@ -49,8 +49,9 @@ public class SearchQuery
|
||||
private final List<FilterQuery> filterQueries;
|
||||
private final List<FacetQuery> facetQueries;
|
||||
private final Spelling spellcheck;
|
||||
private final Scope scope;
|
||||
|
||||
public static final SearchQuery EMPTY = new SearchQuery(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);
|
||||
|
||||
@JsonCreator
|
||||
public SearchQuery(@JsonProperty("query") Query query,
|
||||
@@ -61,7 +62,8 @@ public class SearchQuery
|
||||
@JsonProperty("defaults") Default defaults,
|
||||
@JsonProperty("filterQueries") List<FilterQuery> filterQueries,
|
||||
@JsonProperty("facetQueries") List<FacetQuery> facetQueries,
|
||||
@JsonProperty("spellcheck") Spelling spellcheck)
|
||||
@JsonProperty("spellcheck") Spelling spellcheck,
|
||||
@JsonProperty("scope") Scope scope)
|
||||
{
|
||||
this.query = query;
|
||||
this.paging = paging;
|
||||
@@ -72,6 +74,7 @@ public class SearchQuery
|
||||
this.filterQueries = filterQueries;
|
||||
this.facetQueries = facetQueries;
|
||||
this.spellcheck = spellcheck;
|
||||
this.scope = scope;
|
||||
}
|
||||
|
||||
public Query getQuery()
|
||||
@@ -116,4 +119,9 @@ public class SearchQuery
|
||||
{
|
||||
return spellcheck;
|
||||
}
|
||||
|
||||
public Scope getScope()
|
||||
{
|
||||
return scope;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user