changeset 1658:7d11ad5a52d5

Bugfix: #332 Made AT-exports compatible with desktop FLYS. flys-artifacts/trunk@2856 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Wed, 28 Sep 2011 15:02:33 +0000
parents 91d038c7aae5
children ad54896ec369
files flys-artifacts/ChangeLog flys-artifacts/src/main/java/de/intevation/flys/exports/ATExporter.java flys-artifacts/src/main/java/de/intevation/flys/exports/ATWriter.java flys-artifacts/src/main/resources/messages.properties flys-artifacts/src/main/resources/messages_de.properties flys-artifacts/src/main/resources/messages_de_DE.properties flys-artifacts/src/main/resources/messages_en.properties
diffstat 7 files changed, 61 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/flys-artifacts/ChangeLog	Wed Sep 28 14:01:00 2011 +0000
+++ b/flys-artifacts/ChangeLog	Wed Sep 28 15:02:33 2011 +0000
@@ -1,3 +1,20 @@
+2011-09-28  Ingo Weinzierl <ingo@intevation.de>
+
+	flys/issue332 (W-INFO / Berechnung Abflusskurve, Export, FLYS 2.5)
+
+	* src/main/java/de/intevation/flys/exports/ATExporter.java: Store the
+	  master Artifact which is set via setMasterArtifact(). This is required
+	  for meta information used while preparing the header row of AT exports.
+
+	* src/main/java/de/intevation/flys/exports/ATWriter.java: Print a header
+	  row into the AT export for being compatible with desktop FLYS.
+
+	* src/main/resources/messages.properties,
+	  src/main/resources/messages_de_DE.properties,
+	  src/main/resources/messages_en.properties,
+	  src/main/resources/messages_de.properties: Added header row for AT
+	  export files.
+
 2011-09-28  Ingo Weinzierl <ingo@intevation.de>
 
 	flys/issue328 (W-INFO / ÜSK: Auswahl der Wasserspiegellage / Auswahlunterstützung)
--- a/flys-artifacts/src/main/java/de/intevation/flys/exports/ATExporter.java	Wed Sep 28 14:01:00 2011 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/ATExporter.java	Wed Sep 28 15:02:33 2011 +0000
@@ -17,6 +17,9 @@
 
 import de.intevation.flys.artifacts.model.WQ;
 
+import de.intevation.flys.utils.FLYSUtils;
+
+
 public class ATExporter
 implements   OutGenerator
 {
@@ -27,6 +30,7 @@
     protected WQ           data;
     protected CallContext  context;
     protected OutputStream out;
+    protected FLYSArtifact master;
 
     public ATExporter() {
     }
@@ -39,7 +43,7 @@
 
     @Override
     public void setMasterArtifact(Artifact master) {
-        // not needed
+        this.master = (FLYSArtifact) master;
     }
 
     @Override
@@ -72,7 +76,14 @@
             throw new IOException(iae);
         }
 
-        at.write(new OutputStreamWriter(out, DEFAULT_ENCODING));
+        String   river = FLYSUtils.getRiver(master).getName();
+        double[] kms   = FLYSUtils.getLocations(master);
+
+        at.write(
+            new OutputStreamWriter(out, DEFAULT_ENCODING),
+            context.getMeta(),
+            river,
+            kms[0]);
     }
 }
 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- a/flys-artifacts/src/main/java/de/intevation/flys/exports/ATWriter.java	Wed Sep 28 14:01:00 2011 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/ATWriter.java	Wed Sep 28 15:02:33 2011 +0000
@@ -6,7 +6,10 @@
 
 import java.util.Locale;
 
+import de.intevation.artifacts.CallMeta;
+
 import de.intevation.flys.artifacts.model.WQ;
+import de.intevation.flys.artifacts.resources.Resources;
 
 import org.apache.commons.math.analysis.UnivariateRealFunction;
 
@@ -25,6 +28,9 @@
 
     public static final int COLUMNS = 10;
 
