Mercurial > dive4elements > river
comparison backend/src/main/java/org/dive4elements/river/importer/ImportFlowVelocityModelValue.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/ImportFlowVelocityModelValue.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.List; | |
6 | |
7 import org.hibernate.Session; | |
8 import org.hibernate.Query; | |
9 | |
10 import org.dive4elements.river.model.FlowVelocityModel; | |
11 import org.dive4elements.river.model.FlowVelocityModelValue; | |
12 | |
13 | |
14 public class ImportFlowVelocityModelValue { | |
15 | |
16 private BigDecimal station; | |
17 private BigDecimal q; | |
18 private BigDecimal totalChannel; | |
19 private BigDecimal mainChannel; | |
20 private BigDecimal shearStress; | |
21 | |
22 private FlowVelocityModelValue peer; | |
23 | |
24 | |
25 public ImportFlowVelocityModelValue( | |
26 BigDecimal station, | |
27 BigDecimal q, | |
28 BigDecimal totalChannel, | |
29 BigDecimal mainChannel, | |
30 BigDecimal shearStress | |
31 ) { | |
32 this.station = station; | |
33 this.q = q; | |
34 this.totalChannel = totalChannel; | |
35 this.mainChannel = mainChannel; | |
36 this.shearStress = shearStress; | |
37 } | |
38 | |
39 | |
40 public void storeDependencies(FlowVelocityModel model) { | |
41 getPeer(model); | |
42 } | |
43 | |
44 | |
45 public FlowVelocityModelValue getPeer(FlowVelocityModel model) { | |
46 if (peer == null) { | |
47 Session session = ImporterSession.getInstance().getDatabaseSession(); | |
48 | |
49 Query query = session.createQuery( | |
50 "from FlowVelocityModelValue where " + | |
51 " flowVelocity=:model and " + | |
52 " station between :station - 0.00001 and :station + 0.00001" | |
53 ); | |
54 | |
55 query.setParameter("model", model); | |
56 query.setParameter("station", station.doubleValue()); | |
57 | |
58 List<FlowVelocityModelValue> values = query.list(); | |
59 | |
60 if (values.isEmpty()) { | |
61 peer = new FlowVelocityModelValue( | |
62 model, station, q, totalChannel, mainChannel, shearStress); | |
63 | |
64 session.save(peer); | |
65 } | |
66 else { | |
67 peer = values.get(0); | |
68 } | |
69 } | |
70 | |
71 return peer; | |
72 } | |
73 } | |
74 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |