view backend/src/main/java/org/dive4elements/river/importer/sinfo/importitem/ChannelSeriesImport.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 3b3c7513472e
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.apache.log4j.Logger;
import org.dive4elements.river.importer.common.AbstractSeriesImport;
import org.dive4elements.river.model.River;
import org.dive4elements.river.model.sinfo.Channel;
import org.dive4elements.river.model.sinfo.ChannelValue;
import org.hibernate.Query;
import org.hibernate.Session;

/**
 * Imported channel data series of a river
 *
 * @author Matthias Schäfer
 *
 */
public class ChannelSeriesImport extends AbstractSeriesImport<Channel, ChannelValue, ChannelKmLineImport> {

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

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

    private Integer year_from;

    private Integer year_to;


    /***** CONSTRUCTORS *****/

    public ChannelSeriesImport(final String filename) {
        super(filename);
    }


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

    public void setYear_from(final Integer year_from) {
        this.year_from = year_from;
    }

    public void setYear_to(final Integer year_to) {
        this.year_to = year_to;
    }

    @Override
    public Logger getLog() {
        return log;
    }

    @Override
    public List<Channel> querySeriesItem(final Session session, final River river, final boolean doQueryParent) {
        final Query query = session.createQuery("FROM Channel WHERE river=:river AND (lower(filename)=:filename"
                + " OR (:newfrom BETWEEN year_from AND year_to) OR (:newto BETWEEN year_from AND year_to))");
        query.setParameter("river", river);
        query.setParameter("filename", this.filename.toLowerCase());
        query.setParameter("newfrom", this.year_from);
        query.setParameter("newto", this.year_to);
        return query.list();
    }

    @Override
    public Channel createSeriesItem(final River river) {
        return new Channel(river, this.filename, this.kmrange_info, this.notes, this.year_from, this.year_to);
    }
}

http://dive4elements.wald.intevation.org