Mercurial > dive4elements > river
comparison flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/minfo/BedHeightFactory.java @ 3886:633fbb61a0cc
Split bed heights into bed height epochs and single bed heights.
flys-artifacts/trunk@5536 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Raimund Renkert <raimund.renkert@intevation.de> |
---|---|
date | Thu, 20 Sep 2012 09:31:18 +0000 |
parents | 68beaa827751 |
children | bce2dd4310a6 |
comparison
equal
deleted
inserted
replaced
3885:393c10b07a76 | 3886:633fbb61a0cc |
---|---|
1 package de.intevation.flys.artifacts.model.minfo; | 1 package de.intevation.flys.artifacts.model.minfo; |
2 | 2 |
3 | 3 |
4 import java.util.Date; | |
4 import java.util.List; | 5 import java.util.List; |
5 | 6 |
6 import net.sf.ehcache.Cache; | 7 import net.sf.ehcache.Cache; |
7 import net.sf.ehcache.Element; | 8 import net.sf.ehcache.Element; |
8 | 9 |
19 /** Private logger to use here. */ | 20 /** Private logger to use here. */ |
20 private static Logger log = Logger.getLogger(BedHeightFactory.class); | 21 private static Logger log = Logger.getLogger(BedHeightFactory.class); |
21 | 22 |
22 /** Query to get km and ws for wst_id and column_pos. */ | 23 /** Query to get km and ws for wst_id and column_pos. */ |
23 public static final String SQL_SELECT_SINGLE = | 24 public static final String SQL_SELECT_SINGLE = |
24 "SELECT height, station, data_gap FROM bed_height_single_values " + | 25 "SELECT height, station, data_gap, sounding_width, year " + |
25 "WHERE id = :height_id"; | 26 " FROM bed_height_single_values " + |
27 " WHERE id = :height_id"; | |
26 | 28 |
27 /** Query to get name for wst_id and column_pos. */ | 29 /** Query to get name for wst_id and column_pos. */ |
28 public static final String SQL_SELECT_EPOCH = | 30 public static final String SQL_SELECT_EPOCH = |
29 "SELECT height, station FROM bed_height_epoch_values "+ | 31 "SELECT b.height, b.station, ti.start_time, ti.stop_time" + |
30 "WHERE id = :height_id"; | 32 " FROM bed_height_epoch_values b" + |
33 " JOIN time_interval ti ON b.time_interval_id = ti.id" + | |
34 " WHERE id = :height_id"; | |
31 | 35 |
32 /** Query to get name (description) for wst_id. */ | 36 /** Query to get name (description) for wst_id. */ |
33 public static final String SQL_SELECT_DESCR_SINGLE = | 37 public static final String SQL_SELECT_DESCR_SINGLE = |
34 "SELECT description FROM bed_height_single "+ | 38 "SELECT description FROM bed_height_single "+ |
35 "WHERE id = :height_id"; | 39 "WHERE id = :height_id"; |
118 { | 122 { |
119 if (log.isDebugEnabled()) { | 123 if (log.isDebugEnabled()) { |
120 log.debug("BedHeightFactory.getBedHeightUncached"); | 124 log.debug("BedHeightFactory.getBedHeightUncached"); |
121 } | 125 } |
122 | 126 |
123 BedHeight height = new BedHeight(getHeightName(type, height_id)); | |
124 | |
125 Session session = SessionHolder.HOLDER.get(); | 127 Session session = SessionHolder.HOLDER.get(); |
126 SQLQuery sqlQuery = null; | 128 SQLQuery sqlQuery = null; |
127 if (type.equals("single")) { | 129 if (type.equals("single")) { |
130 BedHeightSingle height = | |
131 new BedHeightSingle(getHeightName(type, height_id)); | |
128 sqlQuery = session.createSQLQuery(SQL_SELECT_SINGLE) | 132 sqlQuery = session.createSQLQuery(SQL_SELECT_SINGLE) |
129 .addScalar("height", StandardBasicTypes.DOUBLE) | 133 .addScalar("height", StandardBasicTypes.DOUBLE) |
130 .addScalar("station", StandardBasicTypes.DOUBLE) | 134 .addScalar("station", StandardBasicTypes.DOUBLE) |
131 .addScalar("data_gap", StandardBasicTypes.DOUBLE); | 135 .addScalar("data_gap", StandardBasicTypes.DOUBLE) |
136 .addScalar("sounding_width", StandardBasicTypes.DOUBLE) | |
137 .addScalar("year", StandardBasicTypes.INTEGER); | |
132 sqlQuery.setInteger("height_id", height_id); | 138 sqlQuery.setInteger("height_id", height_id); |
133 List<Object []> results = sqlQuery.list(); | 139 List<Object []> results = sqlQuery.list(); |
134 | 140 |
135 for (int i = 0; i <= results.size(); i++) { | 141 for (int i = 0; i <= results.size(); i++) { |
136 Object[] row = results.get(i); | 142 Object[] row = results.get(i); |
137 height.add((Double) row[0], (Double) row[1], (Double) row[2]); | 143 height.add( |
144 (Double) row[0], | |
145 (Double) row[1], | |
146 (Double) row[2], | |
147 (Double) row[3], | |
148 (Integer) row[4]); | |
138 } | 149 } |
150 return height; | |
139 } | 151 } |
140 else if (type.equals("epoch")) { | 152 else if (type.equals("epoch")) { |
153 BedHeightEpoch height = | |
154 new BedHeightEpoch(getHeightName(type, height_id)); | |
141 sqlQuery = session.createSQLQuery(SQL_SELECT_EPOCH) | 155 sqlQuery = session.createSQLQuery(SQL_SELECT_EPOCH) |
142 .addScalar("height", StandardBasicTypes.DOUBLE) | 156 .addScalar("height", StandardBasicTypes.DOUBLE) |
143 .addScalar("station", StandardBasicTypes.DOUBLE); | 157 .addScalar("station", StandardBasicTypes.DOUBLE) |
158 .addScalar("start_time", StandardBasicTypes.DATE) | |
159 .addScalar("stop_time", StandardBasicTypes.DATE); | |
144 sqlQuery.setInteger("height_id", height_id); | 160 sqlQuery.setInteger("height_id", height_id); |
145 List<Object []> results = sqlQuery.list(); | 161 List<Object []> results = sqlQuery.list(); |
146 | 162 |
147 for (int i = 0; i <= results.size(); i++) { | 163 for (int i = 0; i <= results.size(); i++) { |
148 Object[] row = results.get(i); | 164 Object[] row = results.get(i); |
149 height.add((Double) row[0], (Double) row[1], 0); | 165 height.add( |
166 (Double) row[0], | |
167 (Double) row[1], | |
168 0, | |
169 0, | |
170 (Date) row[2], | |
171 (Date)row[3]); | |
150 } | 172 } |
173 return height; | |
151 } | 174 } |
152 | 175 return new BedHeight(); |
153 return height; | |
154 } | 176 } |
155 } | 177 } |
156 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : | 178 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |