changeset 8257:af4346994952

merged.
author Raimund Renkert <rrenkert@intevation.de>
date Thu, 11 Sep 2014 11:23:10 +0200
parents 5b87aaac8447 (current diff) 5ffbf97766f7 (diff)
children 155a886ab19b
files
diffstat 8 files changed, 50 insertions(+), 48 deletions(-) [+]
line wrap: on
line diff
--- 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"/>
--- 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++;
                 }
             }
--- 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;
 
--- 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;
 
--- 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;
--- 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);
     }
 
--- 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")) {
--- 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;
 

http://dive4elements.wald.intevation.org