Mercurial > dive4elements > river
changeset 8622:124efb3eea94
Handle surprising filter behaivor of *Overviews. Don't create items for unavailable data.
author | Andre Heinecke <andre.heinecke@intevation.de> |
---|---|
date | Thu, 26 Mar 2015 11:06:13 +0100 |
parents | 1125e598df0e |
children | 289486a43be8 |
files | artifacts/src/main/java/org/dive4elements/river/artifacts/states/sq/SQPeriodSelect.java |
diffstat | 1 files changed, 16 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/states/sq/SQPeriodSelect.java Wed Mar 25 19:37:44 2015 +0100 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/states/sq/SQPeriodSelect.java Thu Mar 26 11:06:13 2015 +0100 @@ -30,6 +30,7 @@ import org.dive4elements.artifacts.CallContext; import org.dive4elements.artifactdatabase.data.StateData; +import org.dive4elements.river.backend.utils.EpsilonComparator; public class SQPeriodSelect extends PeriodsSelect { @@ -40,7 +41,7 @@ private static final long serialVersionUID = 1L; /** Get either the start date of the data or the end. */ - protected long getDataMinMaxDate(Artifact artifact, boolean minDate) { + protected Long getDataMinMaxDate(Artifact artifact, boolean minDate) { D4EArtifact arti = (D4EArtifact) artifact; RangeAccess access = new RangeAccess(arti); double km = access.getLocations()[0]; @@ -49,11 +50,18 @@ * in the next state anyway. */ SQOverview overview = SQOverviewFactory.getOverview(access.getRiverName()); - KMIndex<List<Date>> entries = overview.filter(new KmFilter(km)); + /* Filter is not implemented and only checks if a complete + * KMIndex list is acceptable or not. So KMFiltering wont work */ + KMIndex<List<Date>> entries = overview.filter(SQOverview.ACCEPT); TreeSet<Date> allDates = new TreeSet<Date>(); for (int i = 0; i < entries.size(); i++) { - allDates.addAll(entries.get(i).getValue()); + if (EpsilonComparator.CMP.compare(entries.get(i).getKm(), km) == 0) { + allDates.addAll(entries.get(i).getValue()); + } + } + if (allDates.size() < 2) { + return null; } return minDate ? allDates.first().getTime() : allDates.last().getTime(); @@ -69,10 +77,13 @@ if (!name.equals("start") && !name.equals("end")) { return null; } + Long value = getDataMinMaxDate(artifact, name.equals("start")); + if (value == null) { + return null; + } Element def = createItem( cr, - new String[] {"default", Long.toString( - getDataMinMaxDate(artifact, name.equals("start")))}); + new String[] {"default", value.toString()}); return new Element[] { def }; }