view artifacts/src/main/java/org/dive4elements/river/artifacts/bundu/bezugswst/BunduAccess.java @ 9396:6ebc9357550c

Fixed: bundu bzws start year plus one
author mschaefer
date Mon, 13 Aug 2018 17:15:05 +0200
parents 3d006afee054
children d194c5b24bf8
line wrap: on
line source
/* Copyright (C) 2011, 2012, 2013 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.bundu.bezugswst;

import org.apache.log4j.Logger;
import org.dive4elements.river.artifacts.D4EArtifact;
import org.dive4elements.river.artifacts.access.FixAnalysisAccess;

public class BunduAccess extends FixAnalysisAccess {

    private static Logger log = Logger.getLogger(BunduAccess.class);

    // Alles, was in super steht, auskommentiert. TODO: endgültig löschen, nachdem ich es etwas verstanden habe

    // protected DateRange referencePeriod;
    // protected DateRange[] analysisPeriods;
    //
    // protected double[] qs;

    public BunduAccess(final D4EArtifact artifact) {
        super(artifact);
    }

    public boolean isAutoSelect() {
        final String fixChoice = this.artifact.getDataAsString("fix_choice");
        if (fixChoice != null && fixChoice.equals("state.bundu.wst.fix.auto")) {
            return true;
        }
        return false;
    }

    public Integer getBezugsJahr() {
        return this.artifact.getDataAsInteger("singleyear");
    }

    public int[] getEventsTemp() {
        return getIntArray("events_temp");
    }

    public int getQSeriesLength() {
        return this.artifact.getDataAsInteger("year_input_q_series");
    }

    public int getStartYear() {
        return this.getBezugsJahr() - this.getQSeriesLength() + 1;
    }

    public Integer getUd() {
        if (getUd_Q_mode().equals("UD"))
            return getInteger("bundu.wst.ud_value");
        else
            return null;
    }

    @Override
    public double[] getQs() {
        if (getUd_Q_mode().equals("Q"))
            return super.getQs();
        else
            return null;
    }

    private String getUd_Q_mode() {
        return getString("bundu.wst.mode");
    }

    public Double getMissingVolFrom() {
        if (isCalculateMissingValue())
            return getDouble("ld_from_part");
        else
            return null;
    }

    public Double getMissingVolTo() {
        if (isCalculateMissingValue())
            return getDouble("ld_to_part");
        else
            return null;
    }

    private boolean isCalculateMissingValue() { // probably public
        return getBoolean("missing_volume");
    }

    // /** Access the reference date period, return null in case of 'errors'. */
    // public DateRange getReferencePeriod() {
    // if (this.referencePeriod == null) {
    // final StateData refStart = artifact.getData("ref_start");
    // final StateData refEnd = artifact.getData("ref_end");
    //
    // if (refStart == null || refEnd == null) {
    // log.warn("missing 'ref_start' or 'ref_start' value");
    // return null;
    // }
    //
    // try {
    // long rs = Long.parseLong((String) refStart.getValue());
    // long re = Long.parseLong((String) refEnd.getValue());
    //
    // if (rs > re) {
    // final long t = rs;
    // rs = re;
    // re = t;
    // }
    //
    // final Date from = new Date(rs);
    // final Date to = new Date(re);
    // this.referencePeriod = new DateRange(from, to);
    // }
    // catch (final NumberFormatException nfe) {
    // log.warn("ref_start or ref_end is not an integer.");
    // }
    // }
    //
    // return this.referencePeriod;
    // }

    // @Override
    // public DateRange[] getAnalysisPeriods() {
    // if (this.analysisPeriods == null) {
    // this.analysisPeriods = getDateRange("ana_data");
    // }
    //
    // return this.analysisPeriods;
    // }

    /**
     * @return DateRange object ranging from eldest to youngest date
     *         of analysis and reference periods.
     */
    // @Override
    // public DateRange getDateRange() {
    // final DateRange refP = getReferencePeriod();
    //
    // if (refP == null) {
    // return null;
    // }
    //
    // Date from = refP.getFrom();
    // Date to = refP.getTo();
    //
    // final DateRange[] rs = getAnalysisPeriods();
    // for (final DateRange r : rs) {
    // if (r.getFrom().before(from)) {
    // from = r.getFrom();
    // }
    // if (r.getTo().after(to)) {
    // to = r.getTo();
    // }
    // }
    //
    // return new DateRange(from, to);
    // }

    // @Override
    // public double[] getQs() {
    // if (this.qs == null) {
    // this.qs = getDoubleArray("qs");
    // }
    //
    // if (log.isDebugEnabled() && this.qs != null) {
    // log.debug("qs: " + Arrays.toString(this.qs));
    // }
    // return this.qs;
    // }
}
// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org