view artifacts/src/main/java/org/dive4elements/river/artifacts/bundu/bezugswst/BezugswstMissVolCalculationResult3.java @ 9444:ecadc9ed0ba0

Added heights and depths of cross section fields in the bundu bzws calculation and longitudinal section charts
author mschaefer
date Tue, 21 Aug 2018 13:41:18 +0200
parents d194c5b24bf8
children e60584f2a531
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.bundu.bezugswst;

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.AbstractExportContext;
import org.dive4elements.river.artifacts.common.ExportContextCSV;
import org.dive4elements.river.artifacts.common.ExportContextPDF;
import org.dive4elements.river.artifacts.common.MetaAndTableJRDataSource;
import org.dive4elements.river.artifacts.common.ResultRow;
import org.dive4elements.river.artifacts.sinfo.util.RiverInfo;

/**
 * Contains the results of a //TODO LINK{@link BezugswstCalculation}.
 *
 * @author Gernot Belger
 */
final class BezugswstMissVolCalculationResult3 extends AbstractCalculationExportableResult implements BunduWstExporter.MissResultType {

    private static final long serialVersionUID = 1L;

    private static final String JASPER_FILE = "/jasper/templates/bundu.bezugswst.result3.jrxml";

    public BezugswstMissVolCalculationResult3(final String label, final Collection<ResultRow> rows) {
        super(label, rows);

    }

    @Override
    protected void writeCSVResultMetadata(final ExportContextCSV exportContextCSV) {
        // no metadata
    }

    @Override
    protected String getJasperFile() {
        return JASPER_FILE;
    }

    protected String[] formatRow(final AbstractExportContext exportContext, final ResultRow row) {

        final Collection<String> lines = new ArrayList<>(20);

        lines.add(exportContext.formatRowValue(row, BunduResultType.missStationRangeFrom));
        lines.add(exportContext.formatRowValue(row, BunduResultType.missStationRangeTo));
        lines.add(exportContext.formatRowValue(row, BunduResultType.missVolumeTotal));
        lines.add(exportContext.formatRowValue(row, BunduResultType.missMassTotal));
        return lines.toArray(new String[lines.size()]);
    }

    @Override
    public void writeCSVHeader(final ExportContextCSV exportContextCSV, final RiverInfo river) {

        final int colSize = 4;
        exportContextCSV.writeTitleForTabs("bundu.export.csv.title.bezugswst.result3", colSize); // Voraussetzung für Tabs ist, dass der Titel vor den Headern
        final Collection<String> header = new ArrayList<>(colSize);

        header.add(exportContextCSV.formatCsvHeader(BunduResultType.missStationRangeFrom));
        header.add(exportContextCSV.formatCsvHeader(BunduResultType.missStationRangeTo));
        header.add(exportContextCSV.formatCsvHeader(BunduResultType.missVolumeTotal));
        header.add(exportContextCSV.formatCsvHeader(BunduResultType.missMassTotal));

        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", BunduResultType.missStationRangeFrom);
        exportContextPDF.addJRMetadata(source, "station_header", BunduResultType.missStationRangeTo);
        exportContextPDF.addJRMetadata(source, "channel_miss_volume_header", BunduResultType.missVolumeTotal);
        exportContextPDF.addJRMetadata(source, "channel_miss_mass_header", BunduResultType.missMassTotal);

    }
}

http://dive4elements.wald.intevation.org