Mercurial > dive4elements > river
view artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flowdepthdev/FlowDepthDevelopmentCalculationResult.java @ 9268:ae9dee74e43e
Fixed: current station of duration chart was not changed
author | gernotbelger |
---|---|
date | Wed, 18 Jul 2018 18:53:15 +0200 |
parents | a4121ec450d6 |
children | 740d65e4aa14 |
line wrap: on
line source
/* 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.sinfo.flowdepthdev; 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.common.SInfoResultType; import org.dive4elements.river.artifacts.sinfo.util.BedHeightInfo; import org.dive4elements.river.artifacts.sinfo.util.RiverInfo; import org.dive4elements.river.artifacts.sinfo.util.WstInfo; /** * Contains the results of a {@link FloodDurationCalculation}. * * @author Gernot Belger */ final class FlowDepthDevelopmentCalculationResult extends AbstractCalculationExportableResult { private static final long serialVersionUID = 1L; private static final String CSV_META_HEADER_SOUNDING_CURRENT = "sinfo.export.csv.meta.header.sounding.current"; private static final String CSV_META_HEADER_SOUNDING_HISTORICAL = "sinfo.export.csv.meta.header.sounding.historical"; private static final String CSV_META_HEADER_WATERLEVEL_CURRENT = "sinfo.export.csv.meta.header.waterlevel.current"; private static final String CSV_META_HEADER_WATERLEVEL_HISTORICAL = "sinfo.export.csv.meta.header.waterlevel.historical"; private static final String JASPER_FILE = "/jasper/templates/sinfo.flowdepthdevelopment.jrxml"; private final BedHeightInfo currentSounding; private final BedHeightInfo historicalSounding; private final WstInfo historicalWst; private final WstInfo currentWst; public FlowDepthDevelopmentCalculationResult(final String label, final WstInfo currentWst, final WstInfo historicalWst, final BedHeightInfo currentSounding, final BedHeightInfo historicalSounding, final Collection<ResultRow> rows) { super(label, rows); this.currentWst = currentWst; this.historicalWst = historicalWst; this.currentSounding = currentSounding; this.historicalSounding = historicalSounding; } public WstInfo getCurrentWst() { return this.currentWst; } public WstInfo getHistoricalWst() { return this.historicalWst; } public BedHeightInfo getCurrentSounding() { return this.currentSounding; } public BedHeightInfo getHistoricalSounding() { return this.historicalSounding; } public String getWaterlevelDifferenceLabel() { return new StringBuilder(). // append(this.currentWst.getLabel()). // append(" - "). // append(this.historicalWst.getLabel()). // toString(); } public String getBedHeightDifferenceLabel() { return new StringBuilder(). // append(this.currentSounding.getDescription()). // append(" - "). // append(this.historicalSounding.getDescription()). // toString(); } public String getFlowDepthCurrentLabel() { return new StringBuilder(). // append(this.currentWst.getLabel()). // append(" - "). // append(this.currentSounding.getDescription()). // toString(); } public String getFlowDepthHistoricalLabel() { return new StringBuilder(). // append(this.historicalWst.getLabel()). // append(" - "). // append(this.historicalSounding.getDescription()). // toString(); } @Override protected void writeCSVResultMetadata(final ExportContextCSV exportContextCSV) { exportContextCSV.writeCSVSoundingMetadata(getCurrentSounding(), CSV_META_HEADER_SOUNDING_CURRENT); exportContextCSV.writeBlankLine(); exportContextCSV.writeCSVWaterlevelMetadata(getCurrentWst(), CSV_META_HEADER_WATERLEVEL_CURRENT); exportContextCSV.writeBlankLine(); exportContextCSV.writeCSVSoundingMetadata(getHistoricalSounding(), CSV_META_HEADER_SOUNDING_HISTORICAL); exportContextCSV.writeBlankLine(); exportContextCSV.writeCSVWaterlevelMetadata(getHistoricalWst(), CSV_META_HEADER_WATERLEVEL_HISTORICAL); exportContextCSV.writeBlankLine(); } @Override protected String getJasperFile() { return JASPER_FILE; } protected String[] formatRow(final IExportContext exportContext, final ResultRow row) { final Collection<String> lines = new ArrayList<>(10); lines.add(exportContext.formatRowValue(row, GeneralResultType.station)); lines.add(exportContext.formatRowValue(row, SInfoResultType.flowdepthDevelopment)); lines.add(exportContext.formatRowValue(row, SInfoResultType.flowdepthDevelopmentPerYear)); lines.add(exportContext.formatRowValue(row, SInfoResultType.waterlevelDifference)); lines.add(exportContext.formatRowValue(row, SInfoResultType.bedHeightDifference)); lines.add(exportContext.formatRowValue(row, SInfoResultType.flowdepthCurrent)); lines.add(exportContext.formatRowValue(row, SInfoResultType.flowdepthHistorical)); lines.add(exportContext.formatRowValue(row, SInfoResultType.location)); return lines.toArray(new String[lines.size()]); } @Override public void writeCSVHeader(final ExportContextCSV exportContextCSV, final RiverInfo river) { final Collection<String> header = new ArrayList<>(11); header.add(exportContextCSV.formatCsvHeader(GeneralResultType.station)); header.add(exportContextCSV.msgUnitCSV(SInfoResultType.flowdepthDevelopment, SInfoResultType.flowdepthDevelopment.getUnit())); header.add(exportContextCSV.msgUnitCSV(SInfoResultType.flowdepthDevelopmentPerYear, SInfoResultType.flowdepthDevelopmentPerYear.getUnit())); header.add(exportContextCSV.msgUnitLabel(SInfoResultType.waterlevelDifference, getWaterlevelDifferenceLabel())); header.add(exportContextCSV.msgUnitLabel(SInfoResultType.bedHeightDifference, getBedHeightDifferenceLabel())); header.add(exportContextCSV.msgUnitLabel(SInfoResultType.flowdepthCurrent, getFlowDepthCurrentLabel())); header.add(exportContextCSV.msgUnitLabel(SInfoResultType.flowdepthHistorical, getFlowDepthHistoricalLabel())); header.add(exportContextCSV.formatCsvHeader(SInfoResultType.location)); exportContextCSV.writeCSVLine(header.toArray(new String[header.size()])); } @Override protected String[] formatCSVRow(final ExportContextCSV exportContextCSV, final ResultRow row) { return this.formatRow(exportContextCSV, row); } @Override protected String[] formatPDFRow(final ExportContextPDF exportContextPDF, final ResultRow row) { return this.formatRow(exportContextPDF, row); } @Override protected void addJRTableHeader(final ExportContextPDF exportContextPDF, final MetaAndTableJRDataSource source) { /* column headings */ exportContextPDF.addJRMetadata(source, "station_header", GeneralResultType.station); exportContextPDF.addJRMetadata(source, "flowdepthdevelopment_header", SInfoResultType.flowdepthDevelopment); exportContextPDF.addJRMetadata(source, "flowdepthdevelopmentperyear_header", SInfoResultType.flowdepthDevelopmentPerYear); exportContextPDF.addJRMetadata(source, "waterleveldifference_header", SInfoResultType.waterlevelDifference); exportContextPDF.addJRMetadata(source, "waterleveldifference_header2", getWaterlevelDifferenceLabel()); exportContextPDF.addJRMetadata(source, "bedheightdifference_header", SInfoResultType.bedHeightDifference); exportContextPDF.addJRMetadata(source, "bedheightdifference_header2", getBedHeightDifferenceLabel()); exportContextPDF.addJRMetadata(source, "flowdepthcurrent_header", SInfoResultType.flowdepthCurrent); exportContextPDF.addJRMetadata(source, "flowdepthcurrent_header2", getFlowDepthCurrentLabel()); exportContextPDF.addJRMetadata(source, "flowdepthhistorical_header", SInfoResultType.flowdepthHistorical); exportContextPDF.addJRMetadata(source, "flowdepthhistorical_header2", getFlowDepthHistoricalLabel()); exportContextPDF.addJRMetadata(source, "location_header", SInfoResultType.location); } }