Mercurial > dive4elements > river
annotate flys-artifacts/src/main/java/de/intevation/flys/artifacts/services/MeasurementStationInfoService.java @ 4322:f36550788add
NaviChartOutputTab: Get relevant data also from not-fixationanalysis-artifacts.
author | Felix Wolfsteller <felix.wolfsteller@intevation.de> |
---|---|
date | Tue, 30 Oct 2012 12:04:49 +0100 |
parents | 3fffd7d5d67d |
children | 4980659b2f22 |
rev | line source |
---|---|
4246
cac0878b4a92
Add a service to return measurement stations of a river
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
1 package de.intevation.flys.artifacts.services; |
cac0878b4a92
Add a service to return measurement stations of a river
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
2 |
cac0878b4a92
Add a service to return measurement stations of a river
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
3 import java.math.BigDecimal; |
4289
3fffd7d5d67d
Add observation TimeInteval to the artifact MeasurementStationInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents:
4264
diff
changeset
|
4 import java.text.DateFormat; |
3fffd7d5d67d
Add observation TimeInteval to the artifact MeasurementStationInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents:
4264
diff
changeset
|
5 import java.util.Date; |
4246
cac0878b4a92
Add a service to return measurement stations of a river
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
6 import java.util.List; |
4289
3fffd7d5d67d
Add observation TimeInteval to the artifact MeasurementStationInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents:
4264
diff
changeset
|
7 import java.util.Locale; |
4246
cac0878b4a92
Add a service to return measurement stations of a river
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
8 |
cac0878b4a92
Add a service to return measurement stations of a river
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
9 import org.apache.log4j.Logger; |
cac0878b4a92
Add a service to return measurement stations of a river
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
10 |
cac0878b4a92
Add a service to return measurement stations of a river
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
11 import org.w3c.dom.Document; |
cac0878b4a92
Add a service to return measurement stations of a river
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
12 import org.w3c.dom.Element; |
cac0878b4a92
Add a service to return measurement stations of a river
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
13 |
cac0878b4a92
Add a service to return measurement stations of a river
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
14 import de.intevation.artifacts.CallMeta; |
cac0878b4a92
Add a service to return measurement stations of a river
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
15 import de.intevation.artifacts.GlobalContext; |
cac0878b4a92
Add a service to return measurement stations of a river
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
16 import de.intevation.artifacts.common.ArtifactNamespaceContext; |
cac0878b4a92
Add a service to return measurement stations of a river
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
17 import de.intevation.artifacts.common.utils.XMLUtils; |
cac0878b4a92
Add a service to return measurement stations of a river
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
18 |
cac0878b4a92
Add a service to return measurement stations of a river
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
19 import de.intevation.flys.artifacts.model.RiverFactory; |
cac0878b4a92
Add a service to return measurement stations of a river
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
20 import de.intevation.flys.model.MeasurementStation; |
cac0878b4a92
Add a service to return measurement stations of a river
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
21 import de.intevation.flys.model.Range; |
cac0878b4a92
Add a service to return measurement stations of a river
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
22 import de.intevation.flys.model.River; |
4289
3fffd7d5d67d
Add observation TimeInteval to the artifact MeasurementStationInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents:
4264
diff
changeset
|
23 import de.intevation.flys.model.TimeInterval; |
4246
cac0878b4a92
Add a service to return measurement stations of a river
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
24 |
cac0878b4a92
Add a service to return measurement stations of a river
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
25 /** |
cac0878b4a92
Add a service to return measurement stations of a river
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
26 * @author <a href="mailto:bjoern.ricks@intevation.de">Björn Ricks</a> |
cac0878b4a92
Add a service to return measurement stations of a river
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
27 */ |
4247
5da024c2af62
Refactor GaugeOverviewInfoService and MeasurementStationInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents:
4246
diff
changeset
|
28 public class MeasurementStationInfoService extends RiverInfoService { |
4246
cac0878b4a92
Add a service to return measurement stations of a river
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
29 |
cac0878b4a92
Add a service to return measurement stations of a river
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
30 private static final Logger logger = Logger.getLogger( |
4264
31c017420502
Use correct class for logger in MeasurementStationInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents:
4263
diff
changeset
|
31 MeasurementStationInfoService.class); |
4246
cac0878b4a92
Add a service to return measurement stations of a river
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
32 |
4289
3fffd7d5d67d
Add observation TimeInteval to the artifact MeasurementStationInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents:
4264
diff
changeset
|
33 public static final DateFormat DATE_FORMAT = DateFormat.getDateInstance( |
3fffd7d5d67d
Add observation TimeInteval to the artifact MeasurementStationInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents:
4264
diff
changeset
|
34 DateFormat.SHORT, Locale.GERMANY); |
3fffd7d5d67d
Add observation TimeInteval to the artifact MeasurementStationInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents:
4264
diff
changeset
|
35 |
4246
cac0878b4a92
Add a service to return measurement stations of a river
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
36 @Override |
cac0878b4a92
Add a service to return measurement stations of a river
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
37 public Document doProcess( |
cac0878b4a92
Add a service to return measurement stations of a river
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
38 Document data, |
cac0878b4a92
Add a service to return measurement stations of a river
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
39 GlobalContext globalContext, |
cac0878b4a92
Add a service to return measurement stations of a river
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
40 CallMeta callMeta |
cac0878b4a92
Add a service to return measurement stations of a river
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
41 ) { |
4247
5da024c2af62
Refactor GaugeOverviewInfoService and MeasurementStationInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents:
4246
diff
changeset
|
42 Document result = super.doProcess(data, globalContext, callMeta); |
4246
cac0878b4a92
Add a service to return measurement stations of a river
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
43 |
cac0878b4a92
Add a service to return measurement stations of a river
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
44 Element egs = ec.create("measurement-stations"); |
cac0878b4a92
Add a service to return measurement stations of a river
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
45 |
cac0878b4a92
Add a service to return measurement stations of a river
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
46 List<MeasurementStation> mstations = river.getMeasurementStations(); |
cac0878b4a92
Add a service to return measurement stations of a river
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
47 |
cac0878b4a92
Add a service to return measurement stations of a river
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
48 if (logger.isDebugEnabled()) { |
cac0878b4a92
Add a service to return measurement stations of a river
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
49 logger.debug("Loaded stations: " + mstations); |
cac0878b4a92
Add a service to return measurement stations of a river
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
50 } |
cac0878b4a92
Add a service to return measurement stations of a river
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
51 |
cac0878b4a92
Add a service to return measurement stations of a river
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
52 for (MeasurementStation mstation: mstations) { |
cac0878b4a92
Add a service to return measurement stations of a river
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
53 Element eg = ec.create("measurement-station"); |
cac0878b4a92
Add a service to return measurement stations of a river
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
54 |
cac0878b4a92
Add a service to return measurement stations of a river
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
55 String name = mstation.getName(); |
cac0878b4a92
Add a service to return measurement stations of a river
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
56 if (name != null) { |
cac0878b4a92
Add a service to return measurement stations of a river
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
57 ec.addAttr(eg, "name", name, true); |
cac0878b4a92
Add a service to return measurement stations of a river
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
58 } |
cac0878b4a92
Add a service to return measurement stations of a river
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
59 |
4263
6abc8507e3c8
Add operator and station id to the artifact xml
Björn Ricks <bjoern.ricks@intevation.de>
parents:
4247
diff
changeset
|
60 Integer id = mstation.getId(); |
6abc8507e3c8
Add operator and station id to the artifact xml
Björn Ricks <bjoern.ricks@intevation.de>
parents:
4247
diff
changeset
|
61 if (id != null) { |
6abc8507e3c8
Add operator and station id to the artifact xml
Björn Ricks <bjoern.ricks@intevation.de>
parents:
4247
diff
changeset
|
62 ec.addAttr(eg, "id", Integer.toString(id), true); |
6abc8507e3c8
Add operator and station id to the artifact xml
Björn Ricks <bjoern.ricks@intevation.de>
parents:
4247
diff
changeset
|
63 } |
6abc8507e3c8
Add operator and station id to the artifact xml
Björn Ricks <bjoern.ricks@intevation.de>
parents:
4247
diff
changeset
|
64 |
4246
cac0878b4a92
Add a service to return measurement stations of a river
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
65 String type = mstation.getMeasurementType(); |
cac0878b4a92
Add a service to return measurement stations of a river
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
66 if (type != null) { |
cac0878b4a92
Add a service to return measurement stations of a river
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
67 ec.addAttr(eg, "type", type, true); |
cac0878b4a92
Add a service to return measurement stations of a river
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
68 } |
cac0878b4a92
Add a service to return measurement stations of a river
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
69 |
cac0878b4a92
Add a service to return measurement stations of a river
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
70 String riverside = mstation.getRiverside(); |
cac0878b4a92
Add a service to return measurement stations of a river
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
71 if (riverside != null) { |
cac0878b4a92
Add a service to return measurement stations of a river
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
72 ec.addAttr(eg, "riverside", riverside, true); |
cac0878b4a92
Add a service to return measurement stations of a river
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
73 } |
cac0878b4a92
Add a service to return measurement stations of a river
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
74 |
cac0878b4a92
Add a service to return measurement stations of a river
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
75 Double station = mstation.getStation(); |
cac0878b4a92
Add a service to return measurement stations of a river
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
76 if (station != null) { |
cac0878b4a92
Add a service to return measurement stations of a river
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
77 ec.addAttr(eg, "station", Double.toString(station), true); |
cac0878b4a92
Add a service to return measurement stations of a river
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
78 } |
cac0878b4a92
Add a service to return measurement stations of a river
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
79 |
cac0878b4a92
Add a service to return measurement stations of a river
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
80 Range range = mstation.getRange(); |
cac0878b4a92
Add a service to return measurement stations of a river
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
81 if (range != null) { |
cac0878b4a92
Add a service to return measurement stations of a river
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
82 BigDecimal a = range.getA(); |
cac0878b4a92
Add a service to return measurement stations of a river
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
83 if (a != null) { |
cac0878b4a92
Add a service to return measurement stations of a river
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
84 ec.addAttr(eg, "start", getStringValue(a), true); |
cac0878b4a92
Add a service to return measurement stations of a river
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
85 } |
cac0878b4a92
Add a service to return measurement stations of a river
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
86 |
cac0878b4a92
Add a service to return measurement stations of a river
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
87 BigDecimal b = range.getB(); |
cac0878b4a92
Add a service to return measurement stations of a river
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
88 if (b != null) { |
cac0878b4a92
Add a service to return measurement stations of a river
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
89 ec.addAttr(eg, "end", getStringValue(b), true); |
cac0878b4a92
Add a service to return measurement stations of a river
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
90 } |
cac0878b4a92
Add a service to return measurement stations of a river
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
91 } |
cac0878b4a92
Add a service to return measurement stations of a river
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
92 |
4263
6abc8507e3c8
Add operator and station id to the artifact xml
Björn Ricks <bjoern.ricks@intevation.de>
parents:
4247
diff
changeset
|
93 String moperator = mstation.getOperator(); |
6abc8507e3c8
Add operator and station id to the artifact xml
Björn Ricks <bjoern.ricks@intevation.de>
parents:
4247
diff
changeset
|
94 if (moperator != null) { |
6abc8507e3c8
Add operator and station id to the artifact xml
Björn Ricks <bjoern.ricks@intevation.de>
parents:
4247
diff
changeset
|
95 ec.addAttr(eg, "operator", moperator, true); |
6abc8507e3c8
Add operator and station id to the artifact xml
Björn Ricks <bjoern.ricks@intevation.de>
parents:
4247
diff
changeset
|
96 } |
6abc8507e3c8
Add operator and station id to the artifact xml
Björn Ricks <bjoern.ricks@intevation.de>
parents:
4247
diff
changeset
|
97 |
4289
3fffd7d5d67d
Add observation TimeInteval to the artifact MeasurementStationInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents:
4264
diff
changeset
|
98 TimeInterval tinterval = mstation.getObservationTimerange(); |
3fffd7d5d67d
Add observation TimeInteval to the artifact MeasurementStationInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents:
4264
diff
changeset
|
99 if (tinterval != null) { |
3fffd7d5d67d
Add observation TimeInteval to the artifact MeasurementStationInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents:
4264
diff
changeset
|
100 Date tstart = tinterval.getStartTime(); |
3fffd7d5d67d
Add observation TimeInteval to the artifact MeasurementStationInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents:
4264
diff
changeset
|
101 if (tstart != null) { |
3fffd7d5d67d
Add observation TimeInteval to the artifact MeasurementStationInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents:
4264
diff
changeset
|
102 ec.addAttr(eg, "starttime", DATE_FORMAT.format(tstart), |
3fffd7d5d67d
Add observation TimeInteval to the artifact MeasurementStationInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents:
4264
diff
changeset
|
103 true); |
3fffd7d5d67d
Add observation TimeInteval to the artifact MeasurementStationInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents:
4264
diff
changeset
|
104 } |
3fffd7d5d67d
Add observation TimeInteval to the artifact MeasurementStationInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents:
4264
diff
changeset
|
105 Date tstop = tinterval.getStopTime(); |
3fffd7d5d67d
Add observation TimeInteval to the artifact MeasurementStationInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents:
4264
diff
changeset
|
106 if (tstop != null) { |
3fffd7d5d67d
Add observation TimeInteval to the artifact MeasurementStationInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents:
4264
diff
changeset
|
107 ec.addAttr(eg, "stoptime", DATE_FORMAT.format(tstop), |
3fffd7d5d67d
Add observation TimeInteval to the artifact MeasurementStationInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents:
4264
diff
changeset
|
108 true); |
3fffd7d5d67d
Add observation TimeInteval to the artifact MeasurementStationInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents:
4264
diff
changeset
|
109 } |
3fffd7d5d67d
Add observation TimeInteval to the artifact MeasurementStationInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents:
4264
diff
changeset
|
110 } |
3fffd7d5d67d
Add observation TimeInteval to the artifact MeasurementStationInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents:
4264
diff
changeset
|
111 |
4246
cac0878b4a92
Add a service to return measurement stations of a river
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
112 egs.appendChild(eg); |
cac0878b4a92
Add a service to return measurement stations of a river
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
113 } |
cac0878b4a92
Add a service to return measurement stations of a river
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
114 |
4247
5da024c2af62
Refactor GaugeOverviewInfoService and MeasurementStationInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents:
4246
diff
changeset
|
115 this.riverele.appendChild(egs); |
4246
cac0878b4a92
Add a service to return measurement stations of a river
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
116 |
cac0878b4a92
Add a service to return measurement stations of a river
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
117 return result; |
cac0878b4a92
Add a service to return measurement stations of a river
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
118 } |
cac0878b4a92
Add a service to return measurement stations of a river
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
119 |
cac0878b4a92
Add a service to return measurement stations of a river
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
120 } |