changeset 3422:118fe1cc8cc8

OutGenerators got a setCollection() method; analogous to setMasterArtifact(). Registered the SQOverviewGenerator as OutGenerator for 'sq_overview' Output. flys-artifacts/trunk@5076 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Fri, 20 Jul 2012 06:50:25 +0000
parents c44ff50f4970
children c7dde1e074dd
files flys-artifacts/ChangeLog flys-artifacts/doc/conf/conf.xml flys-artifacts/src/main/java/de/intevation/flys/collections/FLYSArtifactCollection.java flys-artifacts/src/main/java/de/intevation/flys/exports/ATExporter.java flys-artifacts/src/main/java/de/intevation/flys/exports/AbstractExporter.java flys-artifacts/src/main/java/de/intevation/flys/exports/ChartGenerator.java flys-artifacts/src/main/java/de/intevation/flys/exports/ChartInfoGenerator.java flys-artifacts/src/main/java/de/intevation/flys/exports/MapGenerator.java flys-artifacts/src/main/java/de/intevation/flys/exports/OutGenerator.java flys-artifacts/src/main/java/de/intevation/flys/exports/ReportGenerator.java flys-artifacts/src/main/java/de/intevation/flys/exports/sq/SQOverviewGenerator.java
diffstat 11 files changed, 105 insertions(+), 18 deletions(-) [+]
line wrap: on
line diff
--- a/flys-artifacts/ChangeLog	Thu Jul 19 21:12:57 2012 +0000
+++ b/flys-artifacts/ChangeLog	Fri Jul 20 06:50:25 2012 +0000
@@ -1,3 +1,22 @@
+2012-07-20  Ingo Weinzierl <ingo@intevation.de>
+
+	* src/main/java/de/intevation/flys/exports/ReportGenerator.java,
+	  src/main/java/de/intevation/flys/exports/AbstractExporter.java,
+	  src/main/java/de/intevation/flys/exports/ATExporter.java,
+	  src/main/java/de/intevation/flys/exports/sq/SQOverviewGenerator.java,
+	  src/main/java/de/intevation/flys/exports/ChartGenerator.java,
+	  src/main/java/de/intevation/flys/exports/MapGenerator.java,
+	  src/main/java/de/intevation/flys/exports/OutGenerator.java,
+	  src/main/java/de/intevation/flys/exports/ChartInfoGenerator.java:
+	  Added a setCollection() method that allows the caller of OutGenerators
+	  to set a reference to a FLYSArtifactCollection.
+
+	* src/main/java/de/intevation/flys/collections/FLYSArtifactCollection.java:
+	  Use setCollection() to set the reference to the current
+	  FLYSArtifactCollection before using OutGenerators.
+
+	* doc/conf/conf.xml: Registered the SQOverviewGenerator.
+
 2012-07-19	Sascha L. Teichmann	<sascha.teichmann@intevation.de>
 
 	* src/main/java/de/intevation/flys/artifacts/model/FixingsOverview.java:
--- a/flys-artifacts/doc/conf/conf.xml	Thu Jul 19 21:12:57 2012 +0000
+++ b/flys-artifacts/doc/conf/conf.xml	Fri Jul 20 06:50:25 2012 +0000
@@ -269,6 +269,7 @@
         <output-generator name="sq_relation_e_chartinfo">de.intevation.flys.exports.sq.SQRelationInfoGenerator</output-generator>
         <output-generator name="sq_relation_f_chartinfo">de.intevation.flys.exports.sq.SQRelationInfoGenerator</output-generator>
         <output-generator name="sq_relation_export">de.intevation.flys.exports.sq.SQRelationExporter</output-generator>
+        <output-generator name="sq_overview">de.intevation.flys.exports.sq.SQOverviewGenerator</output-generator>
         <output-generator name="fix_parameters_export">de.intevation.flys.exports.fixings.ParametersExporter</output-generator>
         <output-generator name="fix_deltawt_export">de.intevation.flys.exports.fixings.DeltaWtExporter</output-generator>
         <output-generator name="fix_deltawt_curve">de.intevation.flys.exports.fixings.FixDeltaWtGenerator</output-generator>
--- a/flys-artifacts/src/main/java/de/intevation/flys/collections/FLYSArtifactCollection.java	Thu Jul 19 21:12:57 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/collections/FLYSArtifactCollection.java	Fri Jul 20 06:50:25 2012 +0000
@@ -378,6 +378,7 @@
 
         generator.init(format, out, context);
         generator.setSettings(settings);
+        generator.setCollection(this);
         prepareMasterArtifact(generator, context);
 
         try {
--- a/flys-artifacts/src/main/java/de/intevation/flys/exports/ATExporter.java	Thu Jul 19 21:12:57 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/ATExporter.java	Fri Jul 20 06:50:25 2012 +0000
@@ -17,6 +17,7 @@
 import de.intevation.flys.artifacts.FLYSArtifact;
 
 import de.intevation.flys.artifacts.model.WQ;
+import de.intevation.flys.collections.FLYSArtifactCollection;
 
 import de.intevation.flys.utils.FLYSUtils;
 
@@ -33,6 +34,9 @@
     protected OutputStream out;
     protected FLYSArtifact master;
 
+    protected FLYSArtifactCollection collection;
+
+
     public ATExporter() {
     }
 
@@ -42,12 +46,18 @@
         this.out     = out;
     }
 
