changeset 2185:a9a8df1473fd

Added i18n support to PDF report export. flys-artifacts/trunk@3789 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Raimund Renkert <raimund.renkert@intevation.de>
date Fri, 27 Jan 2012 11:58:35 +0000
parents fc86fcfe503e
children ec2574eb2d32
files flys-artifacts/ChangeLog flys-artifacts/doc/conf/jasper/computed-discharge.jasper flys-artifacts/doc/conf/jasper/computed-discharge_en.jasper flys-artifacts/doc/conf/jasper/duration.jasper flys-artifacts/doc/conf/jasper/duration_en.jasper flys-artifacts/doc/conf/jasper/waterlevel.jasper flys-artifacts/doc/conf/jasper/waterlevel_en.jasper flys-artifacts/doc/conf/jasper/wdifferences.jasper flys-artifacts/doc/conf/jasper/wdifferences_en.jasper flys-artifacts/src/main/java/de/intevation/flys/exports/ComputedDischargeCurveExporter.java flys-artifacts/src/main/java/de/intevation/flys/exports/DurationCurveExporter.java flys-artifacts/src/main/java/de/intevation/flys/exports/WDifferencesExporter.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 17 files changed, 96 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/flys-artifacts/ChangeLog	Fri Jan 27 11:19:16 2012 +0000
+++ b/flys-artifacts/ChangeLog	Fri Jan 27 11:58:35 2012 +0000
@@ -1,3 +1,29 @@
+2012-01-27  Raimund Renkert <raimund.renkert@intevation.de>
+
+	* 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,
+	  src/main/java/de/intevation/flys/exports/WDifferencesExporter.java:
+	  Read jasper template file from resources to support i18n reports.
+
+	* doc/conf/jasper/wdifferences.jasper,
+	  doc/conf/jasper/duration.jasper,
+	  doc/conf/jasper/computed-discharge.jasper,
+	  doc/conf/jasper/waterlevel.jasper:
+	  Updated report template. Resized left margin.
+
+	* doc/conf/jasper/computed-discharge_en.jasper,
+	  doc/conf/jasper/duration_en.jasper,
+	  doc/conf/jasper/wdifferences_en.jasper,
+	  doc/conf/jasper/waterlevel_en.jasper:
+	  New. Templates for english reports.
+
+	* 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 i18n strings for template files and modes.
+
 2012-01-27  Felix Wolfsteller	<felix.wolfsteller@intevation.de>
 
 	* src/main/java/de/intevation/flys/exports/LongitudinalSectionGenerator.java,
Binary file flys-artifacts/doc/conf/jasper/computed-discharge.jasper has changed
Binary file flys-artifacts/doc/conf/jasper/computed-discharge_en.jasper has changed
Binary file flys-artifacts/doc/conf/jasper/duration.jasper has changed
Binary file flys-artifacts/doc/conf/jasper/duration_en.jasper has changed
Binary file flys-artifacts/doc/conf/jasper/waterlevel.jasper has changed
Binary file flys-artifacts/doc/conf/jasper/waterlevel_en.jasper has changed
Binary file flys-artifacts/doc/conf/jasper/wdifferences.jasper has changed
Binary file flys-artifacts/doc/conf/jasper/wdifferences_en.jasper has changed
--- a/flys-artifacts/src/main/java/de/intevation/flys/exports/ComputedDischargeCurveExporter.java	Fri Jan 27 11:19:16 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/ComputedDischargeCurveExporter.java	Fri Jan 27 11:58:35 2012 +0000
@@ -22,6 +22,8 @@
 import net.sf.jasperreports.engine.JasperPrint;
 import net.sf.jasperreports.engine.JRException;
 
+import de.intevation.artifacts.common.utils.Config;
+
 import de.intevation.artifacts.CallContext;
 import de.intevation.artifacts.CallMeta;
 
@@ -56,7 +58,7 @@
     public static final String DEFAULT_CSV_Q_HEADER  = "Q [m\u00b3/s]";
 
     public static final String PDF_HEADER_MODE = "export.computed.discharge.pdf.mode";
-
+    public static final String JASPER_FILE = "export.computed.discharge.pdf.file";
 
     protected List<WQKms> data;
 
@@ -139,11 +141,18 @@
     @Override
     protected void writePDF(OutputStream out) {
         WKmsJRDataSource source = createJRData();
+
+        String jasperFile = Resources.getMsg(
+                                context.getMeta(),
+                                JASPER_FILE,
+                                "/jasper/computed-discharge_en.jasper");
+        String confPath = Config.getConfigDirectory().toString();
+
         Map parameters = new HashMap();
         parameters.put("ReportTitle", "Exported Data");
         try {
             JasperPrint print = JasperFillManager.fillReport(
-                "conf/jasper/computed-discharge.jasper",
+                confPath + jasperFile,
                 parameters,
                 source);
             JasperExportManager.exportReportToPdfStream(print, out);
--- a/flys-artifacts/src/main/java/de/intevation/flys/exports/DurationCurveExporter.java	Fri Jan 27 11:19:16 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/DurationCurveExporter.java	Fri Jan 27 11:58:35 2012 +0000
@@ -23,6 +23,7 @@
 
 import de.intevation.artifacts.CallContext;
 import de.intevation.artifacts.CallMeta;
+import de.intevation.artifacts.common.utils.Config;
 
 import de.intevation.flys.artifacts.FLYSArtifact;
 
@@ -58,6 +59,7 @@
     public static final String DEFAULT_CSV_Q_HEADER  = "Q [m\u00b3/s]";
 
     public static final String PDF_HEADER_MODE = "export.duration.pdf.mode";
+    public static final String JASPER_FILE = "export.duration.pdf.file";
 
     /** The storage that contains all WQKms objects for the different facets. */
     protected List<WQDay> data;
@@ -168,11 +170,18 @@
     @Override
     protected void writePDF(OutputStream out) {
         WKmsJRDataSource source = createJRData();
+
+        String jasperFile = Resources.getMsg(
+                                context.getMeta(),
+                                JASPER_FILE,
+                                "/jasper/duration_en.jasper");
+        String confPath = Config.getConfigDirectory().toString();
+
         Map parameters = new HashMap();
         parameters.put("ReportTitle", "Exported Data");
         try {
             JasperPrint print = JasperFillManager.fillReport(
-                "conf/jasper/duration.jasper",
+                confPath + jasperFile,
                 parameters,
                 source);
             JasperExportManager.exportReportToPdfStream(print, out);
--- a/flys-artifacts/src/main/java/de/intevation/flys/exports/WDifferencesExporter.java	Fri Jan 27 11:19:16 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/WDifferencesExporter.java	Fri Jan 27 11:58:35 2012 +0000
@@ -24,6 +24,7 @@
 
 import de.intevation.artifacts.CallContext;
 import de.intevation.artifacts.CallMeta;
+import de.intevation.artifacts.common.utils.Config;
 
 import de.intevation.flys.artifacts.WINFOArtifact;
 
@@ -54,6 +55,7 @@
     public static final String WDIFF_DEFAULT_CSV_W_HEADER  = "m";
 
     public static final String PDF_HEADER_MODE = "export.wdifferences.pdf.mode";
+    public static final String JASPER_FILE = "export.wdifferences.pdf.file";
 
     /** The storage that contains all WKms objects for the different facets. */
     protected List<WKms[]> data;
@@ -182,11 +184,18 @@
     @Override
     protected void writePDF(OutputStream out) {
         WKmsJRDataSource source = createJRData();
+
+        String jasperFile = Resources.getMsg(
+                                context.getMeta(),
+                                JASPER_FILE,
+                                "/jasper/wdifferences_en.jasper");
+        String confPath = Config.getConfigDirectory().toString();
+
         Map parameters = new HashMap();
         parameters.put("ReportTitle", "Exported Data");
         try {
             JasperPrint print = JasperFillManager.fillReport(
-                "conf/jasper/wdifferences.jasper",
+                confPath + jasperFile,
                 parameters,
                 source);
             JasperExportManager.exportReportToPdfStream(print, out);
--- a/flys-artifacts/src/main/java/de/intevation/flys/exports/WaterlevelExporter.java	Fri Jan 27 11:19:16 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/WaterlevelExporter.java	Fri Jan 27 11:58:35 2012 +0000
@@ -26,6 +26,7 @@
 
 import de.intevation.artifacts.CallContext;
 import de.intevation.artifacts.CallMeta;
+import de.intevation.artifacts.common.utils.Config;
 
 import de.intevation.flys.model.Gauge;
 
@@ -117,6 +118,7 @@
         "außerhalb des gewählten Bezugspegels";
 
     public static final String PDF_HEADER_MODE = "export.waterlevel.pdf.mode";
+    public static final String JASPER_FILE = "export.waterlevel.pdf.file";
 
     /** The storage that contains all WQKms objects for the different facets.*/
     protected List<WQKms[]> data;
@@ -591,11 +593,19 @@
     protected void writePDF(OutputStream out) {
         logger.debug("write PDF");
         WKmsJRDataSource source = createJRData();
+
+        String jasperFile = Resources.getMsg(
+                                context.getMeta(),
+                                JASPER_FILE,
+                                "/jasper/waterlevel_en.jasper");
+        String confPath = Config.getConfigDirectory().toString();
+
+
         Map parameters = new HashMap();
         parameters.put("ReportTitle", "Exported Data");
         try {
             JasperPrint print = JasperFillManager.fillReport(
-                "conf/jasper/waterlevel.jasper",
+                confPath + jasperFile,
                 parameters,
                 source);
             JasperExportManager.exportReportToPdfStream(print, out);
--- a/flys-artifacts/src/main/resources/messages.properties	Fri Jan 27 11:19:16 2012 +0000
+++ b/flys-artifacts/src/main/resources/messages.properties	Fri Jan 27 11:58:35 2012 +0000
@@ -108,6 +108,13 @@
 export.discharge.curve.at.header = Computed Discharge Curve for {0} {0}-km: {1}
 
 export.waterlevel.pdf.mode = Waterlevel
+export.computed.discharge.pdf.mode = Computed Dischargecurve
+export.duration.pdf.mode = Durationcurve
+export.wdifferences.pdf.mode = W Differences
+export.computed.discharge.pdf.file = /jasper/computed-discharge_en.jasper
+export.duration.pdf.file = /jasper/duration_en.jasper
+export.waterlevel.pdf.file = /jasper/waterlevel_en.jasper
+export.wdifferences.pdf.file = /jasper/wdifferences_en.jasper
 
 floodmap.wmsbackground = Background Map
 floodmap.riveraxis = River Axis
--- a/flys-artifacts/src/main/resources/messages_de.properties	Fri Jan 27 11:19:16 2012 +0000
+++ b/flys-artifacts/src/main/resources/messages_de.properties	Fri Jan 27 11:58:35 2012 +0000
@@ -108,6 +108,13 @@
 export.discharge.curve.at.header = Berechnete Abflusskurve f\u00fcr {0} {0}-km: {1}
 
 export.waterlevel.pdf.mode = Wasserstand
+export.computed.discharge.pdf.mode = Abflusskurve
+export.duration.pdf.mode = Dauerlinie
+export.wdifferences.pdf.mode = W Differenzen
+export.computed.discharge.pdf.file = /jasper/computed-discharge.jasper
+export.duration.pdf.file = /jasper/duration.jasper
+export.waterlevel.pdf.file = /jasper/waterlevel.jasper
+export.wdifferences.pdf.file = /jasper/wdifferences.jasper
 
 floodmap.wmsbackground = Hintergrundkarte
 floodmap.riveraxis = Flussachse
--- a/flys-artifacts/src/main/resources/messages_de_DE.properties	Fri Jan 27 11:19:16 2012 +0000
+++ b/flys-artifacts/src/main/resources/messages_de_DE.properties	Fri Jan 27 11:58:35 2012 +0000
@@ -108,6 +108,13 @@
 export.discharge.curve.at.header = Berechnete Abflusskurve f\u00fcr {0} {0}-km: {1}
 
 export.waterlevel.pdf.mode = Wasserstand
+export.computed.discharge.pdf.mode = Abflusskurve
+export.duration.pdf.mode = Dauerline
+export.wdifferences.pdf.mode = W Differenzen
+export.computed.discharge.pdf.file = /jasper/computed-discharge.jasper
+export.duration.pdf.file = /jasper/duration.jasper
+export.waterlevel.pdf.file = /jasper/waterlevel.jasper
+export.wdifferences.pdf.file = /jasper/wdifferences.jasper
 
 floodmap.wmsbackground = Hintergrundkarte
 floodmap.riveraxis = Flussachse
--- a/flys-artifacts/src/main/resources/messages_en.properties	Fri Jan 27 11:19:16 2012 +0000
+++ b/flys-artifacts/src/main/resources/messages_en.properties	Fri Jan 27 11:58:35 2012 +0000
@@ -104,6 +104,13 @@
 export.discharge.curve.at.header = Computed Discharge Curve for {0} {0}-km: {1}
 
 export.waterlevel.pdf.mode = Waterlevel
+export.computed.discharge.pdf.mode = Computed Dischargecurve
+export.duration.pdf.mode = Durationcurve
+export.wdifferences.pdf.mode = W Differences
+export.computed.discharge.pdf.file = /jasper/computed-discharge_en.jasper
+export.duration.pdf.file = /jasper/duration_en.jasper
+export.waterlevel.pdf.file = /jasper/waterlevel_en.jasper
+export.wdifferences.pdf.file = /jasper/wdifferences_en.jasper
 
 floodmap.wmsbackground = Background Map
 floodmap.riveraxis = River Axis

http://dive4elements.wald.intevation.org