Mercurial > dive4elements > river
diff artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/tkhstate/TkhCalculationResult.java @ 9195:a4121ec450d6
'ca.'-issue
ExportContextCSV+PDF separated
uinfo.inundationduration url export
author | gernotbelger |
---|---|
date | Fri, 29 Jun 2018 14:52:54 +0200 |
parents | 9b2e46090099 |
children | 740d65e4aa14 |
line wrap: on
line diff
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/tkhstate/TkhCalculationResult.java Thu Jun 28 15:57:40 2018 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/tkhstate/TkhCalculationResult.java Fri Jun 29 14:52:54 2018 +0200 @@ -13,7 +13,9 @@ import java.util.Collection; 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.AbstractTkhCalculationResult; @@ -26,7 +28,7 @@ * * @author Gernot Belger */ -final class TkhCalculationResult extends AbstractTkhCalculationResult<TkhCalculationResults> { +final class TkhCalculationResult extends AbstractTkhCalculationResult { private static final long serialVersionUID = 1L; private static final String JASPER_FILE = "/jasper/templates/sinfo.tkh.jrxml"; @@ -41,44 +43,45 @@ } @Override - public void writeCSVHeader(final ExportContextCSV exportContextCSV, final TkhCalculationResults results, final RiverInfo river) { + public void writeCSVHeader(final ExportContextCSV exportContext, final RiverInfo river) { final Collection<String> header = new ArrayList<>(11); - header.add(exportContextCSV.formatCsvHeader(GeneralResultType.station)); - header.add(exportContextCSV.msgUnitCSV(SInfoResultType.tkh)); - header.add(exportContextCSV.formatCsvHeader(SInfoResultType.soilkind)); - header.add(exportContextCSV.msgUnitCSV(SInfoResultType.meanBedHeight, river.getWstUnit())); - header.add(exportContextCSV.msgUnitCSV(SInfoResultType.waterlevel, river.getWstUnit())); - header.add(exportContextCSV.msgUnitCSV(SInfoResultType.discharge)); + header.add(exportContext.formatCsvHeader(GeneralResultType.station)); + header.add(exportContext.msgUnitCSV(SInfoResultType.tkh)); + header.add(exportContext.formatCsvHeader(SInfoResultType.soilkind)); + header.add(exportContext.msgUnitCSV(SInfoResultType.meanBedHeight, river.getWstUnit())); + header.add(exportContext.msgUnitCSV(SInfoResultType.waterlevel, river.getWstUnit())); + header.add(exportContext.msgUnitCSV(SInfoResultType.discharge)); + final TkhCalculationResults results = exportContext.getResults(); final String descriptionHeader = results.getDescriptionHeader(); if (descriptionHeader != null) header.add(descriptionHeader); - header.add(exportContextCSV.formatCsvHeader(SInfoResultType.gaugeLabel)); - header.add(exportContextCSV.formatCsvHeader(SInfoResultType.location)); + header.add(exportContext.formatCsvHeader(SInfoResultType.gaugeLabel)); + header.add(exportContext.formatCsvHeader(SInfoResultType.location)); - exportContextCSV.writeCSVLine(header.toArray(new String[header.size()])); + exportContext.writeCSVLine(header.toArray(new String[header.size()])); } @Override - protected void writeCSVResultMetadata(final ExportContextCSV exportContextCSV, final TkhCalculationResults results) { + protected void writeCSVResultMetadata(final ExportContextCSV exportContextCSV) { exportContextCSV.writeCSVWaterlevelMetadata(super.getWst());// TODO: move to super exportContextCSV.writeBlankLine(); } @Override - protected String[] formatCSVRow(final ExportContextCSV exportContextCSV, final TkhCalculationResults results, final ResultRow row) { + protected String[] formatCSVRow(final ExportContextCSV exportContextCSV, final ResultRow row) { - return this.formatRow(exportContextCSV, results, row, ExportMode.csv); + return this.formatRow(exportContextCSV, row, ExportMode.csv); } @Override - protected String[] formatPDFRow(final ExportContextCSV exportContextPDF, final TkhCalculationResults results, final ResultRow row) { + protected String[] formatPDFRow(final ExportContextPDF exportContext, final ResultRow row) { - return this.formatRow(exportContextPDF, results, row, ExportMode.pdf); + return this.formatRow(exportContext, row, ExportMode.pdf); } @Override @@ -87,27 +90,30 @@ } @Override - protected void addJRTableHeader(final ExportContextCSV exportContextPDF, final MetaAndTableJRDataSource source, final TkhCalculationResults results) { + protected void addJRTableHeader(final ExportContextPDF exportContext, final MetaAndTableJRDataSource source) { /* column headings */ - exportContextPDF.addJRMetadata(source, "station_header", GeneralResultType.station); - exportContextPDF.addJRMetadata(source, "tkh_header", SInfoResultType.tkh); - exportContextPDF.addJRMetadata(source, "tkhkind_header", SInfoResultType.soilkind); - exportContextPDF.addJRMetadata(source, "bedheight_header", SInfoResultType.meanBedHeight); - exportContextPDF.addJRMetadata(source, "waterlevel_header", SInfoResultType.waterlevel); - exportContextPDF.addJRMetadata(source, "discharge_header", SInfoResultType.discharge); + exportContext.addJRMetadata(source, "station_header", GeneralResultType.station); + exportContext.addJRMetadata(source, "tkh_header", SInfoResultType.tkh); + exportContext.addJRMetadata(source, "tkhkind_header", SInfoResultType.soilkind); + exportContext.addJRMetadata(source, "bedheight_header", SInfoResultType.meanBedHeight); + exportContext.addJRMetadata(source, "waterlevel_header", SInfoResultType.waterlevel); + exportContext.addJRMetadata(source, "discharge_header", SInfoResultType.discharge); // REMARK: actually the column makes no sense if description header is null. But (software symmetry...) WINFO also // writes an empty column into the pdf in that case (most probably to avoid the need for two jasper templates). + + final TkhCalculationResults results = exportContext.getResults(); final String descriptionHeader = results.getDescriptionHeader(); - final String waterlevelNameHeader = descriptionHeader == null ? exportContextPDF.msgPdf(SInfoResultType.waterlevelLabel) : descriptionHeader; - exportContextPDF.addJRMetadata(source, "waterlevel_name_header", waterlevelNameHeader); - exportContextPDF.addJRMetadata(source, "gauge_header", SInfoResultType.gaugeLabel); - exportContextPDF.addJRMetadata(source, "location_header", SInfoResultType.location); + final String waterlevelNameHeader = descriptionHeader == null ? exportContext.msgPdf(SInfoResultType.waterlevelLabel) : descriptionHeader; + exportContext.addJRMetadata(source, "waterlevel_name_header", waterlevelNameHeader); + + exportContext.addJRMetadata(source, "gauge_header", SInfoResultType.gaugeLabel); + exportContext.addJRMetadata(source, "location_header", SInfoResultType.location); } - private String[] formatRow(final ExportContextCSV exportContext, final TkhCalculationResults results, final ResultRow row, final ExportMode mode) { + private String[] formatRow(final IExportContext exportContext, final ResultRow row, final ExportMode mode) { final Collection<String> lines = new ArrayList<>(11); @@ -119,7 +125,9 @@ lines.add(exportContext.formatRowValue(row, SInfoResultType.discharge)); // REMARK: always export this column in pdf-mode, because WInfo also does it (no need for two jasper-templates). - if (results.getDescriptionHeader() != null || mode == ExportMode.pdf) + 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, SInfoResultType.gaugeLabel)); @@ -127,5 +135,4 @@ return lines.toArray(new String[lines.size()]); } - } \ No newline at end of file