changeset 412:046bd86ae41d

Improved the OutGenerator interface to set a master artifact for the out generation. flys-artifacts/trunk@1874 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Tue, 10 May 2011 10:26:26 +0000
parents 6ab62e5b05b5
children 8a4c219fd0ee
files flys-artifacts/ChangeLog flys-artifacts/src/main/java/de/intevation/flys/collections/FLYSArtifactCollection.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/OutGenerator.java
diffstat 5 files changed, 73 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/flys-artifacts/ChangeLog	Tue May 10 07:40:06 2011 +0000
+++ b/flys-artifacts/ChangeLog	Tue May 10 10:26:26 2011 +0000
@@ -1,3 +1,18 @@
+2011-05-10  Ingo Weinzierl <ingo@intevation.de>
+
+	* src/main/java/de/intevation/flys/exports/OutGenerator.java: Added a
+	  method to set the master artifact that should be used for some special
+	  operations.
+
+	* src/main/java/de/intevation/flys/exports/ChartGenerator.java,
+	  src/main/java/de/intevation/flys/exports/AbstractExporter.java:
+	  Implement the setMasterArtifact() method of the interface.
+
+	* src/main/java/de/intevation/flys/collections/FLYSArtifactCollection.java:
+	  Call OutGenerator.setMasterArtifact().
+
+	  NOTE: The determination of the master artifact needs to be implemented!
+
 2011-05-10  Ingo Weinzierl <ingo@intevation.de>
 
 	* src/main/java/de/intevation/flys/artifacts/FLYSArtifact.java: Removed
--- a/flys-artifacts/src/main/java/de/intevation/flys/collections/FLYSArtifactCollection.java	Tue May 10 07:40:06 2011 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/collections/FLYSArtifactCollection.java	Tue May 10 10:26:26 2011 +0000
@@ -147,6 +147,8 @@
 
         generator.init(format, out, context);
 
+        // TODO Determine the correct master artifact here!
+
         try {
             doOut(generator, name, type, getAttribute(context, name), context);
         }
@@ -203,8 +205,14 @@
                     continue;
                 }
 
+                // TODO Remove the following two lines of code! The master
+                // artifact has to be determined correctly after
+                // OutGenerator.init is called!
+                Artifact artifact = getArtifact(art, context);
+                generator.setMasterArtifact(artifact);
+
                 generator.doOut(
-                    getArtifact(art, context),
+                    artifact,
                     facetName,
                     getFacetThemeFromAttribute(
                         art,
--- a/flys-artifacts/src/main/java/de/intevation/flys/exports/AbstractExporter.java	Tue May 10 07:40:06 2011 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/AbstractExporter.java	Tue May 10 10:26:26 2011 +0000
@@ -48,6 +48,9 @@
     /** The selected facet.*/
     protected String facet;
 
+    /** The master artifact.*/
+    protected Artifact master;
+
 
     /**
      * Concrete subclasses need to use this method to write their special data
@@ -77,6 +80,11 @@
     }
 
 
+    public void setMasterArtifact(Artifact master) {
+        this.master = master;
+    }
+
+
     /**
      * 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	Tue May 10 07:40:06 2011 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/ChartGenerator.java	Tue May 10 10:26:26 2011 +0000
@@ -8,8 +8,12 @@
 import org.w3c.dom.Document;
 
 import de.intevation.artifacts.Artifact;
+import de.intevation.artifacts.CallContext;
+
+import de.intevation.flys.model.River;
+
+import de.intevation.flys.artifacts.FLYSArtifact;
 import de.intevation.flys.artifacts.resources.Resources;
-import de.intevation.artifacts.CallContext;
 
 
 /**
@@ -32,6 +36,9 @@
     /** The CallContext object.*/
     protected CallContext context;
 
+    /** The artifact that is used to decorate the chart with meta information.*/
+    protected Artifact master;
+
 
     public void init(Document request, OutputStream out, CallContext context) {
         logger.debug("ChartGenerator.init");
@@ -42,11 +49,36 @@
     }
 
 
+    public void setMasterArtifact(Artifact master) {
+        this.master = master;
+    }
+
+
     protected String msg(String key, String def) {
         return Resources.getMsg(context.getMeta(), key, def);
     }
 
 
+    protected String msg(String key, String def, Object[] args) {
+        return Resources.getMsg(context.getMeta(), key, def, args);
+    }
+
+
+    protected String getRiverName() {
+        FLYSArtifact flys = (FLYSArtifact) master;
+
+        River river = flys.getRiver();
+        return river != null ? river.getName() : "";
+    }
+
+
+    protected double[] getRange() {
+        FLYSArtifact flys = (FLYSArtifact) master;
+
+        return flys.getDistance();
+    }
+
+
     public abstract void doOut(Artifact artifact, String facet, Document attr);
 
     public abstract void generate() throws IOException;
--- a/flys-artifacts/src/main/java/de/intevation/flys/exports/OutGenerator.java	Tue May 10 07:40:06 2011 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/OutGenerator.java	Tue May 10 10:26:26 2011 +0000
@@ -28,6 +28,14 @@
     void init(Document request, OutputStream out, CallContext context);
 
     /**
+     * This method is used to tell the OutGenerator which artifact is the master
+     * artifact which is used for special operations.
+     *
+     * @param master The master artifact.
+     */
+    void setMasterArtifact(Artifact master);
+
+    /**
      * Creates the output of an Artifact and appends that single output to the
      * total output.
      *

http://dive4elements.wald.intevation.org