Mercurial > dive4elements > river
comparison backend/src/main/java/org/dive4elements/river/importer/sinfo/importitem/BedMobilityKmLineImport.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.BedMobility; | |
17 import org.dive4elements.river.model.sinfo.BedMobilityValue; | |
18 import org.hibernate.Query; | |
19 import org.hibernate.Session; | |
20 | |
21 /** | |
22 * Imported bed mobility value of a river station. | |
23 * | |
24 * @author Matthias Schäfer | |
25 * | |
26 */ | |
27 public class BedMobilityKmLineImport extends AbstractKmLineImport<BedMobility, BedMobilityValue> { | |
28 | |
29 /***** FIELDS *****/ | |
30 | |
31 private boolean bedMoving; | |
32 | |
33 | |
34 /***** CONSTRUCTOR *****/ | |
35 | |
36 public BedMobilityKmLineImport(final Double km, final boolean bedMoving) { | |
37 super(km.doubleValue()); | |
38 this.bedMoving = bedMoving; | |
39 } | |
40 | |
41 /***** METHODS *****/ | |
42 | |
43 public void setBedMoving(final boolean bedMoving) { | |
44 this.bedMoving = bedMoving; | |
45 } | |
46 | |
47 @Override | |
48 protected BedMobilityValue queryValueItem(final Session session, final BedMobility parent) { | |
49 final Query query = session.createQuery("FROM BedMobilityValue WHERE (bedMobility=:parent) AND (station=:station)"); | |
50 query.setParameter("parent", parent); | |
51 query.setParameter("station", this.station); | |
52 final List rows = query.list(); | |
53 if (!rows.isEmpty()) | |
54 return (BedMobilityValue) rows.get(0); | |
55 else | |
56 return null; | |
57 } | |
58 | |
59 | |
60 @Override | |
61 protected BedMobilityValue createValueItem(final BedMobility parent) { | |
62 return new BedMobilityValue(parent, this.station, this.bedMoving); | |
63 } | |
64 } |