Mercurial > dive4elements > river
comparison flys-artifacts/src/main/java/de/intevation/flys/artifacts/services/GaugeOverviewInfoService.java @ 3748:99f80469ba2b
Pegelinfo: Made generation of datum and aeo NPE proof.
flys-artifacts/trunk@5434 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Tue, 11 Sep 2012 14:46:09 +0000 |
parents | a33df17ac9bb |
children | b3fdb5a12613 |
comparison
equal
deleted
inserted
replaced
3747:a33df17ac9bb | 3748:99f80469ba2b |
---|---|
69 /* ec.addAttr(r, "qmax", , true); */ | 69 /* ec.addAttr(r, "qmax", , true); */ |
70 | 70 |
71 Element egs = ec.create("gauges"); | 71 Element egs = ec.create("gauges"); |
72 | 72 |
73 List<Gauge> gauges = river.getGauges(); | 73 List<Gauge> gauges = river.getGauges(); |
74 logger.debug("Loaded gauges: " + gauges); | 74 |
75 if (logger.isDebugEnabled()) { | |
76 logger.debug("Loaded gauges: " + gauges); | |
77 } | |
78 | |
75 for (Gauge gauge: river.getGauges()) { | 79 for (Gauge gauge: river.getGauges()) { |
76 Element eg = ec.create("gauge"); | 80 Element eg = ec.create("gauge"); |
81 | |
77 String name = gauge.getName(); | 82 String name = gauge.getName(); |
78 if (name != null) { | 83 if (name != null) { |
79 ec.addAttr(eg, "name", gauge.getName(), true); | 84 ec.addAttr(eg, "name", gauge.getName(), true); |
85 } | |
86 | |
87 String aeo = getGaugeValue(gauge.getAeo()); | |
88 if (aeo != null) { | |
89 ec.addAttr(eg, "aeo", aeo, true); | |
90 } | |
91 | |
92 String datum = getGaugeValue(gauge.getDatum()); | |
93 if (datum != null) { | |
94 ec.addAttr(eg, "datum", datum, true); | |
80 } | 95 } |
81 | 96 |
82 Range range = gauge.getRange(); | 97 Range range = gauge.getRange(); |
83 if (range != null) { | 98 if (range != null) { |
84 double min = range.getA().doubleValue(); | 99 double min = range.getA().doubleValue(); |
107 } | 122 } |
108 if (maxq != null) { | 123 if (maxq != null) { |
109 ec.addAttr(eg, "maxq", maxq, true); | 124 ec.addAttr(eg, "maxq", maxq, true); |
110 } | 125 } |
111 | 126 |
112 ec.addAttr(eg, "aeo", getGaugeValue(gauge.getAeo()), true); | |
113 ec.addAttr(eg, "datum", getGaugeValue(gauge.getDatum()), true); | |
114 | |
115 egs.appendChild(eg); | 127 egs.appendChild(eg); |
116 } | 128 } |
117 | 129 |
118 go.appendChild(r); | 130 go.appendChild(r); |
119 go.appendChild(egs); | 131 go.appendChild(egs); |
123 } | 135 } |
124 | 136 |
125 /** | 137 /** |
126 * Returns a Double from a BigDecimal value or null if value is null | 138 * Returns a Double from a BigDecimal value or null if value is null |
127 */ | 139 */ |
128 private String getGaugeValue(BigDecimal value) { | 140 private static String getGaugeValue(BigDecimal value) { |
129 if (value == null) { | 141 return value != null |
130 return null; | 142 ? Double.toString(value.doubleValue()) |
131 } | 143 : ""; |
132 return Double.toString(value.doubleValue()); | |
133 } | 144 } |
134 | |
135 } | 145 } |