comparison artifacts/src/main/java/org/dive4elements/river/artifacts/MainValuesArtifact.java @ 8856:5e38e2924c07 3.2.x

Fix code style.
author Tom Gottfried <tom@intevation.de>
date Thu, 18 Jan 2018 20:12:01 +0100
parents 47199406994a
children 669ab639c56b 0a5239a1e46e
comparison
equal deleted inserted replaced
8855:d7c005e12af0 8856:5e38e2924c07
117 List<Facet> fs = new ArrayList<Facet>(); 117 List<Facet> fs = new ArrayList<Facet>();
118 addFacets(state.getID(), fs); 118 addFacets(state.getID(), fs);
119 spawnState(); 119 spawnState();
120 String restriction = getDatacageIDValue(data); 120 String restriction = getDatacageIDValue(data);
121 log.debug("mainvalue restriction " + restriction); 121 log.debug("mainvalue restriction " + restriction);
122 boolean restricted = restriction.endsWith("q") || restriction.endsWith("w"); 122 boolean restricted = restriction.endsWith("q")
123 || restriction.endsWith("w");
123 if (!restricted || restriction.endsWith("q")) { 124 if (!restricted || restriction.endsWith("q")) {
124 fs.add(new MainValuesQFacet( 125 fs.add(new MainValuesQFacet(
125 MAINVALUES_Q, 126 MAINVALUES_Q,
126 Resources.getMsg( 127 Resources.getMsg(
127 callMeta, 128 callMeta,
164 "String", rivername)); 165 "String", rivername));
165 166
166 try { 167 try {
167 Long officialNumber = Long.valueOf(gaugeref); 168 Long officialNumber = Long.valueOf(gaugeref);
168 Gauge gauge = Gauge.getGaugeByOfficialNumber(officialNumber); 169 Gauge gauge = Gauge.getGaugeByOfficialNumber(officialNumber);
169 addData("ld_locations", new DefaultStateData("ld_locations", null, null, 170 addData(
170 String.valueOf(gauge.getStation()))); 171 "ld_locations",
172 new DefaultStateData("ld_locations", null, null,
173 String.valueOf(gauge.getStation()))
174 );
171 } catch (NumberFormatException nfe) { 175 } catch (NumberFormatException nfe) {
172 log.debug("MainValuesArtifact could not parse gaugeref from doc."); 176 log.debug("MainValuesArtifact could not parse gaugeref from doc.");
173 } 177 }
174 } 178 }
175 179
192 } 196 }
193 197
194 198
195 /** Get important data from the 'calling' artifact. */ 199 /** Get important data from the 'calling' artifact. */
196 @Override 200 @Override
197 protected void initialize(Artifact artifact, Object context, CallMeta meta) { 201 protected void initialize(
202 Artifact artifact,
203 Object context,
204 CallMeta meta
205 ) {
198 log.debug("MainValuesArtifact.initialize"); 206 log.debug("MainValuesArtifact.initialize");
199 D4EArtifact winfo = (D4EArtifact) artifact; 207 D4EArtifact winfo = (D4EArtifact) artifact;
200 River river = new RiverAccess(winfo).getRiver(); 208 River river = new RiverAccess(winfo).getRiver();
201 double [] locations = new RangeAccess(winfo).getKmRange(); 209 double [] locations = new RangeAccess(winfo).getKmRange();
202 210
203 if (locations != null) { 211 if (locations != null) {
204 double location = locations[0]; 212 double location = locations[0];
205 addData("ld_locations", new DefaultStateData("ld_locations", null, null, 213 addData(
206 String.valueOf(location))); 214 "ld_locations",
215 new DefaultStateData("ld_locations", null, null,
216 String.valueOf(location))
217 );
207 } 218 }
208 else { 219 else {
209 log.error("No location for mainvalues given."); 220 log.error("No location for mainvalues given.");
210 } 221 }
211 importData(winfo, "river"); 222 importData(winfo, "river");
212 // In the case of DischargeWQCurves, there are no locations, but a gauge. 223 // In the case of DischargeWQCurves, there are no locations,
224 // but a gauge.
213 if (getDataAsString("ld_locations") == null) { 225 if (getDataAsString("ld_locations") == null) {
214 // TODO its a tad difficult to remodel Range/Gauge-Access to 226 // TODO its a tad difficult to remodel Range/Gauge-Access to
215 // do this. 227 // do this.
216 String refGaugeID = winfo.getDataAsString("reference_gauge"); 228 String refGaugeID = winfo.getDataAsString("reference_gauge");
217 if (refGaugeID != null) { 229 if (refGaugeID != null) {
218 Gauge g = Gauge.getGaugeByOfficialNumber(Integer.parseInt(refGaugeID)); 230 Gauge g = Gauge.getGaugeByOfficialNumber(
219 addData("ld_locations", new DefaultStateData("ld_locations", null, null, 231 Integer.parseInt(refGaugeID));
220 String.valueOf(g.getStation()))); 232 addData(
233 "ld_locations",
234 new DefaultStateData("ld_locations", null, null,
235 String.valueOf(g.getStation()))
236 );
221 } 237 }
222 else { 238 else {
223 log.error("MainValuesArtifact: No location/gauge."); 239 log.error("MainValuesArtifact: No location/gauge.");
224 } 240 }
225 } 241 }

http://dive4elements.wald.intevation.org