view artifacts/src/main/java/org/dive4elements/river/artifacts/model/sq/SQMeasurementsJRDataSource.java @ 8578:4eb1a3c71579

(issue1753) Implement PDF export of SQ Measurement data. The SQRelationExporter now consists of two reports (to avoid subreport woes). The old SQReleation PDF only takes the Page count of the Measurement attachment as argument to correctly print the page numbers. Otherwise it is unchanged. The new SQMeasurements report lists the measured data points on which the calculation was based.
author Andre Heinecke <andre.heinecke@intevation.de>
date Mon, 16 Mar 2015 11:35:19 +0100
parents
children 5e38e2924c07
line wrap: on
line source
/* Copyright (C) 2011, 2012, 2013, 2015 by Bundesanstalt für Gewässerkunde
 * Software engineering by Intevation GmbH
 *
 * 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.model.sq;

import java.util.ArrayList;

import org.apache.log4j.Logger;

import net.sf.jasperreports.engine.JRDataSource;
import net.sf.jasperreports.engine.JRException;
import net.sf.jasperreports.engine.JRField;


/**
 * @author <a href="mailto:aheinecke@intevation.de">Andre Heinecke</a>
 */
public class SQMeasurementsJRDataSource implements JRDataSource
{
    /** The log used in this exporter.*/
    private static Logger log = Logger.getLogger(SQMeasurementsJRDataSource.class);

    private ArrayList<String[]> data;

    private int index = -1;

    public SQMeasurementsJRDataSource() {
        data = new ArrayList<String[]>();
    }

    public void addData(String[] val) {
        data.add(val);
    }

    public boolean next() throws JRException {
        index++;
        return (index < data.size());
    }

    public Object getFieldValue(JRField field) throws JRException {
        Object value = "";
        String fieldName = field.getName();
        if ("param".equals(fieldName)) {
            value = data.get(index)[0];
        }
        else if ("transport".equals(fieldName)) {
            value = data.get(index)[1];
        }
        else if ("discharge".equals(fieldName)) {
            value = data.get(index)[2];
        }
        else if ("date".equals(fieldName)) {
            value = data.get(index)[3];
        }
        else if ("outlier".equals(fieldName)) {
            value = data.get(index)[4];
        }
        return value;
    }
}
// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org