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.2) to HEAD (5.2)
137036 gjames: Merged searchrep (5.2.1) to 5.2.N (5.2.1) 136645 gjames: SEARCH-409: Better pivot with stats handling git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@137551 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -524,19 +524,21 @@ public class SearchMapper
|
||||
Pivot pivot = piterator.next();
|
||||
ParameterCheck.mandatoryString("pivot key", pivot.getKey());
|
||||
String pivotKey = pivot.getKey();
|
||||
|
||||
if (facetFields.getFacets() != null && !facetFields.getFacets().isEmpty())
|
||||
{
|
||||
Optional<FacetField> found = facetFields.getFacets().stream().filter(
|
||||
queryable -> pivotKey.equals(queryable.getLabel()!=null?queryable.getLabel():queryable.getField())).findFirst();
|
||||
Optional<FacetField> found = facetFields.getFacets().stream()
|
||||
.filter(queryable -> pivotKey.equals(queryable.getLabel() != null ? queryable.getLabel() : queryable.getField())).findFirst();
|
||||
|
||||
if (found.isPresent())
|
||||
{
|
||||
sp.addPivot(found.get().getField());
|
||||
facetFields.getFacets().remove(found.get());
|
||||
searchRequestContext.getPivotKeys().put(found.get().getField(), pivotKey);
|
||||
continue;
|
||||
}
|
||||
else
|
||||
{
|
||||
}
|
||||
|
||||
if (piterator.hasNext())
|
||||
{
|
||||
//Its not the last one so lets complain
|
||||
@@ -545,20 +547,21 @@ public class SearchMapper
|
||||
}
|
||||
else
|
||||
{
|
||||
//It is the last one so it can reference facetquery or stats
|
||||
/**
|
||||
Optional<StatsRequestParameters> foundStat = stats.stream().filter(stas -> pivotKey.equals(stas.getLabel())).findFirst();
|
||||
if (stats != null && !stats.isEmpty())
|
||||
{
|
||||
//It is the last one so it can reference stats
|
||||
Optional<StatsRequestParameters> foundStat = stats.stream().filter(stas -> pivotKey.equals(stas.getLabel()!=null?stas.getLabel():stas.getField())).findFirst();
|
||||
if (foundStat.isPresent())
|
||||
{
|
||||
stats.remove(foundStat.get());
|
||||
}
|
||||
**/
|
||||
sp.addPivot(pivotKey);
|
||||
searchRequestContext.getPivotKeys().put(pivotKey, pivotKey);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
}
|
||||
throw new InvalidArgumentException(InvalidArgumentException.DEFAULT_MESSAGE_ID,
|
||||
new Object[] { ": Pivot parameter " + pivotKey + " is does not reference a facet Field or stats." });
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -697,8 +697,15 @@ public class SearchMapperTests
|
||||
|
||||
SearchRequestContext searchRequestContext = SearchRequestContext.from(minimalQuery());
|
||||
|
||||
//"bob" doesn't refer to a field facet but its the last one so lets be kind
|
||||
searchMapper.fromPivot(searchParameters, null, ff, Arrays.asList(new Pivot("bob")), searchRequestContext);
|
||||
//"bob" doesn't refer to a field facet but its the last one so needs to refer to a stat
|
||||
StatsRequestParameters bobf = new StatsRequestParameters("bob", null, null, null,null, null, null, null,null, null, null, null,null, null, null, null);
|
||||
StatsRequestParameters bobL = new StatsRequestParameters("creator", "bob", null, null,null, null, null, null,null, null, null, null,null, null, null, null);
|
||||
searchMapper.fromPivot(searchParameters, Arrays.asList(bobf), ff, Arrays.asList(new Pivot("bob")), searchRequestContext);
|
||||
assertEquals(1 ,searchParameters.getPivots().size());
|
||||
|
||||
searchParameters = new SearchParameters();
|
||||
searchMapper.fromPivot(searchParameters, Arrays.asList(bobf), ff, Arrays.asList(new Pivot("bob")), searchRequestContext);
|
||||
assertEquals(1 ,searchParameters.getPivots().size());
|
||||
|
||||
try
|
||||
{
|
||||
|
Reference in New Issue
Block a user