Mercurial > dive4elements > river
annotate flys-artifacts/src/main/java/de/intevation/flys/artifacts/services/GaugeOverviewInfoService.java @ 5772:c0d0b9fd1aa8
issue1276: Re-enable fixation autorecommend at discharge_curves.
author | Felix Wolfsteller <felix.wolfsteller@intevation.de> |
---|---|
date | Fri, 19 Apr 2013 09:22:44 +0200 |
parents | b0173cdbbe51 |
children |
rev | line source |
---|---|
3739
0edc05642fa4
Add new artifact service for the gauge overview
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
1 package de.intevation.flys.artifacts.services; |
0edc05642fa4
Add new artifact service for the gauge overview
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
2 |
0edc05642fa4
Add new artifact service for the gauge overview
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
3 import java.math.BigDecimal; |
0edc05642fa4
Add new artifact service for the gauge overview
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
4 import java.util.List; |
0edc05642fa4
Add new artifact service for the gauge overview
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
5 |
0edc05642fa4
Add new artifact service for the gauge overview
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
6 import org.apache.log4j.Logger; |
0edc05642fa4
Add new artifact service for the gauge overview
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
7 |
0edc05642fa4
Add new artifact service for the gauge overview
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
8 import org.w3c.dom.Document; |
0edc05642fa4
Add new artifact service for the gauge overview
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
9 import org.w3c.dom.Element; |
0edc05642fa4
Add new artifact service for the gauge overview
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
10 |
0edc05642fa4
Add new artifact service for the gauge overview
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
11 import de.intevation.artifacts.CallMeta; |
0edc05642fa4
Add new artifact service for the gauge overview
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
12 import de.intevation.artifacts.GlobalContext; |
0edc05642fa4
Add new artifact service for the gauge overview
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
13 |
0edc05642fa4
Add new artifact service for the gauge overview
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
14 import de.intevation.flys.model.Gauge; |
0edc05642fa4
Add new artifact service for the gauge overview
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
15 import de.intevation.flys.model.MinMaxWQ; |
0edc05642fa4
Add new artifact service for the gauge overview
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
16 import de.intevation.flys.model.Range; |
4343
b0173cdbbe51
Removed obsolete imports.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4247
diff
changeset
|
17 |
3739
0edc05642fa4
Add new artifact service for the gauge overview
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
18 |
0edc05642fa4
Add new artifact service for the gauge overview
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
19 /** |
0edc05642fa4
Add new artifact service for the gauge overview
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
20 * @author <a href="mailto:bjoern.ricks@intevation.de">Björn Ricks</a> |
0edc05642fa4
Add new artifact service for the gauge overview
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
21 */ |
4247
5da024c2af62
Refactor GaugeOverviewInfoService and MeasurementStationInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents:
3912
diff
changeset
|
22 public class GaugeOverviewInfoService extends RiverInfoService { |
3739
0edc05642fa4
Add new artifact service for the gauge overview
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
23 |
0edc05642fa4
Add new artifact service for the gauge overview
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
24 private static final Logger logger = Logger.getLogger( |
0edc05642fa4
Add new artifact service for the gauge overview
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
25 GaugeOverviewInfoService.class); |
0edc05642fa4
Add new artifact service for the gauge overview
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
26 |
0edc05642fa4
Add new artifact service for the gauge overview
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
27 @Override |
0edc05642fa4
Add new artifact service for the gauge overview
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
28 public Document doProcess( |
0edc05642fa4
Add new artifact service for the gauge overview
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
29 Document data, |
0edc05642fa4
Add new artifact service for the gauge overview
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
30 GlobalContext globalContext, |
0edc05642fa4
Add new artifact service for the gauge overview
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
31 CallMeta callMeta |
0edc05642fa4
Add new artifact service for the gauge overview
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
32 ) { |
4247
5da024c2af62
Refactor GaugeOverviewInfoService and MeasurementStationInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents:
3912
diff
changeset
|
33 Document result = super.doProcess(data, globalContext, callMeta); |
3739
0edc05642fa4
Add new artifact service for the gauge overview
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
34 |
4247
5da024c2af62
Refactor GaugeOverviewInfoService and MeasurementStationInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents:
3912
diff
changeset
|
35 logger.debug("GaugeOverviewInfoService.process"); |
3739
0edc05642fa4
Add new artifact service for the gauge overview
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
36 |
0edc05642fa4
Add new artifact service for the gauge overview
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
37 Element egs = ec.create("gauges"); |
0edc05642fa4
Add new artifact service for the gauge overview
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
38 |
0edc05642fa4
Add new artifact service for the gauge overview
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
39 List<Gauge> gauges = river.getGauges(); |
3748
99f80469ba2b
Pegelinfo: Made generation of datum and aeo NPE proof.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3747
diff
changeset
|
40 |
99f80469ba2b
Pegelinfo: Made generation of datum and aeo NPE proof.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3747
diff
changeset
|
41 if (logger.isDebugEnabled()) { |
99f80469ba2b
Pegelinfo: Made generation of datum and aeo NPE proof.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3747
diff
changeset
|
42 logger.debug("Loaded gauges: " + gauges); |
99f80469ba2b
Pegelinfo: Made generation of datum and aeo NPE proof.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3747
diff
changeset
|
43 } |
99f80469ba2b
Pegelinfo: Made generation of datum and aeo NPE proof.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3747
diff
changeset
|
44 |
3739
0edc05642fa4
Add new artifact service for the gauge overview
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
45 for (Gauge gauge: river.getGauges()) { |
0edc05642fa4
Add new artifact service for the gauge overview
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
46 Element eg = ec.create("gauge"); |
3748
99f80469ba2b
Pegelinfo: Made generation of datum and aeo NPE proof.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3747
diff
changeset
|
47 |
3739
0edc05642fa4
Add new artifact service for the gauge overview
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
48 String name = gauge.getName(); |
0edc05642fa4
Add new artifact service for the gauge overview
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
49 if (name != null) { |
0edc05642fa4
Add new artifact service for the gauge overview
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
50 ec.addAttr(eg, "name", gauge.getName(), true); |
0edc05642fa4
Add new artifact service for the gauge overview
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
51 } |
0edc05642fa4
Add new artifact service for the gauge overview
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
52 |
4247
5da024c2af62
Refactor GaugeOverviewInfoService and MeasurementStationInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents:
3912
diff
changeset
|
53 String aeo = getStringValue(gauge.getAeo()); |
3748
99f80469ba2b
Pegelinfo: Made generation of datum and aeo NPE proof.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3747
diff
changeset
|
54 if (aeo != null) { |
99f80469ba2b
Pegelinfo: Made generation of datum and aeo NPE proof.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3747
diff
changeset
|
55 ec.addAttr(eg, "aeo", aeo, true); |
99f80469ba2b
Pegelinfo: Made generation of datum and aeo NPE proof.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3747
diff
changeset
|
56 } |
99f80469ba2b
Pegelinfo: Made generation of datum and aeo NPE proof.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3747
diff
changeset
|
57 |
4247
5da024c2af62
Refactor GaugeOverviewInfoService and MeasurementStationInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents:
3912
diff
changeset
|
58 String datum = getStringValue(gauge.getDatum()); |
3748
99f80469ba2b
Pegelinfo: Made generation of datum and aeo NPE proof.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3747
diff
changeset
|
59 if (datum != null) { |
99f80469ba2b
Pegelinfo: Made generation of datum and aeo NPE proof.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3747
diff
changeset
|
60 ec.addAttr(eg, "datum", datum, true); |
99f80469ba2b
Pegelinfo: Made generation of datum and aeo NPE proof.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3747
diff
changeset
|
61 } |
99f80469ba2b
Pegelinfo: Made generation of datum and aeo NPE proof.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3747
diff
changeset
|
62 |
3739
0edc05642fa4
Add new artifact service for the gauge overview
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
63 Range range = gauge.getRange(); |
0edc05642fa4
Add new artifact service for the gauge overview
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
64 if (range != null) { |
3753
b3fdb5a12613
Add also min and max q values to the river info.
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
3748
diff
changeset
|
65 BigDecimal a = range.getA(); |
b3fdb5a12613
Add also min and max q values to the river info.
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
3748
diff
changeset
|
66 if (a != null) { |
b3fdb5a12613
Add also min and max q values to the river info.
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
3748
diff
changeset
|
67 double min = a.doubleValue(); |
b3fdb5a12613
Add also min and max q values to the river info.
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
3748
diff
changeset
|
68 ec.addAttr(eg, "start", Double.toString(min), true); |
b3fdb5a12613
Add also min and max q values to the river info.
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
3748
diff
changeset
|
69 } |
3739
0edc05642fa4
Add new artifact service for the gauge overview
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
70 |
0edc05642fa4
Add new artifact service for the gauge overview
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
71 BigDecimal b = range.getB(); |
0edc05642fa4
Add new artifact service for the gauge overview
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
72 if (b != null) { |
0edc05642fa4
Add new artifact service for the gauge overview
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
73 double max = range.getB().doubleValue(); |
0edc05642fa4
Add new artifact service for the gauge overview
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
74 ec.addAttr(eg, "end", Double.toString(max), true); |
0edc05642fa4
Add new artifact service for the gauge overview
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
75 } |
0edc05642fa4
Add new artifact service for the gauge overview
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
76 } |
0edc05642fa4
Add new artifact service for the gauge overview
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
77 MinMaxWQ minmaxwq = gauge.fetchMaxMinWQ(); |
4247
5da024c2af62
Refactor GaugeOverviewInfoService and MeasurementStationInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents:
3912
diff
changeset
|
78 String minw = getStringValue(minmaxwq.getMinW()); |
5da024c2af62
Refactor GaugeOverviewInfoService and MeasurementStationInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents:
3912
diff
changeset
|
79 String maxw = getStringValue(minmaxwq.getMaxW()); |
5da024c2af62
Refactor GaugeOverviewInfoService and MeasurementStationInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents:
3912
diff
changeset
|
80 String minq = getStringValue(minmaxwq.getMinQ()); |
5da024c2af62
Refactor GaugeOverviewInfoService and MeasurementStationInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents:
3912
diff
changeset
|
81 String maxq = getStringValue(minmaxwq.getMaxQ()); |
3739
0edc05642fa4
Add new artifact service for the gauge overview
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
82 |
0edc05642fa4
Add new artifact service for the gauge overview
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
83 if (minw != null) { |
0edc05642fa4
Add new artifact service for the gauge overview
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
84 ec.addAttr(eg, "minw", minw, true); |
0edc05642fa4
Add new artifact service for the gauge overview
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
85 } |
0edc05642fa4
Add new artifact service for the gauge overview
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
86 if (maxw != null) { |
0edc05642fa4
Add new artifact service for the gauge overview
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
87 ec.addAttr(eg, "maxw", maxw, true); |
0edc05642fa4
Add new artifact service for the gauge overview
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
88 } |
0edc05642fa4
Add new artifact service for the gauge overview
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
89 if (minq != null) { |
0edc05642fa4
Add new artifact service for the gauge overview
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
90 ec.addAttr(eg, "minq", minq, true); |
0edc05642fa4
Add new artifact service for the gauge overview
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
91 } |
0edc05642fa4
Add new artifact service for the gauge overview
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
92 if (maxq != null) { |
0edc05642fa4
Add new artifact service for the gauge overview
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
93 ec.addAttr(eg, "maxq", maxq, true); |
0edc05642fa4
Add new artifact service for the gauge overview
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
94 } |
0edc05642fa4
Add new artifact service for the gauge overview
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
95 |
4247
5da024c2af62
Refactor GaugeOverviewInfoService and MeasurementStationInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents:
3912
diff
changeset
|
96 String station = getStringValue(gauge.getStation()); |
3785
a5f65e8983be
Merged revisions 5501-5502,5504-5508,5511-5513,5516-5519 via svnmerge from
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3753
diff
changeset
|
97 if (station != null) { |
a5f65e8983be
Merged revisions 5501-5502,5504-5508,5511-5513,5516-5519 via svnmerge from
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3753
diff
changeset
|
98 ec.addAttr(eg, "station", station, true); |
a5f65e8983be
Merged revisions 5501-5502,5504-5508,5511-5513,5516-5519 via svnmerge from
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3753
diff
changeset
|
99 } |
a5f65e8983be
Merged revisions 5501-5502,5504-5508,5511-5513,5516-5519 via svnmerge from
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3753
diff
changeset
|
100 |
3896
82109cea32d2
Return also the official gauge number in a service response
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
3895
diff
changeset
|
101 Long official = gauge.getOfficialNumber(); |
82109cea32d2
Return also the official gauge number in a service response
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
3895
diff
changeset
|
102 if (official != null) { |
82109cea32d2
Return also the official gauge number in a service response
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
3895
diff
changeset
|
103 ec.addAttr(eg, "official", official.toString(), true); |
82109cea32d2
Return also the official gauge number in a service response
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
3895
diff
changeset
|
104 } |
82109cea32d2
Return also the official gauge number in a service response
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
3895
diff
changeset
|
105 |
3739
0edc05642fa4
Add new artifact service for the gauge overview
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
106 egs.appendChild(eg); |
0edc05642fa4
Add new artifact service for the gauge overview
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
107 } |
0edc05642fa4
Add new artifact service for the gauge overview
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
108 |
4247
5da024c2af62
Refactor GaugeOverviewInfoService and MeasurementStationInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents:
3912
diff
changeset
|
109 riverele.appendChild(egs); |
3739
0edc05642fa4
Add new artifact service for the gauge overview
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
110 |
0edc05642fa4
Add new artifact service for the gauge overview
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
111 return result; |
0edc05642fa4
Add new artifact service for the gauge overview
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
112 } |
0edc05642fa4
Add new artifact service for the gauge overview
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
113 } |