# HG changeset patch # User Ingo Weinzierl # Date 1275930708 0 # Node ID 6f35dcd814185695af55dfbf569babba41c73b85 # Parent 9bb1979aabbe0dc6856e508fe644b9ac30064302 Added an output state for verticalprofiles with vector charts on meshes. gnv-artifacts/trunk@1169 c6561f87-3c4e-4783-a992-168aeb5c3f6f diff -r 9bb1979aabbe -r 6f35dcd81418 gnv-artifacts/ChangeLog --- 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 + + * 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 * src/main/java/de/intevation/gnv/utils/VectorDataProcessor.java: The diff -r 9bb1979aabbe -r 6f35dcd81418 gnv-artifacts/src/main/java/de/intevation/gnv/state/profile/vertical/VerticalProfileMeshVectorOutputState.java --- /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 Ingo Weinzierl + */ +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 res = (Collection)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 :