Mercurial > dive4elements > river
annotate flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/SQOverviewFactory.java @ 3432:9c39a25aa849
FixA: Embed german and english translations into the overview stylesheet.
flys-artifacts/trunk@5092 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Sat, 21 Jul 2012 12:50:48 +0000 |
parents | ec9aab93f292 |
children |
rev | line source |
---|---|
3274
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
1 package de.intevation.flys.artifacts.model; |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
2 |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
3 import de.intevation.flys.artifacts.cache.CacheFactory; |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
4 |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
5 import de.intevation.flys.backend.SedDBSessionHolder; |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
6 |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
7 import net.sf.ehcache.Cache; |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
8 import net.sf.ehcache.Element; |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
9 |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
10 import org.apache.log4j.Logger; |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
11 |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
12 import org.hibernate.Session; |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
13 |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
14 public class SQOverviewFactory { |
3289
ec9aab93f292
SQ: First peek into fetching relevant data from SedDB
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3287
diff
changeset
|
15 |
ec9aab93f292
SQ: First peek into fetching relevant data from SedDB
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3287
diff
changeset
|
16 private static Logger log = Logger.getLogger(SQOverviewFactory.class); |
3274
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
17 |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
18 public static final String CACHE_NAME = "sq-overviews"; |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
19 |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
20 private SQOverviewFactory() { |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
21 } |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
22 |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
23 |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
24 public static SQOverview getOverview(String river) { |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
25 |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
26 boolean debug = log.isDebugEnabled(); |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
27 |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
28 if (debug) { |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
29 log.debug( |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
30 "Looking for sq overview for river '" + river + "'"); |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
31 } |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
32 |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
33 Cache cache = CacheFactory.getCache(CACHE_NAME); |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
34 |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
35 if (cache == null) { |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
36 if (debug) { |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
37 log.debug("Cache not configured."); |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
38 } |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
39 return getUncached(river); |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
40 } |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
41 |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
42 String key = "sq-over-" + river; |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
43 |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
44 Element element = cache.get(key); |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
45 |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
46 if (element != null) { |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
47 if (debug) { |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
48 log.debug("Overview found in cache"); |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
49 } |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
50 return (SQOverview)element.getValue(); |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
51 } |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
52 |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
53 SQOverview overview = getUncached(river); |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
54 |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
55 if (overview != null) { |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
56 if (debug) { |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
57 log.debug("Store overview in cache."); |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
58 } |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
59 cache.put(new Element(key, overview)); |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
60 } |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
61 |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
62 return overview; |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
63 } |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
64 |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
65 public static SQOverview getUncached(String river) { |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
66 SQOverview overview = new SQOverview(river); |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
67 |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
68 Session session = SedDBSessionHolder.HOLDER.get(); |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
69 |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
70 return overview.load(session) ? overview : null; |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
71 } |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
72 } |
3287
30f157c7e466
SQ: Filter out meassures which don't have a 'Siebsatz'
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3274
diff
changeset
|
73 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |