[Fix] Fixed wrong value order in CSV export

This commit is contained in:
Robert von Burg 2017-09-13 15:28:40 +02:00
parent 9a5bfefa3f
commit d9db935bbb
2 changed files with 15 additions and 14 deletions

View File

@ -76,7 +76,7 @@ public class GenericReport {
private ParameterBag columnsBag; private ParameterBag columnsBag;
private List<StringParameter> orderingParams; private List<StringParameter> orderingParams;
private boolean descending; private boolean descending;
private Set<String> columnIds; private List<String> columnIds;
private StringParameter dateRangeSelP; private StringParameter dateRangeSelP;
private DateRange dateRange; private DateRange dateRange;
@ -98,7 +98,11 @@ public class GenericReport {
this.hideObjectTypeFromFilterCriteria = hideObjectTypeFromFilterCriteriaP != null this.hideObjectTypeFromFilterCriteria = hideObjectTypeFromFilterCriteriaP != null
&& hideObjectTypeFromFilterCriteriaP.getValue(); && hideObjectTypeFromFilterCriteriaP.getValue();
this.columnsBag = this.report.getParameterBag(BAG_COLUMNS, true); this.columnsBag = this.report.getParameterBag(BAG_COLUMNS, true);
this.columnIds = this.columnsBag.getParameterKeySet();
this.columnIds = this.columnsBag.getParameters().stream() //
.sorted((p1, p2) -> Integer.compare(p1.getIndex(), p2.getIndex())) //
.map(p -> p.getId()) //
.collect(Collectors.toList());
if (this.report.hasParameter(BAG_PARAMETERS, PARAM_DESCENDING)) if (this.report.hasParameter(BAG_PARAMETERS, PARAM_DESCENDING))
this.descending = this.report.getParameter(BAG_PARAMETERS, PARAM_DESCENDING).getValue(); this.descending = this.report.getParameter(BAG_PARAMETERS, PARAM_DESCENDING).getValue();
@ -141,11 +145,8 @@ public class GenericReport {
return this; return this;
} }
public List<String> getOrderedColumnKeys() { public List<String> getColumnKeys() {
return this.columnsBag.getParameters().stream() // return this.columnIds;
.sorted((p1, p2) -> Integer.compare(p1.getIndex(), p2.getIndex())) //
.map(p -> p.getId()) //
.collect(Collectors.toList());
} }
public GenericReport filter(String type, String... ids) { public GenericReport filter(String type, String... ids) {
@ -480,7 +481,8 @@ public class GenericReport {
private StrolchRootElement addColumnJoin(Map<String, StrolchRootElement> refs, ParameterBag joinBag, private StrolchRootElement addColumnJoin(Map<String, StrolchRootElement> refs, ParameterBag joinBag,
StringParameter joinP, boolean optional) { StringParameter joinP, boolean optional) {
String elementType = joinP.getInterpretation().substring(0, joinP.getInterpretation().indexOf(SUFFIX_REF)); String interpretation = joinP.getInterpretation();
String elementType = interpretation.substring(0, interpretation.indexOf(SUFFIX_REF));
String joinType = joinP.getUom(); String joinType = joinP.getUom();
String dependencyType = joinP.getValue(); String dependencyType = joinP.getValue();
@ -501,8 +503,7 @@ public class GenericReport {
throw new IllegalStateException("Invalid join definition value: " + joinP.getValue() + " on: " throw new IllegalStateException("Invalid join definition value: " + joinP.getValue() + " on: "
+ joinP.getLocator() + " as " + dependency.getLocator() + " has no ParameterBag " + BAG_RELATIONS); + joinP.getLocator() + " as " + dependency.getLocator() + " has no ParameterBag " + BAG_RELATIONS);
List<Parameter<?>> relationParams = relationsBag.getParameters().stream() List<Parameter<?>> relationParams = relationsBag.getParametersByInterpretationAndUom(interpretation, joinType);
.filter(p -> p.getUom().equals(joinType)).collect(Collectors.toList());
if (relationParams.isEmpty()) { if (relationParams.isEmpty()) {
throw new IllegalStateException( throw new IllegalStateException(
"Found no relation parameters with UOM " + joinType + " on dependency " + dependency.getLocator()); "Found no relation parameters with UOM " + joinType + " on dependency " + dependency.getLocator());

View File

@ -1,22 +1,22 @@
package li.strolch.report; package li.strolch.report;
import java.util.AbstractMap.SimpleEntry; import java.util.AbstractMap.SimpleEntry;
import java.util.Set; import java.util.List;
import java.util.function.Function; import java.util.function.Function;
import java.util.stream.Stream; import java.util.stream.Stream;
public class ReportElement { public class ReportElement {
private Set<String> columnKeys; private List<String> columnKeys;
private Function<String, String> columnGetter; private Function<String, String> columnGetter;
public ReportElement(Set<String> columnKeys, Function<String, String> columnGetter) { public ReportElement(List<String> columnKeys, Function<String, String> columnGetter) {
super(); super();
this.columnGetter = columnGetter; this.columnGetter = columnGetter;
this.columnKeys = columnKeys; this.columnKeys = columnKeys;
} }
public Set<String> getColumnKeys() { public List<String> getColumnKeys() {
return this.columnKeys; return this.columnKeys;
} }