# HG changeset patch # User gernotbelger # Date 1532679083 -7200 # Node ID 7b2b086e45f05d68a6edf45389d587e219ef337d # Parent 61b5de0b673bfffeb24d6130f72976ce82283d20 collision pdf details, ResultType refactoring, bezugswst result diff -r 61b5de0b673b -r 7b2b086e45f0 artifacts/doc/conf/jasper/templates/sinfo.collision.detail.jrxml --- a/artifacts/doc/conf/jasper/templates/sinfo.collision.detail.jrxml Thu Jul 26 17:37:23 2018 +0200 +++ b/artifacts/doc/conf/jasper/templates/sinfo.collision.detail.jrxml Fri Jul 27 10:11:23 2018 +0200 @@ -1,6 +1,6 @@ - + @@ -74,6 +74,7 @@ + @@ -124,7 +125,7 @@ - + diff -r 61b5de0b673b -r 7b2b086e45f0 artifacts/src/main/java/org/dive4elements/river/artifacts/bundu/BunduResultType.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/bundu/BunduResultType.java Fri Jul 27 10:11:23 2018 +0200 @@ -0,0 +1,47 @@ +/** 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; + +import java.text.NumberFormat; + +import org.dive4elements.artifacts.CallContext; +import org.dive4elements.river.artifacts.common.AbstractResultType; +import org.dive4elements.river.artifacts.common.I18NStrings; +import org.dive4elements.river.utils.Formatter; + +/** + * @author Domenico Nardi Tironi + * + */ +public abstract class BunduResultType extends AbstractResultType { + + protected BunduResultType(final String unit, final String csvHeader, final String pdfHeader) { + super(unit, csvHeader, pdfHeader); + } + + private static final long serialVersionUID = 1L; + + public static final BunduResultType bezugswst = new BunduResultType(I18NStrings.CSV_META_HEIGHT_UNIT_RIVER, "bundu.wst.export.csv.meta.header.bezugswst", + "bundu.wst.export.csv.meta.header.bezugswst") { // UNIT needed? + 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) { + return Formatter.getWaterlevelQ(context); // Richtiges Format? TODO check! + } + }; + +} \ No newline at end of file diff -r 61b5de0b673b -r 7b2b086e45f0 artifacts/src/main/java/org/dive4elements/river/artifacts/bundu/bezugswst/BezugswstCalculation.java --- a/artifacts/src/main/java/org/dive4elements/river/artifacts/bundu/bezugswst/BezugswstCalculation.java Thu Jul 26 17:37:23 2018 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/bundu/bezugswst/BezugswstCalculation.java Fri Jul 27 10:11:23 2018 +0200 @@ -14,6 +14,7 @@ import org.dive4elements.artifacts.CallContext; import org.dive4elements.river.artifacts.bundu.BUNDUArtifact; +import org.dive4elements.river.artifacts.bundu.BunduResultType; import org.dive4elements.river.artifacts.common.GeneralResultType; import org.dive4elements.river.artifacts.common.ResultRow; import org.dive4elements.river.artifacts.model.CalculationResult; @@ -47,8 +48,11 @@ final List list = new ArrayList<>(); final ResultRow row = ResultRow.create(); row.putValue(GeneralResultType.station, 666.666); + row.putValue(BunduResultType.bezugswst, 22.15); row.putValue(GeneralResultType.dischargeQwithUnit, 77.666); - row.putValue(GeneralResultType.location, "Tescht"); + row.putValue(GeneralResultType.waterlevelLabel, "GLQ"); + row.putValue(GeneralResultType.gaugeLabel, "Bonn"); + row.putValue(GeneralResultType.location, "keine Lage"); list.add(row); final BezugswstCalculationResult result = new BezugswstCalculationResult("label? was fürn label?", list); diff -r 61b5de0b673b -r 7b2b086e45f0 artifacts/src/main/java/org/dive4elements/river/artifacts/bundu/bezugswst/BezugswstCalculationResult.java --- a/artifacts/src/main/java/org/dive4elements/river/artifacts/bundu/bezugswst/BezugswstCalculationResult.java Thu Jul 26 17:37:23 2018 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/bundu/bezugswst/BezugswstCalculationResult.java Fri Jul 27 10:11:23 2018 +0200 @@ -12,6 +12,7 @@ import java.util.ArrayList; import java.util.Collection; +import org.dive4elements.river.artifacts.bundu.BunduResultType; import org.dive4elements.river.artifacts.common.AbstractCalculationExportableResult; import org.dive4elements.river.artifacts.common.ExportContextCSV; import org.dive4elements.river.artifacts.common.ExportContextPDF; @@ -47,6 +48,7 @@ @Override protected void writeCSVResultMetadata(final ExportContextCSV exportContextCSV) { + // TODO: wenn wst und peilung vorhanden sind, sollte dieser Teil wieder einkommentiert werden // exportContextCSV.writeCSVSoundingMetadata(this.sounding, " "); // exportContextCSV.writeBlankLine(); // exportContextCSV.writeCSVWaterlevelMetadata(wst); @@ -63,9 +65,11 @@ final Collection lines = new ArrayList<>(10); lines.add(exportContext.formatRowValue(row, GeneralResultType.station)); + lines.add(exportContext.formatRowValue(row, BunduResultType.bezugswst)); lines.add(exportContext.formatRowValue(row, GeneralResultType.dischargeQwithUnit)); - // lines.add(exportContext.formatRowValue(row, SInfoResultType.flowdepthDevelopment)); + lines.add(exportContext.formatRowValue(row, GeneralResultType.waterlevelLabel)); + lines.add(exportContext.formatRowValue(row, GeneralResultType.gaugeLabel)); lines.add(exportContext.formatRowValue(row, GeneralResultType.location)); return lines.toArray(new String[lines.size()]); @@ -77,11 +81,10 @@ final Collection header = new ArrayList<>(11); header.add(exportContextCSV.formatCsvHeader(GeneralResultType.station)); + header.add(exportContextCSV.formatCsvHeader(BunduResultType.bezugswst)); 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.waterlevelLabel)); + header.add(exportContextCSV.formatCsvHeader(GeneralResultType.gaugeLabel)); header.add(exportContextCSV.formatCsvHeader(GeneralResultType.location)); exportContextCSV.writeCSVLine(header.toArray(new String[header.size()])); @@ -104,11 +107,10 @@ 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, "bezugswst_header", BunduResultType.bezugswst); + exportContextPDF.addJRMetadata(source, "discharge_header", GeneralResultType.dischargeQwithUnit); + exportContextPDF.addJRMetadata(source, "waterlevel_name_header", GeneralResultType.waterlevelLabel); + exportContextPDF.addJRMetadata(source, "gauge_header", GeneralResultType.gaugeLabel); exportContextPDF.addJRMetadata(source, "location_header", GeneralResultType.location); } diff -r 61b5de0b673b -r 7b2b086e45f0 artifacts/src/main/java/org/dive4elements/river/artifacts/bundu/bezugswst/BezugswstState.java --- a/artifacts/src/main/java/org/dive4elements/river/artifacts/bundu/bezugswst/BezugswstState.java Thu Jul 26 17:37:23 2018 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/bundu/bezugswst/BezugswstState.java Fri Jul 27 10:11:23 2018 +0200 @@ -27,21 +27,7 @@ */ public class BezugswstState extends DefaultState implements FacetTypes { - /* - * TODO: THIS CLASS IS A CLONE OF FixRealizingCompute - * + - * ++ - * +++ - * ++++ - * +++++ - * ++++++ - * +++++++ - * ++++++++ - * +++++++++ - * ++++++++++ - * +++++++++++ - * IT does not work here - */ + private static final long serialVersionUID = 1L; /** The log used in this class. */ private static Logger log = Logger.getLogger(BezugswstState.class); @@ -59,7 +45,7 @@ @Override public Object computeAdvance(final D4EArtifact artifact, final String hash, final CallContext context, final List facets, final Object old) { log.debug("BezugswstState.computeAdvance"); - + // TODO: remove this old stuff, or replace it by new // final CalculationResult res; // // final FixRealizingAccess access = new FixRealizingAccess(artifact); @@ -165,13 +151,11 @@ if (facets == null) return res; - // if (!((List) res).isEmpty()) { final Facet csv = new DataFacet(FacetTypes.CSV, "CSV data", ComputeType.ADVANCE, hash, this.id); final Facet pdf = new DataFacet(FacetTypes.PDF, "PDF data", ComputeType.ADVANCE, hash, this.id); facets.add(csv); facets.add(pdf); - // } return res; } diff -r 61b5de0b673b -r 7b2b086e45f0 artifacts/src/main/java/org/dive4elements/river/artifacts/bundu/bezugswst/BunduWstExporter.java --- a/artifacts/src/main/java/org/dive4elements/river/artifacts/bundu/bezugswst/BunduWstExporter.java Thu Jul 26 17:37:23 2018 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/bundu/bezugswst/BunduWstExporter.java Fri Jul 27 10:11:23 2018 +0200 @@ -28,16 +28,14 @@ @Override protected void writeCSVGlobalMetadata(final ExportContextCSV exportContext, final BezugswstCalculationResults results) { exportContext.writeCSVGlobalMetadataDefaults(); - } @Override protected void writePDFGlobalMetadata(final ExportContextPDF exportContext, final MetaAndTableJRDataSource source) { exportContext.addJRMetaDataUSINFO(source); + // TODO: add custom stuff here // source.addMetaData("flowdepthdevelopment_header_label", // SInfoResultType.flowdepthDevelopment.getCsvHeader(this.context.getMeta()));// (this.context.getMeta())); } - -} -// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : +} \ No newline at end of file diff -r 61b5de0b673b -r 7b2b086e45f0 artifacts/src/main/java/org/dive4elements/river/artifacts/common/ExportContextPDF.java --- a/artifacts/src/main/java/org/dive4elements/river/artifacts/common/ExportContextPDF.java Thu Jul 26 17:37:23 2018 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/common/ExportContextPDF.java Fri Jul 27 10:11:23 2018 +0200 @@ -18,7 +18,6 @@ import org.dive4elements.artifacts.CallContext; import org.dive4elements.river.FLYS; import org.dive4elements.river.artifacts.resources.Resources; -import org.dive4elements.river.artifacts.sinfo.common.SInfoResultType; import org.dive4elements.river.artifacts.sinfo.util.RiverInfo; /** @@ -32,7 +31,7 @@ } // TODO: rename - public String msgPdf(final SInfoResultType type) { + public String msgPdf(final IResultType type) { return type.getPdfHeader(getContext().getMeta()); } diff -r 61b5de0b673b -r 7b2b086e45f0 artifacts/src/main/java/org/dive4elements/river/artifacts/common/GeneralResultType.java --- a/artifacts/src/main/java/org/dive4elements/river/artifacts/common/GeneralResultType.java Thu Jul 26 17:37:23 2018 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/common/GeneralResultType.java Fri Jul 27 10:11:23 2018 +0200 @@ -36,6 +36,19 @@ return Formatter.getWaterlevelKM(context); } }; + public static final GeneralResultType waterlevelLabel = new GeneralResultType(I18NStrings.UNIT_NONE, SInfoI18NStrings.CSV_LABEL_HEADER) { + private static final long serialVersionUID = 1L; + + @Override + public String exportValue(final CallContext context, final Object value) { + return exportStringValue(value); + } + + @Override + protected NumberFormat createFormatter(final CallContext context) { + throw new UnsupportedOperationException(); + } + }; public static final GeneralResultType date = new GeneralResultType(I18NStrings.UNIT_NONE, I18NStrings.CSV_META_DATE) { @Override @@ -49,6 +62,18 @@ } }; + public static final GeneralResultType dateShort = new GeneralResultType(I18NStrings.UNIT_NONE, "sinfo.export.csv.meta.date") { + @Override + public String exportValue(final CallContext context, final Object value) { + return exportDateValue(context, (Date) value); + } + + @Override + protected NumberFormat createFormatter(final CallContext context) { + throw new UnsupportedOperationException(); + } + }; + private GeneralResultType(final String unit, final String csvHeader) { super(unit, csvHeader, csvHeader); @@ -87,4 +112,32 @@ return Formatter.getWaterlevelQ(context); } }; + + public static final GeneralResultType gaugeLabel = new GeneralResultType(I18NStrings.UNIT_NONE, SInfoI18NStrings.CSV_GAUGE_HEADER) { + private static final long serialVersionUID = 1L; + + @Override + public String exportValue(final CallContext context, final Object value) { + return exportStringValue(value); + } + + @Override + protected NumberFormat createFormatter(final CallContext context) { + throw new UnsupportedOperationException(); + } + }; + + public static final GeneralResultType gaugeLabelCm = new GeneralResultType(I18NStrings.UNIT_NONE, "chart.reference.curve.x.axis.in.cm") { + private static final long serialVersionUID = 1L; + + @Override + public String exportValue(final CallContext context, final Object value) { + return exportStringValue(value); + } + + @Override + protected NumberFormat createFormatter(final CallContext context) { + throw new UnsupportedOperationException(); + } + }; } \ No newline at end of file diff -r 61b5de0b673b -r 7b2b086e45f0 artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/collision/CollisionCalcDetailResult.java --- a/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/collision/CollisionCalcDetailResult.java Thu Jul 26 17:37:23 2018 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/collision/CollisionCalcDetailResult.java Fri Jul 27 10:11:23 2018 +0200 @@ -53,10 +53,10 @@ final Collection header = new ArrayList<>(colSize); header.add(exportContextCSV.formatCsvHeader(GeneralResultType.station)); - header.add(exportContextCSV.formatCsvHeader(GeneralResultType.date)); + header.add(exportContextCSV.formatCsvHeader(GeneralResultType.dateShort)); header.add(exportContextCSV.msgUnitCSV(SInfoResultType.collisionGaugeW, SInfoResultType.collisionGaugeW.getUnit())); - header.add(exportContextCSV.formatCsvHeader(SInfoResultType.gaugeLabel)); - header.add(exportContextCSV.msgUnitCSV(SInfoResultType.discharge, SInfoResultType.discharge.getUnit())); + header.add(exportContextCSV.formatCsvHeader(GeneralResultType.gaugeLabelCm)); + header.add(exportContextCSV.msgUnitCSV(SInfoResultType.dischargeLong, SInfoResultType.dischargeLong.getUnit())); header.add(exportContextCSV.formatCsvHeader(SInfoResultType.dischargeZone)); exportContextCSV.writeCSVLine(header.toArray(new String[colSize])); @@ -71,7 +71,7 @@ protected String[] formatPDFRow(final ExportContextPDF exportContextCSV, final ResultRow row) { /* * final Collection lines = new ArrayList<>(6); - * lines.add(exportContextCSV.formatRowValue(row, GeneralResultType.station)); + * lines.add(exportContextCSV.formatRowValue(row, BunduResultType.station)); * return lines.toArray(new String[lines.size()]); */ return formatRow(exportContextCSV, row); @@ -82,10 +82,10 @@ final Collection lines = new ArrayList<>(6); lines.add(exportContext.formatRowValue(row, GeneralResultType.station)); - lines.add(exportContext.formatRowValue(row, GeneralResultType.date)); + lines.add(exportContext.formatRowValue(row, GeneralResultType.dateShort)); lines.add(exportContext.formatRowValue(row, SInfoResultType.collisionGaugeW)); - lines.add(exportContext.formatRowValue(row, SInfoResultType.gaugeLabel)); - lines.add(exportContext.formatRowValue(row, SInfoResultType.discharge)); + lines.add(exportContext.formatRowValue(row, GeneralResultType.gaugeLabelCm)); + lines.add(exportContext.formatRowValue(row, SInfoResultType.dischargeLong)); lines.add(exportContext.formatRowValue(row, SInfoResultType.dischargeZone)); return lines.toArray(new String[lines.size()]); @@ -101,10 +101,10 @@ /* column headings */ exportContextCSV.addJRMetadata(source, "station_header", GeneralResultType.station); - exportContextCSV.addJRMetadata(source, "date_header", GeneralResultType.date); + exportContextCSV.addJRMetadata(source, "date_header", GeneralResultType.dateShort); exportContextCSV.addJRMetadata(source, "gaugew_header", SInfoResultType.collisionGaugeW); - exportContextCSV.addJRMetadata(source, "gauge_header", SInfoResultType.gaugeLabel); - exportContextCSV.addJRMetadata(source, "discharge_header", SInfoResultType.discharge); + exportContextCSV.addJRMetadata(source, "gauge_header", GeneralResultType.gaugeLabelCm); + exportContextCSV.addJRMetadata(source, "discharge_header", SInfoResultType.dischargeLong); exportContextCSV.addJRMetadata(source, "dischargezone_header", SInfoResultType.dischargeZone); } } \ No newline at end of file diff -r 61b5de0b673b -r 7b2b086e45f0 artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/collision/CollisionCalculation.java --- a/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/collision/CollisionCalculation.java Thu Jul 26 17:37:23 2018 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/collision/CollisionCalculation.java Fri Jul 27 10:11:23 2018 +0200 @@ -69,8 +69,7 @@ if (access.getYears() != null) { for (final int year : access.getYears()) calculateOverview(overViewRows, river, access.getLowerKm(), access.getUpperKm(), year, year, false); - } - else { + } else { for (final DateRange dr : access.getEpochs()) calculateOverview(overViewRows, river, access.getLowerKm(), access.getUpperKm(), dr.getFromYear(), dr.getToYear(), true); } @@ -91,8 +90,7 @@ if (access.getYears() != null) { for (final int year : access.getYears()) calculateDetails(detailsRows, infoProvider, access.getLowerKm(), access.getUpperKm(), year, year, qFinders, zoneFinders); - } - else { + } else { for (final DateRange dr : access.getEpochs()) calculateDetails(detailsRows, infoProvider, access.getLowerKm(), access.getUpperKm(), dr.getFromYear(), dr.getToYear(), qFinders, zoneFinders); } @@ -110,7 +108,7 @@ final int toYear, final boolean isEpoch) { for (final CollisionAggregateValue aggregate : CollisionAggregateValue.getValuesByKm(river, fromKm, toKm, fromYear, toYear)) { rows.add(ResultRow.create().putValue(GeneralResultType.station, aggregate.getStation()) - .putValue(SInfoResultType.years, (isEpoch? String.format("%d-%d", fromYear, toYear) : Integer.toString(fromYear))) + .putValue(SInfoResultType.years, (isEpoch ? String.format("%d-%d", fromYear, toYear) : Integer.toString(fromYear))) .putValue(SInfoResultType.collisionCount, aggregate.getCount())); } } @@ -120,18 +118,15 @@ * and adds them to a ResultRow collection */ private void calculateDetails(final Collection rows, final RiverInfoProvider riverInfo, final double fromKm, final double toKm, - final int fromYear, final int toYear, final Map qFinders, - final Map zoneFinders) { + final int fromYear, final int toYear, final Map qFinders, final Map zoneFinders) { for (final CollisionValue collision : CollisionValue.getValues(riverInfo.getRiver(), fromKm, toKm, DateUtil.getStartDateFromYear(fromYear), DateUtil.getEndDateFromYear(toYear))) { final Gauge gauge = riverInfo.getGauge(collision.getStation(), true); final double q = qFinders.get(gauge).getDischarge(collision.getGaugeW()); final double qOut = Double.isInfinite(q) ? Double.NaN : q; rows.add(ResultRow.create().putValue(GeneralResultType.station, collision.getStation()) - .putValue(GeneralResultType.date, collision.getEventDate()) - .putValue(SInfoResultType.collisionGaugeW, collision.getGaugeW()) - .putValue(SInfoResultType.gaugeLabel, collision.getGaugeName()) - .putValue(SInfoResultType.discharge, qOut) + .putValue(GeneralResultType.dateShort, collision.getEventDate()).putValue(SInfoResultType.collisionGaugeW, collision.getGaugeW()) + .putValue(GeneralResultType.gaugeLabelCm, collision.getGaugeName()).putValue(SInfoResultType.dischargeLong, qOut) .putValue(SInfoResultType.dischargeZone, zoneFinders.get(gauge).findZoneName(q))); } } diff -r 61b5de0b673b -r 7b2b086e45f0 artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/common/SInfoI18NStrings.java --- a/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/common/SInfoI18NStrings.java Thu Jul 26 17:37:23 2018 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/common/SInfoI18NStrings.java Fri Jul 27 10:11:23 2018 +0200 @@ -29,9 +29,9 @@ String CSV_DISCHARGE_HEADER = "sinfo.export.flow_depth.csv.header.discharge"; - String CSV_LABEL_HEADER = "sinfo.export.flow_depth.csv.header.label"; + String CSV_LABEL_HEADER = "common.export.csv.header.mainvalue_label"; - String CSV_GAUGE_HEADER = "sinfo.export.flow_depth.csv.header.gauge"; + String CSV_GAUGE_HEADER = "common.export.csv.header.gauge"; String CSV_LOCATION_HEADER = "common.export.csv.header.location"; diff -r 61b5de0b673b -r 7b2b086e45f0 artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/common/SInfoResultType.java --- a/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/common/SInfoResultType.java Thu Jul 26 17:37:23 2018 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/common/SInfoResultType.java Fri Jul 27 10:11:23 2018 +0200 @@ -153,7 +153,8 @@ // } // }; - public static final SInfoResultType waterlevelLabel = new SInfoResultType(I18NStrings.UNIT_NONE, SInfoI18NStrings.CSV_LABEL_HEADER) { + public static final SInfoResultType infrastructuretype = new SInfoResultType(I18NStrings.UNIT_NONE, + "sinfo.export.flood_duration.csv.header.infrastructure_type", "sinfo.export.flood_duration.pdf.header.infrastructure_type") { private static final long serialVersionUID = 1L; @Override @@ -167,18 +168,19 @@ } }; - public static final SInfoResultType infrastructuretype = new SInfoResultType(I18NStrings.UNIT_NONE, - "sinfo.export.flood_duration.csv.header.infrastructure_type", "sinfo.export.flood_duration.pdf.header.infrastructure_type") { + public static final SInfoResultType dischargeLong = new SInfoResultType(I18NStrings.UNIT_CUBIC_M, "sinfo.export.collision.csv.header.discharge_long") { private static final long serialVersionUID = 1L; @Override public String exportValue(final CallContext context, final Object value) { - return exportStringValue(value); + final double doubleValue = asDouble(value); + final double roundedDischarge = RiverUtils.roundQ(doubleValue); + return exportDoubleValue(context, roundedDischarge); } @Override protected NumberFormat createFormatter(final CallContext context) { - throw new UnsupportedOperationException(); + return Formatter.getWaterlevelQ(context); } }; @@ -351,20 +353,6 @@ return "?"; } - public static final SInfoResultType gaugeLabel = new SInfoResultType(I18NStrings.UNIT_NONE, SInfoI18NStrings.CSV_GAUGE_HEADER) { - private static final long serialVersionUID = 1L; - - @Override - public String exportValue(final CallContext context, final Object value) { - return exportStringValue(value); - } - - @Override - protected NumberFormat createFormatter(final CallContext context) { - throw new UnsupportedOperationException(); - } - }; - public static final SInfoResultType soilkind = new SInfoResultType(I18NStrings.UNIT_NONE, SInfoI18NStrings.CSV_TKHKIND_HEADER, "sinfo.export.tkh.pdf.header.tkhkind") { private static final long serialVersionUID = 1L; diff -r 61b5de0b673b -r 7b2b086e45f0 artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flood_duration/FloodDurationCalculationResult.java --- a/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flood_duration/FloodDurationCalculationResult.java Thu Jul 26 17:37:23 2018 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flood_duration/FloodDurationCalculationResult.java Fri Jul 27 10:11:23 2018 +0200 @@ -139,7 +139,7 @@ } } - lines.add(exportContextCSV.formatRowValue(row, SInfoResultType.gaugeLabel)); + lines.add(exportContextCSV.formatRowValue(row, GeneralResultType.gaugeLabel)); lines.add(exportContextCSV.formatRowValue(row, GeneralResultType.location)); return lines.toArray(new String[lines.size()]); @@ -168,7 +168,7 @@ header.add(exportContextCSV.msg(DurationWaterlevel.getHeaderBezeichnCsv(), appendIndex)); } - header.add(exportContextCSV.formatCsvHeader(SInfoResultType.gaugeLabel)); + header.add(exportContextCSV.formatCsvHeader(GeneralResultType.gaugeLabel)); header.add(exportContextCSV.formatCsvHeader(GeneralResultType.location)); exportContextCSV.writeCSVLine(header.toArray(new String[header.size()])); @@ -212,7 +212,7 @@ exportContextPDF.msg(DurationWaterlevel.getHeaderBezeichnPdf(), appendIndex)); } - exportContextPDF.addJRMetadata(source, "gauge_header", SInfoResultType.gaugeLabel); + exportContextPDF.addJRMetadata(source, "gauge_header", GeneralResultType.gaugeLabel); exportContextPDF.addJRMetadata(source, "location_header", GeneralResultType.location); } diff -r 61b5de0b673b -r 7b2b086e45f0 artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flood_duration/FloodDurationCalculator.java --- a/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flood_duration/FloodDurationCalculator.java Thu Jul 26 17:37:23 2018 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flood_duration/FloodDurationCalculator.java Fri Jul 27 10:11:23 2018 +0200 @@ -416,7 +416,7 @@ row.putValue(SInfoResultType.floodDuration, Double.NaN); // is replaced later for an infrastructure final String gaugeLabel = this.riverInfoProvider.findGauge(station, (gauge == firstGauge)); - row.putValue(SInfoResultType.gaugeLabel, gaugeLabel); + row.putValue(GeneralResultType.gaugeLabel, gaugeLabel); final String location = this.riverInfoProvider.getLocation(station); row.putValue(GeneralResultType.location, location); diff -r 61b5de0b673b -r 7b2b086e45f0 artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flood_duration/FloodDurationExporter.java --- a/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flood_duration/FloodDurationExporter.java Thu Jul 26 17:37:23 2018 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flood_duration/FloodDurationExporter.java Fri Jul 27 10:11:23 2018 +0200 @@ -13,11 +13,11 @@ import org.dive4elements.river.artifacts.common.AbstractCommonExporter; 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.JasperDesigner; import org.dive4elements.river.artifacts.common.MetaAndTableJRDataSource; import org.dive4elements.river.artifacts.common.ResultRow; import org.dive4elements.river.artifacts.sinfo.common.SInfoI18NStrings; -import org.dive4elements.river.artifacts.sinfo.common.SInfoResultType; /** * Generates different output formats (csv, pdf) of data that resulted from a flood duration computation. @@ -55,7 +55,7 @@ // "# Bezugspegel: " for (final ResultRow row : result.getRows()) { - exportContext.writeCSVMetaEntry(SInfoI18NStrings.CSV_META_HEADER_WATERLEVEL_GAUGE, row.getValue(SInfoResultType.gaugeLabel)); + exportContext.writeCSVMetaEntry(SInfoI18NStrings.CSV_META_HEADER_WATERLEVEL_GAUGE, row.getValue(GeneralResultType.gaugeLabel)); break; } } diff -r 61b5de0b673b -r 7b2b086e45f0 artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flowdepth/FlowDepthCalculationResult.java --- a/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flowdepth/FlowDepthCalculationResult.java Thu Jul 26 17:37:23 2018 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flowdepth/FlowDepthCalculationResult.java Fri Jul 27 10:11:23 2018 +0200 @@ -70,8 +70,8 @@ header.add(exportContextCSV.msgUnitCSV(SInfoResultType.waterlevel, river.getWstUnit())); header.add(exportContextCSV.msgUnitCSV(SInfoResultType.discharge)); - header.add(exportContextCSV.formatCsvHeader(SInfoResultType.waterlevelLabel)); - header.add(exportContextCSV.formatCsvHeader(SInfoResultType.gaugeLabel)); + header.add(exportContextCSV.formatCsvHeader(GeneralResultType.waterlevelLabel)); + header.add(exportContextCSV.formatCsvHeader(GeneralResultType.gaugeLabel)); header.add(exportContextCSV.formatCsvHeader(SInfoResultType.meanBedHeight)); header.add(exportContextCSV.formatCsvHeader(SInfoResultType.soundingLabel)); header.add(exportContextCSV.formatCsvHeader(GeneralResultType.location)); @@ -119,8 +119,8 @@ exportContextPDF.addJRMetadata(source, "tkh_header", SInfoResultType.tkh); exportContextPDF.addJRMetadata(source, "waterlevel_header", SInfoResultType.waterlevel); exportContextPDF.addJRMetadata(source, "discharge_header", SInfoResultType.discharge); - exportContextPDF.addJRMetadata(source, "waterlevel_name_header", SInfoResultType.waterlevelLabel); - exportContextPDF.addJRMetadata(source, "gauge_header", SInfoResultType.gaugeLabel); + exportContextPDF.addJRMetadata(source, "waterlevel_name_header", GeneralResultType.waterlevelLabel); + exportContextPDF.addJRMetadata(source, "gauge_header", GeneralResultType.gaugeLabel); exportContextPDF.addJRMetadata(source, "bedheight_header", SInfoResultType.meanBedHeight); exportContextPDF.addJRMetadata(source, "sounding_name_header", SInfoResultType.soundingLabel); exportContextPDF.addJRMetadata(source, "location_header", GeneralResultType.location); @@ -141,8 +141,8 @@ lines.add(exportContext.formatRowValue(row, SInfoResultType.waterlevel)); lines.add(exportContext.formatRowValue(row, SInfoResultType.discharge)); - lines.add(exportContext.formatRowValue(row, SInfoResultType.waterlevelLabel)); - lines.add(exportContext.formatRowValue(row, SInfoResultType.gaugeLabel)); + lines.add(exportContext.formatRowValue(row, GeneralResultType.waterlevelLabel)); + lines.add(exportContext.formatRowValue(row, GeneralResultType.gaugeLabel)); lines.add(exportContext.formatRowValue(row, SInfoResultType.meanBedHeight)); lines.add(exportContext.formatRowValue(row, SInfoResultType.soundingLabel)); lines.add(exportContext.formatRowValue(row, GeneralResultType.location)); diff -r 61b5de0b673b -r 7b2b086e45f0 artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flowdepth/FlowDepthCalculator.java --- a/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flowdepth/FlowDepthCalculator.java Thu Jul 26 17:37:23 2018 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flowdepth/FlowDepthCalculator.java Fri Jul 27 10:11:23 2018 +0200 @@ -67,12 +67,12 @@ final ResultRow row = ResultRow.create(); - row.putValue(SInfoResultType.waterlevelLabel, this.wstLabel); + row.putValue(GeneralResultType.waterlevelLabel, this.wstLabel); row.putValue(SInfoResultType.soundingLabel, this.bedHeightLabel); // REMARK: access the gauge once only during calculation final String gaugeLabel = this.riverInfoProvider.findGauge(station); - row.putValue(SInfoResultType.gaugeLabel, gaugeLabel); + row.putValue(GeneralResultType.gaugeLabel, gaugeLabel); // REMARK: access the location once only during calculation final String location = this.riverInfoProvider.getLocation(station); diff -r 61b5de0b673b -r 7b2b086e45f0 artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flowdepthminmax/FlowDepthMinMaxCalculation.java --- a/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flowdepthminmax/FlowDepthMinMaxCalculation.java Thu Jul 26 17:37:23 2018 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flowdepthminmax/FlowDepthMinMaxCalculation.java Fri Jul 27 10:11:23 2018 +0200 @@ -153,8 +153,8 @@ putValue(SInfoResultType.flowdepthmax, maxFlowDepth). // putValue(SInfoResultType.waterlevel, wst). // putValue(SInfoResultType.discharge, discharge). // - putValue(SInfoResultType.waterlevelLabel, waterlevelLabel). // - putValue(SInfoResultType.gaugeLabel, gaugeLabel). // + putValue(GeneralResultType.waterlevelLabel, waterlevelLabel). // + putValue(GeneralResultType.gaugeLabel, gaugeLabel). // putValue(SInfoResultType.meanBedHeight, meanBedHeight). // putValue(SInfoResultType.soundingLabel, soundingLabel). // putValue(GeneralResultType.location, location); diff -r 61b5de0b673b -r 7b2b086e45f0 artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flowdepthminmax/FlowDepthMinMaxCalculationResult.java --- a/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flowdepthminmax/FlowDepthMinMaxCalculationResult.java Thu Jul 26 17:37:23 2018 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flowdepthminmax/FlowDepthMinMaxCalculationResult.java Fri Jul 27 10:11:23 2018 +0200 @@ -57,8 +57,8 @@ header.add(exportContextCSV.msgUnitCSV(SInfoResultType.flowdepthmax)); header.add(exportContextCSV.msgUnitCSV(SInfoResultType.waterlevel, river.getWstUnit())); header.add(exportContextCSV.msgUnitCSV(SInfoResultType.discharge)); - header.add(exportContextCSV.formatCsvHeader(SInfoResultType.waterlevelLabel)); - header.add(exportContextCSV.formatCsvHeader(SInfoResultType.gaugeLabel)); + header.add(exportContextCSV.formatCsvHeader(GeneralResultType.waterlevelLabel)); + header.add(exportContextCSV.formatCsvHeader(GeneralResultType.gaugeLabel)); header.add(exportContextCSV.msgUnitCSV(SInfoResultType.meanBedHeight, river.getWstUnit())); header.add(exportContextCSV.formatCsvHeader(SInfoResultType.soundingLabel)); header.add(exportContextCSV.formatCsvHeader(GeneralResultType.location)); @@ -104,8 +104,8 @@ exportContextPDF.addJRMetadata(source, "flowdepthmax_header", SInfoResultType.flowdepthmax); exportContextPDF.addJRMetadata(source, "waterlevel_header", SInfoResultType.waterlevel); exportContextPDF.addJRMetadata(source, "discharge_header", SInfoResultType.discharge); - exportContextPDF.addJRMetadata(source, "waterlevel_name_header", SInfoResultType.waterlevelLabel); - exportContextPDF.addJRMetadata(source, "gauge_header", SInfoResultType.gaugeLabel); + exportContextPDF.addJRMetadata(source, "waterlevel_name_header", GeneralResultType.waterlevelLabel); + exportContextPDF.addJRMetadata(source, "gauge_header", GeneralResultType.gaugeLabel); exportContextPDF.addJRMetadata(source, "bedheight_header", SInfoResultType.meanBedHeight); exportContextPDF.addJRMetadata(source, "sounding_name_header", SInfoResultType.soundingLabel); exportContextPDF.addJRMetadata(source, "location_header", GeneralResultType.location); @@ -128,8 +128,8 @@ lines.add(exportContextCSV.formatRowValue(row, SInfoResultType.waterlevel)); lines.add(exportContextCSV.formatRowValue(row, SInfoResultType.discharge)); - lines.add(exportContextCSV.formatRowValue(row, SInfoResultType.waterlevelLabel)); - lines.add(exportContextCSV.formatRowValue(row, SInfoResultType.gaugeLabel)); + lines.add(exportContextCSV.formatRowValue(row, GeneralResultType.waterlevelLabel)); + lines.add(exportContextCSV.formatRowValue(row, GeneralResultType.gaugeLabel)); lines.add(exportContextCSV.formatRowValue(row, SInfoResultType.meanBedHeight)); lines.add(exportContextCSV.formatRowValue(row, SInfoResultType.soundingLabel)); lines.add(exportContextCSV.formatRowValue(row, GeneralResultType.location)); diff -r 61b5de0b673b -r 7b2b086e45f0 artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/tkhstate/TkhCalculation.java --- a/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/tkhstate/TkhCalculation.java Thu Jul 26 17:37:23 2018 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/tkhstate/TkhCalculation.java Fri Jul 27 10:11:23 2018 +0200 @@ -32,7 +32,6 @@ import org.dive4elements.river.artifacts.resources.Resources; import org.dive4elements.river.artifacts.sinfo.SINFOArtifact; import org.dive4elements.river.artifacts.sinfo.common.RiverInfoProvider; -import org.dive4elements.river.artifacts.sinfo.common.SInfoResultType; import org.dive4elements.river.artifacts.sinfo.tkhcalculation.DischargeValuesFinder; import org.dive4elements.river.artifacts.sinfo.tkhcalculation.TkhCalculator; import org.dive4elements.river.artifacts.sinfo.tkhcalculation.WaterlevelValuesFinder; @@ -181,8 +180,8 @@ final ResultRow row = ResultRow.create(); - row.putValue(SInfoResultType.waterlevelLabel, waterlevelLabel); - row.putValue(SInfoResultType.gaugeLabel, riverInfoProvider.findGauge(station)); + row.putValue(GeneralResultType.waterlevelLabel, waterlevelLabel); + row.putValue(GeneralResultType.gaugeLabel, riverInfoProvider.findGauge(station)); row.putValue(GeneralResultType.location, riverInfoProvider.getLocation(station)); if (tkhCalculator.calculateTkh(station, row)) diff -r 61b5de0b673b -r 7b2b086e45f0 artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/tkhstate/TkhCalculationResult.java --- a/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/tkhstate/TkhCalculationResult.java Thu Jul 26 17:37:23 2018 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/tkhstate/TkhCalculationResult.java Fri Jul 27 10:11:23 2018 +0200 @@ -59,7 +59,7 @@ if (descriptionHeader != null) header.add(descriptionHeader); - header.add(exportContext.formatCsvHeader(SInfoResultType.gaugeLabel)); + header.add(exportContext.formatCsvHeader(GeneralResultType.gaugeLabel)); header.add(exportContext.formatCsvHeader(GeneralResultType.location)); exportContext.writeCSVLine(header.toArray(new String[header.size()])); @@ -105,10 +105,10 @@ final TkhCalculationResults results = exportContext.getResults(); final String descriptionHeader = results.getDescriptionHeader(); - final String waterlevelNameHeader = descriptionHeader == null ? exportContext.msgPdf(SInfoResultType.waterlevelLabel) : descriptionHeader; + final String waterlevelNameHeader = descriptionHeader == null ? exportContext.msgPdf(GeneralResultType.waterlevelLabel) : descriptionHeader; exportContext.addJRMetadata(source, "waterlevel_name_header", waterlevelNameHeader); - exportContext.addJRMetadata(source, "gauge_header", SInfoResultType.gaugeLabel); + exportContext.addJRMetadata(source, "gauge_header", GeneralResultType.gaugeLabel); exportContext.addJRMetadata(source, "location_header", GeneralResultType.location); } @@ -128,9 +128,9 @@ final TkhCalculationResults results = exportContext.getResults(); final String descriptionHeader = results.getDescriptionHeader(); if (descriptionHeader != null || mode == ExportMode.pdf) - lines.add(exportContext.formatRowValue(row, SInfoResultType.waterlevelLabel)); + lines.add(exportContext.formatRowValue(row, GeneralResultType.waterlevelLabel)); - lines.add(exportContext.formatRowValue(row, SInfoResultType.gaugeLabel)); + lines.add(exportContext.formatRowValue(row, GeneralResultType.gaugeLabel)); lines.add(exportContext.formatRowValue(row, GeneralResultType.location)); return lines.toArray(new String[lines.size()]); diff -r 61b5de0b673b -r 7b2b086e45f0 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 Thu Jul 26 17:37:23 2018 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/uinfo/salix/SalixLineCalculation.java Fri Jul 27 10:11:23 2018 +0200 @@ -77,7 +77,7 @@ // 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(BunduResultType.station, 100).// // putValue(UInfoResultType.salixline, 28).// // putValue(UInfoResultType.salix_delta_mw, 2); // @@ -122,7 +122,7 @@ // final double step = 0.1; // TODO: get from global setting? // while (currentKm < range.getMaximumDouble()) { // final ResultRow rowSupraRegional = ResultRow.create(). // - // putValue(GeneralResultType.station, currentKm).// + // putValue(BunduResultType.station, currentKm).// // putValue(UInfoResultType.salixline, 28).// // putValue(UInfoResultType.salix_delta_mw, 2); // diff -r 61b5de0b673b -r 7b2b086e45f0 artifacts/src/main/resources/messages.properties --- a/artifacts/src/main/resources/messages.properties Thu Jul 26 17:37:23 2018 +0200 +++ b/artifacts/src/main/resources/messages.properties Fri Jul 27 10:11:23 2018 +0200 @@ -907,8 +907,9 @@ sinfo.export.flow_depth.csv.header.waterlevel = Wasserstand sinfo.export.flow_depth.pdf.header.waterlevel = Wasser-stand sinfo.export.flow_depth.csv.header.discharge = Q -sinfo.export.flow_depth.csv.header.label = Bezeichnung -sinfo.export.flow_depth.csv.header.gauge = Bezugspegel +sinfo.export.collision.csv.header.discharge_long = Abfluss +common.export.csv.header.mainvalue_label = Bezeichnung +common.export.csv.header.gauge = Bezugspegel sinfo.export.flow_depth.csv.header.mean_bed_height = Mittlere Sohlh\u00f6he sinfo.export.flow_depth.csv.header.mean_bed_height.short = Mittlere Sohl- sinfo.export.flow_depth.csv.header.sounding = Peilung/Epoche diff -r 61b5de0b673b -r 7b2b086e45f0 artifacts/src/main/resources/messages_de.properties --- a/artifacts/src/main/resources/messages_de.properties Thu Jul 26 17:37:23 2018 +0200 +++ b/artifacts/src/main/resources/messages_de.properties Fri Jul 27 10:11:23 2018 +0200 @@ -907,8 +907,9 @@ sinfo.export.flow_depth.csv.header.waterlevel = Wasserstand sinfo.export.flow_depth.pdf.header.waterlevel = Wasser-stand sinfo.export.flow_depth.csv.header.discharge = Q -sinfo.export.flow_depth.csv.header.label = Bezeichnung -sinfo.export.flow_depth.csv.header.gauge = Bezugspegel +sinfo.export.collision.csv.header.discharge_long = Abfluss +common.export.csv.header.mainvalue_label = Bezeichnung +common.export.csv.header.gauge = Bezugspegel sinfo.export.flow_depth.csv.header.mean_bed_height = Mittlere Sohlh\u00f6he sinfo.export.flow_depth.csv.header.mean_bed_height.short = Mittlere Sohl- sinfo.export.flow_depth.csv.header.sounding = Peilung/Epoche