Mercurial > dive4elements > river
view backend/src/main/java/org/dive4elements/river/importer/sinfo/importitem/ChannelKmLineImport.java @ 8977:bf8a9df86f32
Two fixes for the tkh and selected additionals import
author | mschaefer |
---|---|
date | Tue, 03 Apr 2018 17:23:51 +0200 |
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.sinfo.importitem; import java.util.List; import org.dive4elements.river.importer.common.AbstractKmLineImport; import org.dive4elements.river.model.sinfo.Channel; import org.dive4elements.river.model.sinfo.ChannelValue; import org.hibernate.Query; import org.hibernate.Session; /** * Imported channel size of a river station. * * @author Matthias Schäfer * */ public class ChannelKmLineImport extends AbstractKmLineImport<Channel, ChannelValue> { /***** FIELDS *****/ private double width; private double depth; /***** CONSTRUCTOR *****/ public ChannelKmLineImport(final Double km, final double width, final double depth) { super(km.doubleValue()); this.width = width; this.depth = depth; } /***** METHODS *****/ public void setWidth(final double width) { this.width = width; } public void setDepth(final double depth) { this.depth = depth; } @Override protected ChannelValue queryValueItem(final Session session, final Channel parent) { final Query query = session.createQuery("FROM ChannelValue WHERE (channel=:parent) AND (station=:station)"); query.setParameter("parent", parent); query.setParameter("station", this.station); final List rows = query.list(); if (!rows.isEmpty()) return (ChannelValue) rows.get(0); else return null; } @Override protected ChannelValue createValueItem(final Channel parent) { return new ChannelValue(parent, this.station, this.width, this.depth); } }