comparison artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentDensityFactory.java @ 7312:349730f8a49f

issue1345: Added getDepth() to SedimentDensityFactory.
author Felix Wolfsteller <felix.wolfsteller@intevation.de>
date Mon, 14 Oct 2013 12:15:34 +0200
parents 13f0bdeb2b47
children fdb26fe898dc
comparison
equal deleted inserted replaced
7311:5ac4c9119aef 7312:349730f8a49f
44 "SELECT sdv.station AS km, " + 44 "SELECT sdv.station AS km, " +
45 " sdv.density AS density," + 45 " sdv.density AS density," +
46 " sdv.year AS year " + 46 " sdv.year AS year " +
47 " FROM sediment_density sd" + 47 " FROM sediment_density sd" +
48 " JOIN sediment_density_values sdv ON sd.id = sdv.sediment_density_id" + 48 " JOIN sediment_density_values sdv ON sd.id = sdv.sediment_density_id" +
49 " WHERE sd.id = :id";
50
51 /** Query to get sediment density depth by sediment density id. */
52 private static final String SQL_SELECT_DENSITY_DEPTH_BY_ID =
53 "SELECT d.lower AS lower, " +
54 " d.upper AS upper" +
55 " FROM sediment_density sd " +
56 " JOIN depths d ON d.id = sd.depth_id " +
49 " WHERE sd.id = :id"; 57 " WHERE sd.id = :id";
50 58
51 /** Query to get sediment density description by id. */ 59 /** Query to get sediment density description by id. */
52 private static final String SQL_SELECT_DESCRIPTION_BY_ID = 60 private static final String SQL_SELECT_DESCRIPTION_BY_ID =
53 "SELECT sd.description " + 61 "SELECT sd.description " +
110 118
111 density.cleanUp(); 119 density.cleanUp();
112 return density; 120 return density;
113 } 121 }
114 122
123 /** Query and return depth of a sediment density entry. */
124 public static double[] getDepth(int id) {
125 log.debug("getDepth");
126 Session session = SessionHolder.HOLDER.get();
127 SQLQuery sqlQuery = session.createSQLQuery(SQL_SELECT_DENSITY_DEPTH_BY_ID)
128 .addScalar("lower", StandardBasicTypes.DOUBLE)
129 .addScalar("upper", StandardBasicTypes.DOUBLE);
130 sqlQuery.setInteger("id", id);
131 List<Object[]> results = sqlQuery.list();
132 Object[] row = results.get(0);
133
134 return new double[] {(Double)row[0], (Double)row[1]};
135 }
136
137 /** Query and return description of a sediment density entry. */
115 public static String getSedimentDensityDescription(int id) { 138 public static String getSedimentDensityDescription(int id) {
116 log.debug("getSedimentDensityDescription"); 139 log.debug("getSedimentDensityDescription");
117 Session session = SessionHolder.HOLDER.get(); 140 Session session = SessionHolder.HOLDER.get();
118 SQLQuery sqlQuery = session.createSQLQuery(SQL_SELECT_DESCRIPTION_BY_ID) 141 SQLQuery sqlQuery = session.createSQLQuery(SQL_SELECT_DESCRIPTION_BY_ID)
119 .addScalar("description", StandardBasicTypes.STRING); 142 .addScalar("description", StandardBasicTypes.STRING);

http://dive4elements.wald.intevation.org