comparison artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/BedHeightFactory.java @ 7391:9513d1af7d58

Renamed artifacts/**/BedHeight(Single) to BedHeight(Single)Data, to resolve class name conflict with class in backend.
author Felix Wolfsteller <felix.wolfsteller@intevation.de>
date Thu, 17 Oct 2013 15:08:59 +0200
parents fe32a7f9655e
children 04b70a6fe8c5
comparison
equal deleted inserted replaced
7390:45e3bb00ce1a 7391:9513d1af7d58
62 private BedHeightFactory() { 62 private BedHeightFactory() {
63 } 63 }
64 64
65 65
66 /** 66 /**
67 * Get BedHeight for given type and height_id, caring about the cache. 67 * Get BedHeightData for given type and height_id, caring about the cache.
68 */ 68 */
69 public static BedHeight getHeight(String type, int height_id, int time) { 69 public static BedHeightData getHeight(String type, int height_id, int time) {
70 log.debug("BedHeightFactory.getHeight"); 70 log.debug("BedHeightFactory.getHeight");
71 Cache cache = CacheFactory.getCache(StaticBedHeightCacheKey.CACHE_NAME); 71 Cache cache = CacheFactory.getCache(StaticBedHeightCacheKey.CACHE_NAME);
72 72
73 StaticBedHeightCacheKey cacheKey; 73 StaticBedHeightCacheKey cacheKey;
74 74
75 if (cache != null) { 75 if (cache != null) {
76 cacheKey = new StaticBedHeightCacheKey(height_id, time); 76 cacheKey = new StaticBedHeightCacheKey(height_id, time);
77 Element element = cache.get(cacheKey); 77 Element element = cache.get(cacheKey);
78 if (element != null) { 78 if (element != null) {
79 log.debug("Got static bedheight values from cache"); 79 log.debug("Got static bedheight values from cache");
80 return (BedHeight)element.getValue(); 80 return (BedHeightData)element.getValue();
81 } 81 }
82 } 82 }
83 else { 83 else {
84 cacheKey = null; 84 cacheKey = null;
85 } 85 }
86 86
87 BedHeight values = getBedHeightUncached(type, height_id, time); 87 BedHeightData values = getBedHeightUncached(type, height_id, time);
88 88
89 if (values != null && cacheKey != null) { 89 if (values != null && cacheKey != null) {
90 log.debug("Store static bed height values in cache."); 90 log.debug("Store static bed height values in cache.");
91 Element element = new Element(cacheKey, values); 91 Element element = new Element(cacheKey, values);
92 cache.put(element); 92 cache.put(element);
123 return name; 123 return name;
124 } 124 }
125 125
126 126
127 /** 127 /**
128 * Get BedHeight from db. 128 * Get BedHeightData from db.
129 * @param height_id database id of the bed_height 129 * @param height_id database id of the bed_height
130 * @return according BedHeight. 130 * @return according BedHeight.
131 */ 131 */
132 public static BedHeight getBedHeightUncached( 132 public static BedHeightData getBedHeightUncached(
133 String type, 133 String type,
134 int height_id, 134 int height_id,
135 int time) 135 int time)
136 { 136 {
137 if (log.isDebugEnabled()) { 137 if (log.isDebugEnabled()) {
139 } 139 }
140 140
141 Session session = SessionHolder.HOLDER.get(); 141 Session session = SessionHolder.HOLDER.get();
142 SQLQuery sqlQuery = null; 142 SQLQuery sqlQuery = null;
143 if (type.equals("single")) { 143 if (type.equals("single")) {
144 BedHeightSingle height = 144 BedHeightSingleData height =
145 new BedHeightSingle(getHeightName(type, height_id)); 145 new BedHeightSingleData(getHeightName(type, height_id));
146 sqlQuery = session.createSQLQuery(SQL_SELECT_SINGLE) 146 sqlQuery = session.createSQLQuery(SQL_SELECT_SINGLE)
147 .addScalar("height", StandardBasicTypes.DOUBLE) 147 .addScalar("height", StandardBasicTypes.DOUBLE)
148 .addScalar("station", StandardBasicTypes.DOUBLE) 148 .addScalar("station", StandardBasicTypes.DOUBLE)
149 .addScalar("data_gap", StandardBasicTypes.DOUBLE) 149 .addScalar("data_gap", StandardBasicTypes.DOUBLE)
150 .addScalar("sounding_width", StandardBasicTypes.DOUBLE) 150 .addScalar("sounding_width", StandardBasicTypes.DOUBLE)
180 (Date) row[2], 180 (Date) row[2],
181 (Date) row[3]); 181 (Date) row[3]);
182 } 182 }
183 return height; 183 return height;
184 } 184 }
185 return new BedHeight(); 185 return new BedHeightData();
186 } 186 }
187 } 187 }
188 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : 188 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org