view artifacts/src/main/java/org/dive4elements/river/artifacts/bundu/bezugswst/BezugswstMissVolCalculationResult1.java @ 9330:0a0937f33bb5

bundu.bezugswst first result for missing volume added
author gernotbelger
date Fri, 27 Jul 2018 17:19:27 +0200
parents
children 127638669052
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.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.util.RiverInfo;

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

    private static final long serialVersionUID = 1L;

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

    public BezugswstMissVolCalculationResult1(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 IExportContext exportContext, final ResultRow row) {

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

        lines.add(exportContext.formatRowValue(row, BunduResultType.bezugswst));
        lines.add(exportContext.formatRowValue(row, GeneralResultType.dischargeQwithUnit));
        lines.add(exportContext.formatRowValue(row, GeneralResultType.waterlevelLabel));
        lines.add(exportContext.formatRowValue(row, GeneralResultType.gaugeLabel));

        lines.add(exportContext.formatRowValue(row, BunduResultType.sounding));
        lines.add(exportContext.formatRowValue(row, BunduResultType.channelLowerEdge));
        lines.add(exportContext.formatRowValue(row, BunduResultType.channelMinDepth));
        lines.add(exportContext.formatRowValue(row, BunduResultType.hasMissingDepth));
        lines.add(exportContext.formatRowValue(row, BunduResultType.missVolume));
        lines.add(exportContext.formatRowValue(row, BunduResultType.missMass));
        lines.add(exportContext.formatRowValue(row, BunduResultType.excavationVolume));
        lines.add(exportContext.formatRowValue(row, BunduResultType.excavationCosts));
        lines.add(exportContext.formatRowValue(row, BunduResultType.channelWidth));
        lines.add(exportContext.formatRowValue(row, BunduResultType.density));

        lines.add(exportContext.formatRowValue(row, GeneralResultType.location));

        return lines.toArray(new String[lines.size()]);
    }

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

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

        header.add(exportContextCSV.formatCsvHeader(BunduResultType.bezugswst) + " [" + river.getWstUnit() + "]");
        header.add(exportContextCSV.formatCsvHeader(GeneralResultType.dischargeQwithUnit));
        header.add(exportContextCSV.formatCsvHeader(GeneralResultType.waterlevelLabel));
        header.add(exportContextCSV.formatCsvHeader(GeneralResultType.gaugeLabel));

        header.add(exportContextCSV.formatCsvHeader(BunduResultType.sounding));
        header.add(exportContextCSV.formatCsvHeader(BunduResultType.channelLowerEdge));
        header.add(exportContextCSV.formatCsvHeader(BunduResultType.channelMinDepth));
        header.add(exportContextCSV.formatCsvHeader(BunduResultType.hasMissingDepth));
        header.add(exportContextCSV.formatCsvHeader(BunduResultType.missVolume));
        header.add(exportContextCSV.formatCsvHeader(BunduResultType.missMass));
        header.add(exportContextCSV.formatCsvHeader(BunduResultType.excavationVolume));
        header.add(exportContextCSV.formatCsvHeader(BunduResultType.excavationCosts));
        header.add(exportContextCSV.formatCsvHeader(BunduResultType.channelWidth));
        header.add(exportContextCSV.formatCsvHeader(BunduResultType.density));

        header.add(exportContextCSV.formatCsvHeader(GeneralResultType.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, "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, "sounding_header", BunduResultType.sounding);
        exportContextPDF.addJRMetadata(source, "channel_lower_edge_header", BunduResultType.channelLowerEdge);
        exportContextPDF.addJRMetadata(source, "channel_min_depth_header", BunduResultType.channelMinDepth);
        exportContextPDF.addJRMetadata(source, "channel_miss_depth_header", BunduResultType.hasMissingDepth);
        exportContextPDF.addJRMetadata(source, "channel_miss_volume_header", BunduResultType.missVolume);
        exportContextPDF.addJRMetadata(source, "channel_miss_mass_header", BunduResultType.missMass);
        exportContextPDF.addJRMetadata(source, "excavation_volume_header", BunduResultType.excavationVolume);
        exportContextPDF.addJRMetadata(source, "excavation_costs_header", BunduResultType.excavationCosts);
        exportContextPDF.addJRMetadata(source, "channel_width_header", BunduResultType.channelWidth);
        exportContextPDF.addJRMetadata(source, "density_header", BunduResultType.density);

        exportContextPDF.addJRMetadata(source, "location_header", GeneralResultType.location);

    }
}

http://dive4elements.wald.intevation.org