comparison artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/BedHeightFactory.java @ 7919:868f55932fe6

Removed serverside path for bed height epochs.
author Raimund Renkert <rrenkert@intevation.de>
date Fri, 06 Jun 2014 16:59:16 +0200
parents 1aba75321441
children b5cba2690347
comparison
equal deleted inserted replaced
7918:5813c206ff64 7919:868f55932fe6
38 " JOIN bed_height_single_values bhsv on bhsv.bed_height_single_id = bhs.id" + 38 " JOIN bed_height_single_values bhsv on bhsv.bed_height_single_id = bhs.id" +
39 " WHERE bhs.id = :height_id" + 39 " WHERE bhs.id = :height_id" +
40 " ORDER BY bhsv.station"; 40 " ORDER BY bhsv.station";
41 41
42 42
43 /** Query to get name for wst_id and column_pos. */
44 public static final String SQL_SELECT_EPOCH =
45 "SELECT bv.height, bv.station, ti.start_time, ti.stop_time" +
46 " FROM bed_height_epoch b" +
47 " JOIN bed_height_epoch_values bv ON b.id = bv.bed_height_epoch_id" +
48 " JOIN time_intervals ti ON b.time_interval_id = ti.id" +
49 " WHERE b.id = :height_id" +
50 " ORDER BY bhsv.station";
51
52 /** Query to get name (description) for wst_id. */ 43 /** Query to get name (description) for wst_id. */
53 public static final String SQL_SELECT_DESCR_SINGLE = 44 public static final String SQL_SELECT_DESCR_SINGLE =
54 "SELECT description FROM bed_height_single "+ 45 "SELECT description FROM bed_height_single "+
55 "WHERE id = :height_id"; 46 "WHERE id = :height_id";
56
57 /** Query to get name (description) for wst_id. */
58 public static final String SQL_SELECT_DESCR_EPOCH =
59 "SELECT description from bed_height_epoch "+
60 "WHERE id = :height_id";
61
62 47
63 private BedHeightFactory() { 48 private BedHeightFactory() {
64 } 49 }
65 50
66 51
103 Session session = SessionHolder.HOLDER.get(); 88 Session session = SessionHolder.HOLDER.get();
104 89
105 SQLQuery nameQuery = null; 90 SQLQuery nameQuery = null;
106 if (type.equals("single")) { 91 if (type.equals("single")) {
107 nameQuery = session.createSQLQuery(SQL_SELECT_DESCR_SINGLE) 92 nameQuery = session.createSQLQuery(SQL_SELECT_DESCR_SINGLE)
108 .addScalar("description", StandardBasicTypes.STRING);
109 nameQuery.setInteger("height_id", height_id);
110 }
111 else if (type.equals("epoch")) {
112 nameQuery = session.createSQLQuery(SQL_SELECT_DESCR_EPOCH)
113 .addScalar("description", StandardBasicTypes.STRING); 93 .addScalar("description", StandardBasicTypes.STRING);
114 nameQuery.setInteger("height_id", height_id); 94 nameQuery.setInteger("height_id", height_id);
115 } 95 }
116 else { 96 else {
117 return "none"; 97 return "none";
163 Double row4 = row[4] != null ? (Double)row[4] : Double.NaN; 143 Double row4 = row[4] != null ? (Double)row[4] : Double.NaN;
164 height.add(row0, row1, row2, row3, row4, (Integer) row[5]); 144 height.add(row0, row1, row2, row3, row4, (Integer) row[5]);
165 } 145 }
166 return height; 146 return height;
167 } 147 }
168 else if (type.equals("epoch")) {
169 BedHeightEpochData height =
170 new BedHeightEpochData(getHeightName(type, height_id));
171 sqlQuery = session.createSQLQuery(SQL_SELECT_EPOCH)
172 .addScalar("height", StandardBasicTypes.DOUBLE)
173 .addScalar("station", StandardBasicTypes.DOUBLE)
174 .addScalar("start_time", StandardBasicTypes.DATE)
175 .addScalar("stop_time", StandardBasicTypes.DATE);
176 sqlQuery.setInteger("height_id", height_id);
177 List<Object []> results = sqlQuery.list();
178
179 for (Object [] row: results) {
180 height.add(
181 (Double) row[0],
182 (Double) row[1],
183 (Date) row[2],
184 (Date) row[3]);
185 }
186 return height;
187 }
188 return new BedHeightData(); 148 return new BedHeightData();
189 } 149 }
190 } 150 }
191 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : 151 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org