# HG changeset patch
# User gernotbelger
# Date 1535457743 -7200
# Node ID 65f28328c9a32a359c0026e11114fa2876ef890c
# Parent c96f6c8a6b03cf8640a79ede3761eea8b72cbfb3
ausgelagerte Wasserspiegellage AWSPL neue Spalte
diff -r c96f6c8a6b03 -r 65f28328c9a3 artifacts/doc/conf/artifacts/bundu.xml
--- a/artifacts/doc/conf/artifacts/bundu.xml Tue Aug 28 13:50:05 2018 +0200
+++ b/artifacts/doc/conf/artifacts/bundu.xml Tue Aug 28 14:02:23 2018 +0200
@@ -545,7 +545,7 @@
-
+
diff -r c96f6c8a6b03 -r 65f28328c9a3 artifacts/doc/conf/generators/generators.xml
--- a/artifacts/doc/conf/generators/generators.xml Tue Aug 28 13:50:05 2018 +0200
+++ b/artifacts/doc/conf/generators/generators.xml Tue Aug 28 14:02:23 2018 +0200
@@ -39,7 +39,7 @@
-
+
diff -r c96f6c8a6b03 -r 65f28328c9a3 artifacts/doc/conf/jasper/templates/fix_waterlevel.jrxml
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/artifacts/doc/conf/jasper/templates/fix_waterlevel.jrxml Tue Aug 28 14:02:23 2018 +0200
@@ -0,0 +1,271 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff -r c96f6c8a6b03 -r 65f28328c9a3 artifacts/src/main/java/org/dive4elements/river/exports/FixWaterlevelExporter.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/artifacts/src/main/java/org/dive4elements/river/exports/FixWaterlevelExporter.java Tue Aug 28 14:02:23 2018 +0200
@@ -0,0 +1,259 @@
+/* Copyright (C) 2011, 2012, 2013 by Bundesanstalt für Gewässerkunde
+ * Software engineering by Intevation GmbH
+ *
+ * This file is Free Software under the GNU AGPL (>=v3)
+ * and comes with ABSOLUTELY NO WARRANTY! Check out the
+ * documentation coming with Dive4Elements River for details.
+ */
+
+package org.dive4elements.river.exports;
+
+import java.io.OutputStream;
+import java.text.NumberFormat;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.log4j.Logger;
+import org.dive4elements.river.artifacts.D4EArtifact;
+import org.dive4elements.river.artifacts.access.RangeAccess;
+import org.dive4elements.river.artifacts.common.DefaultCalculationResults;
+import org.dive4elements.river.artifacts.common.ExportContextPDF;
+import org.dive4elements.river.artifacts.common.GeneralResultType;
+import org.dive4elements.river.artifacts.common.JasperReporter;
+import org.dive4elements.river.artifacts.common.MetaAndTableJRDataSource;
+import org.dive4elements.river.artifacts.model.ConstantWQKms;
+import org.dive4elements.river.artifacts.model.DischargeTables;
+import org.dive4elements.river.artifacts.model.WQKms;
+import org.dive4elements.river.artifacts.sinfo.util.CalculationUtils;
+import org.dive4elements.river.artifacts.sinfo.util.RiverInfo;
+import org.dive4elements.river.model.Gauge;
+import org.dive4elements.river.utils.Formatter;
+import org.dive4elements.river.utils.RiverUtils;
+import org.dive4elements.river.utils.RiverUtils.WQ_MODE;
+
+import au.com.bytecode.opencsv.CSVWriter;
+import net.sf.jasperreports.engine.JRException;
+
+/**
+ * Generates different output formats (wst, csv, pdf) of data that resulted from
+ * a waterlevel computation.
+ *
+ * @author Ingo Weinzierl
+ */
+public class FixWaterlevelExporter extends WaterlevelExporter {
+
+ /** The log used in this exporter. */
+ private static Logger log = Logger.getLogger(FixWaterlevelExporter.class);
+
+ private final Map gaugeQ_W_Map = new HashMap<>();
+
+ @Override
+ protected void writeRow4(final CSVWriter writer, final double wqkm[], final D4EArtifact flys, final Gauge gauge) {
+ final NumberFormat kmf = getKmFormatter();
+ final NumberFormat wf = getWFormatter();
+ final NumberFormat qf = getQFormatter();
+
+ final String waterlevel = getWaterlevel(wqkm[1], gauge);
+
+ writer.writeNext(new String[] { kmf.format(wqkm[2]), wf.format(wqkm[0]), waterlevel, qf.format(RiverUtils.roundQ(wqkm[1])),
+ RiverUtils.getLocationDescription(flys, wqkm[2]) });
+ }
+
+ /** Write an csv-row at gauge location. */
+ @Override
+ protected void writeRow6(final CSVWriter writer, final double wqkm[], final String wOrQDesc, final D4EArtifact flys, final Gauge gauge) {
+ final NumberFormat kmf = getKmFormatter();
+ final NumberFormat wf = getWFormatter();
+ final NumberFormat qf = getQFormatter();
+
+ final String waterlevel = getWaterlevel(wqkm[1], gauge);
+
+ writer.writeNext(new String[] { kmf.format(wqkm[2]), wf.format(wqkm[0]), waterlevel, qf.format(RiverUtils.roundQ(wqkm[1])), wOrQDesc,
+ RiverUtils.getLocationDescription(flys, wqkm[2]), gauge.getName() });
+ }
+
+ private String getWaterlevel(final double discharge, final Gauge gauge) {
+ final NumberFormat formatter = Formatter.getWaterlevelW(this.context);
+ final Double waterlevel = this.getWforGaugeAndQ(gauge, discharge);
+ return formatter.format(waterlevel);
+ }
+
+ private Double getWforGaugeAndQ(final Gauge gauge, final double q) {
+
+ final String key = gauge.getName() + String.valueOf(q);
+ if (!this.gaugeQ_W_Map.containsKey(key)) {
+
+ final DischargeTables dct = new DischargeTables(gauge.getRiver().getName(), gauge.getName());
+ final double[] qs = DischargeTables.getWsForQ(dct.getFirstTable(), q); // TODO: KLÄREN, welche Abflusstabelle genommen werden soll!
+ if (qs != null && qs.length > 0) {
+ this.gaugeQ_W_Map.put(key, qs[0]);
+ }
+ }
+ return this.gaugeQ_W_Map.get(key);
+ }
+
+ /**
+ * Write the header, with different headings depending on whether at a
+ * gauge or at a location.
+ */
+
+ @Override
+ protected void writeCSVHeader(final CSVWriter writer, final boolean atGauge, final boolean isQ) {
+ log.info("WaterlevelExporter.writeCSVHeader");
+
+ final String unit = RiverUtils.getRiver((D4EArtifact) this.master).getWstUnit().getName();
+
+ final String headerWamPegelNeu = msg("fix.export.csv.w_at_gauge");
+
+ if (atGauge) {
+ writer.writeNext(new String[] { msg(CSV_KM_HEADER, DEFAULT_CSV_KM_HEADER), msg(CSV_W_HEADER, DEFAULT_CSV_W_HEADER, new Object[] { unit }),
+ headerWamPegelNeu, msg(CSV_Q_HEADER, DEFAULT_CSV_Q_HEADER),
+
+ // FIXME: use WaterlevelDescriptionBuilder instead and also remove all this duplicate code.
+ (isQ ? msg(CSV_Q_DESC_HEADER, DEFAULT_CSV_Q_DESC_HEADER) : msg(CSV_W_DESC_HEADER, DEFAULT_CSV_W_DESC_HEADER)),
+ msg(CSV_LOCATION_HEADER, DEFAULT_CSV_LOCATION_HEADER), msg(CSV_GAUGE_HEADER, DEFAULT_CSV_GAUGE_HEADER) });
+ } else {
+ writer.writeNext(new String[] { msg(CSV_KM_HEADER, DEFAULT_CSV_KM_HEADER), msg(CSV_W_HEADER, DEFAULT_CSV_W_HEADER, new Object[] { unit }),
+ headerWamPegelNeu, msg(CSV_Q_HEADER, DEFAULT_CSV_Q_HEADER), msg(CSV_LOCATION_HEADER, DEFAULT_CSV_LOCATION_HEADER) });
+ }
+ }
+
+ @Override
+ protected void writePDF(final OutputStream out) {
+
+ log.debug("write PDF");
+
+ final MetaAndTableJRDataSource source = new MetaAndTableJRDataSource();
+ final String jasperFile = "/jasper/templates/fix_waterlevel.jrxml"; // "/jasper/fix_waterlevel_en.jasper");
+
+ addMetaData(source);
+ try {
+ final List sorted = getRows(); // Custom Result could be nice, too...
+ for (final String[] list : sorted) {
+ source.addData(list);
+ }
+
+ final JasperReporter reporter = new JasperReporter();
+ reporter.addReport(jasperFile, source);
+ reporter.exportPDF(out);
+ }
+ catch (final JRException je) {
+ log.warn("Error generating PDF Report!", je);
+ }
+ }
+
+ private void addMetaData(final MetaAndTableJRDataSource source) {
+ final D4EArtifact flys = (D4EArtifact) this.master;
+ final String user = CalculationUtils.findArtifactUser(this.context, flys);
+ final RangeAccess ra = new RangeAccess(flys);
+ final RiverInfo ri = new RiverInfo(ra.getRiver());
+
+ final DefaultCalculationResults results = new DefaultCalculationResults(msg("calculation.analysis"), user, ri, ra.getRange());
+ final ExportContextPDF contextPdf = new ExportContextPDF(this.context, results);
+ contextPdf.addJRMetaDataDefaults(source);
+ contextPdf.addJRMetaDataForModules(source);
+
+ /* column headings */
+ contextPdf.addJRMetadata(source, "station_header", GeneralResultType.station);
+ contextPdf.addJRMetadata(source, "fix_w", msg(CSV_W_HEADER, DEFAULT_CSV_W_HEADER, new Object[] { ri.getWstUnit() }));
+ contextPdf.addJRMetadata(source, "w_at_gauge_header", msg("fix.export.csv.w_at_gauge"));
+ contextPdf.addJRMetadata(source, "fix_q", msg(CSV_Q_HEADER));
+ contextPdf.addJRMetadata(source, "waterlevel_name_header", msg("common.export.csv.header.mainvalue_label"));
+ contextPdf.addJRMetadata(source, "location_header", msg("common.export.csv.header.location"));
+ contextPdf.addJRMetadata(source, "gauge_header", msg("common.export.csv.header.gauge"));
+
+ }
+
+ private List getRows() {
+ final List list = new ArrayList<>();
+ final WQ_MODE mode = RiverUtils.getWQMode((D4EArtifact) this.master);
+ final boolean atGauge = mode == WQ_MODE.QGAUGE || mode == WQ_MODE.WGAUGE;
+ final boolean isQ = mode == WQ_MODE.QGAUGE || mode == WQ_MODE.QFREE;
+
+ Double first = Double.NaN;
+ Double last = Double.NaN;
+
+ for (final WQKms[] tmp : this.data) {
+ for (final WQKms wqkms : tmp) {
+ list.addAll(getRows2(wqkms, atGauge, isQ));
+ final double[] firstLast = wqkms.getFirstLastKM();
+ if (first.isNaN()) {
+ /* Initialize */
+ first = firstLast[0];
+ last = firstLast[1];
+ }
+ if (firstLast[0] > firstLast[1]) {
+ /*
+ * Calculating upstream we assert that it is
+ * impossible that the direction changes during this
+ * loop
+ */
+ first = Math.max(first, firstLast[0]);
+ last = Math.min(last, firstLast[1]);
+ } else if (firstLast[0] < firstLast[1]) {
+ first = Math.min(first, firstLast[0]);
+ last = Math.max(last, firstLast[1]);
+ } else {
+ first = last = firstLast[0];
+ }
+ }
+ }
+
+ /* Append the official fixing at the bottom */
+ for (final WQKms wqkms : this.officalFixings) {
+ list.addAll(getRows2(filterWQKms(wqkms, first, last), atGauge, isQ));
+ }
+ return list;
+ }
+
+ protected List getRows2(final WQKms wqkms, final boolean atGauge, final boolean isQ) {
+ log.debug("WaterlevelExporter.addWKmsData"); // OLD CODE :-/
+
+ final List list = new ArrayList<>();
+ // Skip constant data.
+ if (wqkms instanceof ConstantWQKms) {
+ return null;
+ }
+
+ final NumberFormat kmf = getKmFormatter();
+ final NumberFormat wf = getWFormatter();
+ final NumberFormat qf = getQFormatter();
+
+ final int size = wqkms.size();
+ double[] result = new double[3];
+
+ final D4EArtifact flys = (D4EArtifact) this.master;
+ final RangeAccess rangeAccess = new RangeAccess(flys);
+
+ final Gauge gauge = rangeAccess.getRiver().determineRefGauge(rangeAccess.getKmRange(), rangeAccess.isRange());
+
+ final String gaugeName = gauge.getName();
+ String desc = "";
+ final String notinrange = msg(CSV_NOT_IN_GAUGE_RANGE, DEFAULT_CSV_NOT_IN_GAUGE_RANGE);
+
+ final double a = gauge.getRange().getA().doubleValue();
+ final double b = gauge.getRange().getB().doubleValue();
+
+ desc = getDesc(wqkms, isQ);
+ final long startTime = System.currentTimeMillis();
+
+ for (int i = 0; i < size; i++) {
+ result = wqkms.get(i, result);
+ final double q = result[1];
+ final String waterlevel = this.getWaterlevel(q, gauge); // THIS IS NEW (and makes common super method
+ // difficult)
+ if (atGauge) {
+ list.add(new String[] { kmf.format(result[2]), wf.format(result[0]), waterlevel, qf.format(RiverUtils.roundQ(result[1])), desc,
+ RiverUtils.getLocationDescription(flys, result[2]), result[2] >= a && result[2] <= b ? gaugeName : notinrange });
+ } else {
+ list.add(new String[] { kmf.format(result[2]), wf.format(result[0]), waterlevel, qf.format(RiverUtils.roundQ(result[1])), desc,
+ RiverUtils.getLocationDescription(flys, result[2]), result[2] >= a && result[2] <= b ? gaugeName : notinrange });
+ }
+
+ }
+
+ return list;
+ }
+}
\ No newline at end of file
diff -r c96f6c8a6b03 -r 65f28328c9a3 artifacts/src/main/java/org/dive4elements/river/exports/WaterlevelExporter.java
--- a/artifacts/src/main/java/org/dive4elements/river/exports/WaterlevelExporter.java Tue Aug 28 13:50:05 2018 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/exports/WaterlevelExporter.java Tue Aug 28 14:02:23 2018 +0200
@@ -64,10 +64,10 @@
/** The log used in this exporter. */
private static Logger log = Logger.getLogger(WaterlevelExporter.class);
- public static final String FACET_WST = "wst";
+ private static final String FACET_WST = "wst";
/* This should be the same as in the StaticWQKmsArtifact */
- public static final String STATICWQKMSNAME = "staticwqkms";
+ private static final String STATICWQKMSNAME = "staticwqkms";
public static final String CSV_KM_HEADER = "export.waterlevel.csv.header.km";
@@ -91,25 +91,25 @@
public static final String CSV_GAUGE_HEADER = "export.waterlevel.csv.header.gauge";
- public static final String CSV_META_RESULT = "export.waterlevel.csv.meta.result";
-
- public static final String CSV_META_CREATION = "export.waterlevel.csv.meta.creation";
-
- public static final String CSV_META_CALCULATIONBASE = "export.waterlevel.csv.meta.calculationbase";
+ private static final String CSV_META_RESULT = "export.waterlevel.csv.meta.result";
- public static final String CSV_META_RIVER = "export.waterlevel.csv.meta.river";
-
- public static final String CSV_META_RANGE = "export.waterlevel.csv.meta.range";
+ private static final String CSV_META_CREATION = "export.waterlevel.csv.meta.creation";
- public static final String CSV_META_GAUGE = "export.waterlevel.csv.meta.gauge";
+ private static final String CSV_META_CALCULATIONBASE = "export.waterlevel.csv.meta.calculationbase";
- public static final String CSV_META_Q = "common.export.waterlevel.csv.meta.q";
+ private static final String CSV_META_RIVER = "export.waterlevel.csv.meta.river";
- public static final String CSV_META_W = "export.waterlevel.csv.meta.w";
+ private static final String CSV_META_RANGE = "export.waterlevel.csv.meta.range";
+
+ private static final String CSV_META_GAUGE = "export.waterlevel.csv.meta.gauge";
+
+ private static final String CSV_META_Q = "common.export.waterlevel.csv.meta.q";
+
+ private static final String CSV_META_W = "export.waterlevel.csv.meta.w";
public static final String CSV_NOT_IN_GAUGE_RANGE = "export.waterlevel.csv.not.in.gauge.range";
- public static final Pattern NUMBERS_PATTERN = Pattern.compile("\\D*(\\d++.\\d*)\\D*");
+ private static final Pattern NUMBERS_PATTERN = Pattern.compile("\\D*(\\d++.\\d*)\\D*");
public static final String DEFAULT_CSV_KM_HEADER = "Fluss-Km";
public static final String DEFAULT_CSV_W_HEADER = "W [NN + m]";
@@ -128,14 +128,14 @@
public static final String DEFAULT_CSV_GAUGE_HEADER = "Bezugspegel";
public static final String DEFAULT_CSV_NOT_IN_GAUGE_RANGE = "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";
+ protected static final String PDF_HEADER_MODE = "export.waterlevel.pdf.mode";
+ private static final String JASPER_FILE = "export.waterlevel.pdf.file";
/** The storage that contains all WQKms objects that are calculated. */
- protected List data;
+ public List data;
/** The storage that contains official fixings if available. */
- protected List officalFixings;
+ public List officalFixings;
public WaterlevelExporter() {
this.data = new ArrayList<>();
@@ -216,7 +216,7 @@
* @param wqkms
* A WQKms object that should be prepared.
*/
- protected String getColumnTitle(final WINFOArtifact winfo, final WQKms wqkms) {
+ public String getColumnTitle(final WINFOArtifact winfo, final WQKms wqkms) {
log.debug("WaterlevelExporter.getColumnTitle");
final String name = wqkms.getName();
@@ -257,7 +257,7 @@
* @deprecated Use {@link WaterlevelDescriptionBuilder} instead.
*/
@Deprecated
- protected String getCSVRowTitle(final WINFOArtifact winfo, final WQKms wqkms) {
+ public String getCSVRowTitle(final WINFOArtifact winfo, final WQKms wqkms) {
log.debug("WaterlevelExporter.prepareNamedValue");
final String name = wqkms.getName();
@@ -291,7 +291,7 @@
* @deprecated Use {@link WaterlevelDescriptionBuilder} instead.
*/
@Deprecated
- protected String localizeWQKms(final WINFOArtifact winfo, final WQKms wqkms) {
+ public String localizeWQKms(final WINFOArtifact winfo, final WQKms wqkms) {
final WQ_MODE wqmode = RiverUtils.getWQMode(winfo);
final Double rawValue = wqkms.getRawValue();
@@ -309,7 +309,7 @@
}
@Override
- protected void writeCSVData(final CSVWriter writer) {
+ public void writeCSVData(final CSVWriter writer) {
log.info("WaterlevelExporter.writeData");
final WQ_MODE mode = RiverUtils.getWQMode((D4EArtifact) this.master);
@@ -371,7 +371,7 @@
*
* @return A new WQKms with the relevant data sorted by direction
*/
- private WQKms filterWQKms(final WQKms wqkms, final Double first, final Double last) {
+ public final WQKms filterWQKms(final WQKms wqkms, final Double first, final Double last) {
if (first.isNaN() || last.isNaN()) {
log.warn("Filtering official fixing without valid first/last.");
return wqkms;
@@ -400,7 +400,7 @@
return filtered;
}
- protected void writeCSVMeta(final CSVWriter writer) {
+ public void writeCSVMeta(final CSVWriter writer) {
log.info("WaterlevelExporter.writeCSVMeta");
// TODO use Access instead of RiverUtils
@@ -511,7 +511,7 @@
return null;
}
- private void writeRow4(final CSVWriter writer, final double wqkm[], final D4EArtifact flys) {
+ protected void writeRow4(final CSVWriter writer, final double wqkm[], final D4EArtifact flys, final Gauge gauge) {
final NumberFormat kmf = getKmFormatter();
final NumberFormat wf = getWFormatter();
final NumberFormat qf = getQFormatter();
@@ -520,20 +520,20 @@
}
/** Write an csv-row at gauge location. */
- private void writeRow6(final CSVWriter writer, final double wqkm[], final String wOrQDesc, final D4EArtifact flys, final String gaugeName) {
+ protected void writeRow6(final CSVWriter writer, final double wqkm[], final String wOrQDesc, final D4EArtifact flys, final Gauge gauge) {
final NumberFormat kmf = getKmFormatter();
final NumberFormat wf = getWFormatter();
final NumberFormat qf = getQFormatter();
writer.writeNext(new String[] { kmf.format(wqkm[2]), wf.format(wqkm[0]), qf.format(RiverUtils.roundQ(wqkm[1])), wOrQDesc,
- RiverUtils.getLocationDescription(flys, wqkm[2]), gaugeName });
+ RiverUtils.getLocationDescription(flys, wqkm[2]), gauge.getName() });
}
/**
* @deprecated Use {@link WaterlevelDescriptionBuilder} instead.
*/
@Deprecated
- private String getDesc(final WQKms wqkms, final boolean isQ) {
+ public final String getDesc(final WQKms wqkms, final boolean isQ) {
final D4EArtifact flys = (D4EArtifact) this.master;
String colDesc = "";
@@ -644,12 +644,12 @@
// TODO issue1114: Take correct gauge
gaugeN = km >= a && km <= b ? gaugeName : notinrange;
}
- writeRow6(writer, result, desc, flys, gaugeN);
+ writeRow6(writer, result, desc, flys, gauge);
}
} else { // Not at gauge.
for (int i = 0; i < size; ++i) {
result = wqkms.get(i, result);
- writeRow4(writer, result, flys);
+ writeRow4(writer, result, flys, gauge);
}
}
@@ -663,7 +663,7 @@
/**
* Generates the output in WST format.
*/
- protected void generateWST() throws IOException {
+ public void generateWST() throws IOException {
log.info("WaterlevelExporter.generateWST");
final int cols = this.data.get(0).length + this.officalFixings.size();
@@ -674,7 +674,7 @@
writer.write(this.out);
}
- protected void writeWSTData(final WstWriter writer) {
+ public void writeWSTData(final WstWriter writer) {
log.debug("WaterlevelExporter.writeWSTData");
double[] result = new double[4];
@@ -755,27 +755,31 @@
}
}
- @Override
- protected void writePDF(final OutputStream out) {
- log.debug("write PDF");
- final WKmsJRDataSource source = createJRData();
+ public void doWritePdf(final WKmsJRDataSource source, final String jasperFile) {
- final String jasperFile = // "/jasper/waterlevel_en.jasper";
- Resources.getMsg(this.context.getMeta(), JASPER_FILE, "/jasper/waterlevel_en.jasper");
final String confPath = Config.getConfigDirectory().toString();
final Map parameters = new HashMap();
parameters.put("ReportTitle", "Exported Data");
try {
final JasperPrint print = JasperFillManager.fillReport(confPath + jasperFile, parameters, source);
- JasperExportManager.exportReportToPdfStream(print, out);
+ JasperExportManager.exportReportToPdfStream(print, this.out);
}
catch (final JRException je) {
log.warn("Error generating PDF Report!", je);
}
}
- protected WKmsJRDataSource createJRData() {
+ @Override
+ protected void writePDF(final OutputStream out) {
+ log.debug("write PDF");
+ final WKmsJRDataSource source = createJRData();
+ final String jasperFile = Resources.getMsg(this.context.getMeta(), JASPER_FILE, "/jasper/waterlevel_en.jasper");
+ doWritePdf(source, jasperFile);
+
+ }
+
+ private WKmsJRDataSource createJRData() {
final WKmsJRDataSource source = new WKmsJRDataSource();
final WQ_MODE mode = RiverUtils.getWQMode((D4EArtifact) this.master);
@@ -819,7 +823,7 @@
return source;
}
- protected void addMetaData(final WKmsJRDataSource source) {
+ public void addMetaData(final WKmsJRDataSource source) {
final CallMeta meta = this.context.getMeta();
final D4EArtifact flys = (D4EArtifact) this.master;
@@ -836,6 +840,10 @@
final double[] kms = rangeAccess.getKmRange();
source.addMetaData("range", kmf.format(kms[0]) + " - " + kmf.format(kms[kms.length - 1]));
+ source.addMetaData("w_at_gauge_header", Resources.getMsg(meta, "fix.export.csv.w_at_gauge")); // dürfte kein Problem sein für Vorlagen, die kein
+ // "w_at_gauge"
+ // haben
+
source.addMetaData("gauge", RiverUtils.getGaugename(flys));
source.addMetaData("calculation", Resources.getMsg(locale, PDF_HEADER_MODE, "Waterlevel"));
@@ -881,6 +889,7 @@
source.addData(new String[] { kmf.format(result[2]), wf.format(result[0]), qf.format(RiverUtils.roundQ(result[1])), desc,
RiverUtils.getLocationDescription(flys, result[2]), result[2] >= a && result[2] <= b ? gaugeName : notinrange });
}
+
}
final long stopTime = System.currentTimeMillis();
@@ -889,5 +898,6 @@
log.debug("Writing PDF data took " + (stopTime - startTime) / 1000f + " secs.");
}
}
+
}
// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
diff -r c96f6c8a6b03 -r 65f28328c9a3 artifacts/src/main/resources/messages.properties
--- a/artifacts/src/main/resources/messages.properties Tue Aug 28 13:50:05 2018 +0200
+++ b/artifacts/src/main/resources/messages.properties Tue Aug 28 14:02:23 2018 +0200
@@ -677,6 +677,7 @@
fix.mq=arraound MQ
fix.mhq=arround MHQ
fix.hq5=over HQ5
+fix.export.csv.w_at_gauge = W at Gauge [cm]
chart.fix.deltawt.title=Difference from compensating curve at kilometer {0}
chart.fix.deltawt.subtitle=Water: {0}; Period: {1,date,short} to {2,date,short}; Reference period: {3,date,short} bis {4,date,short}
@@ -943,12 +944,12 @@
sinfo.export.flow_depth.pdf.header.waterlevel = Wasser-stand
sinfo.export.flow_depth.csv.header.discharge = Q
sinfo.export.collision.csv.header.discharge_long = Abfluss
-common.export.csv.header.mainvalue_label = Bezeichnung
-common.export.csv.header.gauge = Bezugspegel
+common.export.csv.header.mainvalue_label = Description
+common.export.csv.header.gauge = Reference Gauge
sinfo.export.flow_depth.csv.header.mean_bed_height = Mittlere Sohlh\u00f6he
sinfo.export.flow_depth.csv.header.mean_bed_height.short = Mittlere Sohl-
sinfo.export.flow_depth.csv.header.sounding = Peilung/Epoche
-common.export.csv.header.location = Lage
+common.export.csv.header.location = Location
sinfo.export.flood_duration.csv.header.riverside = Uferseite
sinfo.export.flood_duration.csv.header.infrastructure.height = H\u00f6he der Infrastruktur
diff -r c96f6c8a6b03 -r 65f28328c9a3 artifacts/src/main/resources/messages_de.properties
--- a/artifacts/src/main/resources/messages_de.properties Tue Aug 28 13:50:05 2018 +0200
+++ b/artifacts/src/main/resources/messages_de.properties Tue Aug 28 14:02:23 2018 +0200
@@ -677,6 +677,7 @@
fix.mq=um MQ
fix.mhq=um MHQ
fix.hq5=um HQ5
+fix.export.csv.w_at_gauge = W am Pegel [cm]
chart.fix.deltawt.title=Abweichungen von der Ausgleichskurve an Kilometer {0}
chart.fix.deltawt.subtitle=Gew\u00e4sser: {0}; Darstellungszeitraum: {1,date,short} bis {2,date,short}; Bezugszeitraum: {3,date,short} bis {4,date,short}