Mercurial > dive4elements > river
view backend/src/main/java/org/dive4elements/river/importer/uinfo/importitem/SalixKmLineImport.java @ 9661:9b8ba3b83a15
Importer (s/u-info) vegetation zones: new database column in vegetation_type table for german type name,
localized vegetation type names by querying the database instead of translating by resource property,
detecting and cancelling the import of a second vegetation zone file for a river,
detecting, logging, cancelling in case of wrong column titles,
detecting, logging and ignoring lines with missing (color) values,
comparing vegetation zone name and class with the database and logging+ignoring in case of inconsistencies,
starting the most elevated zone with 0 instead of -1 overflow days
author | mschaefer |
---|---|
date | Mon, 23 Mar 2020 16:38:12 +0100 |
parents | 50416a0df385 |
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.uinfo.importitem; import java.util.List; import org.dive4elements.river.importer.common.AbstractKmLineImport; import org.dive4elements.river.model.uinfo.Salix; import org.dive4elements.river.model.uinfo.SalixValue; import org.hibernate.Query; import org.hibernate.Session; /** * Imported salix values of a river station. * * @author Matthias Schäfer * */ public class SalixKmLineImport extends AbstractKmLineImport<Salix, SalixValue> { /***** FIELDS *****/ private final double factor; private final double mnw_mw_diff; /***** CONSTRUCTOR *****/ public SalixKmLineImport(final Double km, final double factor, final double mnw_mw_diff) { super(km.doubleValue()); this.factor = factor; this.mnw_mw_diff = mnw_mw_diff; } /***** METHODS *****/ @Override public SalixValue queryValueItem(final Session session, final Salix parent) { final Query query = session.createQuery("FROM SalixValue WHERE (salix=: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 (SalixValue) rows.get(0); else return null; } @Override public SalixValue createValueItem(final Salix parent) { return new SalixValue(parent, this.station, this.factor, this.mnw_mw_diff); } }