+
     @Override
     public void setMasterArtifact(Artifact master) {
         this.master = (FLYSArtifact) master;
     }
 
     @Override
+    public void setCollection(FLYSArtifactCollection collection) {
+        this.collection = collection;
+    }
+
+    @Override
     public void doOut(
         ArtifactAndFacet artifactf,
         Document attr,
--- a/flys-artifacts/src/main/java/de/intevation/flys/exports/AbstractExporter.java	Thu Jul 19 21:12:57 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/AbstractExporter.java	Fri Jul 20 06:50:25 2012 +0000
@@ -22,6 +22,7 @@
 import de.intevation.artifacts.common.utils.XMLUtils;
 
 import de.intevation.flys.artifacts.resources.Resources;
+import de.intevation.flys.collections.FLYSArtifactCollection;
 
 import de.intevation.flys.utils.Formatter;
 
@@ -67,6 +68,9 @@
     /** The selected facet. */
     protected String facet;
 
+    /** The collection.*/
+    protected FLYSArtifactCollection collection;
+
     /** The master artifact. */
     protected Artifact master;
 
@@ -113,6 +117,12 @@
     }
 
 
+    @Override
+    public void setCollection(FLYSArtifactCollection collection) {
+        this.collection = collection;
+    }
+
+
     /**
      * This doOut() just collects the data of multiple artifacts. Therefore, it
      * makes use of the addData() method which enables concrete subclasses to
--- a/flys-artifacts/src/main/java/de/intevation/flys/exports/ChartGenerator.java	Thu Jul 19 21:12:57 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/ChartGenerator.java	Fri Jul 20 06:50:25 2012 +0000
@@ -10,6 +10,7 @@
 import de.intevation.artifacts.common.utils.XMLUtils;
 import de.intevation.flys.artifacts.FLYSArtifact;
 import de.intevation.flys.artifacts.resources.Resources;
+import de.intevation.flys.collections.FLYSArtifactCollection;
 import de.intevation.flys.jfree.Bounds;
 import de.intevation.flys.jfree.CollisionFreeXYTextAnnotation;
 import de.intevation.flys.jfree.DoubleBounds;
@@ -105,6 +106,8 @@
     /** The CallContext object.*/
     protected CallContext context;
 
+    protected FLYSArtifactCollection collection;
+
     /** The artifact that is used to decorate the chart with meta information.*/
     protected Artifact master;
 
@@ -695,6 +698,12 @@
 
 
     @Override
+    public void setCollection(FLYSArtifactCollection collection) {
+        this.collection = collection;
+    }
+
+
+    @Override
     public void setSettings(Settings settings) {
         this.settings = settings;
     }
--- a/flys-artifacts/src/main/java/de/intevation/flys/exports/ChartInfoGenerator.java	Thu Jul 19 21:12:57 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/ChartInfoGenerator.java	Fri Jul 20 06:50:25 2012 +0000
@@ -1,5 +1,6 @@
 package de.intevation.flys.exports;
 
+import de.intevation.flys.collections.FLYSArtifactCollection;
 import de.intevation.flys.java2d.NOPGraphics2D;
 
 import java.io.IOException;
@@ -86,6 +87,16 @@
 
     /**
      * Dispatches the operation to the instantiated generator.
+     *
+     * @param collection The collection.
+     */
+    public void setCollection(FLYSArtifactCollection collection) {
+        generator.setCollection(collection);
+    }
+
+
+    /**
+     * Dispatches the operation to the instantiated generator.
      */
     public void doOut(
         ArtifactAndFacet artifactFacet,
--- a/flys-artifacts/src/main/java/de/intevation/flys/exports/MapGenerator.java	Thu Jul 19 21:12:57 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/MapGenerator.java	Fri Jul 20 06:50:25 2012 +0000
@@ -15,6 +15,7 @@
 import de.intevation.flys.artifacts.model.map.WMSDBLayerFacet;
 import de.intevation.flys.artifacts.model.map.WMSLayerFacet;
 import de.intevation.flys.artifacts.model.map.WSPLGENLayerFacet;
+import de.intevation.flys.collections.FLYSArtifactCollection;
 import de.intevation.flys.utils.GeometryUtils;
 import de.intevation.flys.utils.MapfileGenerator;
 import de.intevation.flys.utils.ThemeUtil;
@@ -35,6 +36,8 @@
 
     private static Logger logger = Logger.getLogger(MapGenerator.class);
 
+    protected FLYSArtifactCollection collection;
+
     protected Artifact master;
 
     protected Settings settings;
@@ -75,6 +78,10 @@
         this.master = master;
     }
 
