Mercurial > dive4elements > river
view artifacts/src/main/java/org/dive4elements/river/artifacts/uinfo/vegetationzones/VegetationZonesCalculationResult.java @ 9559:ba0561906f81
Uinfo inundation duration workflow (vegetation zones, scenario), wms-config changed
author | gernotbelger |
---|---|
date | Wed, 24 Oct 2018 18:40:38 +0200 |
parents | c3ed5dcd5e08 |
children |
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.uinfo.vegetationzones; 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.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.uinfo.common.UInfoResultType; /** * @author Domenico Nardi Tironi */ final class VegetationZonesCalculationResult extends AbstractCalculationExportableResult { private static final long serialVersionUID = 1L; private static final String JASPER_FILE = "/jasper/templates/uinfo.vegetationzones.jrxml"; public VegetationZonesCalculationResult(final String label, final Collection<ResultRow> rows) { super(label, rows); } @Override public void writeCSVHeader(final ExportContextCSV exportContextCSV, final RiverInfo river) { final Collection<String> header = new ArrayList<>(11); header.add(exportContextCSV.formatCsvHeader(UInfoResultType.vegname)); header.add(exportContextCSV.formatCsvHeader(UInfoResultType.vegdauervon)); header.add(exportContextCSV.formatCsvHeader(UInfoResultType.vegdauerbis)); header.add(exportContextCSV.formatCsvHeader(UInfoResultType.vegzone_color)); exportContextCSV.writeCSVLine(header.toArray(new String[header.size()])); } @Override protected void writeCSVResultMetadata(final ExportContextCSV exportContextCSV) { // no metadata } @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 JASPER_FILE; } @Override protected void addJRTableHeader(final ExportContextPDF exportContextPDF, final MetaAndTableJRDataSource source) { /* additional column headings */ exportContextPDF.addJRMetadata(source, "veg_name", UInfoResultType.vegname); exportContextPDF.addJRMetadata(source, "veg_dauervon", UInfoResultType.vegdauervon); exportContextPDF.addJRMetadata(source, "veg_dauerbis", UInfoResultType.vegdauerbis); exportContextPDF.addJRMetadata(source, "color", UInfoResultType.vegzone_color); } protected String[] formatRow(final IExportContext context, final ResultRow row) { final Collection<String> lines = new ArrayList<>(11); lines.add(context.formatRowValue(row, UInfoResultType.vegname)); lines.add(context.formatRowValue(row, UInfoResultType.vegdauervon)); lines.add(context.formatRowValue(row, UInfoResultType.vegdauerbis)); lines.add(context.formatRowValue(row, UInfoResultType.vegzone_color)); return lines.toArray(new String[lines.size()]); } }