Mercurial > dive4elements > gnv-client
changeset 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 | 9bb1979aabbe |
children | 902bcd837995 |
files | gnv-artifacts/ChangeLog gnv-artifacts/src/main/java/de/intevation/gnv/state/profile/vertical/VerticalProfileMeshVectorOutputState.java |
diffstat | 2 files changed, 77 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/gnv-artifacts/ChangeLog Mon Jun 07 15:00:23 2010 +0000 +++ b/gnv-artifacts/ChangeLog Mon Jun 07 17:11:48 2010 +0000 @@ -1,3 +1,9 @@ +2010-06-07 Ingo Weinzierl <ingo.weinzierl@intevation.de> + + * src/main/java/de/intevation/gnv/state/profile/vertical/VerticalProfileMeshVectorOutputState.java: + A new output state for verticalprofiles on meshes that contain vector + data. + 2010-06-07 Ingo Weinzierl <ingo.weinzierl@intevation.de> * src/main/java/de/intevation/gnv/utils/VectorDataProcessor.java: The
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gnv-artifacts/src/main/java/de/intevation/gnv/state/profile/vertical/VerticalProfileMeshVectorOutputState.java Mon Jun 07 17:11:48 2010 +0000 @@ -0,0 +1,71 @@ +package de.intevation.gnv.state.profile.vertical; + +import de.intevation.artifacts.CallContext; + +import de.intevation.gnv.artifacts.cache.CacheFactory; + +import de.intevation.gnv.geobackend.base.Result; + +import de.intevation.gnv.utils.VectorDataProcessor; + +import java.util.Collection; + +import net.sf.ehcache.Cache; + +import org.apache.log4j.Logger; + + +/** + * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a> + */ +public class VerticalProfileMeshVectorOutputState +extends VerticalProfileVectorOutputState +{ + public static final String[] RESULT_COLUMNS = { + "YORDINATE", "XORDINATE", "KPOSITION", + "GROUP1", "GROUP2", "GROUP3", + "DATAID", "FEATUREID", "MESHID", + "SERIES" + }; + + private static Logger logger = + Logger.getLogger(VerticalProfileMeshVectorOutputState.class); + + + @Override + protected Object getChartResult(String uuid, CallContext callContext) { + logger.debug("Fetch chart data for vertical profile with vector data."); + CacheFactory factory = CacheFactory.getInstance(); + + if (factory.isInitialized()) { + // we use a cache + logger.info("Using cache."); + Cache cache = factory.getCache(); + String key = "chart_" + getHash(); + + net.sf.ehcache.Element value = cache.get(key); + if (value != null) { + logger.debug("Found element in cache."); + return value.getObjectValue(); + } + else { + logger.debug("Element not in cache, we ask the database"); + Collection<Result> res = (Collection<Result>)getData(queryID); + logger.debug("Got " + res.size() + " elements from db."); + + res = VectorDataProcessor.process(res, RESULT_COLUMNS); + cache.put(new net.sf.ehcache.Element(key, res)); + + return res; + } + } + else { + // we don't use a cache, so we have to query the database every + // single time + logger.info("Not using a cache."); + return VectorDataProcessor.process( + getData(queryID), RESULT_COLUMNS); + } + } +} +// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :