comparison backend/src/main/java/org/dive4elements/river/importer/uinfo/importitem/SalixKmLineImport.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
comparison
equal deleted inserted replaced
8970:da5dc7446652 8971:50416a0df385
1 /* Copyright (C) 2017 by Bundesanstalt für Gewässerkunde
2 * Software engineering by
3 * Björnsen Beratende Ingenieure GmbH
4 * Dr. Schumacher Ingenieurbüro für Wasser und Umwelt
5 *
6 * This file is Free Software under the GNU AGPL (>=v3)
7 * and comes with ABSOLUTELY NO WARRANTY! Check out the
8 * documentation coming with Dive4Elements River for details.
9 */
10
11 package org.dive4elements.river.importer.uinfo.importitem;
12
13 import java.util.List;
14
15 import org.dive4elements.river.importer.common.AbstractKmLineImport;
16 import org.dive4elements.river.model.uinfo.Salix;
17 import org.dive4elements.river.model.uinfo.SalixValue;
18 import org.hibernate.Query;
19 import org.hibernate.Session;
20
21 /**
22 * Imported salix values of a river station.
23 *
24 * @author Matthias Schäfer
25 *
26 */
27 public class SalixKmLineImport extends AbstractKmLineImport<Salix, SalixValue> {
28
29 /***** FIELDS *****/
30
31 private final double factor;
32
33 private final double mnw_mw_diff;
34
35
36 /***** CONSTRUCTOR *****/
37
38 public SalixKmLineImport(final Double km, final double factor, final double mnw_mw_diff) {
39 super(km.doubleValue());
40 this.factor = factor;
41 this.mnw_mw_diff = mnw_mw_diff;
42 }
43
44
45 /***** METHODS *****/
46
47 @Override
48 public SalixValue queryValueItem(final Session session, final Salix parent) {
49 final Query query = session.createQuery("FROM SalixValue WHERE (salix=:parent)"
50 + " AND (station BETWEEN (:station-0.0001) AND (:station+0.0001))");
51 query.setParameter("parent", parent);
52 query.setParameter("station", this.station);
53 final List rows = query.list();
54 if (!rows.isEmpty())
55 return (SalixValue) rows.get(0);
56 else
57 return null;
58 }
59
60
61 @Override
62 public SalixValue createValueItem(final Salix parent) {
63 return new SalixValue(parent, this.station, this.factor, this.mnw_mw_diff);
64 }
65 }

http://dive4elements.wald.intevation.org