annotate flys-artifacts/src/main/java/de/intevation/flys/artifacts/services/GaugeOverviewInfoService.java @ 4255:670e98f5a441

Fixed leak while merging facets. The ThemeList that is used by OutputHelper to sort the Facets for an Output now uses a list to store the ManagedFacets. The correct order is made up by sorting the List using Collections.sort() function of the Java JDK. Therfore, the ManagedFacet class implements the Comparable interface. The return value of its compareTo(other) method depends on the value of the 'position' field.
author Ingo Weinzierl <weinzierl.ingo@googlemail.com>
date Thu, 25 Oct 2012 14:01:46 +0200
parents 5da024c2af62
children b0173cdbbe51
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 import de.intevation.artifacts.common.ArtifactNamespaceContext;
0edc05642fa4 Add new artifact service for the gauge overview
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
14 import de.intevation.artifacts.common.utils.XMLUtils;
0edc05642fa4 Add new artifact service for the gauge overview
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
15
0edc05642fa4 Add new artifact service for the gauge overview
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
16 import de.intevation.flys.artifacts.model.RiverFactory;
0edc05642fa4 Add new artifact service for the gauge overview
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
17 import de.intevation.flys.model.Gauge;
0edc05642fa4 Add new artifact service for the gauge overview
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
18 import de.intevation.flys.model.MinMaxWQ;
0edc05642fa4 Add new artifact service for the gauge overview
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
19 import de.intevation.flys.model.Range;
0edc05642fa4 Add new artifact service for the gauge overview
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
20 import de.intevation.flys.model.River;
0edc05642fa4 Add new artifact service for the gauge overview
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
21
0edc05642fa4 Add new artifact service for the gauge overview
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
22 /**
0edc05642fa4 Add new artifact service for the gauge overview
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
23 * @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
24 */
4247
5da024c2af62 Refactor GaugeOverviewInfoService and MeasurementStationInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents: 3912
diff changeset
25 public class GaugeOverviewInfoService extends RiverInfoService {
3739
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 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
28 GaugeOverviewInfoService.class);
0edc05642fa4 Add new artifact service for the gauge overview
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
29
0edc05642fa4 Add new artifact service for the gauge overview
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
30 @Override
0edc05642fa4 Add new artifact service for the gauge overview
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
31 public Document doProcess(
0edc05642fa4 Add new artifact service for the gauge overview
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
32 Document data,
0edc05642fa4 Add new artifact service for the gauge overview
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
33 GlobalContext globalContext,
0edc05642fa4 Add new artifact service for the gauge overview
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
34 CallMeta callMeta
0edc05642fa4 Add new artifact service for the gauge overview
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
35 ) {
4247
5da024c2af62 Refactor GaugeOverviewInfoService and MeasurementStationInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents: 3912
diff changeset
36 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
37
4247
5da024c2af62 Refactor GaugeOverviewInfoService and MeasurementStationInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents: 3912
diff changeset
38 logger.debug("GaugeOverviewInfoService.process");
3739
0edc05642fa4 Add new artifact service for the gauge overview
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
39
0edc05642fa4 Add new artifact service for the gauge overview
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
40 Element egs = ec.create("gauges");
0edc05642fa4 Add new artifact service for the gauge overview
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
41
0edc05642fa4 Add new artifact service for the gauge overview
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
42 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
43
99f80469ba2b Pegelinfo: Made generation of datum and aeo NPE proof.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3747
diff changeset
44 if (logger.isDebugEnabled()) {
99f80469ba2b Pegelinfo: Made generation of datum and aeo NPE proof.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3747
diff changeset
45 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
46 }
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 for (Gauge gauge: river.getGauges()) {
0edc05642fa4 Add new artifact service for the gauge overview
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
49 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
50
3739
0edc05642fa4 Add new artifact service for the gauge overview
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
51 String name = gauge.getName();
0edc05642fa4 Add new artifact service for the gauge overview
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
52 if (name != null) {
0edc05642fa4 Add new artifact service for the gauge overview
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
53 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
54 }
0edc05642fa4 Add new artifact service for the gauge overview
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
55
4247
5da024c2af62 Refactor GaugeOverviewInfoService and MeasurementStationInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents: 3912
diff changeset
56 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
57 if (aeo != null) {
99f80469ba2b Pegelinfo: Made generation of datum and aeo NPE proof.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3747
diff changeset
58 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
59 }
99f80469ba2b Pegelinfo: Made generation of datum and aeo NPE proof.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3747
diff changeset
60
4247
5da024c2af62 Refactor GaugeOverviewInfoService and MeasurementStationInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents: 3912
diff changeset
61 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
62 if (datum != null) {
99f80469ba2b Pegelinfo: Made generation of datum and aeo NPE proof.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3747
diff changeset
63 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
64 }
99f80469ba2b Pegelinfo: Made generation of datum and aeo NPE proof.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3747
diff changeset
65
3739
0edc05642fa4 Add new artifact service for the gauge overview
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
66 Range range = gauge.getRange();
0edc05642fa4 Add new artifact service for the gauge overview
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
67 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
68 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
69 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
70 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
71 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
72 }
3739
0edc05642fa4 Add new artifact service for the gauge overview
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
73
0edc05642fa4 Add new artifact service for the gauge overview
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
74 BigDecimal b = range.getB();
0edc05642fa4 Add new artifact service for the gauge overview
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
75 if (b != null) {
0edc05642fa4 Add new artifact service for the gauge overview
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
76 double max = range.getB().doubleValue();
0edc05642fa4 Add new artifact service for the gauge overview
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
77 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
78 }
0edc05642fa4 Add new artifact service for the gauge overview
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
79 }
0edc05642fa4 Add new artifact service for the gauge overview
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
80 MinMaxWQ minmaxwq = gauge.fetchMaxMinWQ();
4247
5da024c2af62 Refactor GaugeOverviewInfoService and MeasurementStationInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents: 3912
diff changeset
81 String minw = getStringValue(minmaxwq.getMinW());
5da024c2af62 Refactor GaugeOverviewInfoService and MeasurementStationInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents: 3912
diff changeset
82 String maxw = getStringValue(minmaxwq.getMaxW());
5da024c2af62 Refactor GaugeOverviewInfoService and MeasurementStationInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents: 3912
diff changeset
83 String minq = getStringValue(minmaxwq.getMinQ());
5da024c2af62 Refactor GaugeOverviewInfoService and MeasurementStationInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents: 3912
diff changeset
84 String maxq = getStringValue(minmaxwq.getMaxQ());
3739
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 (minw != null) {
0edc05642fa4 Add new artifact service for the gauge overview
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
87 ec.addAttr(eg, "minw", minw, 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 (maxw != null) {
0edc05642fa4 Add new artifact service for the gauge overview
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
90 ec.addAttr(eg, "maxw", maxw, 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 (minq != null) {
0edc05642fa4 Add new artifact service for the gauge overview
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
93 ec.addAttr(eg, "minq", minq, 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 if (maxq != null) {
0edc05642fa4 Add new artifact service for the gauge overview
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
96 ec.addAttr(eg, "maxq", maxq, true);
0edc05642fa4 Add new artifact service for the gauge overview
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
97 }
0edc05642fa4 Add new artifact service for the gauge overview
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
98
4247
5da024c2af62 Refactor GaugeOverviewInfoService and MeasurementStationInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents: 3912
diff changeset
99 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
100 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
101 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
102 }
a5f65e8983be Merged revisions 5501-5502,5504-5508,5511-5513,5516-5519 via svnmerge from
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 3753
diff changeset
103
3896
82109cea32d2 Return also the official gauge number in a service response
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3895
diff changeset
104 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
105 if (official != null) {
82109cea32d2 Return also the official gauge number in a service response
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3895
diff changeset
106 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
107 }
82109cea32d2 Return also the official gauge number in a service response
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3895
diff changeset
108
3739
0edc05642fa4 Add new artifact service for the gauge overview
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
109 egs.appendChild(eg);
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
4247
5da024c2af62 Refactor GaugeOverviewInfoService and MeasurementStationInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents: 3912
diff changeset
112 riverele.appendChild(egs);
3739
0edc05642fa4 Add new artifact service for the gauge overview
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
113
0edc05642fa4 Add new artifact service for the gauge overview
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
114 return result;
0edc05642fa4 Add new artifact service for the gauge overview
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
115 }
0edc05642fa4 Add new artifact service for the gauge overview
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
116 }

http://dive4elements.wald.intevation.org