Mercurial > dive4elements > river
comparison backend/src/main/java/org/dive4elements/river/importer/sinfo/importitem/InfrastructureKmLineImport.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 | 75bd347147ad |
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.ImportAttribute; | |
16 import org.dive4elements.river.importer.common.AbstractKmLineImport; | |
17 import org.dive4elements.river.model.sinfo.Infrastructure; | |
18 import org.dive4elements.river.model.sinfo.InfrastructureValue; | |
19 import org.hibernate.Query; | |
20 import org.hibernate.Session; | |
21 | |
22 /** | |
23 * Imported infrastructure of a river station. | |
24 * | |
25 * @author Matthias Schäfer | |
26 * | |
27 */ | |
28 public class InfrastructureKmLineImport extends AbstractKmLineImport<Infrastructure, InfrastructureValue> { | |
29 | |
30 /***** FIELDS *****/ | |
31 | |
32 private double height; | |
33 | |
34 private final ImportAttribute bankAttribute; | |
35 | |
36 | |
37 /***** CONSTRUCTOR *****/ | |
38 | |
39 public InfrastructureKmLineImport(final Double km, final double height, final ImportAttribute bankAttribute) { | |
40 super(km.doubleValue()); | |
41 this.height = height; | |
42 this.bankAttribute = bankAttribute; | |
43 } | |
44 | |
45 | |
46 /***** METHODS *****/ | |
47 | |
48 public void setHeight(final double height) { | |
49 this.height = height; | |
50 } | |
51 | |
52 @Override | |
53 protected InfrastructureValue queryValueItem(final Session session, final Infrastructure parent) { | |
54 final Query query = session.createQuery("FROM InfrastructureValue WHERE (infrastructure=:parent) AND (attribute=:bank)" | |
55 + " AND (station BETWEEN (:station-0.0001) AND (:station+0.0001))"); | |
56 query.setParameter("parent", parent); | |
57 query.setParameter("station", this.station); | |
58 query.setParameter("bank", this.bankAttribute.getPeer()); | |
59 final List rows = query.list(); | |
60 if (!rows.isEmpty()) | |
61 return (InfrastructureValue) rows.get(0); | |
62 else | |
63 return null; | |
64 } | |
65 | |
66 | |
67 @Override | |
68 protected InfrastructureValue createValueItem(final Infrastructure parent) { | |
69 return new InfrastructureValue(parent, this.station, this.bankAttribute.getPeer(), this.height); | |
70 } | |
71 } | |
72 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |