[PATCH] (issue1753) Implement PDF export of SQ Measurement data
Wald Commits
scm-commit at wald.intevation.org
Mon Mar 16 11:35:54 CET 2015
# HG changeset patch
# User Andre Heinecke <andre.heinecke at intevation.de>
# Date 1426502119 -3600
# Node ID 4eb1a3c7157956524f0ec74ce2a554d3f653904d
# Parent 3fae08a8cb9010cddb40cd9a756e5b2f2268ee4b
(issue1753) Implement PDF export of SQ Measurement data.
The SQRelationExporter now consists of two reports
(to avoid subreport woes). The old SQReleation PDF
only takes the Page count of the Measurement attachment
as argument to correctly print the page numbers. Otherwise
it is unchanged.
The new SQMeasurements report lists the measured data points
on which the calculation was based.
diff -r 3fae08a8cb90 -r 4eb1a3c71579 artifacts/doc/conf/jasper/sqmeasurements.jasper
Binary file artifacts/doc/conf/jasper/sqmeasurements.jasper has changed
diff -r 3fae08a8cb90 -r 4eb1a3c71579 artifacts/doc/conf/jasper/sqmeasurements.jrxml
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/artifacts/doc/conf/jasper/sqmeasurements.jrxml Mon Mar 16 11:35:19 2015 +0100
@@ -0,0 +1,104 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="flysreport" language="groovy" pageWidth="595" pageHeight="842" columnWidth="515" leftMargin="60" rightMargin="20" topMargin="20" bottomMargin="20">
+ <property name="ireport.zoom" value="1.5"/>
+ <property name="ireport.x" value="167"/>
+ <property name="ireport.y" value="0"/>
+ <subDataset name="dataset1"/>
+ <field name="date" class="java.lang.String"/>
+ <field name="param" class="java.lang.String"/>
+ <field name="transport" class="java.lang.String"/>
+ <field name="discharge" class="java.lang.String"/>
+ <field name="outlier" class="java.lang.String"/>
+ <background>
+ <band splitType="Stretch"/>
+ </background>
+ <title>
+ <band height="31" splitType="Stretch">
+ <staticText>
+ <reportElement x="0" y="1" width="177" height="30"/>
+ <textElement>
+ <font size="18"/>
+ </textElement>
+ <text><![CDATA[Basisdaten]]></text>
+ </staticText>
+ </band>
+ </title>
+ <columnHeader>
+ <band height="23" splitType="Stretch">
+ <line>
+ <reportElement x="0" y="19" width="515" height="1"/>
+ </line>
+ <staticText>
+ <reportElement x="0" y="0" width="60" height="20"/>
+ <textElement verticalAlignment="Middle"/>
+ <text><![CDATA[Parameter]]></text>
+ </staticText>
+ <staticText>
+ <reportElement x="60" y="0" width="115" height="20"/>
+ <textElement verticalAlignment="Middle"/>
+ <text><![CDATA[Transport in [kg/s]]]></text>
+ </staticText>
+ <staticText>
+ <reportElement x="175" y="0" width="115" height="20"/>
+ <textElement verticalAlignment="Middle"/>
+ <text><![CDATA[Abfluss in [m³/s]]]></text>
+ </staticText>
+ <staticText>
+ <reportElement x="288" y="0" width="104" height="20"/>
+ <textElement verticalAlignment="Middle" markup="styled"/>
+ <text><![CDATA[Datum der Messung]]></text>
+ </staticText>
+ <staticText>
+ <reportElement x="392" y="0" width="123" height="20"/>
+ <textElement textAlignment="Left" verticalAlignment="Middle" markup="styled"/>
+ <text><![CDATA[Ausreißer in Durchgang]]></text>
+ </staticText>
+ </band>
+ </columnHeader>
+ <detail>
+ <band height="17" splitType="Stretch">
+ <textField isStretchWithOverflow="true" isBlankWhenNull="true">
+ <reportElement stretchType="RelativeToBandHeight" x="288" y="0" width="104" height="14"/>
+ <textElement verticalAlignment="Middle"/>
+ <textFieldExpression><![CDATA[$F{date}]]></textFieldExpression>
+ </textField>
+ <textField isBlankWhenNull="true">
+ <reportElement x="0" y="0" width="60" height="14"/>
+ <textElement textAlignment="Center" verticalAlignment="Middle"/>
+ <textFieldExpression><![CDATA[$F{param}]]></textFieldExpression>
+ </textField>
+ <textField isBlankWhenNull="true">
+ <reportElement x="60" y="0" width="115" height="14"/>
+ <textElement verticalAlignment="Middle"/>
+ <textFieldExpression><![CDATA[$F{transport}]]></textFieldExpression>
+ </textField>
+ <textField isStretchWithOverflow="true" isBlankWhenNull="true">
+ <reportElement stretchType="RelativeToBandHeight" x="175" y="0" width="113" height="14"/>
+ <textElement verticalAlignment="Middle"/>
+ <textFieldExpression><![CDATA[$F{discharge}]]></textFieldExpression>
+ </textField>
+ <textField isStretchWithOverflow="true" isBlankWhenNull="true">
+ <reportElement stretchType="RelativeToBandHeight" x="392" y="0" width="123" height="14"/>
+ <textElement textAlignment="Left" verticalAlignment="Middle"/>
+ <textFieldExpression><![CDATA[$F{outlier}]]></textFieldExpression>
+ </textField>
+ </band>
+ </detail>
+ <pageFooter>
+ <band height="30" splitType="Stretch">
+ <textField evaluationTime="Report">
+ <reportElement x="458" y="9" width="57" height="20"/>
+ <textElement/>
+ <textFieldExpression><![CDATA[" / " + ($V{PAGE_NUMBER} + 1)]]></textFieldExpression>
+ </textField>
+ <textField>
+ <reportElement x="403" y="9" width="55" height="20"/>
+ <textElement textAlignment="Right"/>
+ <textFieldExpression><![CDATA[$V{PAGE_NUMBER} + 1]]></textFieldExpression>
+ </textField>
+ </band>
+ </pageFooter>
+ <summary>
+ <band height="42" splitType="Stretch"/>
+ </summary>
+</jasperReport>
diff -r 3fae08a8cb90 -r 4eb1a3c71579 artifacts/doc/conf/jasper/sqrelation.jasper
Binary file artifacts/doc/conf/jasper/sqrelation.jasper has changed
diff -r 3fae08a8cb90 -r 4eb1a3c71579 artifacts/doc/conf/jasper/sqrelation.jrxml
--- a/artifacts/doc/conf/jasper/sqrelation.jrxml Mon Mar 16 10:00:39 2015 +0100
+++ b/artifacts/doc/conf/jasper/sqrelation.jrxml Mon Mar 16 11:35:19 2015 +0100
@@ -2,8 +2,9 @@
<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="flysreport" language="groovy" pageWidth="595" pageHeight="842" columnWidth="515" leftMargin="60" rightMargin="20" topMargin="20" bottomMargin="20">
<property name="ireport.zoom" value="1.5"/>
<property name="ireport.x" value="0"/>
- <property name="ireport.y" value="432"/>
+ <property name="ireport.y" value="0"/>
<subDataset name="dataset1"/>
+ <parameter name="MEASUREMENT_PAGE_NUM" class="java.lang.Integer"/>
<field name="river" class="java.lang.String"/>
<field name="periods" class="java.lang.String"/>
<field name="outliertest" class="java.lang.String"/>
@@ -459,7 +460,7 @@
<textField evaluationTime="Report">
<reportElement x="458" y="9" width="57" height="20"/>
<textElement/>
- <textFieldExpression><![CDATA[" / " + $V{PAGE_NUMBER}]]></textFieldExpression>
+ <textFieldExpression><![CDATA[" / " + ($V{PAGE_NUMBER} + $P{MEASUREMENT_PAGE_NUM})]]></textFieldExpression>
</textField>
<textField>
<reportElement x="403" y="9" width="55" height="20"/>
diff -r 3fae08a8cb90 -r 4eb1a3c71579 artifacts/doc/conf/jasper/sqrelation_en.jasper
Binary file artifacts/doc/conf/jasper/sqrelation_en.jasper has changed
diff -r 3fae08a8cb90 -r 4eb1a3c71579 artifacts/doc/conf/jasper/sqrelation_en.jrxml
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/artifacts/doc/conf/jasper/sqrelation_en.jrxml Mon Mar 16 11:35:19 2015 +0100
@@ -0,0 +1,273 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="flysreport" language="groovy" pageWidth="595" pageHeight="842" columnWidth="515" leftMargin="60" rightMargin="20" topMargin="20" bottomMargin="20">
+ <property name="ireport.zoom" value="1.5"/>
+ <property name="ireport.x" value="0"/>
+ <property name="ireport.y" value="43"/>
+ <parameter name="MEASUREMENT_PAGE_NUM" class="java.lang.Integer"/>
+ <field name="river" class="java.lang.String"/>
+ <field name="periods" class="java.lang.String"/>
+ <field name="outliertest" class="java.lang.String"/>
+ <field name="date" class="java.lang.String"/>
+ <field name="outliers" class="java.lang.String"/>
+ <field name="calculation" class="java.lang.String"/>
+ <field name="total" class="java.lang.String"/>
+ <field name="out" class="java.lang.String"/>
+ <field name="location" class="java.lang.String"/>
+ <field name="sd" class="java.lang.String"/>
+ <field name="a" class="java.lang.String"/>
+ <field name="b" class="java.lang.String"/>
+ <field name="km" class="java.lang.String"/>
+ <field name="param" class="java.lang.String"/>
+ <field name="qmax" class="java.lang.String"/>
+ <field name="cduan" class="java.lang.String"/>
+ <field name="cferg" class="java.lang.String"/>
+ <field name="r2" class="java.lang.String"/>
+ <field name="msGauge" class="java.lang.String"/>
+ <field name="msName" class="java.lang.String"/>
+ <background>
+ <band splitType="Stretch"/>
+ </background>
+ <title>
+ <band height="231" splitType="Stretch">
+ <staticText>
+ <reportElement x="0" y="1" width="177" height="30"/>
+ <textElement>
+ <font size="18"/>
+ </textElement>
+ <text><![CDATA[Calculation result]]></text>
+ </staticText>
+ <textField>
+ <reportElement x="177" y="0" width="338" height="31"/>
+ <textElement>
+ <font size="18"/>
+ </textElement>
+ <textFieldExpression><![CDATA[$F{river}]]></textFieldExpression>
+ </textField>
+ <textField>
+ <reportElement x="0" y="31" width="515" height="26"/>
+ <textElement>
+ <font size="14"/>
+ </textElement>
+ <textFieldExpression><![CDATA[$F{calculation}]]></textFieldExpression>
+ </textField>
+ <staticText>
+ <reportElement x="0" y="70" width="123" height="20"/>
+ <textElement verticalAlignment="Middle"/>
+ <text><![CDATA[River:]]></text>
+ </staticText>
+ <textField>
+ <reportElement x="123" y="70" width="392" height="20"/>
+ <textElement verticalAlignment="Middle"/>
+ <textFieldExpression><![CDATA[$F{river}]]></textFieldExpression>
+ </textField>
+ <staticText>
+ <reportElement x="0" y="90" width="123" height="20"/>
+ <textElement verticalAlignment="Middle"/>
+ <text><![CDATA[Location]]></text>
+ </staticText>
+ <textField>
+ <reportElement x="123" y="90" width="392" height="20"/>
+ <textElement verticalAlignment="Middle"/>
+ <textFieldExpression><![CDATA[$F{location}]]></textFieldExpression>
+ </textField>
+ <staticText>
+ <reportElement x="0" y="150" width="123" height="20"/>
+ <textElement verticalAlignment="Middle"/>
+ <text><![CDATA[Date of creation:]]></text>
+ </staticText>
+ <textField>
+ <reportElement x="123" y="150" width="392" height="20"/>
+ <textElement verticalAlignment="Middle"/>
+ <textFieldExpression><![CDATA[$F{date}]]></textFieldExpression>
+ </textField>
+ <staticText>
+ <reportElement x="0" y="170" width="123" height="20"/>
+ <textElement verticalAlignment="Middle"/>
+ <text><![CDATA[Periods:]]></text>
+ </staticText>
+ <textField>
+ <reportElement x="123" y="170" width="392" height="20"/>
+ <textElement verticalAlignment="Middle"/>
+ <textFieldExpression><![CDATA[$F{periods}]]></textFieldExpression>
+ </textField>
+ <staticText>
+ <reportElement x="0" y="190" width="123" height="20"/>
+ <textElement verticalAlignment="Middle"/>
+ <text><![CDATA[Outliertest:]]></text>
+ </staticText>
+ <textField>
+ <reportElement x="123" y="190" width="392" height="20"/>
+ <textElement verticalAlignment="Middle"/>
+ <textFieldExpression><![CDATA[$F{outliertest}]]></textFieldExpression>
+ </textField>
+ <staticText>
+ <reportElement x="0" y="210" width="123" height="20"/>
+ <textElement verticalAlignment="Middle"/>
+ <text><![CDATA[Outliers:]]></text>
+ </staticText>
+ <textField>
+ <reportElement x="123" y="210" width="392" height="20"/>
+ <textElement verticalAlignment="Middle"/>
+ <textFieldExpression><![CDATA[$F{outliers}]]></textFieldExpression>
+ </textField>
+ <textField isBlankWhenNull="false">
+ <reportElement x="123" y="110" width="392" height="20" isRemoveLineWhenBlank="true"/>
+ <textElement verticalAlignment="Middle"/>
+ <textFieldExpression><![CDATA[$F{msName}]]></textFieldExpression>
+ </textField>
+ <staticText>
+ <reportElement x="0" y="130" width="123" height="20"/>
+ <textElement verticalAlignment="Middle"/>
+ <text><![CDATA[hdyr. Reference Gauge:]]></text>
+ </staticText>
+ <staticText>
+ <reportElement x="0" y="110" width="123" height="20"/>
+ <textElement verticalAlignment="Middle"/>
+ <text><![CDATA[Measurement Station:]]></text>
+ </staticText>
+ <textField isBlankWhenNull="false">
+ <reportElement x="123" y="130" width="392" height="20" isRemoveLineWhenBlank="true"/>
+ <textElement verticalAlignment="Middle"/>
+ <textFieldExpression><![CDATA[$F{msGauge}]]></textFieldExpression>
+ </textField>
+ </band>
+ </title>
+ <columnHeader>
+ <band height="25" splitType="Stretch">
+ <line>
+ <reportElement x="0" y="19" width="515" height="1"/>
+ </line>
+ <staticText>
+ <reportElement x="94" y="0" width="60" height="20"/>
+ <textElement verticalAlignment="Middle"/>
+ <text><![CDATA[a]]></text>
+ </staticText>
+ <staticText>
+ <reportElement x="391" y="0" width="44" height="20"/>
+ <textElement verticalAlignment="Middle" markup="styled"/>
+ <text><![CDATA[n <sub>outlier</sub>]]></text>
+ </staticText>
+ <staticText>
+ <reportElement x="470" y="0" width="45" height="20"/>
+ <textElement verticalAlignment="Middle" markup="styled"/>
+ <text><![CDATA[C <sub>Ferguson</sub>]]></text>
+ </staticText>
+ <staticText>
+ <reportElement x="435" y="0" width="35" height="20"/>
+ <textElement verticalAlignment="Middle" markup="styled"/>
+ <text><![CDATA[C<sub>Duan</sub>]]></text>
+ </staticText>
+ <staticText>
+ <reportElement x="265" y="0" width="60" height="20"/>
+ <textElement verticalAlignment="Middle" markup="styled"/>
+ <text><![CDATA[Q<sub>max,measured</sub>]]></text>
+ </staticText>
+ <staticText>
+ <reportElement x="0" y="0" width="39" height="20"/>
+ <textElement verticalAlignment="Middle"/>
+ <text><![CDATA[R-km ]]></text>
+ </staticText>
+ <staticText>
+ <reportElement x="325" y="0" width="26" height="20"/>
+ <textElement verticalAlignment="Middle" markup="styled"/>
+ <text><![CDATA[r²]]></text>
+ </staticText>
+ <staticText>
+ <reportElement x="351" y="0" width="40" height="20"/>
+ <textElement verticalAlignment="Middle" markup="styled"/>
+ <text><![CDATA[n<sub>total</sub>]]></text>
+ </staticText>
+ <staticText>
+ <reportElement x="189" y="0" width="76" height="20"/>
+ <textElement verticalAlignment="Middle" markup="styled"/>
+ <text><![CDATA[Standard err]]></text>
+ </staticText>
+ <staticText>
+ <reportElement x="154" y="0" width="35" height="20"/>
+ <textElement verticalAlignment="Middle"/>
+ <text><![CDATA[b]]></text>
+ </staticText>
+ <staticText>
+ <reportElement x="39" y="0" width="55" height="20"/>
+ <textElement verticalAlignment="Middle"/>
+ <text><![CDATA[Parameter]]></text>
+ </staticText>
+ </band>
+ </columnHeader>
+ <detail>
+ <band height="14" splitType="Stretch">
+ <textField isStretchWithOverflow="true" isBlankWhenNull="true">
+ <reportElement stretchType="RelativeToBandHeight" x="435" y="0" width="35" height="14"/>
+ <textElement verticalAlignment="Middle"/>
+ <textFieldExpression><![CDATA[$F{cduan}]]></textFieldExpression>
+ </textField>
+ <textField isStretchWithOverflow="true" isBlankWhenNull="true">
+ <reportElement stretchType="RelativeToBandHeight" x="391" y="0" width="44" height="14"/>
+ <textElement verticalAlignment="Middle"/>
+ <textFieldExpression><![CDATA[$F{out}]]></textFieldExpression>
+ </textField>
+ <textField isStretchWithOverflow="true" isBlankWhenNull="true">
+ <reportElement stretchType="RelativeToBandHeight" x="154" y="0" width="35" height="14"/>
+ <textElement verticalAlignment="Middle"/>
+ <textFieldExpression><![CDATA[$F{b}]]></textFieldExpression>
+ </textField>
+ <textField isBlankWhenNull="true">
+ <reportElement x="39" y="0" width="55" height="14"/>
+ <textElement verticalAlignment="Middle"/>
+ <textFieldExpression><![CDATA[$F{param}]]></textFieldExpression>
+ </textField>
+ <textField isBlankWhenNull="true">
+ <reportElement x="0" y="0" width="39" height="14"/>
+ <textElement verticalAlignment="Middle"/>
+ <textFieldExpression><![CDATA[$F{km}]]></textFieldExpression>
+ </textField>
+ <textField isStretchWithOverflow="true" isBlankWhenNull="true">
+ <reportElement stretchType="RelativeToBandHeight" x="470" y="0" width="45" height="14"/>
+ <textElement verticalAlignment="Middle"/>
+ <textFieldExpression><![CDATA[$F{cferg}]]></textFieldExpression>
+ </textField>
+ <textField isBlankWhenNull="true">
+ <reportElement x="94" y="0" width="60" height="14"/>
+ <textElement verticalAlignment="Middle"/>
+ <textFieldExpression><![CDATA[$F{a}]]></textFieldExpression>
+ </textField>
+ <textField isBlankWhenNull="true">
+ <reportElement x="189" y="0" width="76" height="14"/>
+ <textElement verticalAlignment="Middle"/>
+ <textFieldExpression><![CDATA[$F{sd}]]></textFieldExpression>
+ </textField>
+ <textField isStretchWithOverflow="true" isBlankWhenNull="true">
+ <reportElement stretchType="RelativeToBandHeight" x="265" y="0" width="60" height="14"/>
+ <textElement verticalAlignment="Middle"/>
+ <textFieldExpression><![CDATA[$F{qmax}]]></textFieldExpression>
+ </textField>
+ <textField isStretchWithOverflow="true" isBlankWhenNull="true">
+ <reportElement stretchType="RelativeToBandHeight" x="351" y="0" width="40" height="14" isPrintWhenDetailOverflows="true"/>
+ <textElement verticalAlignment="Middle"/>
+ <textFieldExpression><![CDATA[$F{total}]]></textFieldExpression>
+ </textField>
+ <textField isBlankWhenNull="true">
+ <reportElement x="325" y="0" width="26" height="14"/>
+ <textElement verticalAlignment="Middle"/>
+ <textFieldExpression><![CDATA[$F{r2}]]></textFieldExpression>
+ </textField>
+ </band>
+ </detail>
+ <pageFooter>
+ <band height="29" splitType="Stretch">
+ <textField evaluationTime="Report">
+ <reportElement x="458" y="9" width="57" height="20"/>
+ <textElement/>
+ <textFieldExpression><![CDATA[" / " + ($V{PAGE_NUMBER} + $P{MEASUREMENT_PAGE_NUM})]]></textFieldExpression>
+ </textField>
+ <textField>
+ <reportElement x="403" y="9" width="55" height="20"/>
+ <textElement textAlignment="Right"/>
+ <textFieldExpression><![CDATA[$V{PAGE_NUMBER}]]></textFieldExpression>
+ </textField>
+ </band>
+ </pageFooter>
+ <summary>
+ <band height="42" splitType="Stretch"/>
+ </summary>
+</jasperReport>
diff -r 3fae08a8cb90 -r 4eb1a3c71579 artifacts/src/main/java/org/dive4elements/river/artifacts/model/sq/SQMeasurementsJRDataSource.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/model/sq/SQMeasurementsJRDataSource.java Mon Mar 16 11:35:19 2015 +0100
@@ -0,0 +1,66 @@
+/* Copyright (C) 2011, 2012, 2013, 2015 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.artifacts.model.sq;
+
+import java.util.ArrayList;
+
+import org.apache.log4j.Logger;
+
+import net.sf.jasperreports.engine.JRDataSource;
+import net.sf.jasperreports.engine.JRException;
+import net.sf.jasperreports.engine.JRField;
+
+
+/**
+ * @author <a href="mailto:aheinecke at intevation.de">Andre Heinecke</a>
+ */
+public class SQMeasurementsJRDataSource implements JRDataSource
+{
+ /** The log used in this exporter.*/
+ private static Logger log = Logger.getLogger(SQMeasurementsJRDataSource.class);
+
+ private ArrayList<String[]> data;
+
+ private int index = -1;
+
+ public SQMeasurementsJRDataSource() {
+ data = new ArrayList<String[]>();
+ }
+
+ public void addData(String[] val) {
+ data.add(val);
+ }
+
+ public boolean next() throws JRException {
+ index++;
+ return (index < data.size());
+ }
+
+ public Object getFieldValue(JRField field) throws JRException {
+ Object value = "";
+ String fieldName = field.getName();
+ if ("param".equals(fieldName)) {
+ value = data.get(index)[0];
+ }
+ else if ("transport".equals(fieldName)) {
+ value = data.get(index)[1];
+ }
+ else if ("discharge".equals(fieldName)) {
+ value = data.get(index)[2];
+ }
+ else if ("date".equals(fieldName)) {
+ value = data.get(index)[3];
+ }
+ else if ("outlier".equals(fieldName)) {
+ value = data.get(index)[4];
+ }
+ return value;
+ }
+}
+// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
diff -r 3fae08a8cb90 -r 4eb1a3c71579 artifacts/src/main/java/org/dive4elements/river/exports/sq/SQRelationExporter.java
--- a/artifacts/src/main/java/org/dive4elements/river/exports/sq/SQRelationExporter.java Mon Mar 16 10:00:39 2015 +0100
+++ b/artifacts/src/main/java/org/dive4elements/river/exports/sq/SQRelationExporter.java Mon Mar 16 11:35:19 2015 +0100
@@ -1,4 +1,4 @@
-/* Copyright (C) 2011, 2012, 2013 by Bundesanstalt für Gewässerkunde
+/* Copyright (C) 2011, 2012, 2013, 2015 by Bundesanstalt für Gewässerkunde
* Software engineering by Intevation GmbH
*
* This file is Free Software under the GNU AGPL (>=v3)
@@ -21,6 +21,7 @@
import net.sf.jasperreports.engine.JasperExportManager;
import net.sf.jasperreports.engine.JasperFillManager;
import net.sf.jasperreports.engine.JasperPrint;
+import net.sf.jasperreports.engine.JRPrintPage;
import net.sf.jasperreports.engine.JRException;
import au.com.bytecode.opencsv.CSVWriter;
@@ -32,6 +33,7 @@
import org.dive4elements.river.artifacts.model.sq.SQResult;
import org.dive4elements.river.artifacts.model.sq.SQ;
import org.dive4elements.river.artifacts.model.sq.SQRelationJRDataSource;
+import org.dive4elements.river.artifacts.model.sq.SQMeasurementsJRDataSource;
import org.dive4elements.river.artifacts.model.Parameters;
import org.dive4elements.river.artifacts.model.DateRange;
import org.dive4elements.river.artifacts.access.SQRelationAccess;
@@ -175,6 +177,9 @@
public static final String JASPER_FILE =
"export.sqrelation.pdf.file";
+ public static final String JASPER_MEASUREMENTS_FILE =
+ "export.sqrelation.measurements.pdf.file";
+
protected List<SQResult []> data;
public SQRelationExporter() {
@@ -239,12 +244,12 @@
for (SQResult [] results: data) {
for (SQResult result: results) {
- writer.writeAll(data2StringArrays(result));
+ writer.writeAll(data2StringArrays(result, true));
}
}
}
- protected List<String[]> data2StringArrays(SQResult result) {
+ protected List<String[]> data2StringArrays(SQResult result, boolean includeMeasurements) {
String km = Formatter.getSQRelationKM(context
).format(result.getKm());
List<String[]> retval = new ArrayList<String[]>();
@@ -283,7 +288,26 @@
o = String.valueOf(fraction.totalNumOutliers());
t = String.valueOf(fraction.numMeasurements());
- for (SQ sq: fraction.getMeasurements()) {
+ if (includeMeasurements) {
+ for (SQ sq: fraction.getMeasurements()) {
+ retval.add(new String[] {
+ km,
+ name,
+ a,
+ b,
+ sd, // 4
+ max_q, // 5
+ r2, // 6
+ t, // 7
+ o, // 8
+ c_duan, // 9
+ c_ferguson, // 10
+ sqAFormatter.format(sq.getS()),
+ fZeroFormatter.format(sq.getQ()),
+ df.format(sq.getDate())
+ });
+ }
+ } else {
retval.add(new String[] {
km,
name,
@@ -295,10 +319,7 @@
t, // 7
o, // 8
c_duan, // 9
- c_ferguson, // 10
- sqAFormatter.format(sq.getS()),
- fZeroFormatter.format(sq.getQ()),
- df.format(sq.getDate())
+ c_ferguson // 10
});
}
@@ -313,7 +334,7 @@
addMetaData(source);
for (SQResult [] results: data) {
for (SQResult result: results) {
- for (String[] res: data2StringArrays(result)) {
+ for (String[] res: data2StringArrays(result, false)) {
source.addData(res);
}
}
@@ -321,6 +342,44 @@
return source;
}
+ protected SQMeasurementsJRDataSource createMeasurementJRData() {
+ SQMeasurementsJRDataSource source = new SQMeasurementsJRDataSource();
+ NumberFormat fZeroFormatter = Formatter.getFormatter(context, 0, 0);
+ NumberFormat fEightFormatter = Formatter.getFormatter(context, 0, 8);
+ DateFormat df = DateFormat.getDateInstance(DateFormat.SHORT,
+ Resources.getLocale(context.getMeta()));
+
+ for (SQResult [] results: data) {
+ for (SQResult result: results) {
+ for (int i = 0; i < SQResult.NUMBER_FRACTIONS; ++i) {
+ String name = result.getFractionName(i);
+ SQFractionResult fraction = result.getFraction(i);
+ for (SQ sq: fraction.getMeasurements()) {
+ source.addData(new String[] {
+ name,
+ fEightFormatter.format(sq.getS()),
+ fZeroFormatter.format(sq.getQ()),
+ df.format(sq.getDate()),
+ null
+ });
+ }
+ for (int j = 0; j < fraction.numIterations(); j++) {
+ for (SQ sq: fraction.getOutliers(j)) {
+ source.addData(new String[] {
+ name,
+ fEightFormatter.format(sq.getS()),
+ fZeroFormatter.format(sq.getQ()),
+ df.format(sq.getDate()),
+ Integer.toString(j + 1)
+ });
+ }
+ }
+ }
+ }
+ }
+ return source;
+ }
+
protected void addMetaData(SQRelationJRDataSource source) {
CallMeta meta = context.getMeta();
@@ -373,11 +432,16 @@
protected void writePDF(OutputStream out) {
log.debug("write PDF");
SQRelationJRDataSource source = createJRData();
+ SQMeasurementsJRDataSource measureSource = createMeasurementJRData();
String jasperFile = Resources.getMsg(
- context.getMeta(),
- JASPER_FILE,
- "/jasper/sqrelation_en.jasper");
+ context.getMeta(),
+ JASPER_FILE,
+ "/jasper/sqrelation_en.jasper");
+ String jasperMeasurementsFile = Resources.getMsg(
+ context.getMeta(),
+ JASPER_MEASUREMENTS_FILE,
+ "/jasper/sqmeasurements_en.jasper");
String confPath = Config.getConfigDirectory().toString();
@@ -385,11 +449,22 @@
parameters.put("ReportTitle", Resources.getMsg(
context.getMeta(), PDF_TITLE, "Exported Data"));
try {
- JasperPrint print = JasperFillManager.fillReport(
+ /* Page numbers start have a built in offset of 1 so this
+ * is fine. */
+ JasperPrint p2 = JasperFillManager.fillReport(
+ confPath + jasperMeasurementsFile,
+ parameters,
+ measureSource);
+ parameters.put("MEASUREMENT_PAGE_NUM", p2.getPages().size());
+ JasperPrint p1 = JasperFillManager.fillReport(
confPath + jasperFile,
parameters,
source);
- JasperExportManager.exportReportToPdfStream(print, out);
+ for (Object page: p2.getPages()) {
+ JRPrintPage object = (JRPrintPage)page;
+ p1.addPage(object);
+ }
+ JasperExportManager.exportReportToPdfStream(p1, out);
}
catch(JRException je) {
log.warn("Error generating PDF Report!", je);
diff -r 3fae08a8cb90 -r 4eb1a3c71579 artifacts/src/main/resources/messages.properties
--- a/artifacts/src/main/resources/messages.properties Mon Mar 16 10:00:39 2015 +0100
+++ b/artifacts/src/main/resources/messages.properties Mon Mar 16 11:35:19 2015 +0100
@@ -479,6 +479,7 @@
export.sqrelation.csv.header.q = Q [m\u00b3/s]
export.sqrelation.csv.header.date = Measurement date
export.sqrelation.pdf.file = /jasper/sqrelation_en.jasper
+export.sqrelation.measurements.pdf.file = /jasper/sqmeasurements_en.jasper
export.sqrelation.pdf.mode = Load Discharge Relation
export.minfo.bedquality.km = km
export.minfo.bedquality.density_cap = Density Toplayer
diff -r 3fae08a8cb90 -r 4eb1a3c71579 artifacts/src/main/resources/messages_de.properties
--- a/artifacts/src/main/resources/messages_de.properties Mon Mar 16 10:00:39 2015 +0100
+++ b/artifacts/src/main/resources/messages_de.properties Mon Mar 16 11:35:19 2015 +0100
@@ -481,6 +481,7 @@
export.sqrelation.csv.header.q = Q [m\u00b3/s]
export.sqrelation.csv.header.date = Messdatum
export.sqrelation.pdf.file = /jasper/sqrelation.jasper
+export.sqrelation.measurements.pdf.file = /jasper/sqmeasurements.jasper
export.sqrelation.pdf.mode = Transport-Abfluss Beziehung
export.minfo.bedquality.km = km
export.minfo.bedquality.density_cap = Sedimentdichte Deckschicht [t/m\u00b3]
diff -r 3fae08a8cb90 -r 4eb1a3c71579 artifacts/src/main/resources/messages_de_DE.properties
--- a/artifacts/src/main/resources/messages_de_DE.properties Mon Mar 16 10:00:39 2015 +0100
+++ b/artifacts/src/main/resources/messages_de_DE.properties Mon Mar 16 11:35:19 2015 +0100
@@ -477,6 +477,7 @@
export.sqrelation.csv.header.q = Q [m\u00b3/s]
export.sqrelation.csv.header.date = Messdatum
export.sqrelation.pdf.file = /jasper/sqrelation.jasper
+export.sqrelation.measurements.pdf.file = /jasper/sqmeasurements.jasper
export.sqrelation.pdf.mode = Transport-Abfluss Beziehung
export.minfo.bedquality.km = km
export.minfo.bedquality.density_cap = Sedimentdichte Deckschicht [t/m\u00b3]
diff -r 3fae08a8cb90 -r 4eb1a3c71579 artifacts/src/main/resources/messages_en.properties
--- a/artifacts/src/main/resources/messages_en.properties Mon Mar 16 10:00:39 2015 +0100
+++ b/artifacts/src/main/resources/messages_en.properties Mon Mar 16 11:35:19 2015 +0100
@@ -481,6 +481,7 @@
export.sqrelation.csv.header.q = Q [m\u00b3/s]
export.sqrelation.csv.header.date = Measurement date
export.sqrelation.pdf.file = /jasper/sqrelation_en.jasper
+export.sqrelation.measurements.pdf.file = /jasper/sqmeasurements_en.jasper
export.sqrelation.pdf.mode = Load Discharge Relation
export.minfo.bedquality.km = km
export.minfo.bedquality.density_cap = Density Toplayer [t/m\u00b3]
More information about the Dive4Elements-commits
mailing list