annotate flys-artifacts/src/main/java/de/intevation/flys/artifacts/services/MeasurementStationInfoService.java @ 4293:10c1a413a1e0

ExtremeCalc: Rename problem to be unique in its name.
author Felix Wolfsteller <felix.wolfsteller@intevation.de>
date Mon, 29 Oct 2012 11:20:43 +0100
parents 31c017420502
children 3fffd7d5d67d
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;
cac0878b4a92 Add a service to return measurement stations of a river
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
4 import java.util.List;
cac0878b4a92 Add a service to return measurement stations of a river
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
5
cac0878b4a92 Add a service to return measurement stations of a river
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
6 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
7
cac0878b4a92 Add a service to return measurement stations of a river
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
8 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
9 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
10
cac0878b4a92 Add a service to return measurement stations of a river
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
11 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
12 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
13 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
14 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
15
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.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
17 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
18 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
19 import de.intevation.flys.model.River;
cac0878b4a92 Add a service to return measurement stations of a river
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
20
cac0878b4a92 Add a service to return measurement stations of a river
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
21 /**
cac0878b4a92 Add a service to return measurement stations of a river
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
22 * @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
23 */
4247
5da024c2af62 Refactor GaugeOverviewInfoService and MeasurementStationInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents: 4246
diff changeset
24 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
25
cac0878b4a92 Add a service to return measurement stations of a river
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
26 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
27 MeasurementStationInfoService.class);
4246
cac0878b4a92 Add a service to return measurement stations of a river
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
28
cac0878b4a92 Add a service to return measurement stations of a river
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
29 @Override
cac0878b4a92 Add a service to return measurement stations of a river
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
30 public Document doProcess(
cac0878b4a92 Add a service to return measurement stations of a river
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
31 Document data,
cac0878b4a92 Add a service to return measurement stations of a river
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
32 GlobalContext globalContext,
cac0878b4a92 Add a service to return measurement stations of a river
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
33 CallMeta callMeta
cac0878b4a92 Add a service to return measurement stations of a river
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
34 ) {
4247
5da024c2af62 Refactor GaugeOverviewInfoService and MeasurementStationInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents: 4246
diff changeset
35 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
36
cac0878b4a92 Add a service to return measurement stations of a river
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
37 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
38
cac0878b4a92 Add a service to return measurement stations of a river
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
39 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
40
cac0878b4a92 Add a service to return measurement stations of a river
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
41 if (logger.isDebugEnabled()) {
cac0878b4a92 Add a service to return measurement stations of a river
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
42 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
43 }
cac0878b4a92 Add a service to return measurement stations of a river
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
44
cac0878b4a92 Add a service to return measurement stations of a river
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
45 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
46 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
47
cac0878b4a92 Add a service to return measurement stations of a river
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
48 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
49 if (name != null) {
cac0878b4a92 Add a service to return measurement stations of a river
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
50 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
51 }
cac0878b4a92 Add a service to return measurement stations of a river
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
52
4263
6abc8507e3c8 Add operator and station id to the artifact xml
Björn Ricks <bjoern.ricks@intevation.de>
parents: 4247
diff changeset
53 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
54 if (id != null) {
6abc8507e3c8 Add operator and station id to the artifact xml
Björn Ricks <bjoern.ricks@intevation.de>
parents: 4247
diff changeset
55 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
56 }
6abc8507e3c8 Add operator and station id to the artifact xml
Björn Ricks <bjoern.ricks@intevation.de>
parents: 4247
diff changeset
57
4246
cac0878b4a92 Add a service to return measurement stations of a river
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
58 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
59 if (type != null) {
cac0878b4a92 Add a service to return measurement stations of a river
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
60 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
61 }
cac0878b4a92 Add a service to return measurement stations of a river
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
62
cac0878b4a92 Add a service to return measurement stations of a river
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
63 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
64 if (riverside != 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, "riverside", riverside, 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 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
69 if (station != 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, "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
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 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
74 if (range != null) {
cac0878b4a92 Add a service to return measurement stations of a river
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
75 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
76 if (a != 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, "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
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 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
81 if (b != 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, "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
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
4263
6abc8507e3c8 Add operator and station id to the artifact xml
Björn Ricks <bjoern.ricks@intevation.de>
parents: 4247
diff changeset
86 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
87 if (moperator != null) {
6abc8507e3c8 Add operator and station id to the artifact xml
Björn Ricks <bjoern.ricks@intevation.de>
parents: 4247
diff changeset
88 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
89 }
6abc8507e3c8 Add operator and station id to the artifact xml
Björn Ricks <bjoern.ricks@intevation.de>
parents: 4247
diff changeset
90
4246
cac0878b4a92 Add a service to return measurement stations of a river
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
91 egs.appendChild(eg);
cac0878b4a92 Add a service to return measurement stations of a river
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
92 }
cac0878b4a92 Add a service to return measurement stations of a river
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
93
4247
5da024c2af62 Refactor GaugeOverviewInfoService and MeasurementStationInfoService
Björn Ricks <bjoern.ricks@intevation.de>
parents: 4246
diff changeset
94 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
95
cac0878b4a92 Add a service to return measurement stations of a river
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
96 return result;
cac0878b4a92 Add a service to return measurement stations of a river
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
97 }
cac0878b4a92 Add a service to return measurement stations of a river
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
98
cac0878b4a92 Add a service to return measurement stations of a river
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
99 }

http://dive4elements.wald.intevation.org