Mercurial > dive4elements > river
diff artifacts/src/main/java/org/dive4elements/river/artifacts/access/SQRelationAccess.java @ 6859:3ccbc278f2e6
(issue1347) Add SQ Relation fields for measurement station information
author | Andre Heinecke <aheinecke@intevation.de> |
---|---|
date | Mon, 19 Aug 2013 11:41:09 +0200 |
parents | af13ceeba52a |
children | a56fe3bc6700 |
line wrap: on
line diff
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/access/SQRelationAccess.java Mon Aug 19 11:40:34 2013 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/access/SQRelationAccess.java Mon Aug 19 11:41:09 2013 +0200 @@ -9,11 +9,13 @@ package org.dive4elements.river.artifacts.access; import java.util.Date; +import java.util.List; import org.apache.log4j.Logger; import org.dive4elements.river.artifacts.D4EArtifact; import org.dive4elements.river.artifacts.model.DateRange; +import org.dive4elements.river.model.MeasurementStation; public class SQRelationAccess extends RiverAccess @@ -28,6 +30,8 @@ private String method; + protected MeasurementStation measurementStation; + public SQRelationAccess() { } @@ -80,5 +84,30 @@ } return method; } + + public String getMeasurementStationName() { + MeasurementStation station = getMeasurementStation(); + return station == null ? null : station.getName(); + } + + public String getMeasurementStationGaugeName() { + MeasurementStation station = getMeasurementStation(); + return station == null ? null : station.getGaugeName(); + } + + public MeasurementStation getMeasurementStation() { + if (measurementStation != null) { + return measurementStation; + } + List<MeasurementStation> candidates = MeasurementStation.getStationsAtKM( + getRiver(), getLocation()); + if (candidates != null) { + // Just take the first one as we only use the name + // and that "should" be unique at the location + measurementStation = candidates.get(0); + } + + return measurementStation; + } } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :