Mercurial > dive4elements > river
view artifacts/src/main/java/org/dive4elements/river/exports/injector/DischargeInjector.java @ 8346:31272d799dad
Removed obsolete imports.
author | Sascha L. Teichmann <teichmann@intevation.de> |
---|---|
date | Wed, 01 Oct 2014 11:07:52 +0200 |
parents | 10917ec29625 |
children |
line wrap: on
line source
package org.dive4elements.river.exports.injector; import org.apache.log4j.Logger; import org.dive4elements.artifacts.Artifact; import org.dive4elements.artifacts.CallContext; import org.dive4elements.artifacts.ContextInjector; import org.dive4elements.river.artifacts.D4EArtifact; import org.dive4elements.river.artifacts.access.RangeAccess; import org.dive4elements.river.model.Gauge; import org.w3c.dom.Document; import org.w3c.dom.Element; import static org.dive4elements.river.exports.injector.InjectorConstants.CURRENT_KM; public class DischargeInjector implements ContextInjector { private static Logger log = Logger.getLogger(DischargeInjector.class); @Override public void setup(Element cfg) { } @Override public void injectContext(CallContext ctx, Artifact artifact, Document doc) { RangeAccess access = new RangeAccess((D4EArtifact)artifact); if (access.hasFrom()) { ctx.putContextValue(CURRENT_KM, access.getFrom()); return; } D4EArtifact d4e = (D4EArtifact)artifact; String name = d4e.getDataAsString("gauge_name"); if (name == null || name.equals("")) { return; } Gauge gauge = access.getRiver().determineGaugeByName(name); if (gauge == null) { log.error("No Gauge could be found for name " + name + "!"); return; } ctx.putContextValue(CURRENT_KM, gauge.getStation()); return; } }