annotate flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/HYKFactory.java @ 2155:8c9c40459d8f

Respect rivers flow direction when looking for hyk-formations. flys-artifacts/trunk@3738 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Felix Wolfsteller <felix.wolfsteller@intevation.de>
date Fri, 20 Jan 2012 09:38:43 +0000
parents 345a236f7075
children 98a350bb91a9
rev   line source
2131
e50a928187cd Added stubby hyk infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
1 package de.intevation.flys.artifacts.model;
e50a928187cd Added stubby hyk infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
2
e50a928187cd Added stubby hyk infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
3 import java.util.ArrayList;
e50a928187cd Added stubby hyk infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
4 import java.util.List;
e50a928187cd Added stubby hyk infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
5
e50a928187cd Added stubby hyk infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
6 import java.math.BigDecimal;
e50a928187cd Added stubby hyk infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
7
2148
345a236f7075 Made HYKFactory.Zone Serializable (and thus cachable).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2139
diff changeset
8 import java.io.Serializable;
345a236f7075 Made HYKFactory.Zone Serializable (and thus cachable).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2139
diff changeset
9
2131
e50a928187cd Added stubby hyk infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
10 import net.sf.ehcache.Cache;
e50a928187cd Added stubby hyk infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
11 import net.sf.ehcache.Element;
e50a928187cd Added stubby hyk infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
12
e50a928187cd Added stubby hyk infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
13 import org.apache.log4j.Logger;
e50a928187cd Added stubby hyk infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
14
e50a928187cd Added stubby hyk infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
15 import org.hibernate.Query;
e50a928187cd Added stubby hyk infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
16 import org.hibernate.Session;
e50a928187cd Added stubby hyk infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
17
2155
8c9c40459d8f Respect rivers flow direction when looking for hyk-formations.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2148
diff changeset
18 import de.intevation.flys.model.HYK;
2131
e50a928187cd Added stubby hyk infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
19 import de.intevation.flys.model.HYKFormation;
e50a928187cd Added stubby hyk infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
20 import de.intevation.flys.model.HYKFlowZone;
e50a928187cd Added stubby hyk infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
21
e50a928187cd Added stubby hyk infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
22 import de.intevation.flys.artifacts.cache.CacheFactory;
e50a928187cd Added stubby hyk infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
23
e50a928187cd Added stubby hyk infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
24 import de.intevation.flys.backend.SessionHolder;
e50a928187cd Added stubby hyk infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
25
e50a928187cd Added stubby hyk infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
26
e50a928187cd Added stubby hyk infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
27 /**
e50a928187cd Added stubby hyk infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
28 * Factory to access HYKs (hydrographic values).
e50a928187cd Added stubby hyk infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
29 */
e50a928187cd Added stubby hyk infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
30 public class HYKFactory
e50a928187cd Added stubby hyk infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
31 {
e50a928187cd Added stubby hyk infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
32 private static Logger logger = Logger.getLogger(HYKFactory.class);
e50a928187cd Added stubby hyk infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
33
e50a928187cd Added stubby hyk infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
34 public static String HYK_CACHE_NAME = "hykache";
e50a928187cd Added stubby hyk infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
35
e50a928187cd Added stubby hyk infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
36
e50a928187cd Added stubby hyk infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
37 /** Do not instantiate a HYKFactory. */
e50a928187cd Added stubby hyk infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
38 private HYKFactory() {
e50a928187cd Added stubby hyk infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
39 }
e50a928187cd Added stubby hyk infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
40
e50a928187cd Added stubby hyk infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
41
e50a928187cd Added stubby hyk infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
42 /**
e50a928187cd Added stubby hyk infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
43 * Get List of Zones for given river and km.
e50a928187cd Added stubby hyk infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
44 */
2139
923256599afe Somewhat improved hyk handling and rendering.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2137
diff changeset
45 public static Object getHYKs(int hykid, double km) {
2131
e50a928187cd Added stubby hyk infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
46 logger.debug("HYKFactory.getHYKs");
e50a928187cd Added stubby hyk infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
47
e50a928187cd Added stubby hyk infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
48 Cache cache = CacheFactory.getCache(HYK_CACHE_NAME);
e50a928187cd Added stubby hyk infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
49
e50a928187cd Added stubby hyk infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
50 String cacheKey;
e50a928187cd Added stubby hyk infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
51
e50a928187cd Added stubby hyk infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
52 if (cache != null) {
2139
923256599afe Somewhat improved hyk handling and rendering.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2137
diff changeset
53 cacheKey = "" + hykid + "_" + km;
2131
e50a928187cd Added stubby hyk infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
54 Element element = cache.get(cacheKey);
e50a928187cd Added stubby hyk infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
55 if (element != null) {
e50a928187cd Added stubby hyk infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
56 logger.debug("Got hyk from cache");
e50a928187cd Added stubby hyk infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
57 return (List<Zone>)element.getValue();
e50a928187cd Added stubby hyk infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
58 }
e50a928187cd Added stubby hyk infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
59 }
e50a928187cd Added stubby hyk infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
60 else {
e50a928187cd Added stubby hyk infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
61 cacheKey = null;
e50a928187cd Added stubby hyk infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
62 }
e50a928187cd Added stubby hyk infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
63
2139
923256599afe Somewhat improved hyk handling and rendering.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2137
diff changeset
64 List<Zone> zones = getZonesUncached(hykid, km);
2131
e50a928187cd Added stubby hyk infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
65
e50a928187cd Added stubby hyk infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
66 if (zones != null && cacheKey != null) {
e50a928187cd Added stubby hyk infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
67 logger.debug("Store hykzones in cache.");
e50a928187cd Added stubby hyk infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
68 Element element = new Element(cacheKey, zones);
e50a928187cd Added stubby hyk infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
69 cache.put(element);
e50a928187cd Added stubby hyk infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
70 }
e50a928187cd Added stubby hyk infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
71
e50a928187cd Added stubby hyk infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
72 return zones;
e50a928187cd Added stubby hyk infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
73 }
e50a928187cd Added stubby hyk infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
74
e50a928187cd Added stubby hyk infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
75
2155
8c9c40459d8f Respect rivers flow direction when looking for hyk-formations.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2148
diff changeset
76 /** Return name for hyk with given id. */
2139
923256599afe Somewhat improved hyk handling and rendering.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2137
diff changeset
77 public static String getHykName(int hykid) {
923256599afe Somewhat improved hyk handling and rendering.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2137
diff changeset
78 logger.debug("HYKFactory.getHykName " + hykid);
923256599afe Somewhat improved hyk handling and rendering.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2137
diff changeset
79
923256599afe Somewhat improved hyk handling and rendering.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2137
diff changeset
80 Session session = SessionHolder.HOLDER.get();
923256599afe Somewhat improved hyk handling and rendering.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2137
diff changeset
81
923256599afe Somewhat improved hyk handling and rendering.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2137
diff changeset
82 Query query = session.createQuery(
923256599afe Somewhat improved hyk handling and rendering.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2137
diff changeset
83 "select description from HYK where id = :hykid ");
923256599afe Somewhat improved hyk handling and rendering.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2137
diff changeset
84 query.setParameter("hykid", hykid);
923256599afe Somewhat improved hyk handling and rendering.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2137
diff changeset
85
923256599afe Somewhat improved hyk handling and rendering.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2137
diff changeset
86 return (String) query.uniqueResult();
923256599afe Somewhat improved hyk handling and rendering.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2137
diff changeset
87 }
923256599afe Somewhat improved hyk handling and rendering.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2137
diff changeset
88
923256599afe Somewhat improved hyk handling and rendering.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2137
diff changeset
89
2131
e50a928187cd Added stubby hyk infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
90 /**
2155
8c9c40459d8f Respect rivers flow direction when looking for hyk-formations.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2148
diff changeset
91 * Ask DB for hyk zones.
8c9c40459d8f Respect rivers flow direction when looking for hyk-formations.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2148
diff changeset
92 * @param hykid ID of the 'main' HYK to query.
8c9c40459d8f Respect rivers flow direction when looking for hyk-formations.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2148
diff changeset
93 * @param km for which to get the hyk-zones.
8c9c40459d8f Respect rivers flow direction when looking for hyk-formations.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2148
diff changeset
94 * @return according zones.
2131
e50a928187cd Added stubby hyk infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
95 */
2139
923256599afe Somewhat improved hyk handling and rendering.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2137
diff changeset
96 public static List<Zone> getZonesUncached(int hykid, double km) {
2131
e50a928187cd Added stubby hyk infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
97
e50a928187cd Added stubby hyk infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
98 if (logger.isDebugEnabled()) {
2139
923256599afe Somewhat improved hyk handling and rendering.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2137
diff changeset
99 logger.debug("HYKFactory.getZoneUncached " + hykid + " km " + km);
2131
e50a928187cd Added stubby hyk infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
100 }
e50a928187cd Added stubby hyk infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
101
e50a928187cd Added stubby hyk infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
102 Session session = SessionHolder.HOLDER.get();
2137
04b6b6a4564d Prepare improved hyk-handling.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2131
diff changeset
103
2155
8c9c40459d8f Respect rivers flow direction when looking for hyk-formations.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2148
diff changeset
104 // Find out flow-direction of river.
8c9c40459d8f Respect rivers flow direction when looking for hyk-formations.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2148
diff changeset
105 // OPTIMIZE: 1) query kmUp directly 2) merge queries.
8c9c40459d8f Respect rivers flow direction when looking for hyk-formations.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2148
diff changeset
106 Query rQuery = session.createQuery("from HYK where id = :hykid");
8c9c40459d8f Respect rivers flow direction when looking for hyk-formations.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2148
diff changeset
107 rQuery.setParameter("hykid", hykid);
8c9c40459d8f Respect rivers flow direction when looking for hyk-formations.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2148
diff changeset
108 rQuery.setMaxResults(1);
8c9c40459d8f Respect rivers flow direction when looking for hyk-formations.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2148
diff changeset
109 HYK hyk = (HYK) rQuery.uniqueResult();
8c9c40459d8f Respect rivers flow direction when looking for hyk-formations.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2148
diff changeset
110 BigDecimal flowDir = (hyk.getRiver().getKmUp()) ? new BigDecimal(1) : new BigDecimal(-1);
8c9c40459d8f Respect rivers flow direction when looking for hyk-formations.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2148
diff changeset
111
8c9c40459d8f Respect rivers flow direction when looking for hyk-formations.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2148
diff changeset
112 // Query HYKFormations in range.
2131
e50a928187cd Added stubby hyk infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
113 Query query = session.createQuery(
2139
923256599afe Somewhat improved hyk handling and rendering.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2137
diff changeset
114 "from HYKFormation where entry.HYK.id = :hykid " +
2155
8c9c40459d8f Respect rivers flow direction when looking for hyk-formations.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2148
diff changeset
115 " and :km between entry.km and " +
8c9c40459d8f Respect rivers flow direction when looking for hyk-formations.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2148
diff changeset
116 " entry.km + :flowDir * "+
8c9c40459d8f Respect rivers flow direction when looking for hyk-formations.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2148
diff changeset
117 " cast(distance_vl/1000.0 + 0.001 as big_decimal)" +
2139
923256599afe Somewhat improved hyk handling and rendering.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2137
diff changeset
118 " order by entry.km asc");
2155
8c9c40459d8f Respect rivers flow direction when looking for hyk-formations.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2148
diff changeset
119 query.setParameter("hykid", hykid);
8c9c40459d8f Respect rivers flow direction when looking for hyk-formations.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2148
diff changeset
120 query.setParameter("km", new BigDecimal(km));
8c9c40459d8f Respect rivers flow direction when looking for hyk-formations.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2148
diff changeset
121 query.setParameter("flowDir", flowDir);
8c9c40459d8f Respect rivers flow direction when looking for hyk-formations.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2148
diff changeset
122 query.setMaxResults(1);
2148
345a236f7075 Made HYKFactory.Zone Serializable (and thus cachable).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2139
diff changeset
123
2131
e50a928187cd Added stubby hyk infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
124 List<HYKFormation> forms = query.list();
e50a928187cd Added stubby hyk infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
125
e50a928187cd Added stubby hyk infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
126 List<Zone> zones = new ArrayList<Zone>();
2155
8c9c40459d8f Respect rivers flow direction when looking for hyk-formations.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2148
diff changeset
127
2139
923256599afe Somewhat improved hyk handling and rendering.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2137
diff changeset
128 // Take the first one.
923256599afe Somewhat improved hyk handling and rendering.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2137
diff changeset
129 if (forms.size() >= 1) {
923256599afe Somewhat improved hyk handling and rendering.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2137
diff changeset
130 HYKFormation form = forms.get(0);
2131
e50a928187cd Added stubby hyk infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
131 // Create respective zones.
e50a928187cd Added stubby hyk infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
132 for (HYKFlowZone flowZone: form.getZones()) {
e50a928187cd Added stubby hyk infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
133 Zone z = new Zone(flowZone.getA().doubleValue(),
e50a928187cd Added stubby hyk infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
134 flowZone.getB().doubleValue(),
e50a928187cd Added stubby hyk infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
135 flowZone.getType().getName());
e50a928187cd Added stubby hyk infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
136 zones.add(z);
e50a928187cd Added stubby hyk infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
137 }
e50a928187cd Added stubby hyk infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
138 }
e50a928187cd Added stubby hyk infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
139
e50a928187cd Added stubby hyk infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
140 return zones;
e50a928187cd Added stubby hyk infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
141 }
e50a928187cd Added stubby hyk infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
142
e50a928187cd Added stubby hyk infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
143 /** Labelled section. */
2148
345a236f7075 Made HYKFactory.Zone Serializable (and thus cachable).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2139
diff changeset
144 public static class Zone implements Serializable {
2131
e50a928187cd Added stubby hyk infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
145 /** Lower end of segment. */
e50a928187cd Added stubby hyk infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
146 protected double from;
e50a928187cd Added stubby hyk infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
147 /** Upper end of segment. */
e50a928187cd Added stubby hyk infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
148 protected double to;
e50a928187cd Added stubby hyk infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
149 /** The label. */
e50a928187cd Added stubby hyk infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
150 protected String name;
e50a928187cd Added stubby hyk infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
151
e50a928187cd Added stubby hyk infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
152 /** Constructor for labelled section. */
e50a928187cd Added stubby hyk infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
153 public Zone (double from, double to, String name) {
e50a928187cd Added stubby hyk infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
154 this.from = from;
e50a928187cd Added stubby hyk infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
155 this.to = to;
e50a928187cd Added stubby hyk infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
156 this.name = name;
e50a928187cd Added stubby hyk infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
157 }
e50a928187cd Added stubby hyk infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
158
2137
04b6b6a4564d Prepare improved hyk-handling.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2131
diff changeset
159 /** Get upper value. */
04b6b6a4564d Prepare improved hyk-handling.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2131
diff changeset
160 public double getTo() {
04b6b6a4564d Prepare improved hyk-handling.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2131
diff changeset
161 return to;
04b6b6a4564d Prepare improved hyk-handling.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2131
diff changeset
162 }
04b6b6a4564d Prepare improved hyk-handling.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2131
diff changeset
163
04b6b6a4564d Prepare improved hyk-handling.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2131
diff changeset
164 /** Get lower value. */
2131
e50a928187cd Added stubby hyk infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
165 public double getFrom() {
e50a928187cd Added stubby hyk infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
166 return from;
e50a928187cd Added stubby hyk infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
167 }
e50a928187cd Added stubby hyk infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
168
2137
04b6b6a4564d Prepare improved hyk-handling.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2131
diff changeset
169 /** Get name (type). */
2131
e50a928187cd Added stubby hyk infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
170 public String getName() {
e50a928187cd Added stubby hyk infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
171 return name;
e50a928187cd Added stubby hyk infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
172 }
e50a928187cd Added stubby hyk infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
173 } // public static class Zone
e50a928187cd Added stubby hyk infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
174 }
e50a928187cd Added stubby hyk infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
175 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org