Mercurial > dive4elements > river
annotate flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/WQKmsFactory.java @ 5759:9f9dfe1b9913
Add a different translation for catchment_wms
author | Andre Heinecke <aheinecke@intevation.de> |
---|---|
date | Thu, 18 Apr 2013 12:37:24 +0200 |
parents | c08f691652cf |
children |
rev | line source |
---|---|
1825
02cd002205a3
Added 'static' wqkms data access.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
1 package de.intevation.flys.artifacts.model; |
02cd002205a3
Added 'static' wqkms data access.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
2 |
02cd002205a3
Added 'static' wqkms data access.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
3 import java.util.List; |
02cd002205a3
Added 'static' wqkms data access.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
4 |
02cd002205a3
Added 'static' wqkms data access.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
5 import net.sf.ehcache.Cache; |
02cd002205a3
Added 'static' wqkms data access.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
6 import net.sf.ehcache.Element; |
02cd002205a3
Added 'static' wqkms data access.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
7 |
02cd002205a3
Added 'static' wqkms data access.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
8 import org.apache.log4j.Logger; |
02cd002205a3
Added 'static' wqkms data access.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
9 |
02cd002205a3
Added 'static' wqkms data access.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
10 import org.hibernate.Session; |
02cd002205a3
Added 'static' wqkms data access.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
11 |
02cd002205a3
Added 'static' wqkms data access.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
12 import org.hibernate.SQLQuery; |
02cd002205a3
Added 'static' wqkms data access.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
13 import org.hibernate.type.StandardBasicTypes; |
02cd002205a3
Added 'static' wqkms data access.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
14 |
02cd002205a3
Added 'static' wqkms data access.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
15 import de.intevation.flys.artifacts.cache.CacheFactory; |
02cd002205a3
Added 'static' wqkms data access.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
16 |
02cd002205a3
Added 'static' wqkms data access.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
17 import de.intevation.flys.backend.SessionHolder; |
02cd002205a3
Added 'static' wqkms data access.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
18 |
02cd002205a3
Added 'static' wqkms data access.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
19 /** |
3076
5642a83420f2
FLYS artifacts: Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1886
diff
changeset
|
20 * Factory to access ready-made WQKms for other (than computed) 'kinds' of |
1825
02cd002205a3
Added 'static' wqkms data access.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
21 * WST-data. |
02cd002205a3
Added 'static' wqkms data access.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
22 */ |
02cd002205a3
Added 'static' wqkms data access.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
23 public class WQKmsFactory |
02cd002205a3
Added 'static' wqkms data access.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
24 { |
02cd002205a3
Added 'static' wqkms data access.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
25 private static Logger log = Logger.getLogger(WQKmsFactory.class); |
02cd002205a3
Added 'static' wqkms data access.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
26 |
02cd002205a3
Added 'static' wqkms data access.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
27 /** Query to get km and wqs for wst_id and column_pos. */ |
02cd002205a3
Added 'static' wqkms data access.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
28 public static final String SQL_SELECT_WQS = |
02cd002205a3
Added 'static' wqkms data access.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
29 "SELECT position, w, q FROM wst_value_table " + |
02cd002205a3
Added 'static' wqkms data access.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
30 "WHERE wst_id = :wst_id AND column_pos = :column_pos"; |
02cd002205a3
Added 'static' wqkms data access.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
31 |
5726
17eba7d251b2
WQKmsFactory: Add name getting function if only column id is known.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4051
diff
changeset
|
32 /** Get wst_id and position from wst_columns. */ |
17eba7d251b2
WQKmsFactory: Add name getting function if only column id is known.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4051
diff
changeset
|
33 public static final String SQL_SELECT_COLUMN = |
17eba7d251b2
WQKmsFactory: Add name getting function if only column id is known.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4051
diff
changeset
|
34 "SELECT wst_id, position FROM wst_columns WHERE id = :column_id"; |
17eba7d251b2
WQKmsFactory: Add name getting function if only column id is known.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4051
diff
changeset
|
35 |
1825
02cd002205a3
Added 'static' wqkms data access.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
36 /** Query to get name for wst_id and column_pos. */ |
02cd002205a3
Added 'static' wqkms data access.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
37 public static final String SQL_SELECT_NAME = |
02cd002205a3
Added 'static' wqkms data access.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
38 "SELECT name " + |
02cd002205a3
Added 'static' wqkms data access.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
39 "FROM wst_columns "+ |
5727
26dcd924befc
WQKmsFactory: Fix name sql.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
5726
diff
changeset
|
40 "WHERE id = :column_id"; |
1825
02cd002205a3
Added 'static' wqkms data access.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
41 |
02cd002205a3
Added 'static' wqkms data access.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
42 |
02cd002205a3
Added 'static' wqkms data access.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
43 /** Hidden constructor, use static methods instead. */ |
02cd002205a3
Added 'static' wqkms data access.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
44 private WQKmsFactory() { |
02cd002205a3
Added 'static' wqkms data access.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
45 } |
02cd002205a3
Added 'static' wqkms data access.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
46 |
02cd002205a3
Added 'static' wqkms data access.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
47 |
02cd002205a3
Added 'static' wqkms data access.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
48 /** |
5727
26dcd924befc
WQKmsFactory: Fix name sql.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
5726
diff
changeset
|
49 * Get WKms for given column (pos) and wst_id, caring about the cache. |
1825
02cd002205a3
Added 'static' wqkms data access.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
50 */ |
5728
c08f691652cf
WQKmsFactory: Add functionality to fetch WQKms if only column id is known.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
5727
diff
changeset
|
51 public static WQKms getWQKms(int columnPos, int wst_id) { |
1825
02cd002205a3
Added 'static' wqkms data access.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
52 log.debug("WQKmsFactory.getWQKms"); |
02cd002205a3
Added 'static' wqkms data access.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
53 Cache cache = CacheFactory.getCache(StaticWQKmsCacheKey.CACHE_NAME); |
02cd002205a3
Added 'static' wqkms data access.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
54 |
02cd002205a3
Added 'static' wqkms data access.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
55 StaticWQKmsCacheKey cacheKey; |
02cd002205a3
Added 'static' wqkms data access.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
56 |
02cd002205a3
Added 'static' wqkms data access.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
57 if (cache != null) { |
5728
c08f691652cf
WQKmsFactory: Add functionality to fetch WQKms if only column id is known.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
5727
diff
changeset
|
58 cacheKey = new StaticWQKmsCacheKey(wst_id, columnPos); |
1825
02cd002205a3
Added 'static' wqkms data access.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
59 Element element = cache.get(cacheKey); |
02cd002205a3
Added 'static' wqkms data access.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
60 if (element != null) { |
02cd002205a3
Added 'static' wqkms data access.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
61 log.debug("Got static wst values from cache"); |
02cd002205a3
Added 'static' wqkms data access.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
62 return (WQKms)element.getValue(); |
02cd002205a3
Added 'static' wqkms data access.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
63 } |
02cd002205a3
Added 'static' wqkms data access.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
64 } |
02cd002205a3
Added 'static' wqkms data access.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
65 else { |
02cd002205a3
Added 'static' wqkms data access.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
66 cacheKey = null; |
02cd002205a3
Added 'static' wqkms data access.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
67 } |
02cd002205a3
Added 'static' wqkms data access.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
68 |
5728
c08f691652cf
WQKmsFactory: Add functionality to fetch WQKms if only column id is known.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
5727
diff
changeset
|
69 WQKms values = getWQKmsUncached(columnPos, wst_id); |
c08f691652cf
WQKmsFactory: Add functionality to fetch WQKms if only column id is known.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
5727
diff
changeset
|
70 |
c08f691652cf
WQKmsFactory: Add functionality to fetch WQKms if only column id is known.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
5727
diff
changeset
|
71 if (values != null && cacheKey != null) { |
c08f691652cf
WQKmsFactory: Add functionality to fetch WQKms if only column id is known.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
5727
diff
changeset
|
72 log.debug("Store static wst values in cache."); |
c08f691652cf
WQKmsFactory: Add functionality to fetch WQKms if only column id is known.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
5727
diff
changeset
|
73 Element element = new Element(cacheKey, values); |
c08f691652cf
WQKmsFactory: Add functionality to fetch WQKms if only column id is known.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
5727
diff
changeset
|
74 cache.put(element); |
c08f691652cf
WQKmsFactory: Add functionality to fetch WQKms if only column id is known.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
5727
diff
changeset
|
75 } |
c08f691652cf
WQKmsFactory: Add functionality to fetch WQKms if only column id is known.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
5727
diff
changeset
|
76 return values; |
c08f691652cf
WQKmsFactory: Add functionality to fetch WQKms if only column id is known.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
5727
diff
changeset
|
77 } |
c08f691652cf
WQKmsFactory: Add functionality to fetch WQKms if only column id is known.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
5727
diff
changeset
|
78 |
c08f691652cf
WQKmsFactory: Add functionality to fetch WQKms if only column id is known.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
5727
diff
changeset
|
79 /** |
c08f691652cf
WQKmsFactory: Add functionality to fetch WQKms if only column id is known.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
5727
diff
changeset
|
80 * Get WKms for given column (id), caring about the cache. |
c08f691652cf
WQKmsFactory: Add functionality to fetch WQKms if only column id is known.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
5727
diff
changeset
|
81 */ |
c08f691652cf
WQKmsFactory: Add functionality to fetch WQKms if only column id is known.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
5727
diff
changeset
|
82 public static WQKms getWQKmsCID(int columnID) { |
c08f691652cf
WQKmsFactory: Add functionality to fetch WQKms if only column id is known.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
5727
diff
changeset
|
83 log.debug("WQKmsFactory.getWQKms"); |
c08f691652cf
WQKmsFactory: Add functionality to fetch WQKms if only column id is known.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
5727
diff
changeset
|
84 Cache cache = CacheFactory.getCache(StaticWQKmsCacheKey.CACHE_NAME); |
c08f691652cf
WQKmsFactory: Add functionality to fetch WQKms if only column id is known.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
5727
diff
changeset
|
85 |
c08f691652cf
WQKmsFactory: Add functionality to fetch WQKms if only column id is known.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
5727
diff
changeset
|
86 StaticWQKmsCacheKey cacheKey; |
c08f691652cf
WQKmsFactory: Add functionality to fetch WQKms if only column id is known.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
5727
diff
changeset
|
87 |
c08f691652cf
WQKmsFactory: Add functionality to fetch WQKms if only column id is known.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
5727
diff
changeset
|
88 if (cache != null) { |
c08f691652cf
WQKmsFactory: Add functionality to fetch WQKms if only column id is known.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
5727
diff
changeset
|
89 cacheKey = new StaticWQKmsCacheKey(-columnID, -columnID); |
c08f691652cf
WQKmsFactory: Add functionality to fetch WQKms if only column id is known.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
5727
diff
changeset
|
90 Element element = cache.get(cacheKey); |
c08f691652cf
WQKmsFactory: Add functionality to fetch WQKms if only column id is known.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
5727
diff
changeset
|
91 if (element != null) { |
c08f691652cf
WQKmsFactory: Add functionality to fetch WQKms if only column id is known.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
5727
diff
changeset
|
92 log.debug("Got static wst values from cache"); |
c08f691652cf
WQKmsFactory: Add functionality to fetch WQKms if only column id is known.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
5727
diff
changeset
|
93 return (WQKms)element.getValue(); |
c08f691652cf
WQKmsFactory: Add functionality to fetch WQKms if only column id is known.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
5727
diff
changeset
|
94 } |
c08f691652cf
WQKmsFactory: Add functionality to fetch WQKms if only column id is known.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
5727
diff
changeset
|
95 } |
c08f691652cf
WQKmsFactory: Add functionality to fetch WQKms if only column id is known.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
5727
diff
changeset
|
96 else { |
c08f691652cf
WQKmsFactory: Add functionality to fetch WQKms if only column id is known.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
5727
diff
changeset
|
97 cacheKey = null; |
c08f691652cf
WQKmsFactory: Add functionality to fetch WQKms if only column id is known.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
5727
diff
changeset
|
98 } |
c08f691652cf
WQKmsFactory: Add functionality to fetch WQKms if only column id is known.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
5727
diff
changeset
|
99 |
c08f691652cf
WQKmsFactory: Add functionality to fetch WQKms if only column id is known.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
5727
diff
changeset
|
100 int[] cInfo = getColumn(columnID); |
c08f691652cf
WQKmsFactory: Add functionality to fetch WQKms if only column id is known.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
5727
diff
changeset
|
101 if (cInfo == null) return null; |
c08f691652cf
WQKmsFactory: Add functionality to fetch WQKms if only column id is known.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
5727
diff
changeset
|
102 WQKms values = getWQKmsUncached(cInfo[1], cInfo[0]); |
c08f691652cf
WQKmsFactory: Add functionality to fetch WQKms if only column id is known.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
5727
diff
changeset
|
103 |
1825
02cd002205a3
Added 'static' wqkms data access.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
104 |
02cd002205a3
Added 'static' wqkms data access.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
105 if (values != null && cacheKey != null) { |
02cd002205a3
Added 'static' wqkms data access.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
106 log.debug("Store static wst values in cache."); |
02cd002205a3
Added 'static' wqkms data access.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
107 Element element = new Element(cacheKey, values); |
02cd002205a3
Added 'static' wqkms data access.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
108 cache.put(element); |
02cd002205a3
Added 'static' wqkms data access.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
109 } |
02cd002205a3
Added 'static' wqkms data access.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
110 return values; |
02cd002205a3
Added 'static' wqkms data access.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
111 } |
02cd002205a3
Added 'static' wqkms data access.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
112 |
02cd002205a3
Added 'static' wqkms data access.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
113 |
02cd002205a3
Added 'static' wqkms data access.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
114 /** |
02cd002205a3
Added 'static' wqkms data access.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
115 * Get WQKms from db. |
02cd002205a3
Added 'static' wqkms data access.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
116 * @param column the position columns value |
02cd002205a3
Added 'static' wqkms data access.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
117 * @param wst_id database id of the wst |
02cd002205a3
Added 'static' wqkms data access.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
118 * @return respective WQKms. |
02cd002205a3
Added 'static' wqkms data access.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
119 */ |
02cd002205a3
Added 'static' wqkms data access.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
120 public static WQKms getWQKmsUncached(int column, int wst_id) { |
02cd002205a3
Added 'static' wqkms data access.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
121 |
02cd002205a3
Added 'static' wqkms data access.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
122 if (log.isDebugEnabled()) { |
02cd002205a3
Added 'static' wqkms data access.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
123 log.debug("WQKmsFactory.getWQKmsUncached, column " |
02cd002205a3
Added 'static' wqkms data access.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
124 + column + ", wst_id " + wst_id); |
02cd002205a3
Added 'static' wqkms data access.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
125 } |
02cd002205a3
Added 'static' wqkms data access.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
126 |
02cd002205a3
Added 'static' wqkms data access.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
127 WQKms wqkms = new WQKms(WKmsFactory.getWKmsName(column, wst_id)); |
02cd002205a3
Added 'static' wqkms data access.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
128 |
02cd002205a3
Added 'static' wqkms data access.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
129 Session session = SessionHolder.HOLDER.get(); |
02cd002205a3
Added 'static' wqkms data access.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
130 SQLQuery sqlQuery = session.createSQLQuery(SQL_SELECT_WQS) |
02cd002205a3
Added 'static' wqkms data access.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
131 .addScalar("position", StandardBasicTypes.DOUBLE) |
02cd002205a3
Added 'static' wqkms data access.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
132 .addScalar("w", StandardBasicTypes.DOUBLE) |
02cd002205a3
Added 'static' wqkms data access.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
133 .addScalar("q", StandardBasicTypes.DOUBLE); |
02cd002205a3
Added 'static' wqkms data access.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
134 sqlQuery.setInteger("wst_id", wst_id); |
02cd002205a3
Added 'static' wqkms data access.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
135 sqlQuery.setInteger("column_pos", column); |
02cd002205a3
Added 'static' wqkms data access.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
136 |
02cd002205a3
Added 'static' wqkms data access.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
137 List<Object []> results = sqlQuery.list(); |
02cd002205a3
Added 'static' wqkms data access.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
138 |
02cd002205a3
Added 'static' wqkms data access.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
139 for (int i = 0, N = results.size(); i < N; i++) { |
02cd002205a3
Added 'static' wqkms data access.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
140 Object[] row = results.get(i); |
02cd002205a3
Added 'static' wqkms data access.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
141 // add(w, q, km) |
02cd002205a3
Added 'static' wqkms data access.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
142 wqkms.add((Double) row[1], (Double) row[2], (Double) row[0]); |
02cd002205a3
Added 'static' wqkms data access.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
143 } |
02cd002205a3
Added 'static' wqkms data access.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
144 |
02cd002205a3
Added 'static' wqkms data access.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
145 return wqkms; |
02cd002205a3
Added 'static' wqkms data access.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
146 } |
5726
17eba7d251b2
WQKmsFactory: Add name getting function if only column id is known.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4051
diff
changeset
|
147 |
17eba7d251b2
WQKmsFactory: Add name getting function if only column id is known.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4051
diff
changeset
|
148 |
17eba7d251b2
WQKmsFactory: Add name getting function if only column id is known.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4051
diff
changeset
|
149 /** |
17eba7d251b2
WQKmsFactory: Add name getting function if only column id is known.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4051
diff
changeset
|
150 * Get WQKms from db. |
17eba7d251b2
WQKmsFactory: Add name getting function if only column id is known.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4051
diff
changeset
|
151 * @param columnID the columns database id value |
17eba7d251b2
WQKmsFactory: Add name getting function if only column id is known.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4051
diff
changeset
|
152 * @param wst_id database id of the wst |
17eba7d251b2
WQKmsFactory: Add name getting function if only column id is known.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4051
diff
changeset
|
153 * @return respective WQKms. |
17eba7d251b2
WQKmsFactory: Add name getting function if only column id is known.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4051
diff
changeset
|
154 */ |
17eba7d251b2
WQKmsFactory: Add name getting function if only column id is known.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4051
diff
changeset
|
155 public static int[] getColumn(int columnID) { |
17eba7d251b2
WQKmsFactory: Add name getting function if only column id is known.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4051
diff
changeset
|
156 |
17eba7d251b2
WQKmsFactory: Add name getting function if only column id is known.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4051
diff
changeset
|
157 if (log.isDebugEnabled()) { |
17eba7d251b2
WQKmsFactory: Add name getting function if only column id is known.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4051
diff
changeset
|
158 log.debug("WQKmsFactory.getColumn, columnID " |
17eba7d251b2
WQKmsFactory: Add name getting function if only column id is known.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4051
diff
changeset
|
159 + columnID); |
17eba7d251b2
WQKmsFactory: Add name getting function if only column id is known.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4051
diff
changeset
|
160 } |
17eba7d251b2
WQKmsFactory: Add name getting function if only column id is known.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4051
diff
changeset
|
161 |
17eba7d251b2
WQKmsFactory: Add name getting function if only column id is known.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4051
diff
changeset
|
162 Session session = SessionHolder.HOLDER.get(); |
17eba7d251b2
WQKmsFactory: Add name getting function if only column id is known.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4051
diff
changeset
|
163 |
17eba7d251b2
WQKmsFactory: Add name getting function if only column id is known.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4051
diff
changeset
|
164 SQLQuery sqlQuery = session.createSQLQuery(SQL_SELECT_COLUMN) |
17eba7d251b2
WQKmsFactory: Add name getting function if only column id is known.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4051
diff
changeset
|
165 .addScalar("wst_id", StandardBasicTypes.INTEGER) |
17eba7d251b2
WQKmsFactory: Add name getting function if only column id is known.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4051
diff
changeset
|
166 .addScalar("position", StandardBasicTypes.INTEGER); |
17eba7d251b2
WQKmsFactory: Add name getting function if only column id is known.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4051
diff
changeset
|
167 sqlQuery.setInteger("column_id", columnID); |
17eba7d251b2
WQKmsFactory: Add name getting function if only column id is known.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4051
diff
changeset
|
168 |
17eba7d251b2
WQKmsFactory: Add name getting function if only column id is known.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4051
diff
changeset
|
169 List<Object []> results = sqlQuery.list(); |
17eba7d251b2
WQKmsFactory: Add name getting function if only column id is known.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4051
diff
changeset
|
170 |
17eba7d251b2
WQKmsFactory: Add name getting function if only column id is known.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4051
diff
changeset
|
171 for (int i = 0, N = results.size(); i < N; i++) { |
17eba7d251b2
WQKmsFactory: Add name getting function if only column id is known.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4051
diff
changeset
|
172 Object[] row = results.get(i); |
17eba7d251b2
WQKmsFactory: Add name getting function if only column id is known.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4051
diff
changeset
|
173 return new int[] {(Integer)row[0], (Integer)row[1]}; |
17eba7d251b2
WQKmsFactory: Add name getting function if only column id is known.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4051
diff
changeset
|
174 } |
17eba7d251b2
WQKmsFactory: Add name getting function if only column id is known.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4051
diff
changeset
|
175 |
17eba7d251b2
WQKmsFactory: Add name getting function if only column id is known.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4051
diff
changeset
|
176 return null; |
17eba7d251b2
WQKmsFactory: Add name getting function if only column id is known.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4051
diff
changeset
|
177 } |
17eba7d251b2
WQKmsFactory: Add name getting function if only column id is known.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4051
diff
changeset
|
178 |
17eba7d251b2
WQKmsFactory: Add name getting function if only column id is known.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4051
diff
changeset
|
179 |
17eba7d251b2
WQKmsFactory: Add name getting function if only column id is known.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4051
diff
changeset
|
180 /** Get name for a WKms. */ |
17eba7d251b2
WQKmsFactory: Add name getting function if only column id is known.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4051
diff
changeset
|
181 public static String getWQKmsName(int columnID) { |
17eba7d251b2
WQKmsFactory: Add name getting function if only column id is known.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4051
diff
changeset
|
182 log.debug("WQKmsFactory.getWQKmsName c/" + columnID); |
17eba7d251b2
WQKmsFactory: Add name getting function if only column id is known.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4051
diff
changeset
|
183 |
17eba7d251b2
WQKmsFactory: Add name getting function if only column id is known.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4051
diff
changeset
|
184 String name = null; |
17eba7d251b2
WQKmsFactory: Add name getting function if only column id is known.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4051
diff
changeset
|
185 Session session = SessionHolder.HOLDER.get(); |
17eba7d251b2
WQKmsFactory: Add name getting function if only column id is known.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4051
diff
changeset
|
186 |
17eba7d251b2
WQKmsFactory: Add name getting function if only column id is known.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4051
diff
changeset
|
187 SQLQuery nameQuery = session.createSQLQuery(SQL_SELECT_NAME) |
17eba7d251b2
WQKmsFactory: Add name getting function if only column id is known.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4051
diff
changeset
|
188 .addScalar("name", StandardBasicTypes.STRING); |
17eba7d251b2
WQKmsFactory: Add name getting function if only column id is known.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4051
diff
changeset
|
189 nameQuery.setInteger("column_id", columnID); |
17eba7d251b2
WQKmsFactory: Add name getting function if only column id is known.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4051
diff
changeset
|
190 |
17eba7d251b2
WQKmsFactory: Add name getting function if only column id is known.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4051
diff
changeset
|
191 List<String> names = nameQuery.list(); |
17eba7d251b2
WQKmsFactory: Add name getting function if only column id is known.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4051
diff
changeset
|
192 if (names.size() >= 1) { |
17eba7d251b2
WQKmsFactory: Add name getting function if only column id is known.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4051
diff
changeset
|
193 name = names.get(0); |
17eba7d251b2
WQKmsFactory: Add name getting function if only column id is known.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4051
diff
changeset
|
194 } |
17eba7d251b2
WQKmsFactory: Add name getting function if only column id is known.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4051
diff
changeset
|
195 |
17eba7d251b2
WQKmsFactory: Add name getting function if only column id is known.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4051
diff
changeset
|
196 return name; |
17eba7d251b2
WQKmsFactory: Add name getting function if only column id is known.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4051
diff
changeset
|
197 } |
1825
02cd002205a3
Added 'static' wqkms data access.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
198 } |
02cd002205a3
Added 'static' wqkms data access.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
199 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |