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)
132107 gjames: SEARCH-227: Adding additional display information for facetting api git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@132335 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -66,7 +66,6 @@ public class SearchApiWebscript extends AbstractWebScript implements RecognizedP
|
||||
{
|
||||
private ServiceRegistry serviceRegistry;
|
||||
private SearchService searchService;
|
||||
private Nodes nodes;
|
||||
private SearchMapper searchMapper;
|
||||
private ResultMapper resultMapper;
|
||||
protected ApiAssistant assistant;
|
||||
@@ -78,10 +77,8 @@ public class SearchApiWebscript extends AbstractWebScript implements RecognizedP
|
||||
PropertyCheck.mandatory(this, "serviceRegistry", serviceRegistry);
|
||||
this.searchService = serviceRegistry.getSearchService();
|
||||
ParameterCheck.mandatory("assistant", this.assistant);
|
||||
ParameterCheck.mandatory("nodes", this.nodes);
|
||||
|
||||
searchMapper = new SearchMapper();
|
||||
resultMapper = new ResultMapper(nodes);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -145,8 +142,9 @@ public class SearchApiWebscript extends AbstractWebScript implements RecognizedP
|
||||
return Params.valueOf(null, recognizedParams, null, webScriptRequest);
|
||||
}
|
||||
|
||||
public void setNodes(Nodes nodes) {
|
||||
this.nodes = nodes;
|
||||
public void setResultMapper(ResultMapper resultMapper)
|
||||
{
|
||||
this.resultMapper = resultMapper;
|
||||
}
|
||||
|
||||
public void setAssistant(ApiAssistant assistant) {
|
||||
|
@@ -55,11 +55,18 @@ public class FacetFieldContext
|
||||
{
|
||||
private final String label;
|
||||
private final int count;
|
||||
private final Object display;
|
||||
|
||||
public Bucket(String label, int count)
|
||||
public Bucket(String label, int count, Object display)
|
||||
{
|
||||
this.label = label;
|
||||
this.count = count;
|
||||
this.display = display;
|
||||
}
|
||||
|
||||
public Object getDisplay()
|
||||
{
|
||||
return display;
|
||||
}
|
||||
|
||||
public String getLabel()
|
||||
|
@@ -28,22 +28,22 @@ package org.alfresco.rest.api.search.impl;
|
||||
|
||||
import org.alfresco.repo.search.impl.lucene.SolrJSONResultSet;
|
||||
import org.alfresco.rest.api.Nodes;
|
||||
import org.alfresco.rest.api.lookups.PropertyLookupRegistry;
|
||||
import org.alfresco.rest.api.model.Node;
|
||||
import org.alfresco.rest.api.model.UserInfo;
|
||||
import org.alfresco.rest.api.search.context.FacetFieldContext;
|
||||
import org.alfresco.rest.api.search.context.FacetFieldContext.Bucket;
|
||||
import org.alfresco.rest.api.search.context.FacetQueryContext;
|
||||
import org.alfresco.rest.api.search.context.SearchContext;
|
||||
import org.alfresco.rest.api.search.context.SpellCheckContext;
|
||||
import org.alfresco.rest.api.search.model.HighlightEntry;
|
||||
import org.alfresco.rest.api.search.model.SearchEntry;
|
||||
import org.alfresco.rest.framework.resource.parameters.CollectionWithPagingInfo;
|
||||
import org.alfresco.rest.api.search.context.SearchContext;
|
||||
import org.alfresco.rest.api.search.context.FacetQueryContext;
|
||||
import org.alfresco.rest.framework.resource.parameters.Params;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.search.ResultSet;
|
||||
import org.alfresco.service.cmr.search.SpellCheckResult;
|
||||
import org.alfresco.util.Pair;
|
||||
import org.alfresco.util.ParameterCheck;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
@@ -62,12 +62,21 @@ public class ResultMapper
|
||||
{
|
||||
|
||||
private Nodes nodes;
|
||||
private PropertyLookupRegistry propertyLookup;
|
||||
private static Log logger = LogFactory.getLog(ResultMapper.class);
|
||||
|
||||
public ResultMapper(Nodes nodes)
|
||||
public ResultMapper()
|
||||
{
|
||||
}
|
||||
|
||||
public void setNodes(Nodes nodes)
|
||||
{
|
||||
this.nodes = nodes;
|
||||
ParameterCheck.mandatory("nodes", this.nodes);
|
||||
}
|
||||
|
||||
public void setPropertyLookup(PropertyLookupRegistry propertyLookup)
|
||||
{
|
||||
this.propertyLookup = propertyLookup;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -179,7 +188,8 @@ public class ResultMapper
|
||||
List<Bucket> buckets = new ArrayList<>(facet.getValue().size());
|
||||
for (Pair<String, Integer> buck:facet.getValue())
|
||||
{
|
||||
buckets.add(new Bucket(buck.getFirst(), buck.getSecond()));
|
||||
Object display = propertyLookup.lookup(facet.getKey(), buck.getFirst());
|
||||
buckets.add(new Bucket(buck.getFirst(), buck.getSecond(), display));
|
||||
}
|
||||
ffcs.add(new FacetFieldContext(facet.getKey(), buckets));
|
||||
}
|
||||
|
Reference in New Issue
Block a user