Mercurial > dive4elements > river
diff backend/src/main/java/org/dive4elements/river/importer/sinfo/importitem/DepthEvolutionKmLineImport.java @ 8971:50416a0df385
Importer for the Schifffahrt (S-INFO) and Oekologie (U-INFO) files
author | mschaefer |
---|---|
date | Tue, 03 Apr 2018 10:18:30 +0200 |
parents | |
children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/backend/src/main/java/org/dive4elements/river/importer/sinfo/importitem/DepthEvolutionKmLineImport.java Tue Apr 03 10:18:30 2018 +0200 @@ -0,0 +1,71 @@ +/* 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.DepthEvolution; +import org.dive4elements.river.model.sinfo.DepthEvolutionValue; +import org.hibernate.Query; +import org.hibernate.Session; + +/** + * Imported depth evolution values of a river station. + * + * @author Matthias Schäfer + * + */ +public class DepthEvolutionKmLineImport extends AbstractKmLineImport<DepthEvolution, DepthEvolutionValue> { + + /***** FIELDS *****/ + + private double total_change; + + private double change_per_year; + + + /***** CONSTRUCTOR *****/ + + public DepthEvolutionKmLineImport(final Double km, final double total_change, final double change_per_year) { + super(km.doubleValue()); + this.total_change = total_change; + this.change_per_year = change_per_year; + } + + /***** METHODS *****/ + + public void setTotal_change(final double total_change) { + this.total_change = total_change; + } + + public void setChange_per_year(final double change_per_year) { + this.change_per_year = change_per_year; + } + + @Override + protected DepthEvolutionValue queryValueItem(final Session session, final DepthEvolution parent) { + final Query query = session.createQuery("FROM DepthEvolutionValue WHERE (DepthEvolution=:parent) AND (station=:station)"); + query.setParameter("parent", parent); + query.setParameter("station", this.station); + final List rows = query.list(); + if (!rows.isEmpty()) + return (DepthEvolutionValue) rows.get(0); + else + return null; + } + + + @Override + protected DepthEvolutionValue createValueItem(final DepthEvolution parent) { + return new DepthEvolutionValue(parent, this.station, this.total_change, this.change_per_year); + } +}