# HG changeset patch # User Sascha L. Teichmann # Date 1342628880 0 # Node ID 0336132ec9dbfd0f2ad4cde2ed70bcddf86a598c # Parent 086326be721c521286ca18e4e8d677692c5ffb92 Adjusted Delta W(t) CSV exporter to customers wishes. flys-artifacts/trunk@5044 c6561f87-3c4e-4783-a992-168aeb5c3f6f diff -r 086326be721c -r 0336132ec9db flys-artifacts/ChangeLog --- a/flys-artifacts/ChangeLog Wed Jul 18 14:44:29 2012 +0000 +++ b/flys-artifacts/ChangeLog Wed Jul 18 16:28:00 2012 +0000 @@ -1,3 +1,20 @@ +2012-07-18 Sascha L. Teichmann + + Adjusted Delta W(t) CSV exporter to customers wishes. + + * src/main/java/de/intevation/flys/exports/fixings/DeltaWtExporter.java: + Reordered columns, removed description, added W and formatted date + via i18n. + + * src/main/java/de/intevation/flys/utils/Formatter.java: + Added method to get a formatter based on pattern and locale. + + * src/main/resources/messages.properties, + src/main/resources/messages_de_DE.properties, + src/main/resources/messages_en.properties, + src/main/resources/messages_de.properties: + Adjusted i18n strings. + 2012-07-18 Sascha L. Teichmann * src/main/java/de/intevation/flys/artifacts/model/FixingsOverview.java: diff -r 086326be721c -r 0336132ec9db flys-artifacts/src/main/java/de/intevation/flys/exports/fixings/DeltaWtExporter.java --- 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> 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) }); } diff -r 086326be721c -r 0336132ec9db flys-artifacts/src/main/java/de/intevation/flys/utils/Formatter.java --- a/flys-artifacts/src/main/java/de/intevation/flys/utils/Formatter.java Wed Jul 18 14:44:29 2012 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/utils/Formatter.java Wed Jul 18 16:28:00 2012 +0000 @@ -1,14 +1,16 @@ package de.intevation.flys.utils; -import java.text.DateFormat; -import java.text.NumberFormat; -import java.util.Locale; - import de.intevation.artifacts.CallContext; import de.intevation.artifacts.CallMeta; import de.intevation.flys.artifacts.resources.Resources; +import java.text.DateFormat; +import java.text.NumberFormat; +import java.text.SimpleDateFormat; + +import java.util.Locale; + public final class Formatter { @@ -377,6 +379,12 @@ FIX_DELTA_W_DELTA_Q_MAX_DIGITS); } + public static NumberFormat getFixDeltaWW(CallContext context) { + return getFormatter( + context, + FIX_DELTA_W_DELTA_W_MIN_DIGITS, + FIX_DELTA_W_DELTA_W_MAX_DIGITS); + } public static NumberFormat getMeterFormat(CallContext context) { return getFormatter( @@ -385,5 +393,10 @@ 2); } + + public static DateFormat getDateFormatter(CallMeta m, String pattern) { + Locale locale = Resources.getLocale(m); + return new SimpleDateFormat(pattern, locale); + } } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : diff -r 086326be721c -r 0336132ec9db flys-artifacts/src/main/resources/messages.properties --- a/flys-artifacts/src/main/resources/messages.properties Wed Jul 18 14:44:29 2012 +0000 +++ b/flys-artifacts/src/main/resources/messages.properties Wed Jul 18 16:28:00 2012 +0000 @@ -345,11 +345,12 @@ export.fixings.deltawt.csv.header.km=km export.fixings.deltawt.csv.header.deltaw=\u0394 W [cm] export.fixings.deltawt.csv.header.q=Discharge [m\u00b3/s] +export.fixings.deltawt.csv.header.q=Waterlevel [m] export.fixings.deltawt.csv.header.t=Date -export.fixings.deltawt.csv.header.description=Description -export.fixings.deltawt.csv.header.time.range=Time range -export.fixings.deltawt.csv.reference=Reference -export.fixings.deltawt.csv.analysis=Analysis {0,number,integer} +export.fixings.deltawt.csv.t.format=yyyy/MM/dd +export.fixings.deltawt.csv.header.time.range=State +export.fixings.deltawt.csv.reference=R +export.fixings.deltawt.csv.analysis=A{0,number,integer} fix.missing.river=Missing river fix.missing.from=Missing start km diff -r 086326be721c -r 0336132ec9db flys-artifacts/src/main/resources/messages_de.properties --- a/flys-artifacts/src/main/resources/messages_de.properties Wed Jul 18 14:44:29 2012 +0000 +++ b/flys-artifacts/src/main/resources/messages_de.properties Wed Jul 18 16:28:00 2012 +0000 @@ -346,11 +346,12 @@ export.fixings.deltawt.csv.header.km=km export.fixings.deltawt.csv.header.deltaw=\u0394 W [cm] export.fixings.deltawt.csv.header.q=Abfluss [m\u00b3/s] +export.fixings.deltawt.csv.header.w=Wasserstand [m] export.fixings.deltawt.csv.header.t=Datum -export.fixings.deltawt.csv.header.description=Beschreibung -export.fixings.deltawt.csv.header.time.range=Zeitraum -export.fixings.deltawt.csv.reference=Bezug -export.fixings.deltawt.csv.analysis=Analyse {0,number,integer} +export.fixings.deltawt.csv.t.format=dd.MM.yyyy +export.fixings.deltawt.csv.header.time.range=Status +export.fixings.deltawt.csv.reference=B +export.fixings.deltawt.csv.analysis=A{0,number,integer} fix.missing.river=Kein Gew\u00e4sser gew\u00e4hlt fix.missing.from=Kein Startkilometer gew\u00e4hlt diff -r 086326be721c -r 0336132ec9db flys-artifacts/src/main/resources/messages_de_DE.properties --- a/flys-artifacts/src/main/resources/messages_de_DE.properties Wed Jul 18 14:44:29 2012 +0000 +++ b/flys-artifacts/src/main/resources/messages_de_DE.properties Wed Jul 18 16:28:00 2012 +0000 @@ -345,11 +345,12 @@ export.fixings.deltawt.csv.header.km=km export.fixings.deltawt.csv.header.deltaw=\u0394 W [cm] export.fixings.deltawt.csv.header.q=Abfluss [m\u00b3/s] +export.fixings.deltawt.csv.header.w=Wasserstand [m] export.fixings.deltawt.csv.header.t=Datum -export.fixings.deltawt.csv.header.description=Beschreibung -export.fixings.deltawt.csv.header.time.range=Zeitraum -export.fixings.deltawt.csv.reference=Bezug -export.fixings.deltawt.csv.analysis=Analyse {0,number,integer} +export.fixings.deltawt.csv.t.format=dd.MM.yyyy +export.fixings.deltawt.csv.header.time.range=Status +export.fixings.deltawt.csv.reference=B +export.fixings.deltawt.csv.analysis=A{0,number,integer} fix.missing.river=Kein Gew\u00e4sser gew\u00e4hlt fix.missing.from=Kein Startkilometer gew\u00e4hlt diff -r 086326be721c -r 0336132ec9db flys-artifacts/src/main/resources/messages_en.properties --- a/flys-artifacts/src/main/resources/messages_en.properties Wed Jul 18 14:44:29 2012 +0000 +++ b/flys-artifacts/src/main/resources/messages_en.properties Wed Jul 18 16:28:00 2012 +0000 @@ -345,11 +345,12 @@ export.fixings.deltawt.csv.header.km=km export.fixings.deltawt.csv.header.deltaw=\u0394 W [cm] export.fixings.deltawt.csv.header.q=Discharge [m\u00b3/s] +export.fixings.deltawt.csv.header.w=Waterlevel [m] export.fixings.deltawt.csv.header.t=Date -export.fixings.deltawt.csv.header.description=Description -export.fixings.deltawt.csv.header.time.range=Time range -export.fixings.deltawt.csv.reference=Reference -export.fixings.deltawt.csv.analysis=Analysis {0,number,integer} +export.fixings.deltawt.csv.t.format=yyyy/MM/dd +export.fixings.deltawt.csv.header.time.range=State +export.fixings.deltawt.csv.reference=R +export.fixings.deltawt.csv.analysis=A{0,number,integer} fix.missing.river=Missing river fix.missing.from=Missing start km