Mercurial > dive4elements > river
comparison backend/src/main/java/org/dive4elements/river/importer/ImportFlowVelocityMeasurementValue.java @ 5838:5aa05a7a34b7
Rename modules to more fitting names.
author | Sascha L. Teichmann <teichmann@intevation.de> |
---|---|
date | Thu, 25 Apr 2013 15:23:37 +0200 |
parents | flys-backend/src/main/java/org/dive4elements/river/importer/ImportFlowVelocityMeasurementValue.java@18619c1e7c2a |
children | 4dd33b86dc61 |
comparison
equal
deleted
inserted
replaced
5837:d9901a08d0a6 | 5838:5aa05a7a34b7 |
---|---|
1 package org.dive4elements.river.importer; | |
2 | |
3 import java.math.BigDecimal; | |
4 | |
5 import java.util.Date; | |
6 import java.util.List; | |
7 | |
8 import org.apache.log4j.Logger; | |
9 | |
10 import org.hibernate.Session; | |
11 import org.hibernate.Query; | |
12 | |
13 import org.dive4elements.river.model.FlowVelocityMeasurement; | |
14 import org.dive4elements.river.model.FlowVelocityMeasurementValue; | |
15 | |
16 | |
17 public class ImportFlowVelocityMeasurementValue { | |
18 | |
19 private static final Logger log = | |
20 Logger.getLogger(ImportFlowVelocityMeasurementValue.class); | |
21 | |
22 | |
23 private Date datetime; | |
24 | |
25 private String description; | |
26 | |
27 private BigDecimal station; | |
28 private BigDecimal w; | |
29 private BigDecimal q; | |
30 private BigDecimal v; | |
31 | |
32 private FlowVelocityMeasurementValue peer; | |
33 | |
34 | |
35 public ImportFlowVelocityMeasurementValue( | |
36 Date datetime, | |
37 BigDecimal station, | |
38 BigDecimal w, | |
39 BigDecimal q, | |
40 BigDecimal v, | |
41 String description | |
42 ) { | |
43 this.datetime = datetime; | |
44 this.station = station; | |
45 this.w = w; | |
46 this.q = q; | |
47 this.v = v; | |
48 this.description = description; | |
49 } | |
50 | |
51 | |
52 | |
53 public void storeDependencies(FlowVelocityMeasurement measurement) { | |
54 log.debug("store dependencies"); | |
55 | |
56 getPeer(measurement); | |
57 } | |
58 | |
59 | |
60 public FlowVelocityMeasurementValue getPeer(FlowVelocityMeasurement m) { | |
61 if (peer == null) { | |
62 Session session = ImporterSession.getInstance().getDatabaseSession(); | |
63 | |
64 Query query = session.createQuery( | |
65 "from FlowVelocityMeasurementValue where " + | |
66 " measurement=:measurement and " + | |
67 " station=:station and " + | |
68 " datetime=:datetime" | |
69 ); | |
70 | |
71 query.setParameter("measurement", m); | |
72 query.setParameter("station", station); | |
73 query.setParameter("datetime", datetime); | |
74 | |
75 List<FlowVelocityMeasurementValue> values = query.list(); | |
76 | |
77 if (values.isEmpty()) { | |
78 peer = new FlowVelocityMeasurementValue( | |
79 m, | |
80 datetime, | |
81 station, | |
82 w, | |
83 q, | |
84 v, | |
85 description); | |
86 | |
87 session.save(peer); | |
88 } | |
89 else { | |
90 peer = values.get(0); | |
91 } | |
92 } | |
93 | |
94 return peer; | |
95 } | |
96 } | |
97 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |