Mercurial > dive4elements > river
comparison flys-artifacts/src/main/java/org/dive4elements/river/artifacts/services/GaugeOverviewInfoService.java @ 5831:bd047b71ab37
Repaired internal references
author | Sascha L. Teichmann <teichmann@intevation.de> |
---|---|
date | Thu, 25 Apr 2013 12:06:39 +0200 |
parents | flys-artifacts/src/main/java/de/intevation/flys/artifacts/services/GaugeOverviewInfoService.java@b0173cdbbe51 |
children |
comparison
equal
deleted
inserted
replaced
5830:160f53ee0870 | 5831:bd047b71ab37 |
---|---|
1 package org.dive4elements.river.artifacts.services; | |
2 | |
3 import java.math.BigDecimal; | |
4 import java.util.List; | |
5 | |
6 import org.apache.log4j.Logger; | |
7 | |
8 import org.w3c.dom.Document; | |
9 import org.w3c.dom.Element; | |
10 | |
11 import org.dive4elements.artifacts.CallMeta; | |
12 import org.dive4elements.artifacts.GlobalContext; | |
13 | |
14 import org.dive4elements.river.model.Gauge; | |
15 import org.dive4elements.river.model.MinMaxWQ; | |
16 import org.dive4elements.river.model.Range; | |
17 | |
18 | |
19 /** | |
20 * @author <a href="mailto:bjoern.ricks@intevation.de">Björn Ricks</a> | |
21 */ | |
22 public class GaugeOverviewInfoService extends RiverInfoService { | |
23 | |
24 private static final Logger logger = Logger.getLogger( | |
25 GaugeOverviewInfoService.class); | |
26 | |
27 @Override | |
28 public Document doProcess( | |
29 Document data, | |
30 GlobalContext globalContext, | |
31 CallMeta callMeta | |
32 ) { | |
33 Document result = super.doProcess(data, globalContext, callMeta); | |
34 | |
35 logger.debug("GaugeOverviewInfoService.process"); | |
36 | |
37 Element egs = ec.create("gauges"); | |
38 | |
39 List<Gauge> gauges = river.getGauges(); | |
40 | |
41 if (logger.isDebugEnabled()) { | |
42 logger.debug("Loaded gauges: " + gauges); | |
43 } | |
44 | |
45 for (Gauge gauge: river.getGauges()) { | |
46 Element eg = ec.create("gauge"); | |
47 | |
48 String name = gauge.getName(); | |
49 if (name != null) { | |
50 ec.addAttr(eg, "name", gauge.getName(), true); | |
51 } | |
52 | |
53 String aeo = getStringValue(gauge.getAeo()); | |
54 if (aeo != null) { | |
55 ec.addAttr(eg, "aeo", aeo, true); | |
56 } | |
57 | |
58 String datum = getStringValue(gauge.getDatum()); | |
59 if (datum != null) { | |
60 ec.addAttr(eg, "datum", datum, true); | |
61 } | |
62 | |
63 Range range = gauge.getRange(); | |
64 if (range != null) { | |
65 BigDecimal a = range.getA(); | |
66 if (a != null) { | |
67 double min = a.doubleValue(); | |
68 ec.addAttr(eg, "start", Double.toString(min), true); | |
69 } | |
70 | |
71 BigDecimal b = range.getB(); | |
72 if (b != null) { | |
73 double max = range.getB().doubleValue(); | |
74 ec.addAttr(eg, "end", Double.toString(max), true); | |
75 } | |
76 } | |
77 MinMaxWQ minmaxwq = gauge.fetchMaxMinWQ(); | |
78 String minw = getStringValue(minmaxwq.getMinW()); | |
79 String maxw = getStringValue(minmaxwq.getMaxW()); | |
80 String minq = getStringValue(minmaxwq.getMinQ()); | |
81 String maxq = getStringValue(minmaxwq.getMaxQ()); | |
82 | |
83 if (minw != null) { | |
84 ec.addAttr(eg, "minw", minw, true); | |
85 } | |
86 if (maxw != null) { | |
87 ec.addAttr(eg, "maxw", maxw, true); | |
88 } | |
89 if (minq != null) { | |
90 ec.addAttr(eg, "minq", minq, true); | |
91 } | |
92 if (maxq != null) { | |
93 ec.addAttr(eg, "maxq", maxq, true); | |
94 } | |
95 | |
96 String station = getStringValue(gauge.getStation()); | |
97 if (station != null) { | |
98 ec.addAttr(eg, "station", station, true); | |
99 } | |
100 | |
101 Long official = gauge.getOfficialNumber(); | |
102 if (official != null) { | |
103 ec.addAttr(eg, "official", official.toString(), true); | |
104 } | |
105 | |
106 egs.appendChild(eg); | |
107 } | |
108 | |
109 riverele.appendChild(egs); | |
110 | |
111 return result; | |
112 } | |
113 } |