Mercurial > dive4elements > river
changeset 416:340dc41a7ea3
The CSV exports will now have headers.
flys-artifacts/trunk@1880 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Tue, 10 May 2011 13:18:03 +0000 (2011-05-10) |
parents | 7c018f466d6d |
children | e54053bc0e70 |
files | flys-artifacts/ChangeLog flys-artifacts/src/main/java/de/intevation/flys/exports/AbstractExporter.java flys-artifacts/src/main/java/de/intevation/flys/exports/ComputedDischargeCurveExporter.java flys-artifacts/src/main/java/de/intevation/flys/exports/DischargeLongitudinalSectionExporter.java flys-artifacts/src/main/java/de/intevation/flys/exports/DurationCurveExporter.java flys-artifacts/src/main/java/de/intevation/flys/exports/WaterlevelExporter.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 | 10 files changed, 182 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/flys-artifacts/ChangeLog Tue May 10 12:43:12 2011 +0000 +++ b/flys-artifacts/ChangeLog Tue May 10 13:18:03 2011 +0000 @@ -1,3 +1,20 @@ +2011-05-10 Ingo Weinzierl <ingo@intevation.de> + + * src/main/java/de/intevation/flys/exports/AbstractExporter.java: New + method to retrieve i18n messages based on keys. + + * src/main/java/de/intevation/flys/exports/DischargeLongitudinalSectionExporter.java, + src/main/java/de/intevation/flys/exports/WaterlevelExporter.java, + src/main/java/de/intevation/flys/exports/DurationCurveExporter.java, + src/main/java/de/intevation/flys/exports/ComputedDischargeCurveExporter.java: + Added headers for CSV exports. + + * 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 new i18n strings for + CSV headers. + 2011-05-10 Sascha L. Teichmann <sascha.teichmann@intevation.de> * src/main/java/de/intevation/flys/artifacts/services/MetaDataService.java:
--- a/flys-artifacts/src/main/java/de/intevation/flys/exports/AbstractExporter.java Tue May 10 12:43:12 2011 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/AbstractExporter.java Tue May 10 13:18:03 2011 +0000 @@ -13,6 +13,8 @@ import de.intevation.artifacts.Artifact; import de.intevation.artifacts.CallContext; +import de.intevation.flys.artifacts.resources.Resources; + /** * An abstract exporter that implements some basic methods for exporting data of @@ -152,6 +154,12 @@ } + + protected String msg(String key, String def) { + return Resources.getMsg(context.getMeta(), key, def); + } + + /** * This method starts CSV creation. It makes use of writeCSVData() which has * to be implemented by concrete subclasses.
--- a/flys-artifacts/src/main/java/de/intevation/flys/exports/ComputedDischargeCurveExporter.java Tue May 10 12:43:12 2011 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/ComputedDischargeCurveExporter.java Tue May 10 13:18:03 2011 +0000 @@ -26,6 +26,15 @@ private static Logger logger = Logger.getLogger(ComputedDischargeCurveExporter.class); + public static final String CSV_W_HEADER = + "export.computed.discharge.curve.csv.header.w"; + + public static final String CSV_Q_HEADER = + "export.computed.discharge.curve.csv.header.q"; + + public static final String DEFAULT_CSV_W_HEADER = "W [NN + m]"; + public static final String DEFAULT_CSV_Q_HEADER = "Q [m³/s]"; + protected List<WQKms> data; @@ -48,6 +57,8 @@ protected void writeCSVData(CSVWriter writer) { logger.info("ComputedDischargeCurveExporter.writeData"); + writeCSVHeader(writer); + double[] res = new double[3]; for (WQKms wqkms: data) { @@ -63,5 +74,15 @@ } } } + + + protected void writeCSVHeader(CSVWriter writer) { + logger.debug("ComputedDischargeCurveExporter.writeCSVHeader"); + + writer.writeNext(new String[] { + msg(CSV_W_HEADER, DEFAULT_CSV_W_HEADER), + msg(CSV_Q_HEADER, DEFAULT_CSV_Q_HEADER) + }); + } } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- a/flys-artifacts/src/main/java/de/intevation/flys/exports/DischargeLongitudinalSectionExporter.java Tue May 10 12:43:12 2011 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/DischargeLongitudinalSectionExporter.java Tue May 10 13:18:03 2011 +0000 @@ -20,6 +20,24 @@ Logger.getLogger(DischargeLongitudinalSectionExporter.class); + public static final String CSV_KM_HEADER = + "export.discharge.longitudinal.section.csv.header.km"; + + public static final String CSV_W_HEADER = + "export.discharge.longitudinal.section.csv.header.w"; + + public static final String CSV_CW_HEADER = + "export.discharge.longitudinal.section.csv.header.cw"; + + public static final String CSV_Q_HEADER = + "export.discharge.longitudinal.section.csv.header.q"; + + public static final String DEFAULT_CSV_KM_HEADER = "Fluss-Km"; + public static final String DEFAULT_CSV_W_HEADER = "W [NN + m]"; + public static final String DEFAULT_CSV_CW_HEADER = "W korr."; + public static final String DEFAULT_CSV_Q_HEADER = "Q [m³/s]"; + + @Override protected void addData(Artifact artifact) { WINFOArtifact winfo = (WINFOArtifact) artifact; @@ -32,6 +50,18 @@ @Override + protected void writeCSVHeader(CSVWriter writer) { + logger.info("WaterlevelExporter.writeCSVHeader"); + + writer.writeNext(new String[] { + msg(CSV_KM_HEADER, DEFAULT_CSV_KM_HEADER), + msg(CSV_W_HEADER, DEFAULT_CSV_W_HEADER), + msg(CSV_CW_HEADER, DEFAULT_CSV_CW_HEADER), + msg(CSV_Q_HEADER, DEFAULT_CSV_Q_HEADER) + }); + } + + @Override protected void wQKms2CSV(CSVWriter writer, WQKms wqkms) { logger.debug("WaterlevelExporter.wQKms2CSV");
--- a/flys-artifacts/src/main/java/de/intevation/flys/exports/DurationCurveExporter.java Tue May 10 12:43:12 2011 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/DurationCurveExporter.java Tue May 10 13:18:03 2011 +0000 @@ -26,6 +26,20 @@ private static Logger logger = Logger.getLogger(WaterlevelExporter.class); + public static final String CSV_DURATION_HEADER = + "export.duration.curve.csv.header.duration"; + + public static final String CSV_W_HEADER = + "export.duration.curve.csv.header.w"; + + public static final String CSV_Q_HEADER = + "export.duration.curve.csv.header.q"; + + public static final String DEFAULT_CSV_DURATION_HEADER = "D [Tagen]"; + public static final String DEFAULT_CSV_W_HEADER = "W [NN + m]"; + public static final String DEFAULT_CSV_Q_HEADER = "Q [m³/s]"; + + /** The storage that contains all WQKms objects for the different facets.*/ protected List<WQDay> data; @@ -48,12 +62,25 @@ protected void writeCSVData(CSVWriter writer) { logger.info("DurationCurveExporter.writeData"); + writeCSVHeader(writer); + for (WQDay wqday: data) { wQDay2CSV(writer, wqday); } } + protected void writeCSVHeader(CSVWriter writer) { + logger.info("DurationCurveExporter.writeCSVHeader"); + + writer.writeNext(new String[] { + msg(CSV_W_HEADER, DEFAULT_CSV_W_HEADER), + msg(CSV_Q_HEADER, DEFAULT_CSV_Q_HEADER), + msg(CSV_DURATION_HEADER, DEFAULT_CSV_DURATION_HEADER) + }); + } + + protected void wQDay2CSV(CSVWriter writer, WQDay wqday) { logger.debug("DurationCurveExporter.wQDay2CSV");
--- a/flys-artifacts/src/main/java/de/intevation/flys/exports/WaterlevelExporter.java Tue May 10 12:43:12 2011 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/WaterlevelExporter.java Tue May 10 13:18:03 2011 +0000 @@ -26,6 +26,20 @@ private static Logger logger = Logger.getLogger(WaterlevelExporter.class); + public static final String CSV_KM_HEADER = + "export.waterlevel.csv.header.km"; + + public static final String CSV_W_HEADER = + "export.waterlevel.csv.header.w"; + + public static final String CSV_Q_HEADER = + "export.waterlevel.csv.header.q"; + + public static final String DEFAULT_CSV_KM_HEADER = "Fluss-Km"; + public static final String DEFAULT_CSV_W_HEADER = "W [NN + m]"; + public static final String DEFAULT_CSV_Q_HEADER = "Q [m³/s]"; + + /** The storage that contains all WQKms objects for the different facets.*/ protected List<WQKms[]> data; @@ -64,6 +78,8 @@ protected void writeCSVData(CSVWriter writer) { logger.info("WaterlevelExporter.writeData"); + writeCSVHeader(writer); + for (WQKms[] tmp: data) { for (WQKms wqkms: tmp) { wQKms2CSV(writer, wqkms); @@ -72,6 +88,17 @@ } + protected void writeCSVHeader(CSVWriter writer) { + logger.info("WaterlevelExporter.writeCSVHeader"); + + writer.writeNext(new String[] { + msg(CSV_KM_HEADER, DEFAULT_CSV_KM_HEADER), + msg(CSV_W_HEADER, DEFAULT_CSV_W_HEADER), + msg(CSV_Q_HEADER, DEFAULT_CSV_Q_HEADER) + }); + } + + protected void wQKms2CSV(CSVWriter writer, WQKms wqkms) { logger.debug("WaterlevelExporter.wQKms2CSV");
--- a/flys-artifacts/src/main/resources/messages.properties Tue May 10 12:43:12 2011 +0000 +++ b/flys-artifacts/src/main/resources/messages.properties Tue May 10 13:18:03 2011 +0000 @@ -30,3 +30,16 @@ chart.duration.curve.subtitle = {0}-km: {1,number,#.###} chart.duration.curve.xaxis.label = Duration of Non-Exceedence [Days] chart.duration.curve.yaxis.label = W [NN + m] + +export.waterlevel.csv.header.km = River-Km +export.waterlevel.csv.header.w = W [NN + m] +export.waterlevel.csv.header.q = Q [m\u00b3/s] +export.computed.discharge.curve.csv.header.w = W [NN + m] +export.computed.discharge.curve.csv.header.q = Q [m\u00b3/s] +export.duration.curve.csv.header.duration = D [Days] +export.duration.curve.csv.header.w = W [NN + m] +export.duration.curve.csv.header.q = Q [m\u00b3/s] +export.discharge.longitudinal.section.csv.header.km = River-Km +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]
--- a/flys-artifacts/src/main/resources/messages_de.properties Tue May 10 12:43:12 2011 +0000 +++ b/flys-artifacts/src/main/resources/messages_de.properties Tue May 10 13:18:03 2011 +0000 @@ -30,3 +30,16 @@ chart.duration.curve.subtitle = {0}-km: {1,number,#.###} chart.duration.curve.xaxis.label = Unterschreitungsdauer [Tage] chart.duration.curve.yaxis.label = W [NN + m] + +export.waterlevel.csv.header.km = Fluss-Km +export.waterlevel.csv.header.w = W [NN + m] +export.waterlevel.csv.header.q = Q [m\u00b3/s] +export.computed.discharge.curve.csv.header.w = W [NN + m] +export.computed.discharge.curve.csv.header.q = Q [m\u00b3/s] +export.duration.curve.csv.header.duration = D [Tagen] +export.duration.curve.csv.header.w = W [NN + m] +export.duration.curve.csv.header.q = Q [m\u00b3/s] +export.discharge.longitudinal.section.csv.header.km = Fluss-Km +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]
--- a/flys-artifacts/src/main/resources/messages_de_DE.properties Tue May 10 12:43:12 2011 +0000 +++ b/flys-artifacts/src/main/resources/messages_de_DE.properties Tue May 10 13:18:03 2011 +0000 @@ -30,3 +30,16 @@ chart.duration.curve.subtitle = {0}-km: {1,number,#.###} chart.duration.curve.xaxis.label = Unterschreitungsdauer [Tage] chart.duration.curve.yaxis.label = W [NN + m] + +export.waterlevel.csv.header.km = Fluss-Km +export.waterlevel.csv.header.w = W [NN + m] +export.waterlevel.csv.header.q = Q [m\u00b3/s] +export.computed.discharge.curve.csv.header.w = W [NN + m] +export.computed.discharge.curve.csv.header.q = Q [m\u00b3/s] +export.duration.curve.csv.header.duration = D [Tagen] +export.duration.curve.csv.header.w = W [NN + m] +export.duration.curve.csv.header.q = Q [m\u00b3/s] +export.discharge.longitudinal.section.csv.header.km = Fluss-Km +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]
--- a/flys-artifacts/src/main/resources/messages_en.properties Tue May 10 12:43:12 2011 +0000 +++ b/flys-artifacts/src/main/resources/messages_en.properties Tue May 10 13:18:03 2011 +0000 @@ -30,3 +30,16 @@ chart.duration.curve.subtitle = {0}-km: {1,number,#.###} chart.duration.curve.xaxis.label = Duration of Non-Exceedence [Days] chart.duration.curve.yaxis.label = W [NN + m] + +export.waterlevel.csv.header.km = River-Km +export.waterlevel.csv.header.w = W [NN + m] +export.waterlevel.csv.header.q = Q [m\u00b3/s] +export.computed.discharge.curve.csv.header.w = W [NN + m] +export.computed.discharge.curve.csv.header.q = Q [m\u00b3/s] +export.duration.curve.csv.header.duration = D [Days] +export.duration.curve.csv.header.w = W [NN + m] +export.duration.curve.csv.header.q = Q [m\u00b3/s] +export.discharge.longitudinal.section.csv.header.km = River-Km +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]