diff flys-artifacts/src/main/java/de/intevation/flys/exports/fixings/DeltaWtExporter.java @ 3402:0336132ec9db

Adjusted Delta W(t) CSV exporter to customers wishes. flys-artifacts/trunk@5044 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Wed, 18 Jul 2012 16:28:00 +0000
parents 7f9fe694f8d1
children e3c7a3228bc2
line wrap: on
line diff
--- a/flys-artifacts/src/main/java/de/intevation/flys/exports/fixings/DeltaWtExporter.java	Wed Jul 18 14:44:29 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/fixings/DeltaWtExporter.java	Wed Jul 18 16:28:00 2012 +0000
@@ -27,7 +27,6 @@
 
 import java.util.ArrayList;
 import java.util.List;
-import java.util.Locale;
 
 import org.apache.log4j.Logger;
 
@@ -47,27 +46,30 @@
     public static final String CSV_Q_HEADER =
         "export.fixings.deltawt.csv.header.q";
 
+    public static final String CSV_W_HEADER =
+        "export.fixings.deltawt.csv.header.w";
+
     public static final String CSV_TRANGE_HEADER =
         "export.fixings.deltawt.csv.header.time.range";
 
     public static final String CSV_T_HEADER =
         "export.fixings.deltawt.csv.header.t";
 
-    public static final String CSV_T_DESC_HEADER =
-        "export.fixings.deltawt.csv.header.description";
+    public static final String CSV_T_FORMAT =
+        "export.fixings.deltawt.csv.t.format";
 
     public static final String DEFAULT_CSV_KM_HEADER = "km";
 
     public static final String DEFAULT_CSV_DELTA_W_HEADER = "\u0394 W [cm]";
 
+    public static final String DEFAULT_CSV_W_HEADER = "Wasserstand [m]";
+
     public static final String DEFAULT_CSV_Q_HEADER = "Abfluss [m\u00b3/s]";
 
     public static final String DEFAULT_CSV_T_HEADER = "Datum";
 
-    public static final String DEFAULT_CSV_T_DESC_HEADER = "Beschreibung";
-
     public static final String DEFAULT_CSV_TRANGE_DESC_HEADER =
-        "Zeitraum";
+        "Status";
 
     public static final String CSV_REFERENCE =
         "export.fixings.deltawt.csv.reference";
@@ -76,10 +78,13 @@
         "export.fixings.deltawt.csv.analysis";
 
     public static final String DEFAULT_CSV_REFERENCE =
-        "Bezug";
+        "B";
 
     public static final String DEFAULT_CSV_ANALYSIS =
-        "Analyse {0,number,integer}";
+        "A{0,number,integer}";
+
+    public static final String DEFAULT_CSV_T_FORMAT =
+        "dd.MM.yyyy";
 
     protected List<KMIndex<AnalysisPeriod []>> analysisPeriods;
 
@@ -120,10 +125,9 @@
         NumberFormat kmF = getKMFormatter();
         NumberFormat dwF = getDeltaWFormatter();
         NumberFormat qF  = getQFormatter();
+        NumberFormat wF  = getWFormatter();
 
-        CallMeta meta = context.getMeta();
-        Locale locale = Resources.getLocale(meta);
-        DateFormat dF = DateFormat.getDateInstance(DateFormat.SHORT, locale);
+        DateFormat dF = getDateFormatter();
 
         String referenceS = getReference();
 
@@ -133,18 +137,19 @@
 
                String kmS = kmF.format(kmEntry.getKm());
                for (QWD qwd: kmEntry.getValue()) {
-                    String desc    = qwd.getDescription();
                     String deltaWS = dwF.format(qwd.getDeltaW());
                     String qS      = qF.format(qwd.getQ());
+                    String wS      = wF.format(qwd.getW());
                     String dateS   = dF.format(qwd.getDate());
 
                     writer.writeNext(new String[] {
                         kmS,
+                        qS,
+                        wS,
                         referenceS,
-                        deltaWS,
-                        qS,
                         dateS,
-                        desc != null ? desc : "" });
+                        deltaWS
+                        });
                }
             }
         }
@@ -170,18 +175,18 @@
                     QWD [] qwds = period.getQWDs();
                     if (qwds != null) {
                         for (QWD qwd: qwds) {
-                            String desc    = qwd.getDescription();
                             String deltaWS = dwF.format(qwd.getDeltaW());
                             String qS      = qF.format(qwd.getQ());
+                            String wS      = wF.format(qwd.getW());
                             String dateS   = dF.format(qwd.getDate());
 
                             writer.writeNext(new String[] {
                                 kmS,
+                                qS,
+                                wS,
                                 analyisS,
-                                deltaWS,
-                                qS,
                                 dateS,
-                                desc != null ? desc : "" });
+                                deltaWS });
                         }
                     }
                 }
@@ -215,16 +220,30 @@
         return Formatter.getFixDeltaWQ(context);
     }
 
+    protected NumberFormat getWFormatter() {
+        return Formatter.getFixDeltaWW(context);
+    }
+
+    protected DateFormat getDateFormatter() {
+        CallMeta meta = context.getMeta();
+        return Formatter.getDateFormatter(
+            meta,
+            Resources.getMsg(
+                meta,
+                CSV_T_FORMAT,
+                DEFAULT_CSV_T_FORMAT));
+    }
+
     protected void writeCSVHeader(CSVWriter writer) {
         log.debug("DeltaWtExporter.writeCSVHeader");
 
         writer.writeNext(new String[] {
             msg(CSV_KM_HEADER,      DEFAULT_CSV_KM_HEADER),
+            msg(CSV_Q_HEADER,       DEFAULT_CSV_Q_HEADER),
+            msg(CSV_W_HEADER,       DEFAULT_CSV_W_HEADER),
             msg(CSV_TRANGE_HEADER,  DEFAULT_CSV_TRANGE_DESC_HEADER),
-            msg(CSV_DELTA_W_HEADER, DEFAULT_CSV_DELTA_W_HEADER),
-            msg(CSV_Q_HEADER,       DEFAULT_CSV_Q_HEADER),
             msg(CSV_T_HEADER,       DEFAULT_CSV_T_HEADER),
-            msg(CSV_T_DESC_HEADER,  DEFAULT_CSV_T_DESC_HEADER)
+            msg(CSV_DELTA_W_HEADER, DEFAULT_CSV_DELTA_W_HEADER)
         });
     }
 

http://dive4elements.wald.intevation.org