comparison gnv-artifacts/src/main/java/de/intevation/gnv/state/profile/verticalcrosssection/VerticalCrossSectionOutputState.java @ 632:62ea2a7b1067

'Profilschnitte' are working without cache as well, now. gnv-artifacts/trunk@711 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Thu, 25 Feb 2010 09:06:36 +0000
parents 78e0e239a0b9
children 987584605a60
comparison
equal deleted inserted replaced
631:f4331a0df032 632:62ea2a7b1067
74 import java.util.Iterator; 74 import java.util.Iterator;
75 import java.util.List; 75 import java.util.List;
76 import java.util.Locale; 76 import java.util.Locale;
77 import java.util.Map; 77 import java.util.Map;
78 78
79 import net.sf.ehcache.Cache;
79 import net.sf.ehcache.Element; 80 import net.sf.ehcache.Element;
80 81
81 import org.apache.log4j.Logger; 82 import org.apache.log4j.Logger;
82 83
83 import org.jfree.chart.ChartTheme; 84 import org.jfree.chart.ChartTheme;
169 170
170 171
171 @Override 172 @Override
172 protected Object getChartResult(String uuid, CallContext callContext) { 173 protected Object getChartResult(String uuid, CallContext callContext) {
173 log.debug("VerticalCrossSectionOutputState.getChartResult"); 174 log.debug("VerticalCrossSectionOutputState.getChartResult");
175 String key = uuid + super.getID();
176
177 CacheFactory factory = CacheFactory.getInstance();
178 if (factory.isInitialized()) {
179 log.info("Using a cachce.");
180 Cache cache = factory.getCache();
181
182 Element element = cache.get(key);
183 if (element != null)
184 return element.getObjectValue();
185
186 log.debug("No results in cache yet.");
187 Object obj = getData(uuid, callContext);
188 cache.put(new Element(key, obj));
189
190 return obj;
191 }
192 else {
193 log.info("Not using a cache.");
194 return getData(uuid, callContext);
195 }
196 }
197
198
199 protected Object getData(String uuid, CallContext callContext) {
174 Collection<Result> result = null; 200 Collection<Result> result = null;
175 String key = uuid + super.getID(); 201 InputData meshLine = inputData.get("mesh_linestring");
176 202 InputData meshId = inputData.get("meshid");
177 Element element = CacheFactory.getInstance().getCache().get(key);
178 if (element != null)
179 return element.getObjectValue();
180
181 log.debug("No results in cache yet.");
182
183 InputData meshLine = inputData.get("mesh_linestring");
184 InputData meshId = inputData.get("meshid");
185 203
186 if (meshLine == null) { 204 if (meshLine == null) {
187 log.error("mesh_linestring is not defined"); 205 log.error("mesh_linestring is not defined");
188 throw new IllegalStateException("missing mesh_linestring"); 206 throw new IllegalStateException("missing mesh_linestring");
189 } 207 }
225 243
226 Object obj = process( 244 Object obj = process(
227 Arrays.asList(coords), 245 Arrays.asList(coords),
228 preProcess(result), 246 preProcess(result),
229 callContext); 247 callContext);
230
231 CacheFactory.getInstance().getCache().put(new Element(key, obj));
232 248
233 return obj; 249 return obj;
234 } 250 }
235 251
236 252

http://dive4elements.wald.intevation.org