Mercurial > dive4elements > gnv-client
diff gnv-artifacts/src/main/java/de/intevation/gnv/transition/OutputTransitionBase.java @ 325:3eff9241ea1e
Refactoring of the Transitionmodel.
Now each Transition is responsible to allocate the Data which is required to describe or feed it.
gnv-artifacts/trunk@390 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Tim Englich <tim.englich@intevation.de> |
---|---|
date | Tue, 01 Dec 2009 15:58:02 +0000 |
parents | 91c37bf28c0e |
children | 1c427acb6c76 |
line wrap: on
line diff
--- a/gnv-artifacts/src/main/java/de/intevation/gnv/transition/OutputTransitionBase.java Mon Nov 30 15:08:47 2009 +0000 +++ b/gnv-artifacts/src/main/java/de/intevation/gnv/transition/OutputTransitionBase.java Tue Dec 01 15:58:02 2009 +0000 @@ -9,6 +9,7 @@ import org.apache.log4j.Logger; +import org.w3c.dom.Document; import org.w3c.dom.Element; import org.w3c.dom.Node; import org.w3c.dom.NodeList; @@ -116,10 +117,16 @@ @Override public void advance(String uuid, CallMeta callMeta) throws TransitionException { - log.debug("OutputTransitionBase.advance"); - if (this.getChartResult(uuid) == null) { - super.advance(uuid, callMeta); - } + } + + @Override + public void initialize(String uuid, CallMeta callMeta) + throws TransitionException { + } + + public void out(Document format, Collection<InputData> inputData, + OutputStream outputStream, String uuid, CallMeta callMeta) + throws TransitionException { } /** @@ -135,15 +142,22 @@ */ protected Collection<Result> getChartResult(String uuid) { log.debug("OutputTransitionBase.getChartResult"); + Collection<Result> result = null; if (CacheFactory.getInstance().isInitialized()) { String key = uuid + super.getID(); log.debug("Hash for Queryelements: " + key); net.sf.ehcache.Element value = CacheFactory.getInstance().getCache().get(key); if (value != null) { - return (Collection<Result>) (value.getObjectValue()); + result = (Collection<Result>) (value.getObjectValue()); + }else{ + result = this.getData(this.queryID); + if (CacheFactory.getInstance().isInitialized()) { + CacheFactory.getInstance().getCache().put(new net.sf.ehcache.Element(key, result)); + } + } } - return null; + return result; } protected Object getChartFromCache(String uuid) { @@ -165,22 +179,32 @@ // TODO add Caching? I think it's not nessessary Collection<Result> returnValue = null; if (this.queryODVID != null){ + returnValue = this.getData(this.queryODVID); + }else{ + log.warn("No Query for ODV Data is defined."); + } + return returnValue; + } + + /** + * @param returnValue + * @return + */ + private Collection<Result> getData(String queryID) { + log.debug("OutputTransitionBase.getData"); + Collection<Result> returnValue = null; + try { + String[] filterValues = this.generateFilterValuesFromInputData(); try { - String[] filterValues = this.generateFilterValuesFromInputData(); - try { - QueryExecutor queryExecutor = QueryExecutorFactory - .getInstance() - .getQueryExecutor(); - returnValue = queryExecutor.executeQuery(this.queryODVID, - filterValues); - } catch (RuntimeException e) { - log.error(e, e); - } - } catch (QueryException e) { + QueryExecutor queryExecutor = QueryExecutorFactory + .getInstance() + .getQueryExecutor(); + returnValue = queryExecutor.executeQuery(queryID,filterValues); + } catch (RuntimeException e) { log.error(e, e); } - }else{ - log.warn("No Query for ODV Data is defined."); + } catch (QueryException e) { + log.error(e, e); } return returnValue; } @@ -209,21 +233,6 @@ } } - /** - * @see de.intevation.gnv.transition.TransitionBase#purifyResult(java.util.Collection, - * java.lang.String) - */ - @Override - protected void purifyResult(Collection<Result> result, String uuid) { - log.debug("OutputTransitionBase.purifyResult"); - if (CacheFactory.getInstance().isInitialized()) { - String key = uuid + super.getID(); - log.debug("Hash for Queryelements: " + key); - CacheFactory.getInstance().getCache().put(new net.sf.ehcache.Element(key, result)); - } - } - - protected void purifyChart(Object chart, String uuid) { log.debug("Prufify chart [" + uuid + "]"); CacheFactory cacheFactory = CacheFactory.getInstance();