changeset 5728:c08f691652cf

WQKmsFactory: Add functionality to fetch WQKms if only column id is known.
author Felix Wolfsteller <felix.wolfsteller@intevation.de>
date Tue, 16 Apr 2013 12:39:47 +0200
parents 26dcd924befc
children 187762f5e905
files flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/WQKmsFactory.java
diffstat 1 files changed, 37 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- 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.");

http://dive4elements.wald.intevation.org