Mercurial > dive4elements > river
comparison flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/WQKmsFactory.java @ 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 |
comparison
equal
deleted
inserted
replaced
5727:26dcd924befc | 5728:c08f691652cf |
---|---|
46 | 46 |
47 | 47 |
48 /** | 48 /** |
49 * Get WKms for given column (pos) and wst_id, caring about the cache. | 49 * Get WKms for given column (pos) and wst_id, caring about the cache. |
50 */ | 50 */ |
51 public static WQKms getWQKms(int column, int wst_id) { | 51 public static WQKms getWQKms(int columnPos, int wst_id) { |
52 log.debug("WQKmsFactory.getWQKms"); | 52 log.debug("WQKmsFactory.getWQKms"); |
53 Cache cache = CacheFactory.getCache(StaticWQKmsCacheKey.CACHE_NAME); | 53 Cache cache = CacheFactory.getCache(StaticWQKmsCacheKey.CACHE_NAME); |
54 | 54 |
55 StaticWQKmsCacheKey cacheKey; | 55 StaticWQKmsCacheKey cacheKey; |
56 | 56 |
57 if (cache != null) { | 57 if (cache != null) { |
58 cacheKey = new StaticWQKmsCacheKey(wst_id, column); | 58 cacheKey = new StaticWQKmsCacheKey(wst_id, columnPos); |
59 Element element = cache.get(cacheKey); | 59 Element element = cache.get(cacheKey); |
60 if (element != null) { | 60 if (element != null) { |
61 log.debug("Got static wst values from cache"); | 61 log.debug("Got static wst values from cache"); |
62 return (WQKms)element.getValue(); | 62 return (WQKms)element.getValue(); |
63 } | 63 } |
64 } | 64 } |
65 else { | 65 else { |
66 cacheKey = null; | 66 cacheKey = null; |
67 } | 67 } |
68 | 68 |
69 WQKms values = getWQKmsUncached(column, wst_id); | 69 WQKms values = getWQKmsUncached(columnPos, wst_id); |
70 | |
71 if (values != null && cacheKey != null) { | |
72 log.debug("Store static wst values in cache."); | |
73 Element element = new Element(cacheKey, values); | |
74 cache.put(element); | |
75 } | |
76 return values; | |
77 } | |
78 | |
79 /** | |
80 * Get WKms for given column (id), caring about the cache. | |
81 */ | |
82 public static WQKms getWQKmsCID(int columnID) { | |
83 log.debug("WQKmsFactory.getWQKms"); | |
84 Cache cache = CacheFactory.getCache(StaticWQKmsCacheKey.CACHE_NAME); | |
85 | |
86 StaticWQKmsCacheKey cacheKey; | |
87 | |
88 if (cache != null) { | |
89 cacheKey = new StaticWQKmsCacheKey(-columnID, -columnID); | |
90 Element element = cache.get(cacheKey); | |
91 if (element != null) { | |
92 log.debug("Got static wst values from cache"); | |
93 return (WQKms)element.getValue(); | |
94 } | |
95 } | |
96 else { | |
97 cacheKey = null; | |
98 } | |
99 | |
100 int[] cInfo = getColumn(columnID); | |
101 if (cInfo == null) return null; | |
102 WQKms values = getWQKmsUncached(cInfo[1], cInfo[0]); | |
103 | |
70 | 104 |
71 if (values != null && cacheKey != null) { | 105 if (values != null && cacheKey != null) { |
72 log.debug("Store static wst values in cache."); | 106 log.debug("Store static wst values in cache."); |
73 Element element = new Element(cacheKey, values); | 107 Element element = new Element(cacheKey, values); |
74 cache.put(element); | 108 cache.put(element); |