[PATCH] salix.supraRegional+Regional results

Wald Commits scm-commit at wald.intevation.org
Wed Jul 11 13:36:30 CEST 2018


# HG changeset patch
# User gernotbelger
# Date 1531308978 -7200
# Node ID da0bdbcd6f098693dc6b773b9c31ca392b4b745d
# Parent  2ea7b61797d34eceab5658269be5a265d93cd372
salix.supraRegional+Regional results

diff -r 2ea7b61797d3 -r da0bdbcd6f09 artifacts/doc/conf/jasper/templates/uinfo.salixline.jrxml
--- a/artifacts/doc/conf/jasper/templates/uinfo.salixline.jrxml	Wed Jul 11 10:19:53 2018 +0200
+++ b/artifacts/doc/conf/jasper/templates/uinfo.salixline.jrxml	Wed Jul 11 13:36:18 2018 +0200
@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!-- Created with Jaspersoft Studio version 6.5.1.final using JasperReports Library version 4.5.0  -->
-<!-- 2018-06-06T13:16:36 -->
+<!-- 2018-07-10T15:31:50 -->
 <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"/>
@@ -54,6 +54,7 @@
 	<field name="meta:salix_line" class="java.lang.String"/>
 	<field name="meta:salix_line_hist" class="java.lang.String"/>
 	<field name="meta:salix_line_scen" class="java.lang.String"/>
+	<field name="meta:salix_delta_mw" 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"/>
@@ -134,17 +135,11 @@
 				<reportElement key="" style="htmlStyle" positionType="Float" stretchType="RelativeToBandHeight" x="170" y="0" width="140" height="24"/>
 				<box padding="5"/>
 				<textElement textAlignment="Right" verticalAlignment="Bottom"/>
-				<textFieldExpression><![CDATA[$F{meta:salix_line_hist}]]></textFieldExpression>
+				<textFieldExpression><![CDATA[$F{meta:salix_delta_mw}]]></textFieldExpression>
 			</textField>
 			<line>
 				<reportElement style="htmlStyle" positionType="FixRelativeToBottom" x="0" y="24" width="550" height="1"/>
 			</line>
-			<textField isStretchWithOverflow="true">
-				<reportElement key="" style="htmlStyle" positionType="Float" stretchType="RelativeToBandHeight" x="310" y="0" width="140" height="24"/>
-				<box padding="5"/>
-				<textElement textAlignment="Right" verticalAlignment="Bottom"/>
-				<textFieldExpression><![CDATA[$F{meta:salix_line_scen}]]></textFieldExpression>
-			</textField>
 		</band>
 	</columnHeader>
 	<detail>
@@ -182,17 +177,6 @@
 				<textElement textAlignment="Right"/>
 				<textFieldExpression><![CDATA[$F{data:2}]]></textFieldExpression>
 			</textField>
-			<textField isStretchWithOverflow="true" isBlankWhenNull="true">
-				<reportElement key="" style="htmlStyle" positionType="Float" stretchType="RelativeToBandHeight" x="310" y="0" width="140" 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"/>
-				<textFieldExpression><![CDATA[$F{data:3}]]></textFieldExpression>
-			</textField>
 		</band>
 	</detail>
 	<pageFooter>
diff -r 2ea7b61797d3 -r da0bdbcd6f09 artifacts/src/main/java/org/dive4elements/river/artifacts/common/AbstractExportContext.java
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/common/AbstractExportContext.java	Wed Jul 11 10:19:53 2018 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/common/AbstractExportContext.java	Wed Jul 11 13:36:18 2018 +0200
@@ -23,7 +23,7 @@
     private NumberFormat qFormat = null;
 
     private NumberFormat flowDepthFormat = null;
-
+    private NumberFormat salixScenFormat = null;
     private NumberFormat kmFormat = null;
 
     /** The CallContext object. */
@@ -70,6 +70,13 @@
         return this.flowDepthFormat;
     }
 
+    public final NumberFormat getSalixScenFormatter() {
+        if (this.salixScenFormat == null)
+            this.salixScenFormat = Formatter.getSalixLine(this.context);
+
+        return this.salixScenFormat;
+    }
+
     protected String msg(final String key) {
         return Resources.getMsg(this.context.getMeta(), key, key);
     }
diff -r 2ea7b61797d3 -r da0bdbcd6f09 artifacts/src/main/java/org/dive4elements/river/artifacts/uinfo/commons/UInfoResultType.java
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/uinfo/commons/UInfoResultType.java	Wed Jul 11 10:19:53 2018 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/uinfo/commons/UInfoResultType.java	Wed Jul 11 13:36:18 2018 +0200
@@ -40,6 +40,69 @@
         return null;
     }
 
