Mercurial > dive4elements > river
comparison backend/src/main/java/org/dive4elements/river/importer/ImportSQRelationValue.java @ 8412:17db08570637
SCHEMA CHANGE: removed superfluous columns station and river_id from measurement_stations and adapted other components accordingly.
author | Tom Gottfried <tom@intevation.de> |
---|---|
date | Wed, 15 Oct 2014 19:20:26 +0200 |
parents | 4c3ccf2b0304 |
children | bfca77cbf353 |
comparison
equal
deleted
inserted
replaced
8411:b8c6cb36607e | 8412:17db08570637 |
---|---|
29 | 29 |
30 | 30 |
31 private SQRelationValue peer; | 31 private SQRelationValue peer; |
32 | 32 |
33 private String parameter; | 33 private String parameter; |
34 | 34 private MeasurementStation station; |
35 private Double km; | |
36 private Double a; | 35 private Double a; |
37 private Double b; | 36 private Double b; |
38 private Double qMax; | 37 private Double qMax; |
39 private Double rSQ; | 38 private Double rSQ; |
40 private Integer nTot; | 39 private Integer nTot; |
43 private Double cDuan; | 42 private Double cDuan; |
44 | 43 |
45 | 44 |
46 public ImportSQRelationValue( | 45 public ImportSQRelationValue( |
47 String parameter, | 46 String parameter, |
48 Double km, | 47 MeasurementStation station, |
49 Double a, | 48 Double a, |
50 Double b, | 49 Double b, |
51 Double qMax, | 50 Double qMax, |
52 Double rSQ, | 51 Double rSQ, |
53 Integer nTot, | 52 Integer nTot, |
54 Integer nOutlier, | 53 Integer nOutlier, |
55 Double cFerguson, | 54 Double cFerguson, |
56 Double cDuan | 55 Double cDuan |
57 ) { | 56 ) { |
58 this.parameter = parameter; | 57 this.parameter = parameter; |
59 this.km = km; | 58 this.station = station; |
60 this.a = a; | 59 this.a = a; |
61 this.b = b; | 60 this.b = b; |
62 this.qMax = qMax; | 61 this.qMax = qMax; |
63 this.rSQ = rSQ; | 62 this.rSQ = rSQ; |
64 this.nTot = nTot; | 63 this.nTot = nTot; |
76 | 75 |
77 | 76 |
78 public SQRelationValue getPeer(SQRelation owner) { | 77 public SQRelationValue getPeer(SQRelation owner) { |
79 if (peer == null) { | 78 if (peer == null) { |
80 Session session = ImporterSession.getInstance().getDatabaseSession(); | 79 Session session = ImporterSession.getInstance().getDatabaseSession(); |
81 | |
82 Query query = session.createQuery( | |
83 "from MeasurementStation " + | |
84 " where station between :kml and :kmh"); | |
85 query.setDouble("kml", km - 1e-4); | |
86 query.setDouble("kmh", km + 1e-4); | |
87 | |
88 List<MeasurementStation> result = query.list(); | |
89 | |
90 if (result.isEmpty()) { | |
91 log.error("No measurement stations found at km " + km); | |
92 return null; | |
93 } | |
94 | |
95 Query query2 = session.createQuery( | 80 Query query2 = session.createQuery( |
96 "from SQRelationValue " + | 81 "from SQRelationValue " + |
97 " where sqRelation=:owner " + | 82 " where sqRelation=:owner " + |
98 " and parameter=:parameter" + | 83 " and parameter=:parameter" + |
99 " and measurementStation=:measurementStation" + | 84 " and measurementStation=:measurementStation" + |
104 " and cFerguson=:cFerguson" + | 89 " and cFerguson=:cFerguson" + |
105 " and cDuan=:cDuan"); | 90 " and cDuan=:cDuan"); |
106 | 91 |
107 query2.setParameter("owner", owner); | 92 query2.setParameter("owner", owner); |
108 query2.setString("parameter", parameter); | 93 query2.setString("parameter", parameter); |
109 query2.setParameter("measurementStation", result.get(0)); | 94 query2.setParameter("measurementStation", station); |
110 query2.setBigDecimal("a", toBigDecimal(a)); | 95 query2.setBigDecimal("a", toBigDecimal(a)); |
111 query2.setBigDecimal("b", toBigDecimal(b)); | 96 query2.setBigDecimal("b", toBigDecimal(b)); |
112 query2.setBigDecimal("qMax", toBigDecimal(qMax)); | 97 query2.setBigDecimal("qMax", toBigDecimal(qMax)); |
113 query2.setBigDecimal("rSQ", toBigDecimal(rSQ)); | 98 query2.setBigDecimal("rSQ", toBigDecimal(rSQ)); |
114 query2.setBigDecimal("cFerguson", toBigDecimal(cFerguson)); | 99 query2.setBigDecimal("cFerguson", toBigDecimal(cFerguson)); |
118 | 103 |
119 if (values.isEmpty()) { | 104 if (values.isEmpty()) { |
120 peer = new SQRelationValue( | 105 peer = new SQRelationValue( |
121 owner, | 106 owner, |
122 parameter, | 107 parameter, |
123 result.get(0), | 108 station, |
124 a, | 109 a, |
125 b, | 110 b, |
126 qMax, | 111 qMax, |
127 rSQ, | 112 rSQ, |
128 nTot, | 113 nTot, |