annotate flys-artifacts/src/main/java/de/intevation/flys/artifacts/services/MeasurementStationInfoService.java @ 4346:603233b5a719

Removed doExtreme*() as its implemented in own generator now, opened visibility of field artifact for refac.
author Felix Wolfsteller <felix.wolfsteller@intevation.de>
date Thu, 01 Nov 2012 12:12:53 +0100
parents c6db11e3b83a
children 3937c6a85db4
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
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.flys.model.MeasurementStation;
4324
4980659b2f22 Add gauge name to the measurement station xml response
Björn Ricks <bjoern.ricks@intevation.de>
parents: 4289
diff changeset
18 import de.intevation.flys.model.Gauge;
4246
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.model.Range;
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.River;
4289
3fffd7d5d67d Add observation TimeInteval to the artifact MeasurementStationInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents: 4264
diff changeset
21 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
22
cac0878b4a92 Add a service to return measurement stations of a river
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
23 /**
cac0878b4a92 Add a service to return measurement stations of a river
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
24 * @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
25 */
4247
5da024c2af62 Refactor GaugeOverviewInfoService and MeasurementStationInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents: 4246
diff changeset
26 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
27
cac0878b4a92 Add a service to return measurement stations of a river
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
28 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
29 MeasurementStationInfoService.class);
4246
cac0878b4a92 Add a service to return measurement stations of a river
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
30
4289
3fffd7d5d67d Add observation TimeInteval to the artifact MeasurementStationInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents: 4264
diff changeset
31 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
32 DateFormat.SHORT, Locale.GERMANY);
3fffd7d5d67d Add observation TimeInteval to the artifact MeasurementStationInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents: 4264
diff changeset
33
4246
cac0878b4a92 Add a service to return measurement stations of a river
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
34 @Override
cac0878b4a92 Add a service to return measurement stations of a river
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
35 public Document doProcess(
cac0878b4a92 Add a service to return measurement stations of a river
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
36 Document data,
cac0878b4a92 Add a service to return measurement stations of a river
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
37 GlobalContext globalContext,
cac0878b4a92 Add a service to return measurement stations of a river
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
38 CallMeta callMeta
cac0878b4a92 Add a service to return measurement stations of a river
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
39 ) {
4247
5da024c2af62 Refactor GaugeOverviewInfoService and MeasurementStationInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents: 4246
diff changeset
40 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
41
cac0878b4a92 Add a service to return measurement stations of a river
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
42 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
43
cac0878b4a92 Add a service to return measurement stations of a river
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
44 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
45
cac0878b4a92 Add a service to return measurement stations of a river
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
46 if (logger.isDebugEnabled()) {
cac0878b4a92 Add a service to return measurement stations of a river
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
47 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
48 }
cac0878b4a92 Add a service to return measurement stations of a river
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
49
cac0878b4a92 Add a service to return measurement stations of a river
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
50 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
51 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
52
cac0878b4a92 Add a service to return measurement stations of a river
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
53 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
54 if (name != null) {
cac0878b4a92 Add a service to return measurement stations of a river
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
55 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
56 }
cac0878b4a92 Add a service to return measurement stations of a river
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
57
4263
6abc8507e3c8 Add operator and station id to the artifact xml
Björn Ricks <bjoern.ricks@intevation.de>
parents: 4247
diff changeset
58 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
59 if (id != null) {
6abc8507e3c8 Add operator and station id to the artifact xml
Björn Ricks <bjoern.ricks@intevation.de>
parents: 4247
diff changeset
60 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
61 }
6abc8507e3c8 Add operator and station id to the artifact xml
Björn Ricks <bjoern.ricks@intevation.de>
parents: 4247
diff changeset
62
4246
cac0878b4a92 Add a service to return measurement stations of a river
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
63 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
64 if (type != null) {
cac0878b4a92 Add a service to return measurement stations of a river
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
65 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
66 }
cac0878b4a92 Add a service to return measurement stations of a river
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
67
cac0878b4a92 Add a service to return measurement stations of a river
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
68 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
69 if (riverside != null) {
cac0878b4a92 Add a service to return measurement stations of a river
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
70 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
71 }
cac0878b4a92 Add a service to return measurement stations of a river
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
72
cac0878b4a92 Add a service to return measurement stations of a river
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
73 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
74 if (station != null) {
cac0878b4a92 Add a service to return measurement stations of a river
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
75 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
76 }
cac0878b4a92 Add a service to return measurement stations of a river
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
77
cac0878b4a92 Add a service to return measurement stations of a river
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
78 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
79 if (range != null) {
cac0878b4a92 Add a service to return measurement stations of a river
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
80 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
81 if (a != null) {
cac0878b4a92 Add a service to return measurement stations of a river
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
82 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
83 }
cac0878b4a92 Add a service to return measurement stations of a river
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
84
cac0878b4a92 Add a service to return measurement stations of a river
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
85 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
86 if (b != null) {
cac0878b4a92 Add a service to return measurement stations of a river
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
87 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
88 }
cac0878b4a92 Add a service to return measurement stations of a river
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
89 }
cac0878b4a92 Add a service to return measurement stations of a river
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
90
4263
6abc8507e3c8 Add operator and station id to the artifact xml
Björn Ricks <bjoern.ricks@intevation.de>
parents: 4247
diff changeset
91 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
92 if (moperator != null) {
6abc8507e3c8 Add operator and station id to the artifact xml
Björn Ricks <bjoern.ricks@intevation.de>
parents: 4247
diff changeset
93 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
94 }
6abc8507e3c8 Add operator and station id to the artifact xml
Björn Ricks <bjoern.ricks@intevation.de>
parents: 4247
diff changeset
95
4289
3fffd7d5d67d Add observation TimeInteval to the artifact MeasurementStationInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents: 4264
diff changeset
96 TimeInterval tinterval = mstation.getObservationTimerange();
3fffd7d5d67d Add observation TimeInteval to the artifact MeasurementStationInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents: 4264
diff changeset
97 if (tinterval != null) {
3fffd7d5d67d Add observation TimeInteval to the artifact MeasurementStationInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents: 4264
diff changeset
98 Date tstart = tinterval.getStartTime();
3fffd7d5d67d Add observation TimeInteval to the artifact MeasurementStationInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents: 4264
diff changeset
99 if (tstart != null) {
3fffd7d5d67d Add observation TimeInteval to the artifact MeasurementStationInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents: 4264
diff changeset
100 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
101 true);
3fffd7d5d67d Add observation TimeInteval to the artifact MeasurementStationInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents: 4264
diff changeset
102 }
3fffd7d5d67d Add observation TimeInteval to the artifact MeasurementStationInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents: 4264
diff changeset
103 Date tstop = tinterval.getStopTime();
3fffd7d5d67d Add observation TimeInteval to the artifact MeasurementStationInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents: 4264
diff changeset
104 if (tstop != null) {
3fffd7d5d67d Add observation TimeInteval to the artifact MeasurementStationInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents: 4264
diff changeset
105 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
106 true);
3fffd7d5d67d Add observation TimeInteval to the artifact MeasurementStationInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents: 4264
diff changeset
107 }
3fffd7d5d67d Add observation TimeInteval to the artifact MeasurementStationInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents: 4264
diff changeset
108 }
3fffd7d5d67d Add observation TimeInteval to the artifact MeasurementStationInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents: 4264
diff changeset
109
4324
4980659b2f22 Add gauge name to the measurement station xml response
Björn Ricks <bjoern.ricks@intevation.de>
parents: 4289
diff changeset
110 Gauge gauge = mstation.getGauge();
4980659b2f22 Add gauge name to the measurement station xml response
Björn Ricks <bjoern.ricks@intevation.de>
parents: 4289
diff changeset
111 String gaugename = gauge.getName();
4980659b2f22 Add gauge name to the measurement station xml response
Björn Ricks <bjoern.ricks@intevation.de>
parents: 4289
diff changeset
112
4980659b2f22 Add gauge name to the measurement station xml response
Björn Ricks <bjoern.ricks@intevation.de>
parents: 4289
diff changeset
113 if (gaugename != null) {
4980659b2f22 Add gauge name to the measurement station xml response
Björn Ricks <bjoern.ricks@intevation.de>
parents: 4289
diff changeset
114 Element egauge = ec.create("gauge");
4980659b2f22 Add gauge name to the measurement station xml response
Björn Ricks <bjoern.ricks@intevation.de>
parents: 4289
diff changeset
115 ec.addAttr(egauge, "name", gaugename, true);
4980659b2f22 Add gauge name to the measurement station xml response
Björn Ricks <bjoern.ricks@intevation.de>
parents: 4289
diff changeset
116 eg.appendChild(egauge);
4980659b2f22 Add gauge name to the measurement station xml response
Björn Ricks <bjoern.ricks@intevation.de>
parents: 4289
diff changeset
117 }
4980659b2f22 Add gauge name to the measurement station xml response
Björn Ricks <bjoern.ricks@intevation.de>
parents: 4289
diff changeset
118
4246
cac0878b4a92 Add a service to return measurement stations of a river
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
119 egs.appendChild(eg);
cac0878b4a92 Add a service to return measurement stations of a river
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
120 }
cac0878b4a92 Add a service to return measurement stations of a river
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
121
4247
5da024c2af62 Refactor GaugeOverviewInfoService and MeasurementStationInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents: 4246
diff changeset
122 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
123
cac0878b4a92 Add a service to return measurement stations of a river
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
124 return result;
cac0878b4a92 Add a service to return measurement stations of a river
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
125 }
cac0878b4a92 Add a service to return measurement stations of a river
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
126
cac0878b4a92 Add a service to return measurement stations of a river
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
127 }

http://dive4elements.wald.intevation.org