view artifacts/src/main/java/org/dive4elements/river/artifacts/uinfo/salix/SalixLineAccess.java @ 9246:c08d5cfa4981

some hibernate queries on bedheigts for salix
author gernotbelger
date Thu, 12 Jul 2018 11:15:42 +0200
parents da0bdbcd6f09
children 9a9f076d5716
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.salix;

import org.dive4elements.river.artifacts.access.RangeAccess;
import org.dive4elements.river.artifacts.uinfo.UINFOArtifact;
import org.dive4elements.river.artifacts.uinfo.UinfoCalcMode;

/**
 * Access to the flow depth calculation type specific SInfo artifact data.
 * REMARK: this class is NOT intended to be hold in the results (or anywhere else), in order to avoid a permanent
 * reference to the artifact instance.
 * Hence we do NOT cache any data.
 *
 * @author Gernot Belger
 */
final class SalixLineAccess extends RangeAccess {

    static final String FIELD_DIFFID_CURRENT = "diffid_current";
    static final String FIELD_DIFFID_HIST = "diffid_historical";
    // calculation_mode
    // ld_from , ld_to
    // use_scenario (boolean)
    // ld_from_part; ld_to_part
    // scenario_selection (mögliche Werte:"scenarioType.option1" "scenarioType.option2" "scenarioType.option3"

    public SalixLineAccess(final UINFOArtifact artifact) {
        super(artifact);

        /* assert calculation mode */
        final UinfoCalcMode calculationMode = artifact.getCalculationMode();
        assert (calculationMode == UinfoCalcMode.uinfo_salix_line);
    }

    public boolean getUseScenario() {
        return super.getBoolean("use_scenario");
    }

    public String getScenario() {
        if (getUseScenario()) {
            return getString("scenario_selection");
        }
        return null;
    }

    public Double getFromPart() {
        return getDouble("ld_from_part");
    }

    public Double getToPart() {
        return getDouble("ld_to_part");
    }

    public int[] getRegionalScenarioIntegers() {
        // super.getIntArray("sedimentheight"); DOES NOT WORK!
        final String ints = super.getString("sedimentheight");
        if (ints != null) {
            final String[] intsSplit = ints.split(" ");
            final int[] values = new int[intsSplit.length];
            for (int i = 0; i < intsSplit.length; i++) {
                values[i] = Integer.valueOf(intsSplit[i]);
            }
            return values;
        }
        return null;
    }

    public String getSupraRegionalString() {
        return super.getString("supraregional_table");
    }

    public Integer getYear() {
        if (getString("ye_select").equals("state.uinfo.year")) {
            return super.getInteger("singleyear");
        }
        return null;
    }

    public Integer getEpoch() {
        if (getString("ye_select").equals("state.uinfo.epoch")) {
            return super.getInteger("singleepoch");
        }
        return null;
    }
}

http://dive4elements.wald.intevation.org