Mercurial > dive4elements > gnv-client
comparison gnv-artifacts/src/main/java/de/intevation/gnv/state/profile/horizontal/HorizontalProfileMeshCrossOutputState.java @ 1030:c07d9f9a738c
Removed bugs that existed in the caching mechanism (issue264, issue268).
gnv-artifacts/trunk@1067 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Thu, 06 May 2010 08:32:56 +0000 |
parents | c9996913ff4b |
children | 50a5ce7a47b7 |
comparison
equal
deleted
inserted
replaced
1029:a5e0384fe464 | 1030:c07d9f9a738c |
---|---|
161 } | 161 } |
162 | 162 |
163 @Override | 163 @Override |
164 protected Object getChartResult(String uuid, CallContext callContext) { | 164 protected Object getChartResult(String uuid, CallContext callContext) { |
165 log.debug("HorizontalProfileMeshCrossOutputState.getChartResult"); | 165 log.debug("HorizontalProfileMeshCrossOutputState.getChartResult"); |
166 | |
167 String key = getHash(uuid); | |
168 if (CacheFactory.getInstance().isInitialized()) { | |
169 log.debug("Using cache - key: " + key); | |
170 net.sf.ehcache.Element value = CacheFactory.getInstance().getCache().get(key); | |
171 | |
172 if (value != null) { | |
173 log.debug("Found element in cache."); | |
174 return (Collection<Result>) (value.getObjectValue()); | |
175 } | |
176 } | |
177 | |
178 log.debug("Not using cache or element not found."); | |
166 Collection<Result> result = null; | 179 Collection<Result> result = null; |
180 | |
181 InputData meshLine = inputData.get("mesh_linestring"); | |
182 InputData meshId = inputData.get("meshid"); | |
183 | |
184 if (meshLine == null) { | |
185 log.error("mesh_linestring is not defined"); | |
186 throw new IllegalStateException("missing mesh_linestring"); | |
187 } | |
188 | |
189 if (meshId == null) { | |
190 log.error("meshid is not defined"); | |
191 throw new IllegalStateException("missing meshid"); | |
192 } | |
193 | |
194 Coordinate [] coords = WKTUtils.toCoordinates( | |
195 meshLine.getValue()); | |
196 | |
197 if (coords == null) { | |
198 throw new IllegalStateException("cannot read coordinates"); | |
199 } | |
200 | |
201 try { | |
202 String additionWhere = USE_INDEX_BUFFER | |
203 ? WKTUtils.worldCoordinatesToIndex( | |
204 coords, | |
205 result, | |
206 meshId.getValue(), | |
207 ijkQueryID) | |
208 : WKTUtils.TRUE_EXPRESSION; | |
209 | |
210 String[] addedFilterValues = StringUtils.append( | |
211 generateFilterValuesFromInputData(), | |
212 additionWhere); | |
213 | |
214 QueryExecutor queryExecutor = QueryExecutorFactory | |
215 .getInstance() | |
216 .getQueryExecutor(); | |
217 | |
218 result = process( | |
219 Arrays.asList(coords), | |
220 numSamples(callContext), | |
221 queryExecutor.executeQuery( | |
222 queryID, | |
223 addedFilterValues)); | |
224 } | |
225 catch (QueryException e) { | |
226 log.error(e,e); | |
227 } | |
228 | |
167 if (CacheFactory.getInstance().isInitialized()) { | 229 if (CacheFactory.getInstance().isInitialized()) { |
168 String key = uuid + super.getID(); | 230 CacheFactory.getInstance().getCache().put(new net.sf.ehcache.Element(key, result)); |
169 log.debug("Hash for Queryelements: " + key); | 231 } |
170 net.sf.ehcache.Element value = CacheFactory.getInstance().getCache().get(key); | 232 |
171 if (value != null) { | |
172 result = (Collection<Result>) (value.getObjectValue()); | |
173 }else{ | |
174 | |
175 InputData meshLine = inputData.get("mesh_linestring"); | |
176 InputData meshId = inputData.get("meshid"); | |
177 | |
178 if (meshLine == null) { | |
179 log.error("mesh_linestring is not defined"); | |
180 throw new IllegalStateException("missing mesh_linestring"); | |
181 } | |
182 | |
183 if (meshId == null) { | |
184 log.error("meshid is not defined"); | |
185 throw new IllegalStateException("missing meshid"); | |
186 } | |
187 | |
188 Coordinate [] coords = WKTUtils.toCoordinates( | |
189 meshLine.getValue()); | |
190 | |
191 if (coords == null) { | |
192 throw new IllegalStateException("cannot read coordinates"); | |
193 } | |
194 | |
195 try { | |
196 String additionWhere = USE_INDEX_BUFFER | |
197 ? WKTUtils.worldCoordinatesToIndex( | |
198 coords, | |
199 result, | |
200 meshId.getValue(), | |
201 ijkQueryID) | |
202 : WKTUtils.TRUE_EXPRESSION; | |
203 | |
204 String[] addedFilterValues = StringUtils.append( | |
205 generateFilterValuesFromInputData(), | |
206 additionWhere); | |
207 | |
208 QueryExecutor queryExecutor = QueryExecutorFactory | |
209 .getInstance() | |
210 .getQueryExecutor(); | |
211 | |
212 result = process( | |
213 Arrays.asList(coords), | |
214 numSamples(callContext), | |
215 queryExecutor.executeQuery( | |
216 queryID, | |
217 addedFilterValues)); | |
218 } | |
219 catch (QueryException e) { | |
220 log.error(e,e); | |
221 } | |
222 | |
223 if (CacheFactory.getInstance().isInitialized()) { | |
224 CacheFactory.getInstance().getCache().put(new net.sf.ehcache.Element(key, result)); | |
225 } | |
226 | |
227 } | |
228 } | |
229 return result; | 233 return result; |
230 } | 234 } |
231 | 235 |
232 | 236 |
233 /** | 237 /** |