[PATCH] Overwriting the current km in context gives unexpected results if artifacts from different km have been loaded
Wald Commits
scm-commit at wald.intevation.org
Thu Oct 2 11:47:00 CEST 2014
# HG changeset patch
# User Tom Gottfried <tom at intevation.de>
# Date 1412243204 -7200
# Node ID 16dc2da05aefd25e35def0cacaa78dab59c1f627
# Parent 061e85212d25c7f13e340fbfbe4205a9f2d2eb4c
Overwriting the current km in context gives unexpected results if artifacts from different km have been loaded.
diff -r 061e85212d25 -r 16dc2da05aef artifacts/src/main/java/org/dive4elements/river/exports/injector/KmFromGaugeNameInjector.java
--- a/artifacts/src/main/java/org/dive4elements/river/exports/injector/KmFromGaugeNameInjector.java Thu Oct 02 11:04:14 2014 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/exports/injector/KmFromGaugeNameInjector.java Thu Oct 02 11:46:44 2014 +0200
@@ -25,6 +25,10 @@
@Override
public void injectContext(CallContext ctx, Artifact artifact, Document doc) {
+ if (ctx.getContextValue(CURRENT_KM) instanceof Number) {
+ return;
+ }
+
D4EArtifact d4e = (D4EArtifact)artifact;
RangeAccess access = new RangeAccess(d4e);
String name = d4e.getDataAsString("gauge_name");
diff -r 061e85212d25 -r 16dc2da05aef artifacts/src/main/java/org/dive4elements/river/exports/injector/KmFromGaugeNumberInjector.java
--- a/artifacts/src/main/java/org/dive4elements/river/exports/injector/KmFromGaugeNumberInjector.java Thu Oct 02 11:04:14 2014 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/exports/injector/KmFromGaugeNumberInjector.java Thu Oct 02 11:46:44 2014 +0200
@@ -29,6 +29,10 @@
Artifact artifact,
Document request
) {
+ if (ctx.getContextValue(CURRENT_KM) instanceof Number) {
+ return;
+ }
+
HistoricalDischargeAccess access =
new HistoricalDischargeAccess((D4EArtifact)artifact);
Long gaugeNumber = access.getOfficialGaugeNumber();
diff -r 061e85212d25 -r 16dc2da05aef artifacts/src/main/java/org/dive4elements/river/exports/injector/KmFromLocationInjector.java
--- a/artifacts/src/main/java/org/dive4elements/river/exports/injector/KmFromLocationInjector.java Thu Oct 02 11:04:14 2014 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/exports/injector/KmFromLocationInjector.java Thu Oct 02 11:46:44 2014 +0200
@@ -27,6 +27,10 @@
Artifact artifact,
Document doc
) {
+ if (ctx.getContextValue(CURRENT_KM) instanceof Number) {
+ return;
+ }
+
RangeAccess access = new RangeAccess((D4EArtifact)artifact);
if (access.getLocations() != null &&
access.getLocations().length > 0) {
diff -r 061e85212d25 -r 16dc2da05aef artifacts/src/main/java/org/dive4elements/river/exports/injector/KmFromRequestInjector.java
--- a/artifacts/src/main/java/org/dive4elements/river/exports/injector/KmFromRequestInjector.java Thu Oct 02 11:04:14 2014 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/exports/injector/KmFromRequestInjector.java Thu Oct 02 11:46:44 2014 +0200
@@ -19,7 +19,6 @@
{
private static final Logger log = Logger.getLogger(KmFromRequestInjector.class);
- public static final Double INVALID_KM = Double.valueOf(-1d);
public static final String XPATH_CHART_CURRENTKM =
"/art:action/art:attributes/art:currentKm/@art:km";
@Override
@@ -31,7 +30,12 @@
public void injectContext(
CallContext ctx,
Artifact artifact,
- Document request) {
+ Document request
+ ) {
+ if (ctx.getContextValue(CURRENT_KM) instanceof Number) {
+ return;
+ }
+
Double km = getCurrentKmFromRequest(request);
if (Double.isNaN(km)) {
RangeAccess access = new RangeAccess((D4EArtifact)artifact);
More information about the Dive4Elements-commits
mailing list