comparison backend/src/main/java/org/dive4elements/river/importer/sinfo/importitem/FlowDepthKmLineImport.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 31549fdfaf4f
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.sinfo.importitem;
12
13 import java.util.List;
14
15 import org.dive4elements.river.importer.common.AbstractKmLineImport;
16 import org.dive4elements.river.model.sinfo.FlowDepthColumn;
17 import org.dive4elements.river.model.sinfo.FlowDepthValue;
18 import org.hibernate.Query;
19 import org.hibernate.Session;
20
21 /**
22 * Imported flow depth value of a river station.
23 *
24 * @author Matthias Schäfer
25 *
26 */
27 public class FlowDepthKmLineImport extends AbstractKmLineImport<FlowDepthColumn, FlowDepthValue> {
28
29 /***** FIELDS *****/
30
31 /**
32 * Flow depth in m
33 */
34 private final double depth;
35
36
37 /***** CONSTRUCTOR *****/
38
39 public FlowDepthKmLineImport(final Double km, final double depth) {
40 super(km.doubleValue());
41 this.depth = depth;
42 }
43
44
45 /***** METHODS *****/
46
47 @Override
48 protected FlowDepthValue queryValueItem(final Session session, final FlowDepthColumn parent) {
49 final Query query = session.createQuery("FROM FlowDepthValue WHERE (FlowDepthColumn=: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 (FlowDepthValue) rows.get(0);
56 else
57 return null;
58 }
59
60
61 @Override
62 protected FlowDepthValue createValueItem(final FlowDepthColumn parent) {
63 return new FlowDepthValue(parent, this.station, this.depth);
64 }
65 }

http://dive4elements.wald.intevation.org