+    @Override
+    public void setCollection(FLYSArtifactCollection collection) {
+        this.collection = collection;
+    }
 
     @Override
     public void doOut(
--- a/flys-artifacts/src/main/java/de/intevation/flys/exports/OutGenerator.java	Thu Jul 19 21:12:57 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/OutGenerator.java	Fri Jul 20 06:50:25 2012 +0000
@@ -9,6 +9,7 @@
 import de.intevation.artifactdatabase.state.Settings;
 import de.intevation.artifacts.Artifact;
 import de.intevation.artifacts.CallContext;
+import de.intevation.flys.collections.FLYSArtifactCollection;
 
 
 /**
@@ -38,6 +39,13 @@
     void setMasterArtifact(Artifact master);
 
     /**
+     * This method is used to set the Collection of the OutGenerator.
+     *
+     * @param collection A reference to the collection.
+     */
+    void setCollection(FLYSArtifactCollection collection);
+
+    /**
      * Creates the output of an Artifact and appends that single output to the
      * total output.
      *
--- a/flys-artifacts/src/main/java/de/intevation/flys/exports/ReportGenerator.java	Thu Jul 19 21:12:57 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/ReportGenerator.java	Fri Jul 20 06:50:25 2012 +0000
@@ -15,6 +15,7 @@
 import de.intevation.artifactdatabase.state.Settings;
 
 import de.intevation.flys.artifacts.model.Calculation;
+import de.intevation.flys.collections.FLYSArtifactCollection;
 
 import org.w3c.dom.Document;
 
@@ -44,6 +45,11 @@
     }
 
     @Override
+    public void setCollection(FLYSArtifactCollection collection) {
+        // not needed
+    }
+
+    @Override
     public void doOut(
         ArtifactAndFacet artifactFacet,
         Document         attr,
--- a/flys-artifacts/src/main/java/de/intevation/flys/exports/sq/SQOverviewGenerator.java	Thu Jul 19 21:12:57 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/sq/SQOverviewGenerator.java	Fri Jul 20 06:50:25 2012 +0000
@@ -28,6 +28,7 @@
 import de.intevation.flys.artifacts.context.FLYSContext;
 import de.intevation.flys.collections.AttributeParser;
 import de.intevation.flys.collections.CollectionAttribute;
+import de.intevation.flys.collections.FLYSArtifactCollection;
 import de.intevation.flys.exports.ChartGenerator;
 import de.intevation.flys.exports.OutGenerator;
 import de.intevation.flys.exports.OutputHelper;
@@ -40,6 +41,8 @@
     public static final String XPATH_CHART_SIZE =
         "/art:action/art:attributes/art:size";
 
+    protected FLYSArtifactCollection collection;
+
     protected Artifact master;
 
     protected Settings settings;
@@ -64,7 +67,6 @@
     ) {
         logger.debug("doOut()");
 
-        logger.debug(XMLUtils.toString(attr));
         String name = artifactAndFacet.getData(context).toString();
         if(name != null) {
             logger.debug("name: " + name);
@@ -73,25 +75,26 @@
                     context,
                     name,
                     null);
+
             if (g == null) {
                 logger.debug("generator is null.");
                 return;
             }
-            logger.debug(XMLUtils.toString(attr));
+
             OutputHelper helper = new OutputHelper(master.identifier());
+            Document collectionAttribute = collection.getAttribute();
+
             try {
-                AttributeParser parser    = new AttributeParser(request);
-                CollectionAttribute cAttr = parser.getCollectionAttribute();
-
+                Document cAttr = getAttribute(context, collectionAttribute, name);
                 g.init(request, out, context);
-                Document chartAttr = getAttribute(context, cAttr, name);
-                logger.debug(XMLUtils.toString(chartAttr));
-                helper.doOut(g, name, name, request, context);
+
+                helper.doOut(g, name, name, cAttr, context);
                 charts.add(g.generateChart());
-            } catch (IOException e) {
+            }
+            catch (IOException e) {
                 logger.warn(e);
-            } catch (ArtifactDatabaseException e) {
-                // TODO Auto-generated catch block
+            }
+            catch (ArtifactDatabaseException e) {
                 logger.warn(e);
             }
         }
@@ -108,6 +111,10 @@
         this.master = master;
     }
 
+    public void setCollection(FLYSArtifactCollection collection) {
+        this.collection = collection;
+    }
+
     public void generate() throws IOException {
         logger.debug("SQOverviewGenerator.generate");
 
@@ -151,18 +158,18 @@
      * output type.
      *
      * @param context The CallContext object.
-     * @param cAttr The CollectionAttribute.
+     * @param attr The xml attribute saved at the collection.
      * @param output The name of the desired output type.
      *
      * @return the attribute for the desired output type.
      */
     protected Document getAttribute(
-        CallContext         context,
-        CollectionAttribute cAttr,
-        String              output)
+        CallContext context,
+        Document    attr,
+        String      output)
     throws    ArtifactDatabaseException
     {
-        Document attr = cAttr.toXML();
+        logger.debug("find specific XML node for Output: " + output);
 
         Map<String, String> vars = new HashMap<String, String>();
         vars.put("output", output);
@@ -174,10 +181,8 @@
             ArtifactNamespaceContext.INSTANCE,
             vars);
 
-
         if (out != null) {
             Document o = XMLUtils.newDocument();
-
             o.appendChild(o.importNode(out, true));
 
             return o;

http://dive4elements.wald.intevation.org