[PATCH] Fix handling of multiple entries in SQPeriodSelect default start/end calculation
Wald Commits
scm-commit at wald.intevation.org
Wed Mar 25 19:37:49 CET 2015
# HG changeset patch
# User Andre Heinecke <andre.heinecke at intevation.de>
# Date 1427308664 -3600
# Node ID 1125e598df0e3716a8a6567f2aa9f0bc3ede114b
# Parent 8737de2ca76384ace91e1b9ba6d504f7180c7bfb
Fix handling of multiple entries in SQPeriodSelect default start/end calculation
diff -r 8737de2ca763 -r 1125e598df0e artifacts/src/main/java/org/dive4elements/river/artifacts/states/sq/SQPeriodSelect.java
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/states/sq/SQPeriodSelect.java Wed Mar 25 19:20:13 2015 +0100
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/states/sq/SQPeriodSelect.java Wed Mar 25 19:37:44 2015 +0100
@@ -10,7 +10,7 @@
import java.util.Date;
import java.util.List;
-import java.util.Collections;
+import java.util.TreeSet;
import org.apache.log4j.Logger;
@@ -50,16 +50,13 @@
SQOverview overview = SQOverviewFactory.getOverview(access.getRiverName());
KMIndex<List<Date>> entries = overview.filter(new KmFilter(km));
- if (entries.size() == 0) {
- return 0;
+ TreeSet<Date> allDates = new TreeSet<Date>();
+
+ for (int i = 0; i < entries.size(); i++) {
+ allDates.addAll(entries.get(i).getValue());
}
- List<Date> dates = entries.get(0).getValue();
- if (dates.isEmpty()) {
- return 0;
- }
- Collections.sort(dates);
- return minDate ? dates.get(0).getTime() : dates.get(dates.size() - 1).getTime();
+ return minDate ? allDates.first().getTime() : allDates.last().getTime();
}
@Override
More information about the Dive4Elements-commits
mailing list