view gwt-client/src/test/java/test/bundu/BunduBezugswstRunner.java @ 9442:173f188569c6

little improvements
author gernotbelger
date Mon, 20 Aug 2018 18:20:15 +0200
parents ce0a48b93f4b
children 86e522bc7f36
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 test.bundu;

import java.io.IOException;
import java.util.List;

import org.dive4elements.artifacts.httpclient.exceptions.ConnectionException;
import org.dive4elements.river.client.shared.exceptions.ServerException;
import org.dive4elements.river.client.shared.model.Data;
import org.dive4elements.river.client.shared.model.DataItem;
import org.dive4elements.river.client.shared.model.DefaultDataItem;
import org.dive4elements.river.client.shared.model.IntDataItem;
import org.dive4elements.river.client.shared.model.IntegerArrayData;
import org.dive4elements.river.client.shared.model.StringOptionsData;

import test.AbstractBerechnungsartenTester.River;
import test.AbstractModuleRunner;
import test.IFilenameMapper;

/**
 * @author Domenico Nardi Tironi
 *
 */
class BunduBezugswstRunner extends AbstractModuleRunner {

    private final String fixationChoice;
    private final int bezugsjahr;
    private final int years_length;

    private final boolean fehlvolumina;
    private final String sounding;

    private final String calcChoice;
    private final double step;
    private final List<Segment> segments;
    private final String qSectorStart;
    private final String qSectorEnd;
    private final int[] events;
    private final String function;

    public BunduBezugswstRunner(final IFilenameMapper file, final double from, final double to, final double step, final River river, final int bezugsjahr,
            final String fixationChoice, final String function, final String abflussklasseFrom, final String abflussklasseTo, final int[] events,
            final int years_length, final List<Segment> segments, final String calcChoice, final boolean fehlvolumina, final String sounding)
            throws ConnectionException, ServerException {
        super(AbstractModuleRunner.Infotype.bundu, test.bundu.BunduBerechnungsartenTester.CalcMode.bundu_bezugswst, file, from, to, river);
        this.fixationChoice = fixationChoice;
        this.qSectorStart = abflussklasseFrom;
        this.qSectorEnd = abflussklasseTo;
        this.bezugsjahr = bezugsjahr;
        this.years_length = years_length;
        this.fehlvolumina = fehlvolumina;
        this.sounding = sounding;
        this.calcChoice = calcChoice;
        this.step = step;
        this.segments = segments;
        this.events = events;
        this.function = function;
    }

    @Override
    public void runTest(final boolean exportToFile) throws ServerException, IOException {
        /* Select River */
        super.selectRiver();

        /* Select ICalcMode */
        super.selectCalcMode();

        /* Select Range with step */
        final Data[] temp = super.makeFromToData("ld_from", "ld_to");
        final String stepStr = String.valueOf(this.step);
        final Data[] data = super.addItemToExistingData(temp,
                new StringOptionsData("ld_step", "ld_step", new DataItem[] { new DefaultDataItem(stepStr, stepStr, stepStr) }));

        super.feedAndGo(data, 0);

        /* bezugsjahr */
        final String bezugsjahr = String.valueOf(this.bezugsjahr);
        super.feedAndGoSimpleTextInput("singleyear", bezugsjahr);

        /* fixierungsauswahl - auto oder manuell */
        // AUTO: 0, 3
        final Data q1 = super.getSimpleTextInput("q1", this.qSectorStart);
        final Data q2 = super.getSimpleTextInput("q2", this.qSectorEnd);
        final Data fixChoice = super.getSimpleTextInput("fix_choice", this.fixationChoice);

        final IntDataItem[] arr = new IntDataItem[this.events.length];
        for (int i = 0; i < this.events.length; i++) {
            arr[i] = new IntDataItem("id", "id", this.events[i]);
        }
        final IntegerArrayData iad = new IntegerArrayData("events", "events", arr);

        super.feedAndGo(new Data[] { q1, q2, iad, fixChoice }, 0);

        // TODO: Automatische ereignisauswahl + Wahl der Abflussklassen im Hintergrund

        /* Länge der Abflusszeitreihe */
        super.feedAndGoSimpleTextInput("year_input_q_series", String.valueOf(this.years_length));

        /* (W)Q-Input / UD Input */

        final Data[] wqData = Segment.getDataforFeed("wq_values", this.segments);
        final Data[] wqAndMode = super.addItemToExistingData(wqData,
                new StringOptionsData("bundu.wst.mode", "bundu.wst.mode", new DataItem[] { new DefaultDataItem("Q", "Q", "Q") }));

        super.feedAndGo(wqAndMode, //
                0);// reachable state index

        /* calc_choice */
        final Data preprocessingData = super.getSimpleTextInput("preprocessing", "false");
        final Data functionData = super.getSimpleTextInput("function", this.function);
        final Data calcChoice = super.getSimpleTextInput("calc_choice", this.calcChoice);
        super.feedAndGoData(new Data[] { preprocessingData, functionData, calcChoice });

        // TODO: automaitische Wahl der Berechnungsgrundlagen + Ausreißer (preprocessing)

        /* missing_volume */
        super.feedAndGoSimpleTextInput("missing_volume", String.valueOf(this.fehlvolumina));

        // TODO: Strecke der FehlVolumina machen

        /* Wahl der Peilungen */

        super.feedAndGoSimpleTextInput("soundings", this.sounding);

        describeCollection();

        super.export(exportToFile);
    }

}

http://dive4elements.wald.intevation.org