view backend/src/main/java/org/dive4elements/river/importer/sinfo/importitem/TkhKmLineImport.java @ 9657:a79881a892c9

Importer (s/u-info) extensions: depth-evolution: corrected directory name Bezug_aktueller_GlW, detecting and logging of wrong units, then cancelling, various checks of the plausibility of the meta data year values and cancelling in case of errors, detecting and logging missing change values, skipping those lines
author mschaefer
date Mon, 23 Mar 2020 15:26:50 +0100
parents 1f57381b3bb5
children
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.importer.sinfo.importitem;

import java.util.List;

import org.dive4elements.river.importer.common.AbstractKmLineImport;
import org.dive4elements.river.model.sinfo.TkhColumn;
import org.dive4elements.river.model.sinfo.TkhValue;
import org.hibernate.Query;
import org.hibernate.Session;

/**
 * Imported Transportkörperhöhe value of a river station.
 *
 * @author Matthias Schäfer
 *
 */
public class TkhKmLineImport extends AbstractKmLineImport<TkhColumn, TkhValue> {

    /***** FIELDS *****/

    /**
     * TKH in m
     */
    private final double tkheight;


    /***** CONSTRUCTOR *****/

    public TkhKmLineImport(final Double km, final double tkheight) {
        super(km.doubleValue());
        this.tkheight = tkheight;
    }


    /***** METHODS *****/

    @Override
    protected TkhValue queryValueItem(final Session session, final TkhColumn parent) {
        final Query query = session.createQuery("FROM TkhValue WHERE (tkhColumn=:parent)"
                + " AND (station BETWEEN (:station-0.0001) AND (:station+0.0001))");
        query.setParameter("parent", parent);
        query.setParameter("station", this.station);
        final List rows = query.list();
        if (!rows.isEmpty())
            return (TkhValue) rows.get(0);
        else
            return null;
    }


    @Override
    protected TkhValue createValueItem(final TkhColumn parent) {
        return new TkhValue(parent, this.station, this.tkheight);
    }
}

http://dive4elements.wald.intevation.org