+    public static final UInfoResultType customMultiRowColSalixRegionalValue_Dwspl = new UInfoResultType(null, "uinfo.export.salix_line.csv.header.scenario") {
+        private static final long serialVersionUID = 1L;
+
+        @Override
+        public String exportValue(final CallContext context, final Object value) {
+            throw new UnsupportedOperationException();
+        }
+
+        @Override
+        protected NumberFormat createFormatter(final CallContext context) {
+            throw new UnsupportedOperationException();
+        }
+    };
+
+    public static final UInfoResultType salix_line_scenario = new UInfoResultType(null, "uinfo.export.salix_line.csv.header.scenario") {
+        private static final long serialVersionUID = 1L;
+
+        @Override
+        public String exportValue(final CallContext context, final Object value) {
+            final double doubleValue = asDouble(value);
+            return exportDoubleValue(context, doubleValue);
+        }
+
+        @Override
+        protected NumberFormat createFormatter(final CallContext context) {
+            // REMARK: other modules use Formatter.getWaterlevelW(context) instead, but that format with a variable number of
+            // digits.
+            return Formatter.getSalixLine(context);
+        }
+    };
+
+    public static final UInfoResultType salix_line_scenario_dwspl = new UInfoResultType(null, "uinfo.export.salix_line.csv.header.scenario_dwspl") {
+        private static final long serialVersionUID = 1L;
+
+        @Override
+        public String exportValue(final CallContext context, final Object value) {
+            final String valueStr = String.valueOf(value);
+            return exportStringValue(valueStr);
+        }
+
+        @Override
+        protected NumberFormat createFormatter(final CallContext context) {
+
+            return Formatter.getIntegerFormatter(context);
+        }
+    };
+    public static final UInfoResultType salix_delta_mw = new UInfoResultType(null, "uinfo.export.salix_line.csv.header.delta_mw") {
+        private static final long serialVersionUID = 1L;
+
+        @Override
+        public String exportValue(final CallContext context, final Object value) {
+            final double doubleValue = asDouble(value);
+            return exportDoubleValue(context, doubleValue);
+        }
+
+        @Override
+        protected NumberFormat createFormatter(final CallContext context) {
+            // REMARK: other modules use Formatter.getWaterlevelW(context) instead, but that format with a variable number of
+            // digits.
+            return Formatter.getSalixLine(context);
+        }
+    };
+
     public static final UInfoResultType salixline = new UInfoResultType(null, "uinfo.export.salix_line.csv.header.salix_line") {
         private static final long serialVersionUID = 1L;
 
diff -r 2ea7b61797d3 -r da0bdbcd6f09 artifacts/src/main/java/org/dive4elements/river/artifacts/uinfo/salix/SalixLineAccess.java
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/uinfo/salix/SalixLineAccess.java	Wed Jul 11 10:19:53 2018 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/uinfo/salix/SalixLineAccess.java	Wed Jul 11 13:36:18 2018 +0200
@@ -58,4 +58,22 @@
     public Double getToPart() {
         return getDouble("ld_to_part");
     }
+
+    public int[] getRegionalScenarioIntegers() {
+        // super.getIntArray("sedimentheight"); DOES NOT WORK!
+        final String ints = super.getString("sedimentheight");
+        if (ints != null) {
+            final String[] intsSplit = ints.split(" ");
+            final int[] values = new int[intsSplit.length];
+            for (int i = 0; i < intsSplit.length; i++) {
+                values[i] = Integer.valueOf(intsSplit[i]);
+            }
+            return values;
+        }
+        return null;
+    }
+
+    public String getSupraRegionalString() {
+        return super.getString("supraregional_table");
+    }
 }
\ No newline at end of file
diff -r 2ea7b61797d3 -r da0bdbcd6f09 artifacts/src/main/java/org/dive4elements/river/artifacts/uinfo/salix/SalixLineCalculation.java
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/uinfo/salix/SalixLineCalculation.java	Wed Jul 11 10:19:53 2018 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/uinfo/salix/SalixLineCalculation.java	Wed Jul 11 13:36:18 2018 +0200
@@ -11,6 +11,10 @@
 
 import java.util.ArrayList;
 import java.util.Collection;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
 
 import org.apache.commons.lang.math.DoubleRange;
 import org.dive4elements.artifacts.CallContext;
@@ -53,6 +57,9 @@
         final String selectedScenario = accessSalix.getScenario();
         final Double fromPart = accessSalix.getFromPart();
         final Double toPart = accessSalix.getToPart();
+
+        final boolean useSCenario = accessSalix.getUseScenario();
+        final String scenario = accessSalix.getScenario();
         // calculation_mode
         // ld_from , ld_to
         // use_scenario (boolean)
@@ -64,26 +71,92 @@
         final SalixLineCalculationResults results = new SalixLineCalculationResults(calcModeLabel, user, riverInfo, range);
 
         final Collection<ResultRow> rows = new ArrayList<>();
-
+        SalixLineCalculationNoScenarioResult result = null; // verzweigung etwas ungünstig. möglicherweise auch die Abstraktion. ist erstmal nur ne idee
         final ResultRow row1 = ResultRow.create(). //
                 putValue(GeneralResultType.station, 100).//
                 putValue(UInfoResultType.salixline, 28).//
-                putValue(UInfoResultType.salixlinehist, 2).//
-                putValue(UInfoResultType.salixlinescen, 82);
-        rows.add(row1);
+                putValue(UInfoResultType.salix_delta_mw, 2);
 
-        final ResultRow row2 = ResultRow.create(). //
-                putValue(GeneralResultType.station, 200). //
-                putValue(UInfoResultType.salixline, 3). //
-                putValue(UInfoResultType.salixlinehist, 2).//
-                putValue(UInfoResultType.salixlinescen, 822);
+        if (!useScenario) {
 
-        rows.add(row2);
+            rows.add(row1);
+            result = new SalixLineCalculationNoScenarioResult("Ergebnis 1", null, rows);
+        } else {
 
-        final SalixLineCalculationResult result = new SalixLineCalculationResult("Ergebnis 1", null, rows);
+            if (scenario.equals("scenarioType.option1")) {
+
+                final int[] scenarios = accessSalix.getRegionalScenarioIntegers();
+                final List<SalixScenario> list = new ArrayList<>();
+                for (final int scen_val : scenarios) {
+                    list.add(new SalixScenario(scen_val, 666.));// TODO: replace 666 by real calculated value
+                }
+                row1.putValue(UInfoResultType.customMultiRowColSalixRegionalValue_Dwspl, list);//
+                rows.add(row1);
+                result = new SalixLineCalculationRegionalResult("Ergebnis 1 regional test", null, rows, scenarios);
+            } else if (scenario.equals("scenarioType.option2")) {
+                // SupraRegional
+
+                final String supraRegional = accessSalix.getSupraRegionalString();
+                final List<SalixZone> list = SalixZone.parse(supraRegional);
+
+                final Map<DoubleRange, SalixScenario> rangeScenarioMap = new HashMap<>();
+                // make double range
+                for (int i = 0; i < list.size(); i++) {
+                    final SalixZone zone = list.get(i);
+                    final double upper = i < list.size() - 1 ? (zone.getUpperFromTo() - 0.0001) : zone.getUpperFrossssssssssmTo() + 0.0001;// "halboffenes
+                                                                                                                                           // Intervall
+
+                    final DoubleRange zonerange = new DoubleRange((double) zone.getLowerFromTo(), upper);
+                    final double salixValue = 666.;// TODO: calculate the salix value
+                    final SalixScenario salixscen = new SalixScenario(zone.getDwsplValue(), salixValue);
+
+                    rangeScenarioMap.put(zonerange, salixscen);
+                }
+
+                // make calculation (replace
+                double currentKm = range.getMinimumDouble();
+                final double step = 0.1;
+                while (currentKm < range.getMaximumDouble()) {
+                    final ResultRow rowSupraRegional = ResultRow.create(). //
+                            putValue(GeneralResultType.station, currentKm).//
+                            putValue(UInfoResultType.salixline, 28).//
+                            putValue(UInfoResultType.salix_delta_mw, 2);
+
+                    final SalixScenario scenarioCurrentKm = findScenarioByKm(currentKm, rangeScenarioMap);
+
+                    if (scenarioCurrentKm != null) { // should not happen, scenarioCurrentKm == 0 -> BUG
+                        rowSupraRegional.putValue(UInfoResultType.salix_line_scenario, scenarioCurrentKm.getSalixValue());
+                        rowSupraRegional.putValue(UInfoResultType.salix_line_scenario_dwspl, scenarioCurrentKm.getDwspl());
+                    }
+                    rows.add(rowSupraRegional);
+
+                    currentKm = currentKm + step;
+                }
+
+                result = new SalixLineCalculationSupraRegionalResult("Ergebnis 1 supra regional test", null, rows);
+
+            } else if (scenario.equals("scenarioType.option3")) {
+                // historisch
+                row1.putValue(UInfoResultType.salixlinehist, 2).//
+                        putValue(UInfoResultType.salixlinescen, 82);
+            }
+
+        }
 
         results.addResult(result, problems);
 
         return new CalculationResult(results, problems);
     }
+
+    private SalixScenario findScenarioByKm(final double km, final Map<DoubleRange, SalixScenario> rangeScenarioMap) {
+        final Iterator<DoubleRange> rangeIterator = rangeScenarioMap.keySet().iterator();
+        while (rangeIterator.hasNext()) {
+            final DoubleRange range = rangeIterator.next();
+            if (range.containsDouble(km + 0.0001)) {
+                return rangeScenarioMap.get(range);
+            }
+        }
+        return null;
+    }
+
 }
