comparison artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/BedHeightFactory.java @ 8151:a709e6334c4a

IDs can be assumed to be unique.
author Tom Gottfried <tom@intevation.de>
date Thu, 28 Aug 2014 18:42:20 +0200
parents b5cba2690347
children c3dfb18dcefc
comparison
equal deleted inserted replaced
8150:fe67edde6189 8151:a709e6334c4a
49 49
50 50
51 /** 51 /**
52 * Get BedHeightData for given type and height_id, caring about the cache. 52 * Get BedHeightData for given type and height_id, caring about the cache.
53 */ 53 */
54 public static BedHeightData getHeight(String type, int height_id, int time) { 54 public static BedHeightData getHeight(String type, int height_id) {
55 log.debug("BedHeightFactory.getHeight"); 55 log.debug("BedHeightFactory.getHeight");
56 Cache cache = CacheFactory.getCache(StaticBedHeightCacheKey.CACHE_NAME); 56 Cache cache = CacheFactory.getCache("bedheight-value-table-static");
57 57
58 StaticBedHeightCacheKey cacheKey; 58 String cacheKey = Integer.toString(height_id);
59 59
60 if (cache != null) { 60 if (cache != null) {
61 cacheKey = new StaticBedHeightCacheKey(height_id, time);
62 Element element = cache.get(cacheKey); 61 Element element = cache.get(cacheKey);
63 if (element != null) { 62 if (element != null) {
64 log.debug("Got static bedheight values from cache"); 63 log.debug("Got static bedheight values from cache");
65 return (BedHeightData)element.getValue(); 64 return (BedHeightData)element.getValue();
66 } 65 }
67 } 66 }
68 else { 67 else {
69 cacheKey = null; 68 cacheKey = null;
70 } 69 }
71 70
72 BedHeightData values = getBedHeightUncached(type, height_id, time); 71 BedHeightData values = getBedHeightUncached(type, height_id);
73 72
74 if (values != null && cacheKey != null) { 73 if (values != null && cacheKey != null) {
75 log.debug("Store static bed height values in cache."); 74 log.debug("Store static bed height values in cache.");
76 Element element = new Element(cacheKey, values); 75 Element element = new Element(cacheKey, values);
77 cache.put(element); 76 cache.put(element);
109 * @param height_id database id of the bed_height 108 * @param height_id database id of the bed_height
110 * @return according BedHeight. 109 * @return according BedHeight.
111 */ 110 */
112 public static BedHeightData getBedHeightUncached( 111 public static BedHeightData getBedHeightUncached(
113 String type, 112 String type,
114 int height_id, 113 int height_id)
115 int time)
116 { 114 {
117 if (log.isDebugEnabled()) { 115 if (log.isDebugEnabled()) {
118 log.debug("BedHeightFactory.getBedHeightUncached"); 116 log.debug("BedHeightFactory.getBedHeightUncached");
119 } 117 }
120 118

http://dive4elements.wald.intevation.org