[PATCH 1 of 2] Salix: Fixed ArrrayoutOfBoundsException; minor cleanup
Wald Commits
scm-commit at wald.intevation.org
Fri Jul 27 10:19:47 CEST 2018
# HG changeset patch
# User gernotbelger
# Date 1532679498 -7200
# Node ID c36befc9011cbf231d95c22a475efe1056acde48
# Parent 61b5de0b673bfffeb24d6130f72976ce82283d20
Salix: Fixed ArrrayoutOfBoundsException; minor cleanup
diff -r 61b5de0b673b -r c36befc9011c artifacts/src/main/java/org/dive4elements/river/artifacts/uinfo/salix/SalixLineCalculationHistoricalResult.java
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/uinfo/salix/SalixLineCalculationHistoricalResult.java Thu Jul 26 17:37:23 2018 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/uinfo/salix/SalixLineCalculationHistoricalResult.java Fri Jul 27 10:18:18 2018 +0200
@@ -9,7 +9,6 @@
*/
package org.dive4elements.river.artifacts.uinfo.salix;
-import java.text.NumberFormat;
import java.util.Collection;
import org.dive4elements.river.artifacts.common.ExportContextCSV;
@@ -44,7 +43,6 @@
protected void writeCSVResultMetadata(final ExportContextCSV exportContextCSV) {
writeHistoricalViewCSVMetadata(exportContextCSV);
exportContextCSV.writeBlankLine();
-
}
@Override
@@ -53,8 +51,6 @@
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.salixlinehist));
lines.add(context.formatRowValue(row, UInfoResultType.salix_line_scenario_dwspl));
@@ -62,20 +58,15 @@
return lines.toArray(new String[lines.size()]);
}
- // 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");
}
diff -r 61b5de0b673b -r c36befc9011c artifacts/src/main/java/org/dive4elements/river/artifacts/uinfo/salix/SalixLineCalculationNoScenarioResult.java
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/uinfo/salix/SalixLineCalculationNoScenarioResult.java Thu Jul 26 17:37:23 2018 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/uinfo/salix/SalixLineCalculationNoScenarioResult.java Fri Jul 27 10:18:18 2018 +0200
@@ -38,7 +38,6 @@
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) {
@@ -51,20 +50,17 @@
@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;
+ return JASPER_FILE;
}
@Override
@@ -74,7 +70,6 @@
exportContextPDF.addJRMetadata(source, "station_header", GeneralResultType.station);
exportContextPDF.addJRMetadata(source, "salix_line", UInfoResultType.salixline);
exportContextPDF.addJRMetadata(source, "salix_delta_mw", UInfoResultType.salix_delta_mw);
-
}
protected String[] formatRow(final IExportContext context, final ResultRow row) {
@@ -102,8 +97,6 @@
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: "
@@ -115,21 +108,4 @@
// 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 61b5de0b673b -r c36befc9011c artifacts/src/main/java/org/dive4elements/river/artifacts/uinfo/salix/SalixLineCalculationRegionalResult.java
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/uinfo/salix/SalixLineCalculationRegionalResult.java Thu Jul 26 17:37:23 2018 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/uinfo/salix/SalixLineCalculationRegionalResult.java Fri Jul 27 10:18:18 2018 +0200
@@ -13,6 +13,7 @@
import java.util.Collection;
import java.util.List;
+import org.apache.commons.lang.StringUtils;
import org.dive4elements.river.artifacts.common.ExportContextCSV;
import org.dive4elements.river.artifacts.common.GeneralResultType;
import org.dive4elements.river.artifacts.common.IExportContext;
@@ -43,8 +44,8 @@
public String getScenarioLabel(final int i) {
if ((this.scenarioLabels != null) && (i < this.scenarioLabels.length))
return this.scenarioLabels[i];
- else
- return "";
+
+ return "";
}
@Override
@@ -63,7 +64,6 @@
protected void writeCSVResultMetadata(final ExportContextCSV exportContextCSV) {
writeRegionalEffectsCSVMetadata(exportContextCSV);
exportContextCSV.writeBlankLine();
-
}
@Override
@@ -77,8 +77,13 @@
for (final SalixScenario scenario : scenList) {
// scenario unused; index wurde ja verworfen, stattdessen 2 spalten
- lines.add(scenario.getSalixValueFormatted(formatter));
- lines.add(scenario.getDwsplFormatted());
+ if (scenario == null) {
+ lines.add(StringUtils.EMPTY);
+ lines.add(StringUtils.EMPTY);
+ } else {
+ lines.add(scenario.getSalixValueFormatted(formatter));
+ lines.add(scenario.getDwsplFormatted());
+ }
}
}
return lines.toArray(new String[lines.size()]);
@@ -106,8 +111,9 @@
final double station = row.getDoubleValue(GeneralResultType.station);
final List<SalixScenario> scenarios = (List<SalixScenario>) row.getValue(UInfoResultType.customMultiRowColSalixRegionalValue_Dwspl);
- if (dataIndex <= scenarios.size() - 1) {
- final double value = scenarios.get(dataIndex).getSalixValue();
+ final SalixScenario salixScenario = scenarios.get(dataIndex);
+ if (salixScenario != null) {
+ final double value = salixScenario.getSalixValue();
xPoints.add(station);
yPoints.add(value);
}
@@ -115,31 +121,4 @@
return new double[][] { xPoints.toNativeArray(), yPoints.toNativeArray() };
}
-
- // 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 61b5de0b673b -r c36befc9011c artifacts/src/main/java/org/dive4elements/river/artifacts/uinfo/salix/SalixLineCalculationSupraRegionalResult.java
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/uinfo/salix/SalixLineCalculationSupraRegionalResult.java Thu Jul 26 17:37:23 2018 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/uinfo/salix/SalixLineCalculationSupraRegionalResult.java Fri Jul 27 10:18:18 2018 +0200
@@ -69,22 +69,4 @@
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 61b5de0b673b -r c36befc9011c 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 Thu Jul 26 17:37:23 2018 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/uinfo/salix/SalixLineExporter.java Fri Jul 27 10:18:18 2018 +0200
@@ -16,7 +16,6 @@
/**
* @author Domenico Nardi Tironi
- *
*/
public class SalixLineExporter extends AbstractCommonExporter<SalixLineCalculationNoScenarioResult, SalixLineCalculationResults> {
@@ -24,22 +23,10 @@
protected void writeCSVGlobalMetadata(final ExportContextCSV exportContextCSV, final SalixLineCalculationResults results) {
/* write as csv */
exportContextCSV.writeCSVGlobalMetadataDefaults();
-
- // Add Auswerter, Bezugspegel, Jahr/Zeitraum der Wasserspiegellage
-
- // "# Auswerter: "
- exportContextCSV.writeCSVMetaEntry("uinfo.export.salix_line.csv.meta.header.evaluator", "sounding.getEvaluationBy()");
- // "# Bezugspegel: "
- exportContextCSV.writeCSVMetaEntry("uinfo.export.salix_line.csv.meta.header.waterlevel.gauge", "wst.getGauge()");
-
- // "# Jahr/Zeitraum der Wasserspiegellage: "
- exportContextCSV.writeCSVMetaEntry("uinfo.export.salix_line.csv.meta.header.waterlevel.year", "TODO...");
-
}
@Override
protected void writePDFGlobalMetadata(final ExportContextPDF exportContext, final MetaAndTableJRDataSource source) {
exportContext.addJRMetaDataUSINFO(source);
}
-
}
\ No newline at end of file
More information about the Dive4Elements-commits
mailing list