Mercurial > dive4elements > river
changeset 9306:8024e51e828a
pdf export, issue 2.3.4.1.2
author | gernotbelger |
---|---|
date | Wed, 25 Jul 2018 18:36:26 +0200 |
parents | 8b3ecb1a7e16 |
children | 45bbd2c232f8 |
files | artifacts/doc/conf/artifacts/bundu.xml artifacts/doc/conf/artifacts/fixanalysis.xml artifacts/doc/conf/jasper/templates/fixanalysis.delta_wt.jrxml artifacts/src/main/java/org/dive4elements/river/artifacts/common/DefaultCalculationResult.java artifacts/src/main/java/org/dive4elements/river/artifacts/common/DefaultCalculationResults.java artifacts/src/main/java/org/dive4elements/river/artifacts/common/JasperReporter.java artifacts/src/main/java/org/dive4elements/river/exports/fixings/DeltaWtExporter.java |
diffstat | 7 files changed, 361 insertions(+), 34 deletions(-) [+] |
line wrap: on
line diff
--- a/artifacts/doc/conf/artifacts/bundu.xml Wed Jul 25 16:20:27 2018 +0200 +++ b/artifacts/doc/conf/artifacts/bundu.xml Wed Jul 25 18:36:26 2018 +0200 @@ -122,14 +122,14 @@ <outputmode name="fix_deltawt_export" description="output.fix_deltawt_export" mine-type="text/plain" type="export"> <facets> <facet name="csv" description="facet.fix_deltawt.csv" /> - <facet name="pdf" description="facet.fix_deltawt.pdf" /> + <facet name="pdf" description="facet.waterlevel_export.pdf" /> </facets> </outputmode> <outputmode name="fix_parameters_export" description="output.fix_parameters_export" mine-type="text/plain" type="export"> <facets> <facet name="fix_parameters" description="facet.fix_parameters.csv" /> </facets> - </outputmode> + </outputmode> <outputmode name="fix_wq_curve_at_export" description="output.fix_wq_curve_at_export" mime-type="text/plain" type="export"> <facets> <facet name="at" description="facet.fix_wq_curve_export.at" /> @@ -405,7 +405,7 @@ <state id="state.bundu.wst.load.calc_choice" helpText="state.bundu.wst.load.calc_choice" description="state.bundu.wst.load.calc_choice" state="org.dive4elements.river.artifacts.bundu.bezugswst.CalcChoice"> <data name="calc_choice" type="String" /> - <data name="function" type="String" /> <!-- will be set, if auto is selected --> + <data name="function" type="String" /> <!-- will be set, if auto is selected --> </state> <transition transition="org.dive4elements.river.artifacts.transitions.ValueCompareTransition"> @@ -454,7 +454,7 @@ <transition transition="org.dive4elements.river.artifacts.transitions.ValueCompareTransition"> <from state="state.bundu.wst.load.missing_volume" /> - <to state="state.bundu.wst.soundings" /> + <to state="state.bundu.wst.soundings" /> <condition data="missing_volume" value="false" operator="equal" /> </transition>
--- a/artifacts/doc/conf/artifacts/fixanalysis.xml Wed Jul 25 16:20:27 2018 +0200 +++ b/artifacts/doc/conf/artifacts/fixanalysis.xml Wed Jul 25 18:36:26 2018 +0200 @@ -104,20 +104,18 @@ </transition> <state id="state.fix.analysis.compute" helpText="help.state.fix.analysis.compute" description="state.fix.analysis.compute" state="org.dive4elements.river.artifacts.states.fixation.FixAnalysisCompute"> - <outputmodes> - <outputmode name="fix_deltawt_export" description="output.fix_deltawt_export" mime-type="text/plain" type="export"> + <outputmodes> + <outputmode name="fix_deltawt_export" description="output.fix_deltawt_export" mine-type="text/plain" type="export"> <facets> - <facet name="csv" description="facet.fix_deltawt.csv" /> - </facets> - </outputmode> - <outputmode name="fix_waterlevel_export" description="output.fix_waterlevel_export" mime-type="text/plain" type="export"> - <facets> - <facet name="csv" description="facet.waterlevel_export.csv" /> - <facet name="wst" description="facet.waterlevel_export.wst" /> + <facet name="csv" description="facet.fix_deltawt.csv" /> <facet name="pdf" description="facet.waterlevel_export.pdf" /> </facets> </outputmode> - + <outputmode name="fix_parameters_export" description="output.fix_parameters_export" mine-type="text/plain" type="export"> + <facets> + <facet name="fix_parameters" description="facet.fix_parameters.csv" /> + </facets> + </outputmode> <outputmode name="fix_parameters_export" description="output.fix_parameters_export" mime-type="text/plain" type="export"> <facets> <facet name="fix_parameters" description="facet.fix_parameters.csv" /> @@ -128,7 +126,7 @@ <facet name="at" description="facet.fix_wq_curve_export.at" /> </facets> </outputmode> - + <outputmode name="fix_wq_curve" description="output.fix_wq_curve" mime-type="image/png" type="chart"> <facets> <facet name="fix_sector_average_wq_0" description="Average values for Ws in Q sectors." /> @@ -301,6 +299,6 @@ </outputmode> </outputmodes> </state> - + </states> </artifact>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/artifacts/doc/conf/jasper/templates/fixanalysis.delta_wt.jrxml Wed Jul 25 18:36:26 2018 +0200 @@ -0,0 +1,255 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- Created with Jaspersoft Studio version 6.5.1.final using JasperReports Library version 4.5.0 --> +<!-- 2018-07-25T18:01:47 --> +<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="545" leftMargin="30" rightMargin="20" topMargin="20" bottomMargin="20"> + <property name="ireport.zoom" value="1.0"/> + <property name="ireport.x" value="0"/> + <property name="ireport.y" value="0"/> + <style name="htmlStyle" isDefault="true" mode="Transparent" markup="html" fontName="Roboto"> + <paragraph lineSpacing="Single"/> + </style> + <field name="meta:header" class="java.lang.String"/> + <field name="meta:calcMode" class="java.lang.String"/> + <field name="meta:version_label" class="java.lang.String"/> + <field name="meta:version" class="java.lang.String"/> + <field name="meta:user_label" class="java.lang.String"/> + <field name="meta:user" class="java.lang.String"/> + <field name="meta:date_label" class="java.lang.String"/> + <field name="meta:date" class="java.lang.String"/> + <field name="meta:river_label" class="java.lang.String"/> + <field name="meta:river" class="java.lang.String"/> + <field name="meta:range_label" class="java.lang.String"/> + <field name="meta:range" class="java.lang.String"/> + <field name="meta:calculation_label" class="java.lang.String"/> + <field name="meta:calculation_name" class="java.lang.String"/> + <field name="meta:station_header" class="java.lang.String"/> + <field name="meta:flowdepthdevelopment_header" class="java.lang.String"/> + <field name="meta:flowdepthdevelopmentperyear_header" class="java.lang.String"/> + <field name="meta:waterleveldifference_header" class="java.lang.String"/> + <field name="meta:waterleveldifference_header2" class="java.lang.String"/> + <field name="meta:waterleveldifference_header_label" class="java.lang.String"/> + <field name="meta:bedheightdifference_header" class="java.lang.String"/> + <field name="meta:bedheightdifference_header2" class="java.lang.String"/> + <field name="meta:bedheightdifference_header_label" class="java.lang.String"/> + <field name="meta:flowdepthcurrent_header" class="java.lang.String"/> + <field name="meta:flowdepthcurrent_header2" class="java.lang.String"/> + <field name="meta:flowdepthhistorical_header" class="java.lang.String"/> + <field name="meta:flowdepthhistorical_header2" class="java.lang.String"/> + <field name="meta:flowdepthcurrent_header_label" class="java.lang.String"/> + <field name="meta:flowdepthhistorical_header_label" class="java.lang.String"/> + <field name="meta:flowdepth_header" class="java.lang.String"/> + <field name="meta:flowdepthdevelopment" class="java.lang.String"/> + <field name="meta:flowdepthmin_header" class="java.lang.String"/> + <field name="meta:flowdepthmax_header" class="java.lang.String"/> + <field name="meta:flowdepthdevelopment_header_label" class="java.lang.String"/> + <field name="meta:flowdepth_tkh_header" class="java.lang.String"/> + <field name="meta:tkh_header" class="java.lang.String"/> + <field name="meta:tkhkind_header" class="java.lang.String"/> + <field name="meta:waterlevel_header" class="java.lang.String"/> + <field name="meta:discharge_header" class="java.lang.String"/> + <field name="meta:waterlevel_name_header" class="java.lang.String"/> + <field name="meta:gauge_header" class="java.lang.String"/> + <field name="meta:bedheight_header" class="java.lang.String"/> + <field name="meta:sounding_name_header" class="java.lang.String"/> + <field name="meta:location_header" class="java.lang.String"/> + <field name="meta:fix_date" class="java.lang.String"/> + <field name="meta:fix_q" class="java.lang.String"/> + <field name="meta:fix_w" class="java.lang.String"/> + <field name="meta:fix_state" class="java.lang.String"/> + <field name="meta:fix_delta_w" class="java.lang.String"/> + <field name="data:0" class="java.lang.String"/> + <field name="data:1" class="java.lang.String"/> + <field name="data:2" class="java.lang.String"/> + <field name="data:3" class="java.lang.String"/> + <field name="data:4" class="java.lang.String"/> + <field name="data:5" class="java.lang.String"/> + <background> + <band splitType="Stretch"/> + </background> + <title> + <band height="169" splitType="Stretch"> + <textField> + <reportElement style="htmlStyle" x="0" y="0" width="515" height="30"/> + <textElement> + <font size="18"/> + </textElement> + <textFieldExpression><![CDATA[$F{meta:header} + " " + $F{meta:river}]]></textFieldExpression> + </textField> + <textField> + <reportElement style="htmlStyle" x="0" y="39" width="165" height="20"/> + <textFieldExpression><![CDATA[$F{meta:calcMode}]]></textFieldExpression> + </textField> + <textField> + <reportElement style="htmlStyle" x="0" y="69" width="123" height="20"/> + <textFieldExpression><![CDATA[$F{meta:version_label} + ":"]]></textFieldExpression> + </textField> + <textField> + <reportElement style="htmlStyle" x="123" y="69" width="392" height="20"/> + <textFieldExpression><![CDATA[$F{meta:version}]]></textFieldExpression> + </textField> + <textField> + <reportElement style="htmlStyle" x="0" y="89" width="123" height="20"/> + <textFieldExpression><![CDATA[$F{meta:user_label} + ":"]]></textFieldExpression> + </textField> + <textField> + <reportElement style="htmlStyle" x="123" y="89" width="392" height="20"/> + <textFieldExpression><![CDATA[$F{meta:user}]]></textFieldExpression> + </textField> + <textField> + <reportElement style="htmlStyle" x="0" y="109" width="123" height="20"/> + <textFieldExpression><![CDATA[$F{meta:date_label} + ":"]]></textFieldExpression> + </textField> + <textField> + <reportElement style="htmlStyle" x="123" y="109" width="392" height="20"/> + <textFieldExpression><![CDATA[$F{meta:date}]]></textFieldExpression> + </textField> + <textField> + <reportElement style="htmlStyle" x="0" y="129" width="123" height="20"/> + <textFieldExpression><![CDATA[$F{meta:river_label} + ":"]]></textFieldExpression> + </textField> + <textField> + <reportElement style="htmlStyle" x="123" y="129" width="392" height="20"/> + <textFieldExpression><![CDATA[$F{meta:river}]]></textFieldExpression> + </textField> + <textField> + <reportElement style="htmlStyle" x="0" y="149" width="123" height="20"/> + <textFieldExpression><![CDATA[$F{meta:range_label} + ":"]]></textFieldExpression> + </textField> + <textField> + <reportElement style="htmlStyle" x="123" y="149" width="392" height="20"/> + <textFieldExpression><![CDATA[$F{meta:range}]]></textFieldExpression> + </textField> + </band> + </title> + <columnHeader> + <band height="25" splitType="Stretch"> + <line> + <reportElement style="htmlStyle" positionType="FixRelativeToBottom" x="0" y="24" width="550" height="1"/> + </line> + <textField isStretchWithOverflow="true"> + <reportElement style="htmlStyle" positionType="Float" stretchType="RelativeToBandHeight" x="0" y="0" width="85" height="24"/> + <box padding="5"/> + <textElement textAlignment="Right" verticalAlignment="Bottom"/> + <textFieldExpression><![CDATA[$F{meta:station_header}]]></textFieldExpression> + </textField> + <textField isStretchWithOverflow="true"> + <reportElement style="htmlStyle" positionType="Float" stretchType="RelativeToBandHeight" x="85" y="0" width="85" height="24"/> + <box padding="5"/> + <textElement textAlignment="Left" verticalAlignment="Bottom"/> + <textFieldExpression><![CDATA[$F{meta:fix_date}]]></textFieldExpression> + </textField> + <textField isStretchWithOverflow="true"> + <reportElement style="htmlStyle" positionType="Float" stretchType="RelativeToBandHeight" x="170" y="0" width="85" height="24"/> + <box padding="5"/> + <textElement textAlignment="Right" verticalAlignment="Bottom"/> + <textFieldExpression><![CDATA[$F{meta:fix_q}]]></textFieldExpression> + </textField> + <textField isStretchWithOverflow="true"> + <reportElement style="htmlStyle" positionType="Float" stretchType="RelativeToBandHeight" x="255" y="0" width="85" height="24"/> + <box padding="5"/> + <textElement textAlignment="Right" verticalAlignment="Bottom"/> + <textFieldExpression><![CDATA[$F{meta:fix_w}]]></textFieldExpression> + </textField> + <textField isStretchWithOverflow="true"> + <reportElement style="htmlStyle" positionType="Float" stretchType="RelativeToBandHeight" x="340" y="0" width="60" height="24"/> + <box padding="5"/> + <textElement textAlignment="Left" verticalAlignment="Bottom"/> + <textFieldExpression><![CDATA[$F{meta:fix_state}]]></textFieldExpression> + </textField> + <textField isStretchWithOverflow="true"> + <reportElement style="htmlStyle" positionType="Float" stretchType="RelativeToBandHeight" x="400" y="0" width="85" height="24"/> + <box padding="5"/> + <textElement textAlignment="Right" verticalAlignment="Bottom"/> + <textFieldExpression><![CDATA[$F{meta:fix_delta_w}]]></textFieldExpression> + </textField> + </band> + </columnHeader> + <detail> + <band height="15" splitType="Prevent"> + <textField isStretchWithOverflow="true" isBlankWhenNull="true"> + <reportElement style="htmlStyle" positionType="Float" stretchType="RelativeToBandHeight" x="0" y="0" width="85" height="15"/> + <box topPadding="2" leftPadding="5" bottomPadding="0" rightPadding="5"> + <topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <bottomPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + </box> + <textElement textAlignment="Right" verticalAlignment="Top"/> + <textFieldExpression><![CDATA[$F{data:0}]]></textFieldExpression> + </textField> + <textField isStretchWithOverflow="true" isBlankWhenNull="true"> + <reportElement style="htmlStyle" positionType="Float" stretchType="RelativeToBandHeight" x="85" y="0" width="85" height="15"/> + <box topPadding="2" leftPadding="5" bottomPadding="0" rightPadding="5"> + <topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <bottomPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + </box> + <textElement textAlignment="Left" verticalAlignment="Top"/> + <textFieldExpression><![CDATA[$F{data:1}]]></textFieldExpression> + </textField> + <textField isStretchWithOverflow="true" isBlankWhenNull="true"> + <reportElement style="htmlStyle" positionType="Float" stretchType="RelativeToBandHeight" x="170" y="0" width="85" height="15"/> + <box topPadding="2" leftPadding="5" bottomPadding="0" rightPadding="5"> + <topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <bottomPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + </box> + <textElement textAlignment="Right" verticalAlignment="Top"/> + <textFieldExpression><![CDATA[$F{data:2}]]></textFieldExpression> + </textField> + <textField isStretchWithOverflow="true" isBlankWhenNull="true"> + <reportElement style="htmlStyle" positionType="Float" stretchType="RelativeToBandHeight" x="255" y="0" width="85" height="15"/> + <box topPadding="2" leftPadding="5" bottomPadding="0" rightPadding="5"> + <topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <bottomPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + </box> + <textElement textAlignment="Right" verticalAlignment="Top"/> + <textFieldExpression><![CDATA[$F{data:3}]]></textFieldExpression> + </textField> + <textField isStretchWithOverflow="true" isBlankWhenNull="true"> + <reportElement style="htmlStyle" positionType="Float" stretchType="RelativeToBandHeight" x="340" y="0" width="60" height="15"/> + <box topPadding="2" leftPadding="5" bottomPadding="0" rightPadding="5"> + <topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <bottomPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + </box> + <textElement textAlignment="Left" verticalAlignment="Top"/> + <textFieldExpression><![CDATA[$F{data:4}]]></textFieldExpression> + </textField> + <textField isStretchWithOverflow="true" isBlankWhenNull="true"> + <reportElement style="htmlStyle" positionType="Float" stretchType="RelativeToBandHeight" x="400" y="0" width="85" height="15"/> + <box topPadding="2" leftPadding="5" bottomPadding="0" rightPadding="5"> + <topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <bottomPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + </box> + <textElement textAlignment="Right" verticalAlignment="Top"/> + <textFieldExpression><![CDATA[$F{data:5}]]></textFieldExpression> + </textField> + </band> + </detail> + <pageFooter> + <band height="15" splitType="Stretch"> + <textField isStretchWithOverflow="true"> + <reportElement style="htmlStyle" x="437" y="0" width="55" height="15"/> + <box topPadding="2" rightPadding="3"/> + <textElement textAlignment="Right"/> + <textFieldExpression><![CDATA[$V{PAGE_NUMBER}]]></textFieldExpression> + </textField> + <textField isStretchWithOverflow="true" evaluationTime="Report"> + <reportElement style="htmlStyle" x="493" y="0" width="57" height="15"/> + <box topPadding="2" leftPadding="0" bottomPadding="0" rightPadding="0"/> + <textFieldExpression><![CDATA["/ " + $V{PAGE_NUMBER}]]></textFieldExpression> + </textField> + </band> + </pageFooter> + <summary> + <band height="30" splitType="Stretch"/> + </summary> +</jasperReport>
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/common/DefaultCalculationResult.java Wed Jul 25 16:20:27 2018 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/common/DefaultCalculationResult.java Wed Jul 25 18:36:26 2018 +0200 @@ -17,6 +17,8 @@ */ public class DefaultCalculationResult extends AbstractCalculationResult { + private static final long serialVersionUID = 1L; + public DefaultCalculationResult(final String label, final Collection<ResultRow> rows) { super(label, rows); // do nothing,
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/common/DefaultCalculationResults.java Wed Jul 25 18:36:26 2018 +0200 @@ -0,0 +1,26 @@ +/** Copyright (C) 2017 by Bundesanstalt für Gewässerkunde + * Software engineering by + * Björnsen Beratende Ingenieure GmbH + * Dr. Schumacher Ingenieurbüro für Wasser und Umwelt + * + * 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.common; + +import org.apache.commons.lang.math.DoubleRange; +import org.dive4elements.river.artifacts.sinfo.util.RiverInfo; + +/** + * @author Gernot Belger + */ +public class DefaultCalculationResults extends AbstractCalculationResults<DefaultCalculationResult> { + + private static final long serialVersionUID = 1L; + + public DefaultCalculationResults(final String calcModeLabel, final String user, final RiverInfo river, final DoubleRange calcRange) { + super(calcModeLabel, user, river, calcRange); + } + +} \ No newline at end of file
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/common/JasperReporter.java Wed Jul 25 16:20:27 2018 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/common/JasperReporter.java Wed Jul 25 18:36:26 2018 +0200 @@ -62,13 +62,9 @@ } public void exportPDF(final OutputStream out) throws JRException { - final List<JasperReport> compiledReports = new ArrayList<>(); - final List<JRDataSource> sourcesWithPages = new ArrayList<>(); - final List<JasperPrint> jasperPrintList = new ArrayList<>(); - if (this.designs.size() == 1) { final JasperDesigner designer = this.designs.get(0); final JasperDesign jDesign = designer.getDesign();
--- a/artifacts/src/main/java/org/dive4elements/river/exports/fixings/DeltaWtExporter.java Wed Jul 25 16:20:27 2018 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/exports/fixings/DeltaWtExporter.java Wed Jul 25 18:36:26 2018 +0200 @@ -20,23 +20,34 @@ import org.apache.log4j.Logger; import org.dive4elements.artifacts.CallMeta; import org.dive4elements.river.artifacts.D4EArtifact; +import org.dive4elements.river.artifacts.access.RangeAccess; import org.dive4elements.river.artifacts.access.RiverAccess; +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.CalculationResult; import org.dive4elements.river.artifacts.model.fixings.AnalysisPeriod; import org.dive4elements.river.artifacts.model.fixings.FixAnalysisResult; import org.dive4elements.river.artifacts.model.fixings.QWD; import org.dive4elements.river.artifacts.resources.Resources; +import org.dive4elements.river.artifacts.sinfo.util.CalculationUtils; +import org.dive4elements.river.artifacts.sinfo.util.RiverInfo; import org.dive4elements.river.exports.AbstractExporter; import org.dive4elements.river.utils.Formatter; import org.dive4elements.river.utils.KMIndex; import au.com.bytecode.opencsv.CSVWriter; +import net.sf.jasperreports.engine.JRException; /** Exports fixation analysis deltaw(t) computation results to csv. */ public class DeltaWtExporter extends AbstractExporter { /** Private log. */ private static Logger log = Logger.getLogger(DeltaWtExporter.class); + private static final String JASPER_FILE = "/jasper/templates/fixanalysis.delta_wt.jrxml"; + public static final String CSV_KM_HEADER = "export.fixings.deltawt.csv.header.km"; public static final String CSV_DELTA_W_HEADER = "export.fixings.deltawt.csv.header.deltaw"; @@ -106,6 +117,17 @@ writeCSVHeader(writer); + final TreeMap<Double, ArrayList<String[]>> sorted = getRows(); + for (final ArrayList<String[]> list : sorted.values()) { + for (final String[] row : list) { + writer.writeNext(row); + } + } + + writer.flush(); + } + + private TreeMap<Double, ArrayList<String[]>> getRows() { final NumberFormat kmF = getKMFormatter(); final NumberFormat dwF = getDeltaWFormatter(); final NumberFormat qF = getQFormatter(); @@ -142,9 +164,9 @@ } } - if (debug) { - log.debug("AnalysisPeriods: " + this.analysisPeriods.size()); - } + // if (debug) { + // log.debug("AnalysisPeriods: " + this.analysisPeriods.size()); + // } final String analysisTemplate = getAnalysisTemplate(); @@ -183,14 +205,8 @@ } } } + return sorted; - for (final ArrayList<String[]> list : sorted.values()) { - for (final String[] row : list) { - writer.writeNext(row); - } - } - - writer.flush(); } /** Template to create "State" strings like A1,A2... */ @@ -241,10 +257,44 @@ msg(CSV_TRANGE_HEADER, DEFAULT_CSV_TRANGE_DESC_HEADER), msg(CSV_DELTA_W_HEADER, DEFAULT_CSV_DELTA_W_HEADER) }); } + 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.addJRMetaDataUSINFO(source); + + /* column headings */ + contextPdf.addJRMetadata(source, "station_header", GeneralResultType.station); + contextPdf.addJRMetadata(source, "fix_date", msg(CSV_T_HEADER)); + contextPdf.addJRMetadata(source, "fix_q", msg(CSV_Q_HEADER)); + contextPdf.addJRMetadata(source, "fix_w", msg(CSV_W_HEADER, DEFAULT_CSV_W_HEADER, new Object[] { ri.getWstUnit() })); + contextPdf.addJRMetadata(source, "fix_state", msg(CSV_TRANGE_HEADER)); + contextPdf.addJRMetadata(source, "fix_delta_w", msg(CSV_DELTA_W_HEADER)); + } + @Override protected void writePDF(final OutputStream out) { - // TODO: Implement me! - // wird doch NICHT erledigt vom WaterlevelExporter + final MetaAndTableJRDataSource source = new MetaAndTableJRDataSource(); + final String jasperFile = Resources.getMsg(this.context.getMeta(), JASPER_FILE); + addMetaData(source); + try { + final TreeMap<Double, ArrayList<String[]>> sorted = getRows(); // Custom Result could be nice, too... + for (final ArrayList<String[]> list : sorted.values()) { + for (final String[] row : list) { + source.addData(row); + } + } + final JasperReporter reporter = new JasperReporter(); + reporter.addReport(jasperFile, source); + reporter.exportPDF(out); + } + catch (final JRException je) { + log.warn("Error generating PDF Report!", je); + } } -} -// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : +} \ No newline at end of file