mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-14 17:58:59 +00:00
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/BRANCHES/DEV/5.2.N/root@137036 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -524,19 +524,21 @@ public class SearchMapper
|
|||||||
Pivot pivot = piterator.next();
|
Pivot pivot = piterator.next();
|
||||||
ParameterCheck.mandatoryString("pivot key", pivot.getKey());
|
ParameterCheck.mandatoryString("pivot key", pivot.getKey());
|
||||||
String pivotKey = pivot.getKey();
|
String pivotKey = pivot.getKey();
|
||||||
|
|
||||||
if (facetFields.getFacets() != null && !facetFields.getFacets().isEmpty())
|
if (facetFields.getFacets() != null && !facetFields.getFacets().isEmpty())
|
||||||
{
|
{
|
||||||
Optional<FacetField> found = facetFields.getFacets().stream().filter(
|
Optional<FacetField> found = facetFields.getFacets().stream()
|
||||||
queryable -> pivotKey.equals(queryable.getLabel()!=null?queryable.getLabel():queryable.getField())).findFirst();
|
.filter(queryable -> pivotKey.equals(queryable.getLabel() != null ? queryable.getLabel() : queryable.getField())).findFirst();
|
||||||
|
|
||||||
if (found.isPresent())
|
if (found.isPresent())
|
||||||
{
|
{
|
||||||
sp.addPivot(found.get().getField());
|
sp.addPivot(found.get().getField());
|
||||||
facetFields.getFacets().remove(found.get());
|
facetFields.getFacets().remove(found.get());
|
||||||
searchRequestContext.getPivotKeys().put(found.get().getField(), pivotKey);
|
searchRequestContext.getPivotKeys().put(found.get().getField(), pivotKey);
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
else
|
}
|
||||||
{
|
|
||||||
if (piterator.hasNext())
|
if (piterator.hasNext())
|
||||||
{
|
{
|
||||||
//Its not the last one so lets complain
|
//Its not the last one so lets complain
|
||||||
@@ -545,20 +547,21 @@ public class SearchMapper
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
//It is the last one so it can reference facetquery or stats
|
if (stats != null && !stats.isEmpty())
|
||||||
/**
|
{
|
||||||
Optional<StatsRequestParameters> foundStat = stats.stream().filter(stas -> pivotKey.equals(stas.getLabel())).findFirst();
|
//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())
|
if (foundStat.isPresent())
|
||||||
{
|
{
|
||||||
stats.remove(foundStat.get());
|
|
||||||
}
|
|
||||||
**/
|
|
||||||
sp.addPivot(pivotKey);
|
sp.addPivot(pivotKey);
|
||||||
searchRequestContext.getPivotKeys().put(pivotKey, 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());
|
SearchRequestContext searchRequestContext = SearchRequestContext.from(minimalQuery());
|
||||||
|
|
||||||
//"bob" doesn't refer to a field facet but its the last one so lets be kind
|
//"bob" doesn't refer to a field facet but its the last one so needs to refer to a stat
|
||||||
searchMapper.fromPivot(searchParameters, null, ff, Arrays.asList(new Pivot("bob")), searchRequestContext);
|
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
|
try
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user