+    public static final String I18N_AT_HEADER =
+        "export.discharge.curve.at.header";
+
     public static final String EMPTY = "         ";
 
     protected double minW;
@@ -98,10 +104,30 @@
         out.printf(Locale.US, format, q);
     }
 
-    public void write(Writer writer) throws IOException {
 
+    protected static void printHeader(
+        PrintWriter out,
+        CallMeta    callMeta,
+        String      river,
+        double      km
+    ) {
+        out.println(Resources.getMsg(
+            callMeta,
+            I18N_AT_HEADER,
+            I18N_AT_HEADER,
+            new Object[] { river, km } ));
+    }
+
+
+    public void write(Writer writer, CallMeta meta, String river, double km)
+    throws IOException
+    {
         PrintWriter out = new PrintWriter(writer);
 
+        // a header is required, because the desktop version of FLYS will skip
+        // the first row.
+        printHeader(out, meta, river, km);
+
         double rest = Math.abs(minW % COLUMNS);
 
         double startW = Math.round(minW*10.0)/10.0;
--- a/flys-artifacts/src/main/resources/messages.properties	Wed Sep 28 14:01:00 2011 +0000
+++ b/flys-artifacts/src/main/resources/messages.properties	Wed Sep 28 15:02:33 2011 +0000
@@ -73,6 +73,7 @@
 export.discharge.longitudinal.section.csv.header.w = W [NN + m]
 export.discharge.longitudinal.section.csv.header.cw = W corr.
 export.discharge.longitudinal.section.csv.header.q = Q [m\u00b3/s]
+export.discharge.curve.at.header = Computed Discharge Curve for {0} {0}-km: {1}
 
 floodmap.wmsbackground = Background Map
 floodmap.riveraxis = River Axis
--- a/flys-artifacts/src/main/resources/messages_de.properties	Wed Sep 28 14:01:00 2011 +0000
+++ b/flys-artifacts/src/main/resources/messages_de.properties	Wed Sep 28 15:02:33 2011 +0000
@@ -74,6 +74,7 @@
 export.discharge.longitudinal.section.csv.header.w = W [NN + m]
 export.discharge.longitudinal.section.csv.header.cw = W korr.
 export.discharge.longitudinal.section.csv.header.q = Q [m\u00b3/s]
+export.discharge.curve.at.header = Berechnete Abflusskurve f\u00fcr {0} {0}-km: {1}
 
 floodmap.wmsbackground = Hintergrundkarte
 floodmap.riveraxis = Flussachse
--- a/flys-artifacts/src/main/resources/messages_de_DE.properties	Wed Sep 28 14:01:00 2011 +0000
+++ b/flys-artifacts/src/main/resources/messages_de_DE.properties	Wed Sep 28 15:02:33 2011 +0000
@@ -73,6 +73,7 @@
 export.discharge.longitudinal.section.csv.header.w = W [NN + m]
 export.discharge.longitudinal.section.csv.header.cw = W korr.
 export.discharge.longitudinal.section.csv.header.q = Q [m\u00b3/s]
+export.discharge.curve.at.header = Berechnete Abflusskurve f\u00fcr {0} {0}-km: {1}
 
 floodmap.wmsbackground = Hintergrundkarte
 floodmap.riveraxis = Flussachse
--- a/flys-artifacts/src/main/resources/messages_en.properties	Wed Sep 28 14:01:00 2011 +0000
+++ b/flys-artifacts/src/main/resources/messages_en.properties	Wed Sep 28 15:02:33 2011 +0000
@@ -71,6 +71,7 @@
 export.discharge.longitudinal.section.csv.header.w = W [NN + m]
 export.discharge.longitudinal.section.csv.header.cw = W corr.
 export.discharge.longitudinal.section.csv.header.q = Q [m\u00b3/s]
+export.discharge.curve.at.header = Computed Discharge Curve for {0} {0}-km: {1}
 
 floodmap.wmsbackground = Background Map
 floodmap.riveraxis = River Axis

http://dive4elements.wald.intevation.org