[PATCH 2 of 2] merged

Wald Commits scm-commit at wald.intevation.org
Thu Sep 11 11:23:17 CEST 2014


# HG changeset patch
# User Raimund Renkert <rrenkert at intevation.de>
# Date 1410427390 -7200
# Node ID af434699495277f6df4e1293b23b91fb4876b8a2
# Parent  5b87aaac8447d65c15809330d31df0404b208f81
# Parent  5ffbf97766f78e03f8cef8ddcb8ecac3a673a8b8
merged.

diff -r 5b87aaac8447 -r af4346994952 artifacts/doc/conf/generators/discharge-diagrams2.xml
--- a/artifacts/doc/conf/generators/discharge-diagrams2.xml	Thu Sep 11 11:22:38 2014 +0200
+++ b/artifacts/doc/conf/generators/discharge-diagrams2.xml	Thu Sep 11 11:23:10 2014 +0200
@@ -4,7 +4,7 @@
   <output-generator names="historical_discharge_wq,historical_discharge_wq_chartinfo"
       class="org.dive4elements.river.exports.DischargeGenerator"
       converter="org.dive4elements.river.exports.DiagramAttributes"
-      injector="org.dive4elements.river.exports.injector.HistoricalDischargeInjector">
+      injectors="org.dive4elements.river.exports.injector.HistoricalDischargeInjector">
     <title key="chart.historical.discharge.title" default="chart.historical.discharge.title"/>
     &discharge-defaults;
   </output-generator>
@@ -12,7 +12,7 @@
   <output-generator names="computed_discharge_curve_chartinfo,computed_discharge_curve"
       class="org.dive4elements.river.exports.DischargeGenerator"
       converter="org.dive4elements.river.exports.DiagramAttributes"
-      injector="org.dive4elements.river.exports.injector.ComputedDischargeInjector">
+      injectors="org.dive4elements.river.exports.injector.ComputedDischargeInjector">
     <title key="chart.computed.discharge.curve.title" default="chart.computed.discharge.curve.title"/>
     <subtitle key="chart.computed.discharge.curve.subtitle" default="-">
         <arg expr="artifact.river"/>
@@ -24,7 +24,7 @@
   <output-generator names="discharge_curve_chartinfo,discharge_curve"
       class="org.dive4elements.river.exports.DischargeGenerator"
       converter="org.dive4elements.river.exports.DiagramAttributes"
-      injector="org.dive4elements.river.exports.injector.DischargeInjector">
+      injectors="org.dive4elements.river.exports.injector.DischargeInjector">
     <title key="chart.discharge.curve.title" default="chart.discharge.curve.title"/>
     <subtitle key="chart.computed.discharge.curve.subtitle" default="-">
         <arg expr="artifact.river"/>
@@ -36,7 +36,7 @@
   <output-generator names="fix_wq_curve,fix_wq_curve_chartinfo"
       class="org.dive4elements.river.exports.DischargeGenerator"
       converter="org.dive4elements.river.exports.DiagramAttributes"
-      injector="org.dive4elements.river.exports.injector.FixWQInjector">
+      injectors="org.dive4elements.river.exports.injector.FixWQInjector">
       <title key="chart.fixings.discharge.curve.title" default="Fixierungsanalyse W/Q"/>
     <subtitle key="chart.computed.discharge.curve.subtitle" default="-">
         <arg expr="artifact.river"/>
diff -r 5b87aaac8447 -r af4346994952 artifacts/src/main/java/org/dive4elements/river/artifacts/context/RiverContextFactory.java
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/context/RiverContextFactory.java	Thu Sep 11 11:22:38 2014 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/context/RiverContextFactory.java	Thu Sep 11 11:23:10 2014 +0200
@@ -352,10 +352,10 @@
         for (int i = 0; i < num; i++) {
             Element item = (Element)outGenerators.item(i);
 
-            String names     = item.getAttribute("names").trim();
-            String clazz     = item.getAttribute("class").trim();
-            String converter = item.getAttribute("converter").trim();
-            String injector  = item.getAttribute("injector").trim();
+            String names      = item.getAttribute("names").trim();
+            String clazz      = item.getAttribute("class").trim();
+            String converter  = item.getAttribute("converter").trim();
+            String injectors  = item.getAttribute("injectors").trim();
 
             if (names.isEmpty() || clazz.isEmpty()) {
                 continue;
@@ -391,28 +391,32 @@
                 }
             }
 