\ No newline at end of file
diff -r 2ea7b61797d3 -r da0bdbcd6f09 artifacts/src/main/java/org/dive4elements/river/artifacts/uinfo/salix/SalixLineCalculationNoScenarioResult.java
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/uinfo/salix/SalixLineCalculationNoScenarioResult.java	Wed Jul 11 13:36:18 2018 +0200
@@ -0,0 +1,136 @@
+/** 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.uinfo.salix;
+
+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.RiverInfo;
+import org.dive4elements.river.artifacts.sinfo.util.WstInfo;
+import org.dive4elements.river.artifacts.uinfo.commons.UInfoResultType;
+
+/**
+ * @author Domenico Nardi Tironi
+ */
+class SalixLineCalculationNoScenarioResult extends AbstractCalculationExportableResult {
+
+    private static final long serialVersionUID = 1L;
+    private static final String JASPER_FILE = "/jasper/templates/uinfo.salixline.jrxml";
+
+    public SalixLineCalculationNoScenarioResult(final String label, final WstInfo wst, final Collection<ResultRow> rows) {
+        super(label, rows);
+    }
+
+    @Override
+    public void writeCSVHeader(final ExportContextCSV exportContextCSV, final RiverInfo river) {
+        final Collection<String> header = writeNoScenarioHeader(exportContextCSV);
+        exportContextCSV.writeCSVLine(header.toArray(new String[header.size()]));
+
+    }
+
+    protected final Collection<String> writeNoScenarioHeader(final ExportContextCSV exportContextCSV) {
+        final Collection<String> header = new ArrayList<>();
+        header.add(exportContextCSV.formatCsvHeader(GeneralResultType.station));
+        header.add(exportContextCSV.formatCsvHeader(UInfoResultType.salixline));
+        header.add(exportContextCSV.formatCsvHeader(UInfoResultType.salix_delta_mw));
+        return header;
+    }
+
+    @Override
+    protected String[] formatCSVRow(final ExportContextCSV exportContextCSV, final ResultRow row) {
+
+        return formatRow(exportContextCSV, row);
+    }
+
+    @Override
+    protected String[] formatPDFRow(final ExportContextPDF exportContextPDF, final ResultRow row) {
+
+        return formatRow(exportContextPDF, row);
+    }
+
+    @Override
+    protected String getJasperFile() {
+
+        return this.JASPER_FILE;
+    }
+
+    @Override
+    protected void addJRTableHeader(final ExportContextPDF exportContextPDF, final MetaAndTableJRDataSource source) {
+
+        /* additional column headings */
+        exportContextPDF.addJRMetadata(source, "station_header", GeneralResultType.station);
+        exportContextPDF.addJRMetadata(source, "salix_line", UInfoResultType.salixline);
+        exportContextPDF.addJRMetadata(source, "salix_delta_mw", UInfoResultType.salix_delta_mw);
+
+    }
+
+    private String[] formatRow(final IExportContext context, final ResultRow row) {
+
+        final Collection<String> lines = getNoScenarioFormat(row, context);
+
+        // // ??
+        // // wenn "historisch" gewählt wurde, nur "historisch" anzeigen; sonst für jeden scen-wert ne neue Spalte und "hist"
+        // // ausblenden!...!..!!
+        // lines.add(context.formatRowValue(row, UInfoResultType.salixlinehist));
+        // lines.add(context.formatRowValue(row, UInfoResultType.salixlinescen));
+
+        return lines.toArray(new String[lines.size()]);
+    }
+
+    protected final Collection<String> getNoScenarioFormat(final ResultRow row, final IExportContext context) {
+        final Collection<String> lines = new ArrayList<>();
+        lines.add(context.formatRowValue(row, GeneralResultType.station));
+        lines.add(context.formatRowValue(row, UInfoResultType.salixline));
+        lines.add(context.formatRowValue(row, UInfoResultType.salix_delta_mw));
+
+        return lines;
+
+    }
+
+    protected final void writeRegionalCommonCSVMeta(final ExportContextCSV exportContextCSV) {
+        final String main = "uinfo.export.csv.meta.header.salix";
+        // "# Szenariotyp: "
+        exportContextCSV.writeCSVMetaEntry(main + ".szenariotyp");
+        // "# Teilabschnitt: "
+        exportContextCSV.writeCSVMetaEntry(main + ".teilabschnitt");
+        // "# Mittelwasserspiegellagenänderung: "
+        exportContextCSV.writeCSVMetaEntry(main + ".mwspiegellaenderung");
+    }
+
+    @Override
+    protected void writeCSVResultMetadata(final ExportContextCSV exportContextCSV) {
+        // do nothing. subclass may override
+
+    }
+
+    // private void writeHistoricalViewCSVMetadata(final ExportContextCSV exportContextCSV) {
+    // final String main = "uinfo.export.csv.meta.header.salix.historical";
+    // // "##Historische Betrachtung"
+    // exportContextCSV.writeCSVMetaEntry(main);
+    //
+    // final String mainSub = "uinfo.export.csv.meta.header.salix";
+    // // "# Szenariotyp: "
+    // exportContextCSV.writeCSVMetaEntry(mainSub + ".szenariotyp");
+    // // "# Teilabschnitt: "
+    // exportContextCSV.writeCSVMetaEntry(mainSub + ".teilabschnitt");
+    //
+    // // "# Art des Zeitraums: "
+    // exportContextCSV.writeCSVMetaEntry(main + ".zeitart");
+    // // "# Historischer Zeitpunkt: "
+    // exportContextCSV.writeCSVMetaEntry(main + ".zeitpunkt");
+    // }
+}
\ No newline at end of file
diff -r 2ea7b61797d3 -r da0bdbcd6f09 artifacts/src/main/java/org/dive4elements/river/artifacts/uinfo/salix/SalixLineCalculationRegionalResult.java
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/uinfo/salix/SalixLineCalculationRegionalResult.java	Wed Jul 11 13:36:18 2018 +0200
@@ -0,0 +1,113 @@
+/** 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.uinfo.salix;
+
+import java.text.NumberFormat;
+import java.util.Collection;
+import java.util.List;
+
+import org.dive4elements.river.artifacts.common.ExportContextCSV;
+import org.dive4elements.river.artifacts.common.IExportContext;
+import org.dive4elements.river.artifacts.common.ResultRow;
+import org.dive4elements.river.artifacts.sinfo.util.RiverInfo;
+import org.dive4elements.river.artifacts.sinfo.util.WstInfo;
+import org.dive4elements.river.artifacts.uinfo.commons.UInfoResultType;
+
+/**
+ * @author Domenico Nardi Tironi
+ */
+final class SalixLineCalculationRegionalResult extends SalixLineCalculationNoScenarioResult {
+
+    private static final long serialVersionUID = 1L;
+    private final int[] scenarioValues;
+
+    public SalixLineCalculationRegionalResult(final String label, final WstInfo wst, final Collection<ResultRow> rows, final int[] scenarioValues) {
+        super(label, wst, rows);
+        this.scenarioValues = scenarioValues; // TODO: diese values müssen eigentlich nur ne anzahl sein, oder so. Ergibt sihc in der Berech
+    }
+
+    @Override
+    public void writeCSVHeader(final ExportContextCSV exportContextCSV, final RiverInfo river) {
+
+        final Collection<String> header = super.writeNoScenarioHeader(exportContextCSV);
+
+        for (int i = 0; i < this.scenarioValues.length; i++) {
+            // index wurde verworfen, stattdessen 2 spalten
+
+            header.add(exportContextCSV.msg(SalixScenario.getScenarioValueHeader()) + " (" + (i + 1) + ")"); // index kann auch weg, war nur ne idee
+            header.add(exportContextCSV.msg(SalixScenario.getDwsplHeader()) + " (" + (i + 1) + ")");
+        }
+        exportContextCSV.writeCSVLine(header.toArray(new String[header.size()]));
+    }
+
+    @Override
+    protected void writeCSVResultMetadata(final ExportContextCSV exportContextCSV) {
+        writeRegionalEffectsCSVMetadata(exportContextCSV);
+        exportContextCSV.writeBlankLine();
+
+    }
+
+    @Override
+    protected String[] formatCSVRow(final ExportContextCSV exportContextCSV, final ResultRow row) {
+
+        return formatRow(exportContextCSV, row);
+    }
+
+    private String[] formatRow(final IExportContext context, final ResultRow row) {
+
+        final Collection<String> lines = super.getNoScenarioFormat(row, context);
+
+        if (context instanceof ExportContextCSV) { // enum gespart - pdf-export hat ja nur die drei spalten
+            final NumberFormat formatter = ((ExportContextCSV) context).getSalixScenFormatter();
+            final List<SalixScenario> scenList = (List<SalixScenario>) row.getValue(UInfoResultType.customMultiRowColSalixRegionalValue_Dwspl);
+
+            for (final SalixScenario scenario : scenList) {
+                // scenario unused; index wurde ja verworfen, stattdessen 2 spalten
+                lines.add(scenario.getSalixValueFormatted(formatter));
+                lines.add(scenario.getDwsplFormatted());
+            }
+        }
+        return lines.toArray(new String[lines.size()]);
+    }
+
+    private void writeRegionalEffectsCSVMetadata(final ExportContextCSV exportContextCSV) {
+        final String main = "uinfo.export.csv.meta.header.salix.regional";
+        // "##Regional wirkende Eingriffe"
+        exportContextCSV.writeCSVMetaEntry(main);
+        writeRegionalCommonCSVMeta(exportContextCSV);
+    }
+
+    // TODO: move to SupraRegionalEffectsResult-Class; remove here
+    // private void writeExtendedRegionalEffectsCSVMetadata(final ExportContextCSV exportContextCSV) {
+    // final String main = "uinfo.export.csv.meta.header.salix.regionalextended";
+    // // "##Überregional wirkende Eingriffe"
+    // exportContextCSV.writeCSVMetaEntry(main);
+    //
+    // writeRegionalCommonCSVMeta(exportContextCSV);
+    // }
+
+    // TODO: move to historical class and delete here
+    // private void writeHistoricalViewCSVMetadata(final ExportContextCSV exportContextCSV) {
+    // final String main = "uinfo.export.csv.meta.header.salix.historical";
+    // // "##Historische Betrachtung"
+    // exportContextCSV.writeCSVMetaEntry(main);
+    //
+    // final String mainSub = "uinfo.export.csv.meta.header.salix";
+    // // "# Szenariotyp: "
+    // exportContextCSV.writeCSVMetaEntry(mainSub + ".szenariotyp");
+    // // "# Teilabschnitt: "
+    // exportContextCSV.writeCSVMetaEntry(mainSub + ".teilabschnitt");
+    //
+    // // "# Art des Zeitraums: "
+    // exportContextCSV.writeCSVMetaEntry(main + ".zeitart");
+    // // "# Historischer Zeitpunkt: "
+    // exportContextCSV.writeCSVMetaEntry(main + ".zeitpunkt");
+    // }
+}
\ No newline at end of file
diff -r 2ea7b61797d3 -r da0bdbcd6f09 artifacts/src/main/java/org/dive4elements/river/artifacts/uinfo/salix/SalixLineCalculationResult.java
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/uinfo/salix/SalixLineCalculationResult.java	Wed Jul 11 10:19:53 2018 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,153 +0,0 @@
-/** 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.uinfo.salix;
-
-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.RiverInfo;
-import org.dive4elements.river.artifacts.sinfo.util.WstInfo;
-import org.dive4elements.river.artifacts.uinfo.commons.UInfoResultType;
-
-/**
- * @author Domenico Nardi Tironi
- */
-final class SalixLineCalculationResult extends AbstractCalculationExportableResult {
-
-    private static final long serialVersionUID = 1L;
-    private static final String JASPER_FILE = "/jasper/templates/uinfo.salixline.jrxml";
-
-    public SalixLineCalculationResult(final String label, final WstInfo wst, final Collection<ResultRow> rows) {
-        super(label, rows);
-    }
-
-    @Override
-    public void writeCSVHeader(final ExportContextCSV exportContextCSV, final RiverInfo river) {
-
-        final Collection<String> header = new ArrayList<>(4);
-
-        header.add(exportContextCSV.formatCsvHeader(GeneralResultType.station));
-        // header.add(msgUnit(SInfoResultType.flowdepth, SInfoResultType.flowdepth.getUnit()));
-
-        header.add(exportContextCSV.formatCsvHeader(UInfoResultType.salixline));
-        // wenn "historisch" gewählt wurde, nur "historisch" anzeigen; sonst für jeden scen-wert ne neue Spalte und "hist"
-        // ausblenden!...!..!!
-        header.add(exportContextCSV.formatCsvHeader(UInfoResultType.salixlinehist));
-        header.add(exportContextCSV.formatCsvHeader(UInfoResultType.salixlinescen));
-        exportContextCSV.writeCSVLine(header.toArray(new String[header.size()]));
-
-    }
-
-    @Override
-    protected void writeCSVResultMetadata(final ExportContextCSV exportContextCSV) {
-        writeRegionalEffectsCSVMetadata(exportContextCSV);
-        exportContextCSV.writeBlankLine();
-        writeExtendedRegionalEffectsCSVMetadata(exportContextCSV);
-        exportContextCSV.writeBlankLine();
-        writeHistoricalViewCSVMetadata(exportContextCSV);
-        exportContextCSV.writeBlankLine();
-
-    }
-
-    @Override
-    protected String[] formatCSVRow(final ExportContextCSV exportContextCSV, final ResultRow row) {
-
-        return formatRow(exportContextCSV, row);
-    }
-
-    @Override
-    protected String[] formatPDFRow(final ExportContextPDF exportContextPDF, final ResultRow row) {
-
-        return formatRow(exportContextPDF, row);
-    }
-
-    @Override
-    protected String getJasperFile() {
-
-        return this.JASPER_FILE;
-    }
-
-    @Override
-    protected void addJRTableHeader(final ExportContextPDF exportContextPDF, final MetaAndTableJRDataSource source) {
-
-        /* additional column headings */
-        exportContextPDF.addJRMetadata(source, "station_header", GeneralResultType.station);
-
-        exportContextPDF.addJRMetadata(source, "salix_line", UInfoResultType.salixline);
-        // wenn "historisch" gewählt wurde, nur "historisch" anzeigen; sonst für jeden scen-wert ne neue Spalte und "hist"
-        // ausblenden!...!..!!
-        exportContextPDF.addJRMetadata(source, "salix_line_hist", UInfoResultType.salixlinehist);
-        exportContextPDF.addJRMetadata(source, "salix_line_scen", UInfoResultType.salixlinescen);
-
-    }
-
-    private String[] formatRow(final IExportContext context, final ResultRow row) {
-
-        final Collection<String> lines = new ArrayList<>(3);
-
-        lines.add(context.formatRowValue(row, GeneralResultType.station));
-        lines.add(context.formatRowValue(row, UInfoResultType.salixline));
-
-        // wenn "historisch" gewählt wurde, nur "historisch" anzeigen; sonst für jeden scen-wert ne neue Spalte und "hist"
-        // ausblenden!...!..!!
-        lines.add(context.formatRowValue(row, UInfoResultType.salixlinehist));
-        lines.add(context.formatRowValue(row, UInfoResultType.salixlinescen));
-        return lines.toArray(new String[lines.size()]);
-    }
-
-    private void writeRegionalEffectsCSVMetadata(final ExportContextCSV exportContextCSV) {
-        final String main = "uinfo.export.csv.meta.header.salix.regional";
-        // "##Regional wirkende Eingriffe"
-        exportContextCSV.writeCSVMetaEntry(main);
-        writeRegionalCommonCSVMeta(exportContextCSV);
-    }
-
-    private void writeRegionalCommonCSVMeta(final ExportContextCSV exportContextCSV) {
-        final String main = "uinfo.export.csv.meta.header.salix";
-        // "# Szenariotyp: "
-        exportContextCSV.writeCSVMetaEntry(main + ".szenariotyp");
-        // "# Teilabschnitt: "
-        exportContextCSV.writeCSVMetaEntry(main + ".teilabschnitt");
-        // "# Mittelwasserspiegellagenänderung: "
-        exportContextCSV.writeCSVMetaEntry(main + ".mwspiegellaenderung");
-    }
-
-    private void writeExtendedRegionalEffectsCSVMetadata(final ExportContextCSV exportContextCSV) {
-        final String main = "uinfo.export.csv.meta.header.salix.regionalextended";
-        // "##Überregional wirkende Eingriffe"
-        exportContextCSV.writeCSVMetaEntry(main);
-
-        writeRegionalCommonCSVMeta(exportContextCSV);
-    }
-
-    private void writeHistoricalViewCSVMetadata(final ExportContextCSV exportContextCSV) {
-        final String main = "uinfo.export.csv.meta.header.salix.historical";
-        // "##Historische Betrachtung"
-        exportContextCSV.writeCSVMetaEntry(main);
-
-        final String mainSub = "uinfo.export.csv.meta.header.salix";
-        // "# Szenariotyp: "
-        exportContextCSV.writeCSVMetaEntry(mainSub + ".szenariotyp");
-        // "# Teilabschnitt: "
-        exportContextCSV.writeCSVMetaEntry(mainSub + ".teilabschnitt");
-
-        // "# Art des Zeitraums: "
-        exportContextCSV.writeCSVMetaEntry(main + ".zeitart");
-        // "# Historischer Zeitpunkt: "
-        exportContextCSV.writeCSVMetaEntry(main + ".zeitpunkt");
-    }
-}
\ No newline at end of file
diff -r 2ea7b61797d3 -r da0bdbcd6f09 artifacts/src/main/java/org/dive4elements/river/artifacts/uinfo/salix/SalixLineCalculationResults.java
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/uinfo/salix/SalixLineCalculationResults.java	Wed Jul 11 10:19:53 2018 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/uinfo/salix/SalixLineCalculationResults.java	Wed Jul 11 13:36:18 2018 +0200
@@ -17,7 +17,7 @@
  * @author Domenico Nardi Tironi
  *
  */
