diff artifacts/src/main/java/org/dive4elements/river/artifacts/bundu/bezugswst/BezugswstCalculationResult.java @ 9313:6ffcbb4f35d5

bundu.bezugswst first result stump
author gernotbelger
date Thu, 26 Jul 2018 15:58:08 +0200
parents
children 7b2b086e45f0
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/bundu/bezugswst/BezugswstCalculationResult.java	Thu Jul 26 15:58:08 2018 +0200
@@ -0,0 +1,115 @@
+/* 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.bundu.bezugswst;
+
+import java.util.ArrayList;
+import java.util.Collection;
+
+import org.dive4elements.river.artifacts.common.AbstractCalculationExportableResult;
+import org.dive4elements.river.artifacts.common.ExportContextCSV;
+import org.dive4elements.river.artifacts.common.ExportContextPDF;
+import org.dive4elements.river.artifacts.common.GeneralResultType;
+import org.dive4elements.river.artifacts.common.IExportContext;
+import org.dive4elements.river.artifacts.common.MetaAndTableJRDataSource;
+import org.dive4elements.river.artifacts.common.ResultRow;
+import org.dive4elements.river.artifacts.sinfo.util.BedHeightInfo;
+import org.dive4elements.river.artifacts.sinfo.util.RiverInfo;
+import org.dive4elements.river.artifacts.sinfo.util.WstInfo;
+
+/**
+ * Contains the results of a //TODO LINK{@link BezugswstCalculation}.
+ *
+ * @author Gernot Belger
+ */
+final class BezugswstCalculationResult extends AbstractCalculationExportableResult {
+
+    private static final long serialVersionUID = 1L;
+
+    private static final String JASPER_FILE = "/jasper/templates/bundu.bezugswst.jrxml";
+
+    private final WstInfo wst = null;
+    private final BedHeightInfo sounding = null;
+
+    public BezugswstCalculationResult(final String label, final Collection<ResultRow> rows // , final BedHeightInfo sounding // ,final WstInfo wst
+    ) {
+        super(label, rows);
+        // this.wst = this.wst; //TODO get Peilung and Wasserstand
+        // this.sounding = sounding;
+    }
+
+    @Override
+    protected void writeCSVResultMetadata(final ExportContextCSV exportContextCSV) {
+
+        // exportContextCSV.writeCSVSoundingMetadata(this.sounding, " ");
+        // exportContextCSV.writeBlankLine();
+        // exportContextCSV.writeCSVWaterlevelMetadata(wst);
+        // exportContextCSV.writeBlankLine();
+    }
+
+    @Override
+    protected String getJasperFile() {
+        return JASPER_FILE;
+    }
+
+    protected String[] formatRow(final IExportContext exportContext, final ResultRow row) {
+
+        final Collection<String> lines = new ArrayList<>(10);
+
+        lines.add(exportContext.formatRowValue(row, GeneralResultType.station));
+        lines.add(exportContext.formatRowValue(row, GeneralResultType.dischargeQwithUnit));
+        // lines.add(exportContext.formatRowValue(row, SInfoResultType.flowdepthDevelopment));
+
+        lines.add(exportContext.formatRowValue(row, GeneralResultType.location));
+
+        return lines.toArray(new String[lines.size()]);
+    }
+
+    @Override
+    public void writeCSVHeader(final ExportContextCSV exportContextCSV, final RiverInfo river) {
+
+        final Collection<String> header = new ArrayList<>(11);
+
+        header.add(exportContextCSV.formatCsvHeader(GeneralResultType.station));
+        header.add(exportContextCSV.formatCsvHeader(GeneralResultType.dischargeQwithUnit));
+        // header.add(exportContextCSV.msgUnitCSV(SInfoResultType.flowdepthDevelopment,
+        // SInfoResultType.flowdepthDevelopment.getUnit()));
+        // header.add(exportContextCSV.msgUnitCSV(SInfoResultType.flowdepthDevelopmentPerYear,
+        // SInfoResultType.flowdepthDevelopmentPerYear.getUnit()));
+        header.add(exportContextCSV.formatCsvHeader(GeneralResultType.location));
+
+        exportContextCSV.writeCSVLine(header.toArray(new String[header.size()]));
+
+    }
+
+    @Override
+    protected String[] formatCSVRow(final ExportContextCSV exportContextCSV, final ResultRow row) {
+
+        return this.formatRow(exportContextCSV, row);
+    }
+
+    @Override
+    protected String[] formatPDFRow(final ExportContextPDF exportContextPDF, final ResultRow row) {
+
+        return this.formatRow(exportContextPDF, row);
+    }
+
+    @Override
+    protected void addJRTableHeader(final ExportContextPDF exportContextPDF, final MetaAndTableJRDataSource source) {
+        /* column headings */
+        exportContextPDF.addJRMetadata(source, "station_header", GeneralResultType.station);
+        exportContextPDF.addJRMetadata(source, "TODO_MAKE_JASPER_REPORT...", GeneralResultType.dischargeQwithUnit);
+        // exportContextPDF.addJRMetadata(source, "flowdepthdevelopment_header", SInfoResultType.flowdepthDevelopment);
+        // exportContextPDF.addJRMetadata(source, "flowdepthdevelopmentperyear_header",
+        // SInfoResultType.flowdepthDevelopmentPerYear);
+
+        exportContextPDF.addJRMetadata(source, "location_header", GeneralResultType.location);
+
+    }
+}
\ No newline at end of file

http://dive4elements.wald.intevation.org