-            ContextInjector ci = null;
+            List<ContextInjector> cis = null;
 
-            if (!injector.isEmpty()) {
-                try {
-                    ci = (ContextInjector)Class.forName(injector)
-                        .newInstance();
-                    ci.setup(item);
-                }
-                catch (ClassNotFoundException cnfe) {
-                    log.error(cnfe, cnfe);
-                }
-                catch (InstantiationException ie) {
-                    log.error(ie);
-                }
-                catch (IllegalAccessException iae) {
-                    log.error(iae);
+            if (!injectors.isEmpty()) {
+                cis = new ArrayList<ContextInjector>();
+                for (String injector: injectors.split("[\\s,]+")) {
+                    try {
+                        ContextInjector ci = (ContextInjector)Class.forName(injector)
+                            .newInstance();
+                        ci.setup(item);
+                        cis.add(ci);
+                    }
+                    catch (ClassNotFoundException cnfe) {
+                        log.error(cnfe, cnfe);
+                    }
+                    catch (InstantiationException ie) {
+                        log.error(ie);
+                    }
+                    catch (IllegalAccessException iae) {
+                        log.error(iae);
+                    }
                 }
             }
 
-            for (String key: names.split("[\\s,]")) {
+            for (String key: names.split("[\\s,]+")) {
                 if (!(key = key.trim()).isEmpty()) {
-                    generators.putGenerator(key, generatorClass, cfg, ci);
+                    generators.putGenerator(key, generatorClass, cfg, cis);
                     idx++;
                 }
             }
diff -r 5b87aaac8447 -r af4346994952 artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentLoadData.java
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentLoadData.java	Thu Sep 11 11:22:38 2014 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentLoadData.java	Thu Sep 11 11:23:10 2014 +0200
@@ -16,7 +16,6 @@
 import java.util.List;
 import java.util.TreeMap;
 import java.util.TreeSet;
-import java.util.Iterator;
 
 import org.apache.log4j.Logger;
 
diff -r 5b87aaac8447 -r af4346994952 artifacts/src/main/java/org/dive4elements/river/artifacts/states/minfo/YearEpochSelect.java
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/states/minfo/YearEpochSelect.java	Thu Sep 11 11:22:38 2014 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/states/minfo/YearEpochSelect.java	Thu Sep 11 11:23:10 2014 +0200
@@ -14,7 +14,6 @@
 import org.dive4elements.artifacts.CallContext;
 import org.dive4elements.artifacts.CallMeta;
 import org.dive4elements.artifacts.common.utils.XMLUtils;
-import org.dive4elements.river.artifacts.D4EArtifact;
 import org.dive4elements.river.artifacts.resources.Resources;
 import org.dive4elements.river.artifacts.states.DefaultState;
 
diff -r 5b87aaac8447 -r af4346994952 artifacts/src/main/java/org/dive4elements/river/exports/ChartGenerator.java
--- a/artifacts/src/main/java/org/dive4elements/river/exports/ChartGenerator.java	Thu Sep 11 11:22:38 2014 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/exports/ChartGenerator.java	Thu Sep 11 11:23:10 2014 +0200
@@ -33,11 +33,9 @@
 import org.dive4elements.river.jfree.StyledAreaSeriesCollection;
 import org.dive4elements.river.jfree.StyledSeries;
 import org.dive4elements.river.jfree.AxisDataset;
-import org.dive4elements.river.model.River;
 import org.dive4elements.river.themes.LineStyle;
 import org.dive4elements.river.themes.TextStyle;
 import org.dive4elements.river.themes.ThemeDocument;
-import org.dive4elements.river.utils.RiverUtils;
 
 import java.awt.BasicStroke;
 import java.awt.Color;
diff -r 5b87aaac8447 -r af4346994952 artifacts/src/main/java/org/dive4elements/river/exports/GeneratorLookup.java
--- a/artifacts/src/main/java/org/dive4elements/river/exports/GeneratorLookup.java	Thu Sep 11 11:22:38 2014 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/exports/GeneratorLookup.java	Thu Sep 11 11:23:10 2014 +0200
@@ -9,6 +9,7 @@
 package org.dive4elements.river.exports;
 
 import java.util.HashMap;
+import java.util.List;
 import java.util.Map;
 
 import org.dive4elements.artifacts.ContextInjector;
@@ -19,14 +20,14 @@
 implements   FacetFilter
 {
     public static final class Item {
-        private Class<OutGenerator> generator;
-        private Object              ctx;
-        private ContextInjector     ci;
+        private Class<OutGenerator>   generator;
+        private Object                ctx;
+        private List<ContextInjector> cis;
 
-        public Item(Class<OutGenerator> generator, Object ctx, ContextInjector ci) {
+        public Item(Class<OutGenerator> generator, Object ctx, List<ContextInjector> cis) {
             this.generator = generator;
             this.ctx       = ctx;
-            this.ci        = ci;
+            this.cis       = cis;
         }
 
         public Class<OutGenerator> getGenerator() {
@@ -37,8 +38,8 @@
             return ctx;
         }
 
-        public ContextInjector getContextInjector() {
-            return ci;
+        public List<ContextInjector> getContextInjectors() {
+            return cis;
         }
     } // class Item
 
@@ -49,12 +50,12 @@
     }
 
     public void putGenerator(
-        String              outName,
-        Class<OutGenerator> generatorClass,
-        Object              ctx,
-        ContextInjector     ci
+        String                outName,
+        Class<OutGenerator>   generatorClass,
+        Object                ctx,
+        List<ContextInjector> cis
     ) {
-        Item item = new Item(generatorClass, ctx, ci);
+        Item item = new Item(generatorClass, ctx, cis);
         generators.put(outName, item);
     }
 
diff -r 5b87aaac8447 -r af4346994952 artifacts/src/main/java/org/dive4elements/river/exports/OutputHelper.java
--- a/artifacts/src/main/java/org/dive4elements/river/exports/OutputHelper.java	Thu Sep 11 11:22:38 2014 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/exports/OutputHelper.java	Thu Sep 11 11:23:10 2014 +0200
@@ -55,7 +55,7 @@
         this.identifier = identifier;
     }
 
-    private static ContextInjector getContextInjector(CallContext context, String out) {
+    private static List<ContextInjector> getContextInjectors(CallContext context, String out) {
         RiverContext flysContext = context instanceof RiverContext
             ? (RiverContext)context
             : (RiverContext)context.globalContext();
@@ -69,7 +69,7 @@
 
         GeneratorLookup.Item item = generators.getGenerator(out);
         return item != null
-            ? item.getContextInjector()
+            ? item.getContextInjectors()
             : null;
     }
     /**
@@ -102,7 +102,7 @@
         List<ArtifactAndFacet> dataProviders =
             doBlackboardPass(themeList, context, outName);
 
-        ContextInjector ci = getContextInjector(context, outName);
+        List<ContextInjector> cis = getContextInjectors(context, outName);
 
         try {
             for (int i = 0, T = themeList.size(); i < T; i++) {
@@ -131,8 +131,11 @@
                     continue;
                 }
 
-                if (ci != null) {
-                    ci.injectContext(context, dataProviders.get(i).getArtifact(), request);
+                if (cis != null) {
+                    for (ContextInjector ci: cis) {
+                        ci.injectContext(
+                            context, dataProviders.get(i).getArtifact(), request);
+                    }
                 }
 
                 if (outName.equals("sq_overview")) {
diff -r 5b87aaac8447 -r af4346994952 artifacts/src/main/java/org/dive4elements/river/exports/injector/HistoricalDischargeInjector.java
--- a/artifacts/src/main/java/org/dive4elements/river/exports/injector/HistoricalDischargeInjector.java	Thu Sep 11 11:22:38 2014 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/exports/injector/HistoricalDischargeInjector.java	Thu Sep 11 11:23:10 2014 +0200
@@ -6,9 +6,7 @@
 import org.dive4elements.artifacts.ContextInjector;
 import org.dive4elements.river.artifacts.D4EArtifact;
 import org.dive4elements.river.artifacts.access.HistoricalDischargeAccess;
-import org.dive4elements.river.artifacts.access.RangeAccess;
 import org.dive4elements.river.model.Gauge;
-import org.dive4elements.river.model.River;
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
 


More information about the Dive4Elements-commits mailing list