mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-14 17:58:59 +00:00
Merged searchapi (5.2.1) to 5.2.N (5.2.1)
130028 gjames: SEARCH-120: Moving SearchContext and facets to its own package git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/DEV/5.2.N/root@130289 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -0,0 +1,51 @@
|
||||
/*-
|
||||
* #%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.context;
|
||||
|
||||
/**
|
||||
* The results of a facet query
|
||||
*/
|
||||
public class FacetQueryContext
|
||||
{
|
||||
private final String label;
|
||||
private final int count;
|
||||
|
||||
public FacetQueryContext(String label, int count)
|
||||
{
|
||||
this.label = label;
|
||||
this.count = count;
|
||||
}
|
||||
|
||||
public String getLabel()
|
||||
{
|
||||
return label;
|
||||
}
|
||||
|
||||
public int getCount()
|
||||
{
|
||||
return count;
|
||||
}
|
||||
}
|
@@ -23,10 +23,9 @@
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
* #L%
|
||||
*/
|
||||
package org.alfresco.rest.framework.resource.parameters;
|
||||
package org.alfresco.rest.api.search.context;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* The contextual results of a Search
|
||||
@@ -34,9 +33,9 @@ import java.util.Map;
|
||||
public class SearchContext
|
||||
{
|
||||
private final Consistency consistency;
|
||||
private final List<FacetQueryResult> facetQueries;
|
||||
private final List<FacetQueryContext> facetQueries;
|
||||
|
||||
public SearchContext(long lastTxId, List<FacetQueryResult> facetQueries)
|
||||
public SearchContext(long lastTxId, List<FacetQueryContext> facetQueries)
|
||||
{
|
||||
if (lastTxId > 0)
|
||||
{
|
||||
@@ -54,33 +53,11 @@ public class SearchContext
|
||||
return consistency;
|
||||
}
|
||||
|
||||
public List<FacetQueryResult> getFacetQueries()
|
||||
public List<FacetQueryContext> getFacetQueries()
|
||||
{
|
||||
return facetQueries;
|
||||
}
|
||||
|
||||
public static class FacetQueryResult
|
||||
{
|
||||
private final String label;
|
||||
private final int count;
|
||||
|
||||
public FacetQueryResult(String label, int count)
|
||||
{
|
||||
this.label = label;
|
||||
this.count = count;
|
||||
}
|
||||
|
||||
public String getLabel()
|
||||
{
|
||||
return label;
|
||||
}
|
||||
|
||||
public int getCount()
|
||||
{
|
||||
return count;
|
||||
}
|
||||
}
|
||||
|
||||
public class Consistency
|
||||
{
|
||||
private final long lastTxId;
|
@@ -33,8 +33,8 @@ import org.alfresco.rest.api.model.UserInfo;
|
||||
import org.alfresco.rest.api.search.model.SearchEntry;
|
||||
import org.alfresco.rest.api.search.model.SearchQuery;
|
||||
import org.alfresco.rest.framework.resource.parameters.CollectionWithPagingInfo;
|
||||
import org.alfresco.rest.framework.resource.parameters.SearchContext;
|
||||
import org.alfresco.rest.framework.resource.parameters.SearchContext.FacetQueryResult;
|
||||
import org.alfresco.rest.api.search.context.SearchContext;
|
||||
import org.alfresco.rest.api.search.context.FacetQueryContext;
|
||||
import org.alfresco.service.cmr.search.ResultSet;
|
||||
import org.alfresco.util.ParameterCheck;
|
||||
import org.apache.commons.logging.Log;
|
||||
@@ -134,14 +134,14 @@ public class ResultMapper
|
||||
{
|
||||
SearchContext context = null;
|
||||
Map<String, Integer> facetQueries = solrResultSet.getFacetQueries();
|
||||
List<FacetQueryResult> facetResults = null;
|
||||
List<FacetQueryContext> facetResults = null;
|
||||
|
||||
if(facetQueries!= null && !facetQueries.isEmpty())
|
||||
{
|
||||
facetResults = new ArrayList<>(facetQueries.size());
|
||||
for (Entry<String, Integer> fq:facetQueries.entrySet())
|
||||
{
|
||||
facetResults.add(new FacetQueryResult(fq.getKey(), fq.getValue()));
|
||||
facetResults.add(new FacetQueryContext(fq.getKey(), fq.getValue()));
|
||||
}
|
||||
}
|
||||
context = new SearchContext(solrResultSet.getLastIndexedTxId(), facetResults);
|
||||
|
@@ -26,7 +26,7 @@
|
||||
|
||||
package org.alfresco.rest.framework.resource;
|
||||
|
||||
import org.alfresco.rest.framework.resource.parameters.SearchContext;
|
||||
import org.alfresco.rest.api.search.context.SearchContext;
|
||||
import org.alfresco.rest.framework.resource.parameters.Paging;
|
||||
|
||||
import java.util.Collection;
|
||||
|
@@ -25,6 +25,7 @@
|
||||
*/
|
||||
package org.alfresco.rest.framework.resource.parameters;
|
||||
|
||||
import org.alfresco.rest.api.search.context.SearchContext;
|
||||
import org.alfresco.rest.framework.resource.SerializablePagedCollection;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
@@ -43,7 +43,7 @@ import org.alfresco.rest.api.model.UserInfo;
|
||||
import org.alfresco.rest.api.search.impl.ResultMapper;
|
||||
import org.alfresco.rest.api.search.model.SearchQuery;
|
||||
import org.alfresco.rest.framework.resource.parameters.CollectionWithPagingInfo;
|
||||
import org.alfresco.rest.framework.resource.parameters.SearchContext;
|
||||
import org.alfresco.rest.api.search.context.SearchContext;
|
||||
import org.alfresco.service.ServiceRegistry;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.repository.NodeService;
|
||||
|
@@ -31,8 +31,8 @@ import org.alfresco.rest.api.search.model.Default;
|
||||
import org.alfresco.rest.api.search.model.SearchQuery;
|
||||
import org.alfresco.rest.framework.jacksonextensions.ExecutionResult;
|
||||
import org.alfresco.rest.framework.resource.parameters.CollectionWithPagingInfo;
|
||||
import org.alfresco.rest.framework.resource.parameters.SearchContext;
|
||||
import org.alfresco.rest.framework.resource.parameters.SearchContext.FacetQueryResult;
|
||||
import org.alfresco.rest.api.search.context.SearchContext;
|
||||
import org.alfresco.rest.api.search.context.FacetQueryContext;
|
||||
import org.alfresco.rest.framework.tests.api.mocks.Farmer;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
@@ -92,7 +92,7 @@ public class SearchQuerySerializerTests
|
||||
public void testSerializeContext() throws IOException
|
||||
{
|
||||
ExecutionResult exec1 = new ExecutionResult(new Farmer("180"),null);
|
||||
SearchContext searchContext = new SearchContext(23l, Arrays.asList(new FacetQueryResult("f1", 15), new FacetQueryResult("f2", 20)));
|
||||
SearchContext searchContext = new SearchContext(23l, Arrays.asList(new FacetQueryContext("f1", 15), new FacetQueryContext("f2", 20)));
|
||||
CollectionWithPagingInfo<ExecutionResult> coll = CollectionWithPagingInfo.asPaged(null, Arrays.asList(exec1), false, 2, null, searchContext);
|
||||
String out = helper.writeResponse(coll);
|
||||
assertTrue("There must 'context' json output", out.contains("\"context\":{\"consistency\":{\"lastTxId\":23}"));
|
||||
|
@@ -49,7 +49,6 @@ import org.alfresco.rest.framework.resource.actions.interfaces.MultiPartResource
|
||||
import org.alfresco.rest.framework.resource.actions.interfaces.RelationshipResourceAction;
|
||||
import org.alfresco.rest.framework.resource.content.BinaryProperty;
|
||||
import org.alfresco.rest.framework.resource.parameters.CollectionWithPagingInfo;
|
||||
import org.alfresco.rest.framework.resource.parameters.SearchContext;
|
||||
import org.alfresco.rest.framework.resource.parameters.Paging;
|
||||
import org.alfresco.rest.framework.resource.parameters.Params;
|
||||
import org.alfresco.rest.framework.tests.api.mocks.Farmer;
|
||||
|
Reference in New Issue
Block a user