# HG changeset patch # User Felix Wolfsteller # Date 1366108787 -7200 # Node ID c08f691652cfcc052e024fafdecb3439d5532407 # Parent 26dcd924befc06f264d473832c226202a2d5fe02 WQKmsFactory: Add functionality to fetch WQKms if only column id is known. diff -r 26dcd924befc -r c08f691652cf flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/WQKmsFactory.java --- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/WQKmsFactory.java Tue Apr 16 12:39:12 2013 +0200 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/WQKmsFactory.java Tue Apr 16 12:39:47 2013 +0200 @@ -48,14 +48,14 @@ /** * Get WKms for given column (pos) and wst_id, caring about the cache. */ - public static WQKms getWQKms(int column, int wst_id) { + public static WQKms getWQKms(int columnPos, int wst_id) { log.debug("WQKmsFactory.getWQKms"); Cache cache = CacheFactory.getCache(StaticWQKmsCacheKey.CACHE_NAME); StaticWQKmsCacheKey cacheKey; if (cache != null) { - cacheKey = new StaticWQKmsCacheKey(wst_id, column); + cacheKey = new StaticWQKmsCacheKey(wst_id, columnPos); Element element = cache.get(cacheKey); if (element != null) { log.debug("Got static wst values from cache"); @@ -66,7 +66,41 @@ cacheKey = null; } - WQKms values = getWQKmsUncached(column, wst_id); + WQKms values = getWQKmsUncached(columnPos, wst_id); + + if (values != null && cacheKey != null) { + log.debug("Store static wst values in cache."); + Element element = new Element(cacheKey, values); + cache.put(element); + } + return values; + } + + /** + * Get WKms for given column (id), caring about the cache. + */ + public static WQKms getWQKmsCID(int columnID) { + log.debug("WQKmsFactory.getWQKms"); + Cache cache = CacheFactory.getCache(StaticWQKmsCacheKey.CACHE_NAME); + + StaticWQKmsCacheKey cacheKey; + + if (cache != null) { + cacheKey = new StaticWQKmsCacheKey(-columnID, -columnID); + Element element = cache.get(cacheKey); + if (element != null) { + log.debug("Got static wst values from cache"); + return (WQKms)element.getValue(); + } + } + else { + cacheKey = null; + } + + int[] cInfo = getColumn(columnID); + if (cInfo == null) return null; + WQKms values = getWQKmsUncached(cInfo[1], cInfo[0]); + if (values != null && cacheKey != null) { log.debug("Store static wst values in cache.");