Mercurial > dive4elements > river
comparison flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/WstValueTableFactory.java @ 632:07640ab913fd
First part of storing qs in ranges
flys-artifacts/trunk@1997 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Tue, 24 May 2011 14:46:45 +0000 |
parents | e3ee131d5dd3 |
children | d08f77e7f7e8 |
comparison
equal
deleted
inserted
replaced
631:a9af60c84dca | 632:07640ab913fd |
---|---|
26 | 26 |
27 public class WstValueTableFactory | 27 public class WstValueTableFactory |
28 { | 28 { |
29 private static Logger log = Logger.getLogger(WstValueTableFactory.class); | 29 private static Logger log = Logger.getLogger(WstValueTableFactory.class); |
30 | 30 |
31 public static final String CACHE_NAME = "wst-value-table"; | |
32 | |
33 // TODO: put this into a property file | 31 // TODO: put this into a property file |
34 public static final String SQL_POS_WQ = | 32 public static final String SQL_POS_WQ = |
35 "SELECT position, w, q, column_pos" + | 33 "SELECT position, w, q, column_pos" + |
36 " FROM wst_value_table" + | 34 " FROM wst_value_table" + |
37 " WHERE wst_id = :wst_id"; | 35 " WHERE wst_id = :wst_id"; |
43 return getTable(river, 0); | 41 return getTable(river, 0); |
44 } | 42 } |
45 | 43 |
46 public static WstValueTable getTable(River river, int kind) { | 44 public static WstValueTable getTable(River river, int kind) { |
47 | 45 |
48 Cache cache = CacheFactory.getCache(CACHE_NAME); | 46 Cache cache = CacheFactory.getCache(WstValueTableCacheKey.CACHE_NAME); |
49 | 47 |
50 WstValueTableCacheKey cacheKey; | 48 WstValueTableCacheKey cacheKey; |
51 | 49 |
52 if (cache != null) { | 50 if (cache != null) { |
53 cacheKey = new WstValueTableCacheKey(river.getId(), kind); | 51 cacheKey = new WstValueTableCacheKey(river.getId(), kind); |
61 cacheKey = null; | 59 cacheKey = null; |
62 } | 60 } |
63 | 61 |
64 WstValueTable valueTable = getTableUncached(river, kind); | 62 WstValueTable valueTable = getTableUncached(river, kind); |
65 | 63 |
66 if (cacheKey != null) { | 64 if (valueTable != null && cacheKey != null) { |
67 log.debug("store wst value table in cache"); | 65 log.debug("store wst value table in cache"); |
68 Element element = new Element(cacheKey, valueTable); | 66 Element element = new Element(cacheKey, valueTable); |
69 cache.put(element); | 67 cache.put(element); |
70 } | 68 } |
71 | 69 |