changeset 3216:a46910e61dfb

FixA: Moved DeltaWtExporter to fixings exporter package. flys-artifacts/trunk@4839 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Sat, 30 Jun 2012 19:44:39 +0000
parents 750e98fc8b76
children 79dd823733e2
files flys-artifacts/ChangeLog flys-artifacts/doc/conf/conf.xml flys-artifacts/src/main/java/de/intevation/flys/exports/DeltaWtExporter.java flys-artifacts/src/main/java/de/intevation/flys/exports/fixings/DeltaWtExporter.java
diffstat 4 files changed, 212 insertions(+), 201 deletions(-) [+]
line wrap: on
line diff
--- a/flys-artifacts/ChangeLog	Fri Jun 29 15:40:43 2012 +0000
+++ b/flys-artifacts/ChangeLog	Sat Jun 30 19:44:39 2012 +0000
@@ -1,3 +1,12 @@
+2012-06-30	Sascha L. Teichmann	<sascha.teichmann@intevation.de>
+
+	* src/main/java/de/intevation/flys/exports/DeltaWtExporter.java:
+	  Deleted
+
+	* src/main/java/de/intevation/flys/exports/fixings/DeltaWtExporter.java:
+	  Re-added here
+
+	* doc/conf/conf.xml: Adjusted package name of DeltaWtExporter.
 2012-06-29	Sascha L. Teichmann	<sascha.teichmann@intevation.de>
 
 	* src/main/java/de/intevation/flys/exports/fixings/FixDerivedCurveInfoGenerator.java:
--- a/flys-artifacts/doc/conf/conf.xml	Fri Jun 29 15:40:43 2012 +0000
+++ b/flys-artifacts/doc/conf/conf.xml	Sat Jun 30 19:44:39 2012 +0000
@@ -264,7 +264,7 @@
         <output-generator name="sq_relation_e_chartinfo">de.intevation.flys.exports.sq.SQRelationInfoGenerator</output-generator>
         <output-generator name="sq_relation_f_chartinfo">de.intevation.flys.exports.sq.SQRelationInfoGenerator</output-generator>
         <output-generator name="sq_relation_export">de.intevation.flys.exports.SQRelationExporter</output-generator>
-        <output-generator name="fix_deltawt_export">de.intevation.flys.exports.DeltaWtExporter</output-generator>
+        <output-generator name="fix_deltawt_export">de.intevation.flys.exports.fixings.DeltaWtExporter</output-generator>
         <output-generator name="fix_deltawt_curve">de.intevation.flys.exports.fixings.FixDeltaWtGenerator</output-generator>
         <output-generator name="fix_longitudinal_section_curve">de.intevation.flys.exports.fixings.FixLongitudinalSectionGenerator</output-generator>
         <output-generator name="fix_longitudinal_section_curve_chartinfo">de.intevation.flys.exports.fixings.FixLongitudinalSectionInfoGenerator</output-generator>
