comparison artifacts/src/main/java/org/dive4elements/river/exports/injector/KmFromLocationInjector.java @ 8349:7341bebc79d0

Let injectors be strictly distinct from each other and give more meaningful names (they know what they do, not where they will be used. The latter is configuration).
author Tom Gottfried <tom@intevation.de>
date Wed, 01 Oct 2014 12:23:39 +0200
parents artifacts/src/main/java/org/dive4elements/river/exports/injector/ComputedDischargeInjector.java@10917ec29625
children 16dc2da05aef
comparison
equal deleted inserted replaced
8348:dc3f55141299 8349:7341bebc79d0
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.RangeAccess;
9 import org.w3c.dom.Document;
10 import org.w3c.dom.Element;
11
12 import static org.dive4elements.river.exports.injector.InjectorConstants.CURRENT_KM;
13
14 public class KmFromLocationInjector
15 implements ContextInjector
16 {
17
18 private static Logger log = Logger.getLogger(KmFromLocationInjector.class);
19
20 @Override
21 public void setup(Element cfg) {
22 }
23
24 @Override
25 public void injectContext(
26 CallContext ctx,
27 Artifact artifact,
28 Document doc
29 ) {
30 RangeAccess access = new RangeAccess((D4EArtifact)artifact);
31 if (access.getLocations() != null &&
32 access.getLocations().length > 0) {
33 ctx.putContextValue(CURRENT_KM, access.getLocations()[0]);
34 return;
35 }
36 log.warn("No locations accessible.");
37 }
38 }

http://dive4elements.wald.intevation.org