[New] GenericReport now adheres to facet value limit if trimFaceValues=true on report

This commit is contained in:
Robert von Burg 2022-02-24 15:31:02 +01:00
parent b03a8781fa
commit e31e606754
2 changed files with 4 additions and 4 deletions

View File

@ -20,6 +20,7 @@ public class ReportConstants {
public static final String PARAM_FIELD_REF2 = "fieldRef2";
public static final String PARAM_ALLOW_MISSING_COLUMNS = "allowMissingColumns";
public static final String PARAM_FILTER_MISSING_VALUES_AS_TRUE = "filterMissingValuesAsTrue";
public static final String PARAM_TRIM_FACETS_VALUES = "trimFacetValues";
public static final String PARAM_POLICY = "policy";
public static final String PARAM_JOIN_PARAM = "joinParam";

View File

@ -540,7 +540,7 @@ public class GenericReport extends ReportPolicy {
.sorted(comparing(StringParameter::getIndex)) //
.map(StringParameter::getUom).collect(toList());
int count = 0;
boolean trimFacetValues = this.reportRes.getBoolean(PARAM_TRIM_FACETS_VALUES);
while (iter.hasNext()) {
Map<String, StrolchRootElement> row = iter.next();
@ -553,9 +553,8 @@ public class GenericReport extends ReportPolicy {
}
}
// stop if we have enough data, or iterated over "enough"
count++;
if (count > 1000 || result.size() > limit * result.keySet().size())
// stop if we have enough data
if (trimFacetValues && result.stream().mapToInt(e -> e.getValue().size()).allMatch(v -> v >= limit))
break;
}