--- a/flys-artifacts/src/main/java/de/intevation/flys/exports/DeltaWtExporter.java	Fri Jun 29 15:40:43 2012 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,200 +0,0 @@
-package de.intevation.flys.exports;
-
-import au.com.bytecode.opencsv.CSVWriter;
-
-import de.intevation.artifacts.CallContext;
-import de.intevation.artifacts.CallMeta;
-
-import de.intevation.flys.artifacts.model.CalculationResult;
-
-import de.intevation.flys.artifacts.model.fixings.FixResult;
-import de.intevation.flys.artifacts.model.fixings.AnalysisPeriod;
-import de.intevation.flys.artifacts.model.fixings.QWD;
-
-import de.intevation.flys.artifacts.resources.Resources;
-
-import de.intevation.flys.utils.Formatter;
-import de.intevation.flys.utils.KMIndex;
-
-import java.io.IOException;
-import java.io.OutputStream;
-
-import java.text.DateFormat;
-import java.text.NumberFormat;
-
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.List;
-import java.util.Locale;
-
-import org.apache.log4j.Logger;
-
-import org.w3c.dom.Document;
-
-public class DeltaWtExporter
-extends      AbstractExporter
-{
-    private static Logger log = Logger.getLogger(DeltaWtExporter.class);
-
-    public static final String CSV_KM_HEADER =
-        "export.fixings.deltawt.csv.header.km";
-
-    public static final String CSV_DELTA_W_HEADER =
-        "export.fixings.deltawt.csv.header.deltaw";
-
-    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 DEFAULT_CSV_KM_HEADER = "km";
-
-    public static final String DEFAULT_CSV_DELTA_W_HEADER = "\u0394 W [cm]";
-
-    public static final String DEFAULT_CSV_T_HEADER = "Datum";
-
-    public static final String DEFAULT_CSV_T_DESC_HEADER = "Beschreibung";
-
-    protected List<KMIndex<AnalysisPeriod []>> analysisPeriods;
-
-    protected List<KMIndex<QWD[]>> referenceEvents;
-
-    @Override
-    public void init(Document request, OutputStream out, CallContext context) {
-        log.debug("DeltaWtExporter.init");
-        super.init(request, out, context);
-        analysisPeriods = new ArrayList<KMIndex<AnalysisPeriod []>>();
-        referenceEvents = new ArrayList<KMIndex<QWD[]>>();
-    }
-
-    @Override
-    public void generate() throws IOException {
-        log.debug("DeltaWtExporter.generate");
-        if (facet == null) {
-            throw new IOException("invalid (null) facet for exporter");
-        }
-        else if (facet.equals(FACET_CSV)) {
-            generateCSV();
-        }
-        else if (facet.equals(FACET_PDF)) {
-            generatePDF();
-        }
-        else {
-            throw new IOException("invalid facet (" + facet + ") for exporter");
-        }
-    }
-
-    @Override
-    protected void addData(Object d) {
-        log.debug("DeltaWtExporter.addData");
-        if (!(d instanceof CalculationResult)) {
-            log.warn("Invalid data type");
-            return;
-        }
-
-        Object data = ((CalculationResult)d).getData();
-        if (!(data instanceof FixResult)) {
-            log.warn("Invalid data stored in result.");
-        }
-        FixResult result = (FixResult)data;
-        analysisPeriods.add(result.getAnalysisPeriods());
-        referenceEvents.add(result.getReferenced());
-    }
-
-    @Override
-    protected void writeCSVData(CSVWriter writer) throws IOException {
-
-        boolean debug = log.isDebugEnabled();
-
-        writeCSVHeader(writer);
-
-        NumberFormat kmF = getKMFormatter();
-        NumberFormat dwF = getDeltaWFormatter();
-
-        CallMeta meta = context.getMeta();
-        Locale locale = Resources.getLocale(meta);
-        DateFormat dF = DateFormat.getDateInstance(DateFormat.SHORT, locale);
-
-        for (KMIndex<QWD[]> reference: referenceEvents) {
-
-            for (KMIndex.Entry<QWD[]> kmEntry: reference) {
-
-               String kmS = kmF.format(kmEntry.getKm());
-               for (QWD qwd: kmEntry.getValue()) {
-                    double deltaW = qwd.getDeltaW();
-                    Date   date   = qwd.getDate();
-                    String desc   = qwd.getDescription();
-
-                    String deltaWS = dwF.format(deltaW);
-                    String dateS   = dF.format(date);
-
-                    writer.writeNext(new String[] {
-                        kmS,
-                        deltaWS,
-                        dateS,
-                        desc != null ? desc : "" });
-               }
-            }
-        }
-
-        if (debug) {
-            log.debug("AnalysisPeriods: " + analysisPeriods.size());
-        }
-
-        for (KMIndex<AnalysisPeriod []> periods: analysisPeriods) {
-
-            for (KMIndex.Entry<AnalysisPeriod []> kmEntry: periods) {
-
-                String kmS = kmF.format(kmEntry.getKm());
-
-                for (AnalysisPeriod period: kmEntry.getValue()) {
-                    QWD [] qwds = period.getQWDs();
-                    if (qwds != null) {
-                        for (QWD qwd: qwds) {
-                            double deltaW = qwd.getDeltaW();
-                            Date   date   = qwd.getDate();
-                            String desc   = qwd.getDescription();
-
-                            String deltaWS = dwF.format(deltaW);
-                            String dateS   = dF.format(date);
-
-                            writer.writeNext(new String[] {
-                                kmS,
-                                deltaWS,
-                                dateS,
-                                desc != null ? desc : "" });
-                        }
-                    }
-                }
-            }
-        }
-        writer.flush();
-    }
-
-
-    protected NumberFormat getKMFormatter() {
-        return Formatter.getFixDeltaWKM(context);
-    }
-
-    protected NumberFormat getDeltaWFormatter() {
-        return Formatter.getFixDeltaWDeltaW(context);
-    }
-
-    protected void writeCSVHeader(CSVWriter writer) {
-        log.debug("DeltaWtExporter.writeCSVHeader");
-
-        writer.writeNext(new String[] {
-            msg(CSV_KM_HEADER,      DEFAULT_CSV_KM_HEADER),
-            msg(CSV_DELTA_W_HEADER, DEFAULT_CSV_DELTA_W_HEADER),
-            msg(CSV_T_HEADER,       DEFAULT_CSV_T_HEADER),
-            msg(CSV_T_DESC_HEADER,  DEFAULT_CSV_T_DESC_HEADER)
-        });
-    }
-
-    @Override
-    protected void writePDF(OutputStream out) {
-        // TODO: Implement me!
-    }
-}
-// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/fixings/DeltaWtExporter.java	Sat Jun 30 19:44:39 2012 +0000
@@ -0,0 +1,202 @@
+package de.intevation.flys.exports.fixings;
+
+import au.com.bytecode.opencsv.CSVWriter;
+
+import de.intevation.artifacts.CallContext;
+import de.intevation.artifacts.CallMeta;
+
+import de.intevation.flys.artifacts.model.CalculationResult;
+
+import de.intevation.flys.artifacts.model.fixings.AnalysisPeriod;
+import de.intevation.flys.artifacts.model.fixings.FixResult;
+import de.intevation.flys.artifacts.model.fixings.QWD;
+
+import de.intevation.flys.artifacts.resources.Resources;
+
+import de.intevation.flys.exports.AbstractExporter;
+
+import de.intevation.flys.utils.Formatter;
+import de.intevation.flys.utils.KMIndex;
+
+import java.io.IOException;
+import java.io.OutputStream;
+
+import java.text.DateFormat;
+import java.text.NumberFormat;
+
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+import java.util.Locale;
+
+import org.apache.log4j.Logger;
+
+import org.w3c.dom.Document;
+
+public class DeltaWtExporter
+extends      AbstractExporter
+{
+    private static Logger log = Logger.getLogger(DeltaWtExporter.class);
+
+    public static final String CSV_KM_HEADER =
+        "export.fixings.deltawt.csv.header.km";
+
+    public static final String CSV_DELTA_W_HEADER =
+        "export.fixings.deltawt.csv.header.deltaw";
+
+    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 DEFAULT_CSV_KM_HEADER = "km";
+
+    public static final String DEFAULT_CSV_DELTA_W_HEADER = "\u0394 W [cm]";
+
+    public static final String DEFAULT_CSV_T_HEADER = "Datum";
+
+    public static final String DEFAULT_CSV_T_DESC_HEADER = "Beschreibung";
+
+    protected List<KMIndex<AnalysisPeriod []>> analysisPeriods;
+
+    protected List<KMIndex<QWD[]>> referenceEvents;
+
+    @Override
+    public void init(Document request, OutputStream out, CallContext context) {
+        log.debug("DeltaWtExporter.init");
+        super.init(request, out, context);
+        analysisPeriods = new ArrayList<KMIndex<AnalysisPeriod []>>();
+        referenceEvents = new ArrayList<KMIndex<QWD[]>>();
+    }
+
+    @Override
+    public void generate() throws IOException {
+        log.debug("DeltaWtExporter.generate");
+        if (facet == null) {
+            throw new IOException("invalid (null) facet for exporter");
+        }
+        else if (facet.equals(FACET_CSV)) {
+            generateCSV();
+        }
+        else if (facet.equals(FACET_PDF)) {
+            generatePDF();
+        }
+        else {
+            throw new IOException("invalid facet (" + facet + ") for exporter");
+        }
+    }
+
+    @Override
+    protected void addData(Object d) {
+        log.debug("DeltaWtExporter.addData");
+        if (!(d instanceof CalculationResult)) {
+            log.warn("Invalid data type");
+            return;
+        }
+
+        Object data = ((CalculationResult)d).getData();
+        if (!(data instanceof FixResult)) {
+            log.warn("Invalid data stored in result.");
+        }
+        FixResult result = (FixResult)data;
+        analysisPeriods.add(result.getAnalysisPeriods());
+        referenceEvents.add(result.getReferenced());
+    }
+
+    @Override
+    protected void writeCSVData(CSVWriter writer) throws IOException {
+
+        boolean debug = log.isDebugEnabled();
+
+        writeCSVHeader(writer);
+
+        NumberFormat kmF = getKMFormatter();
+        NumberFormat dwF = getDeltaWFormatter();
+
+        CallMeta meta = context.getMeta();
+        Locale locale = Resources.getLocale(meta);
+        DateFormat dF = DateFormat.getDateInstance(DateFormat.SHORT, locale);
+
+        for (KMIndex<QWD[]> reference: referenceEvents) {
+
+            for (KMIndex.Entry<QWD[]> kmEntry: reference) {
+
+               String kmS = kmF.format(kmEntry.getKm());
+               for (QWD qwd: kmEntry.getValue()) {
+                    double deltaW = qwd.getDeltaW();
+                    Date   date   = qwd.getDate();
+                    String desc   = qwd.getDescription();
+
+                    String deltaWS = dwF.format(deltaW);
+                    String dateS   = dF.format(date);
+
+                    writer.writeNext(new String[] {
+                        kmS,
+                        deltaWS,
+                        dateS,
+                        desc != null ? desc : "" });
+               }
+            }
+        }
+
+        if (debug) {
+            log.debug("AnalysisPeriods: " + analysisPeriods.size());
+        }
+
+        for (KMIndex<AnalysisPeriod []> periods: analysisPeriods) {
+
+            for (KMIndex.Entry<AnalysisPeriod []> kmEntry: periods) {
+
+                String kmS = kmF.format(kmEntry.getKm());
+
+                for (AnalysisPeriod period: kmEntry.getValue()) {
+                    QWD [] qwds = period.getQWDs();
+                    if (qwds != null) {
+                        for (QWD qwd: qwds) {
+                            double deltaW = qwd.getDeltaW();
+                            Date   date   = qwd.getDate();
+                            String desc   = qwd.getDescription();
+
+                            String deltaWS = dwF.format(deltaW);
+                            String dateS   = dF.format(date);
+
+                            writer.writeNext(new String[] {
+                                kmS,
+                                deltaWS,
+                                dateS,
+                                desc != null ? desc : "" });
+                        }
+                    }
+                }
+            }
+        }
+        writer.flush();
+    }
+
+
+    protected NumberFormat getKMFormatter() {
+        return Formatter.getFixDeltaWKM(context);
+    }
+
+    protected NumberFormat getDeltaWFormatter() {
+        return Formatter.getFixDeltaWDeltaW(context);
+    }
+
+    protected void writeCSVHeader(CSVWriter writer) {
+        log.debug("DeltaWtExporter.writeCSVHeader");
+
+        writer.writeNext(new String[] {
+            msg(CSV_KM_HEADER,      DEFAULT_CSV_KM_HEADER),
+            msg(CSV_DELTA_W_HEADER, DEFAULT_CSV_DELTA_W_HEADER),
+            msg(CSV_T_HEADER,       DEFAULT_CSV_T_HEADER),
+            msg(CSV_T_DESC_HEADER,  DEFAULT_CSV_T_DESC_HEADER)
+        });
+    }
+
+    @Override
+    protected void writePDF(OutputStream out) {
+        // TODO: Implement me!
+    }
+}
+// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org