comparison gnv-artifacts/src/main/java/de/intevation/gnv/state/profile/vertical/VerticalProfileMeshVectorOutputState.java @ 1072:6f35dcd81418

Added an output state for verticalprofiles with vector charts on meshes. gnv-artifacts/trunk@1169 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Mon, 07 Jun 2010 17:11:48 +0000
parents
children f953c9a559d8
comparison
equal deleted inserted replaced
1071:9bb1979aabbe 1072:6f35dcd81418
1 package de.intevation.gnv.state.profile.vertical;
2
3 import de.intevation.artifacts.CallContext;
4
5 import de.intevation.gnv.artifacts.cache.CacheFactory;
6
7 import de.intevation.gnv.geobackend.base.Result;
8
9 import de.intevation.gnv.utils.VectorDataProcessor;
10
11 import java.util.Collection;
12
13 import net.sf.ehcache.Cache;
14
15 import org.apache.log4j.Logger;
16
17
18 /**
19 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a>
20 */
21 public class VerticalProfileMeshVectorOutputState
22 extends VerticalProfileVectorOutputState
23 {
24 public static final String[] RESULT_COLUMNS = {
25 "YORDINATE", "XORDINATE", "KPOSITION",
26 "GROUP1", "GROUP2", "GROUP3",
27 "DATAID", "FEATUREID", "MESHID",
28 "SERIES"
29 };
30
31 private static Logger logger =
32 Logger.getLogger(VerticalProfileMeshVectorOutputState.class);
33
34
35 @Override
36 protected Object getChartResult(String uuid, CallContext callContext) {
37 logger.debug("Fetch chart data for vertical profile with vector data.");
38 CacheFactory factory = CacheFactory.getInstance();
39
40 if (factory.isInitialized()) {
41 // we use a cache
42 logger.info("Using cache.");
43 Cache cache = factory.getCache();
44 String key = "chart_" + getHash();
45
46 net.sf.ehcache.Element value = cache.get(key);
47 if (value != null) {
48 logger.debug("Found element in cache.");
49 return value.getObjectValue();
50 }
51 else {
52 logger.debug("Element not in cache, we ask the database");
53 Collection<Result> res = (Collection<Result>)getData(queryID);
54 logger.debug("Got " + res.size() + " elements from db.");
55
56 res = VectorDataProcessor.process(res, RESULT_COLUMNS);
57 cache.put(new net.sf.ehcache.Element(key, res));
58
59 return res;
60 }
61 }
62 else {
63 // we don't use a cache, so we have to query the database every
64 // single time
65 logger.info("Not using a cache.");
66 return VectorDataProcessor.process(
67 getData(queryID), RESULT_COLUMNS);
68 }
69 }
70 }
71 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :

http://dive4elements.wald.intevation.org