# HG changeset patch # User Andre Heinecke # Date 1376905269 -7200 # Node ID 3ccbc278f2e64d092a8c9b9a72f2ba0f4b10fed0 # Parent b5e2d18cc341519d5da62b8b86b9b1bbec5044c6 (issue1347) Add SQ Relation fields for measurement station information diff -r b5e2d18cc341 -r 3ccbc278f2e6 artifacts/src/main/java/org/dive4elements/river/artifacts/access/SQRelationAccess.java --- 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 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 : diff -r b5e2d18cc341 -r 3ccbc278f2e6 artifacts/src/main/java/org/dive4elements/river/artifacts/model/sq/SQRelationJRDataSource.java --- a/artifacts/src/main/java/org/dive4elements/river/artifacts/model/sq/SQRelationJRDataSource.java Mon Aug 19 11:40:34 2013 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/model/sq/SQRelationJRDataSource.java Mon Aug 19 11:41:09 2013 +0200 @@ -73,6 +73,12 @@ else if ("periods".equals(fieldName)) { value = metaData.get("periods"); } + else if ("msName".equals(fieldName)) { + value = metaData.get("msName"); + } + else if ("msGauge".equals(fieldName)) { + value = metaData.get("msGauge"); + } else if ("km".equals(fieldName)) { value = data.get(index)[0]; } diff -r b5e2d18cc341 -r 3ccbc278f2e6 artifacts/src/main/java/org/dive4elements/river/exports/sq/SQRelationExporter.java --- a/artifacts/src/main/java/org/dive4elements/river/exports/sq/SQRelationExporter.java Mon Aug 19 11:40:34 2013 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/exports/sq/SQRelationExporter.java Mon Aug 19 11:41:09 2013 +0200 @@ -261,6 +261,19 @@ locale, PDF_HEADER_MODE, "SQRelation")); + + String measurementStationName = access.getMeasurementStationName(); + + if (measurementStationName != null) { + source.addMetaData("msName", measurementStationName); + } + + String measurementStationGaugeName = access.getMeasurementStationGaugeName(); + + if (measurementStationGaugeName != null) { + source.addMetaData("msGauge", measurementStationGaugeName); + } + } @Override