Mercurial > dive4elements > river
comparison artifacts/src/main/java/org/dive4elements/river/exports/injector/HistoricalDischargeInjector.java @ 8251:c7ca9c228314
Added context injectors for discharge curves.
author | Raimund Renkert <rrenkert@intevation.de> |
---|---|
date | Wed, 10 Sep 2014 10:01:11 +0200 |
parents | |
children | 5ffbf97766f7 |
comparison
equal
deleted
inserted
replaced
8240:61fd22f65bd4 | 8251:c7ca9c228314 |
---|---|
1 package org.dive4elements.river.exports.injector; | |
2 | |
3 import org.apache.log4j.Logger; | |
4 import org.dive4elements.artifacts.Artifact; | |
5 import org.dive4elements.artifacts.CallContext; | |
6 import org.dive4elements.artifacts.ContextInjector; | |
7 import org.dive4elements.river.artifacts.D4EArtifact; | |
8 import org.dive4elements.river.artifacts.access.HistoricalDischargeAccess; | |
9 import org.dive4elements.river.artifacts.access.RangeAccess; | |
10 import org.dive4elements.river.model.Gauge; | |
11 import org.dive4elements.river.model.River; | |
12 import org.w3c.dom.Document; | |
13 import org.w3c.dom.Element; | |
14 | |
15 import static org.dive4elements.river.exports.injector.InjectorConstants.CURRENT_KM; | |
16 | |
17 public class HistoricalDischargeInjector | |
18 implements ContextInjector | |
19 { | |
20 private static Logger log = | |
21 Logger.getLogger(HistoricalDischargeInjector.class); | |
22 | |
23 @Override | |
24 public void setup(Element cfg) { | |
25 | |
26 } | |
27 | |
28 @Override | |
29 public void injectContext( | |
30 CallContext ctx, | |
31 Artifact artifact, | |
32 Document request | |
33 ) { | |
34 HistoricalDischargeAccess access = | |
35 new HistoricalDischargeAccess((D4EArtifact)artifact); | |
36 Long gaugeNumber = access.getOfficialGaugeNumber(); | |
37 if (gaugeNumber == null) { | |
38 return; | |
39 } | |
40 Gauge gauge = Gauge.getGaugeByOfficialNumber(gaugeNumber); | |
41 if (gauge == null) { | |
42 return; | |
43 } | |
44 double km = gauge.getStation().doubleValue(); | |
45 ctx.putContextValue(CURRENT_KM, km); | |
46 } | |
47 } |