Mercurial > dive4elements > river
comparison backend/src/main/java/org/dive4elements/river/importer/sinfo/importitem/ChannelKmLineImport.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.sinfo.importitem; | |
12 | |
13 import java.util.List; | |
14 | |
15 import org.dive4elements.river.importer.common.AbstractKmLineImport; | |
16 import org.dive4elements.river.model.sinfo.Channel; | |
17 import org.dive4elements.river.model.sinfo.ChannelValue; | |
18 import org.hibernate.Query; | |
19 import org.hibernate.Session; | |
20 | |
21 /** | |
22 * Imported channel size of a river station. | |
23 * | |
24 * @author Matthias Schäfer | |
25 * | |
26 */ | |
27 public class ChannelKmLineImport extends AbstractKmLineImport<Channel, ChannelValue> { | |
28 | |
29 /***** FIELDS *****/ | |
30 | |
31 private double width; | |
32 | |
33 private double depth; | |
34 | |
35 | |
36 /***** CONSTRUCTOR *****/ | |
37 | |
38 public ChannelKmLineImport(final Double km, final double width, final double depth) { | |
39 super(km.doubleValue()); | |
40 this.width = width; | |
41 this.depth = depth; | |
42 } | |
43 | |
44 /***** METHODS *****/ | |
45 | |
46 public void setWidth(final double width) { | |
47 this.width = width; | |
48 } | |
49 | |
50 public void setDepth(final double depth) { | |
51 this.depth = depth; | |
52 } | |
53 | |
54 @Override | |
55 protected ChannelValue queryValueItem(final Session session, final Channel parent) { | |
56 final Query query = session.createQuery("FROM ChannelValue WHERE (channel=:parent) AND (station=:station)"); | |
57 query.setParameter("parent", parent); | |
58 query.setParameter("station", this.station); | |
59 final List rows = query.list(); | |
60 if (!rows.isEmpty()) | |
61 return (ChannelValue) rows.get(0); | |
62 else | |
63 return null; | |
64 } | |
65 | |
66 | |
67 @Override | |
68 protected ChannelValue createValueItem(final Channel parent) { | |
69 return new ChannelValue(parent, this.station, this.width, this.depth); | |
70 } | |
71 } |