Mercurial > dive4elements > river
comparison artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentDensityFactory.java @ 7212:8079e3ba31c9
SedimentDensityFactory: query densities by id only (not year).
author | Felix Wolfsteller <felix.wolfsteller@intevation.de> |
---|---|
date | Mon, 30 Sep 2013 17:38:11 +0200 |
parents | f707ee04ac80 |
children | 13f0bdeb2b47 |
comparison
equal
deleted
inserted
replaced
7211:d6030c90b312 | 7212:8079e3ba31c9 |
---|---|
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 sdv.year = :year AND sd.id = :id"; | 49 " WHERE sd.id = :id"; |
50 | 50 |
51 private SedimentDensityFactory() {} | 51 private SedimentDensityFactory() {} |
52 | 52 |
53 public static SedimentDensity getSedimentDensity( | 53 public static SedimentDensity getSedimentDensity( |
54 String river, | 54 String river, |
105 density.cleanUp(); | 105 density.cleanUp(); |
106 return density; | 106 return density; |
107 } | 107 } |
108 | 108 |
109 public static SedimentDensity getSedimentDensityUncached( | 109 public static SedimentDensity getSedimentDensityUncached( |
110 int id, | 110 int id |
111 int year | |
112 ) { | 111 ) { |
113 log.debug("getSedimentDensityUncached id/year"); | 112 log.debug("getSedimentDensityUncached id/year"); |
114 Session session = SessionHolder.HOLDER.get(); | 113 Session session = SessionHolder.HOLDER.get(); |
115 SQLQuery sqlQuery = session.createSQLQuery(SQL_SELECT_DENSITY) | 114 SQLQuery sqlQuery = session.createSQLQuery(SQL_SELECT_DENSITY_BY_ID_YEAR) |
116 .addScalar("km", StandardBasicTypes.DOUBLE) | 115 .addScalar("km", StandardBasicTypes.DOUBLE) |
117 .addScalar("density", StandardBasicTypes.DOUBLE) | 116 .addScalar("density", StandardBasicTypes.DOUBLE) |
118 .addScalar("year", StandardBasicTypes.INTEGER); | 117 .addScalar("year", StandardBasicTypes.INTEGER); |
119 sqlQuery.setInteger("id", id); | 118 sqlQuery.setInteger("id", id); |
120 sqlQuery.setInteger("year", year); | |
121 List<Object[]> results = sqlQuery.list(); | 119 List<Object[]> results = sqlQuery.list(); |
122 SedimentDensity density = new SedimentDensity(); | 120 SedimentDensity density = new SedimentDensity(); |
123 for (Object[] row : results) { | 121 for (Object[] row : results) { |
124 if (row[0] != null && row[1] != null && row[2] != null) { | 122 if (row[0] != null && row[1] != null && row[2] != null) { |
125 density.addDensity((Double)row[0], (Double)row[1], (Integer)row[2]); | 123 density.addDensity((Double)row[0], (Double)row[1], (Integer)row[2]); |