-final class SalixLineCalculationResults extends AbstractCalculationResults<SalixLineCalculationResult> {
+final class SalixLineCalculationResults extends AbstractCalculationResults<SalixLineCalculationNoScenarioResult> {
 
     private static final long serialVersionUID = 1L;
 
diff -r 2ea7b61797d3 -r da0bdbcd6f09 artifacts/src/main/java/org/dive4elements/river/artifacts/uinfo/salix/SalixLineCalculationSupraRegionalResult.java
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/uinfo/salix/SalixLineCalculationSupraRegionalResult.java	Wed Jul 11 13:36:18 2018 +0200
@@ -0,0 +1,97 @@
+/** 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.uinfo.salix;
+
+import java.text.NumberFormat;
+import java.util.Collection;
+
+import org.dive4elements.river.artifacts.common.ExportContextCSV;
+import org.dive4elements.river.artifacts.common.IExportContext;
+import org.dive4elements.river.artifacts.common.ResultRow;
+import org.dive4elements.river.artifacts.sinfo.util.RiverInfo;
+import org.dive4elements.river.artifacts.sinfo.util.WstInfo;
+import org.dive4elements.river.artifacts.uinfo.commons.UInfoResultType;
+
+/**
+ * @author Domenico Nardi Tironi
+ */
+final class SalixLineCalculationSupraRegionalResult extends SalixLineCalculationNoScenarioResult {
+
+    private static final long serialVersionUID = 1L;
+
+    public SalixLineCalculationSupraRegionalResult(final String label, final WstInfo wst, final Collection<ResultRow> rows) {
+        super(label, wst, rows);
+
+    }
+
+    @Override
+    public void writeCSVHeader(final ExportContextCSV exportContextCSV, final RiverInfo river) {
+
+        final Collection<String> header = super.writeNoScenarioHeader(exportContextCSV);
+
+        header.add(exportContextCSV.formatCsvHeader(UInfoResultType.salix_line_scenario));
+        header.add(exportContextCSV.formatCsvHeader(UInfoResultType.salix_line_scenario_dwspl));
+
+        exportContextCSV.writeCSVLine(header.toArray(new String[header.size()]));
+    }
+
+    @Override
+    protected void writeCSVResultMetadata(final ExportContextCSV exportContextCSV) {
+        writeExtendedRegionalEffectsCSVMetadata(exportContextCSV);
+        exportContextCSV.writeBlankLine();
+
+    }
+
+    @Override
+    protected String[] formatCSVRow(final ExportContextCSV exportContextCSV, final ResultRow row) {
+
+        return formatRow(exportContextCSV, row);
+    }
+
+    private String[] formatRow(final IExportContext context, final ResultRow row) {
+
+        final Collection<String> lines = super.getNoScenarioFormat(row, context);
+
+        if (context instanceof ExportContextCSV) { // enum gespart - pdf-export hat ja nur die drei spalten
+            final NumberFormat formatter = ((ExportContextCSV) context).getSalixScenFormatter();
+
+            lines.add(context.formatRowValue(row, UInfoResultType.salix_line_scenario));
+            lines.add(context.formatRowValue(row, UInfoResultType.salix_line_scenario_dwspl));
+
+        }
+        return lines.toArray(new String[lines.size()]);
+    }
+
+    private void writeExtendedRegionalEffectsCSVMetadata(final ExportContextCSV exportContextCSV) {
+        final String main = "uinfo.export.csv.meta.header.salix.regionalextended";
+        // "##Überregional wirkende Eingriffe"
+        exportContextCSV.writeCSVMetaEntry(main);
+
+        writeRegionalCommonCSVMeta(exportContextCSV);
+    }
+
+    // TODO: move to historical class and delete here
+    // private void writeHistoricalViewCSVMetadata(final ExportContextCSV exportContextCSV) {
+    // final String main = "uinfo.export.csv.meta.header.salix.historical";
+    // // "##Historische Betrachtung"
+    // exportContextCSV.writeCSVMetaEntry(main);
+    //
+    // final String mainSub = "uinfo.export.csv.meta.header.salix";
+    // // "# Szenariotyp: "
+    // exportContextCSV.writeCSVMetaEntry(mainSub + ".szenariotyp");
+    // // "# Teilabschnitt: "
+    // exportContextCSV.writeCSVMetaEntry(mainSub + ".teilabschnitt");
+    //
+    // // "# Art des Zeitraums: "
+    // exportContextCSV.writeCSVMetaEntry(main + ".zeitart");
+    // // "# Historischer Zeitpunkt: "
+    // exportContextCSV.writeCSVMetaEntry(main + ".zeitpunkt");
+    // }
+}
\ No newline at end of file
diff -r 2ea7b61797d3 -r da0bdbcd6f09 artifacts/src/main/java/org/dive4elements/river/artifacts/uinfo/salix/SalixLineExporter.java
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/uinfo/salix/SalixLineExporter.java	Wed Jul 11 10:19:53 2018 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/uinfo/salix/SalixLineExporter.java	Wed Jul 11 13:36:18 2018 +0200
@@ -19,7 +19,7 @@
  * @author Domenico Nardi Tironi
  *
  */
-public class SalixLineExporter extends AbstractCommonExporter<SalixLineCalculationResult, SalixLineCalculationResults> {
+public class SalixLineExporter extends AbstractCommonExporter<SalixLineCalculationNoScenarioResult, SalixLineCalculationResults> {
 
     @Override
     protected void writeCSVGlobalMetadata(final ExportContextCSV exportContextCSV, final SalixLineCalculationResults results) {
diff -r 2ea7b61797d3 -r da0bdbcd6f09 artifacts/src/main/java/org/dive4elements/river/artifacts/uinfo/salix/SalixLineState.java
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/uinfo/salix/SalixLineState.java	Wed Jul 11 10:19:53 2018 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/uinfo/salix/SalixLineState.java	Wed Jul 11 13:36:18 2018 +0200
@@ -77,7 +77,7 @@
 
         final SalixLineCalculationResults results = (SalixLineCalculationResults) res.getData();
 
-        final List<SalixLineCalculationResult> resultList = results.getResults();
+        final List<SalixLineCalculationNoScenarioResult> resultList = results.getResults();
 
         if (!resultList.isEmpty()) {
             final Facet csv = new DataFacet(FacetTypes.CSV, "CSV data", ComputeType.ADVANCE, hash, this.id);
diff -r 2ea7b61797d3 -r da0bdbcd6f09 artifacts/src/main/java/org/dive4elements/river/artifacts/uinfo/salix/SalixScenario.java
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/uinfo/salix/SalixScenario.java	Wed Jul 11 13:36:18 2018 +0200
@@ -0,0 +1,55 @@
+/** 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.uinfo.salix;
+
+import java.io.Serializable;
+import java.text.NumberFormat;
+
+/**
+ * @author Domenico Nardi Tironi
+ *
+ */
+public class SalixScenario implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    private final double salix_value;
+    private final int dwspl;
+
+    public SalixScenario(final int scen_val, final double salix_value) {
+        this.dwspl = scen_val;
+        this.salix_value = salix_value;
+    }
+
+    public double getSalixValue() {
+        return this.salix_value;
+    }
+
+    public int getDwspl() {
+        return this.dwspl;
+    }
+
+    public String getDwsplFormatted() {
+        return String.valueOf(this.dwspl);
+    }
+
+    public String getSalixValueFormatted(final NumberFormat formatter) {
+        return formatter.format(this.salix_value);
+    }
+
+    public static final String getScenarioValueHeader() {
+        return "uinfo.export.salix_line.csv.header.scenario";
+    }
+
+    public static final String getDwsplHeader() {
+        return "uinfo.export.salix_line.csv.header.scenario_dwspl";
+    }
+
+}
diff -r 2ea7b61797d3 -r da0bdbcd6f09 artifacts/src/main/java/org/dive4elements/river/artifacts/uinfo/salix/SalixZone.java
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/uinfo/salix/SalixZone.java	Wed Jul 11 10:19:53 2018 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/uinfo/salix/SalixZone.java	Wed Jul 11 13:36:18 2018 +0200
@@ -122,11 +122,11 @@
         return false;
     }
 
-    private Double getLowerFromTo() {
+    public Double getLowerFromTo() {
         return this.fromKm < this.toKm ? this.fromKm : this.toKm; // Math. is forbidden :-(
     }
 
-    private Double getUpperFromTo() {
+    public Double getUpperFromTo() {
         return this.fromKm > this.toKm ? this.fromKm : this.toKm;// Math. is forbidden :-(
     }
 
diff -r 2ea7b61797d3 -r da0bdbcd6f09 gwt-client/src/main/java/org/dive4elements/river/client/shared/model/SalixZone.java
--- a/gwt-client/src/main/java/org/dive4elements/river/client/shared/model/SalixZone.java	Wed Jul 11 10:19:53 2018 +0200
+++ b/gwt-client/src/main/java/org/dive4elements/river/client/shared/model/SalixZone.java	Wed Jul 11 13:36:18 2018 +0200
@@ -123,11 +123,11 @@
         return false;
     }
 
-    private Double getLowerFromTo() {
+    public Double getLowerFromTo() {
         return this.fromKm < this.toKm ? this.fromKm : this.toKm; // Math. is forbidden :-(
     }
 
-    private Double getUpperFromTo() {
+    public Double getUpperFromTo() {
         return this.fromKm > this.toKm ? this.fromKm : this.toKm;// Math. is forbidden :-(
     }
 


More information about the Dive4Elements-commits mailing list