changeset 704:eab5e5089d77

Merged revisions 2127-2133,2136-2137,2140,2143-2144,2146,2150-2151,2153-2154 via svnmerge from svn+ssh://teichmann@thoe/home/projects/Geospatial/bsh-generischer-viewer/Material/SVN/flys-artifacts/branches/facets-slt ........ r2127 | ingo | 2011-06-16 09:50:56 +0200 (Do, 16 Jun 2011) | 1 line Added a compute() method to WINFOArtifact which acts as a dispatcher for different computations. It triggers a calculation based on ComputeCallbacks that are generated by the current states. ........ r2128 | ingo | 2011-06-16 10:25:06 +0200 (Do, 16 Jun 2011) | 1 line Moved Waterlevel state into the correct package. ........ r2129 | ingo | 2011-06-16 10:43:58 +0200 (Do, 16 Jun 2011) | 1 line Added two more compute() methods to ComputeCallback to distinguish between different phases of the artifact. ........ r2130 | ingo | 2011-06-16 10:57:05 +0200 (Do, 16 Jun 2011) | 1 line Use enums to dispatch computeFeed() and computeAdvance(). ........ r2131 | ingo | 2011-06-16 11:04:59 +0200 (Do, 16 Jun 2011) | 1 line Store facets for each state. ........ r2132 | ingo | 2011-06-16 12:05:44 +0200 (Do, 16 Jun 2011) | 1 line Generated facets for each output aspect. ........ r2133 | ingo | 2011-06-16 15:24:00 +0200 (Do, 16 Jun 2011) | 1 line Write computed facets into artifacts describe document. ........ r2136 | ingo | 2011-06-16 16:10:49 +0200 (Do, 16 Jun 2011) | 1 line Add index and description of facets to collections describe document. ........ r2137 | ingo | 2011-06-16 16:31:41 +0200 (Do, 16 Jun 2011) | 1 line OutGenerators doOut() takes a facet object now instead of just its name. ........ r2140 | ingo | 2011-06-17 11:19:43 +0200 (Fr, 17 Jun 2011) | 1 line OutGenerators use now facets to fetch necessary data. ........ r2143 | teichmann | 2011-06-17 12:40:54 +0200 (Fr, 17 Jun 2011) | 1 line Removed ComputeCallback because this was thought too complicated. Fixed issue with facets not be re-generated if same state is entered again. ........ r2144 | teichmann | 2011-06-17 13:08:31 +0200 (Fr, 17 Jun 2011) | 1 line make getGauges() more robust ........ r2146 | teichmann | 2011-06-17 13:23:57 +0200 (Fr, 17 Jun 2011) | 1 line mico opt: inter cmps are faster than str cmps. ........ r2150 | teichmann | 2011-06-17 15:10:20 +0200 (Fr, 17 Jun 2011) | 1 line call computeAdvance() if we want to advance. ........ r2151 | teichmann | 2011-06-17 15:45:50 +0200 (Fr, 17 Jun 2011) | 1 line Base WST/CSV exports on facets. TODO: generate the facets. ........ r2153 | teichmann | 2011-06-17 16:03:29 +0200 (Fr, 17 Jun 2011) | 1 line Add facet to access raw computed data. ........ r2154 | teichmann | 2011-06-17 16:37:09 +0200 (Fr, 17 Jun 2011) | 1 line Generate data facets for the computed states. ........ flys-artifacts/trunk@2156 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Fri, 17 Jun 2011 16:17:03 +0000
parents d45c3ddaed1b (current diff) af3b5d9e91a4 (diff)
children 853dceead0f4
files flys-artifacts/ChangeLog flys-artifacts/doc/conf/artifacts/winfo.xml flys-artifacts/src/main/java/de/intevation/flys/artifacts/FLYSArtifact.java flys-artifacts/src/main/java/de/intevation/flys/artifacts/WINFOArtifact.java flys-artifacts/src/main/java/de/intevation/flys/artifacts/WaterlevelState.java flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/Calculation.java flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/Calculation4.java flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/WQCKms.java flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/WQDay.java flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/WQKms.java flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/WstValueTable.java flys-artifacts/src/main/java/de/intevation/flys/artifacts/services/DistanceInfoService.java flys-artifacts/src/main/java/de/intevation/flys/exports/DurationCurveGenerator.java flys-artifacts/src/main/resources/messages_de.properties flys-artifacts/src/main/resources/messages_de_DE.properties
diffstat 34 files changed, 1081 insertions(+), 283 deletions(-) [+]
line wrap: on
line diff
--- a/flys-artifacts/ChangeLog	Fri Jun 17 13:00:54 2011 +0000
+++ b/flys-artifacts/ChangeLog	Fri Jun 17 16:17:03 2011 +0000
@@ -1,3 +1,73 @@
+2011-06-17  Sascha L. Teichmann <sascha.teichmann@intevation.de>
+
+	Merged in the facet-slt branch to bring in the 'facet' feature.
+
+	* doc/conf/artifacts/winfo.xml: Fixed some facets.
+
+	* doc/conf/cache.xml: Added a "computed.values" cache to store the
+	  results of the WINFO calculations.
+
+	* src/main/java/de/intevation/flys/artifacts/model/ManagedFacet.java:
+	  Add support for index per facet to make them unique and identifiable.
+
+	* src/main/java/de/intevation/flys/artifacts/model/FacetTypes.java:
+	  New. Inteface to be used to access the facet names of the configuration.
+
+	* src/main/java/de/intevation/flys/artifacts/model/DataFacet.java: New.
+	  A facet to be used to have raw access to the computed data of an artifact.
+	  Useful to export things like CSV and WST.
+
+	* src/main/java/de/intevation/flys/artifacts/model/WaterlevelFacet.java: New.
+	  Specialized facet to access the water level data stored in WQKms arrays.
+
+	* src/main/java/de/intevation/flys/artifacts/model/DurationCurveFacet.java: New.
+	  Specialized facet to access the duration data stored in WQDay data structures.
+	  
+	* src/main/java/de/intevation/flys/artifacts/WINFOArtifact.java: Facets are
+	  now generated dynamically from the current available ones stored with
+	  the artifact.
+
+	* src/main/java/de/intevation/flys/artifacts/states/DefaultState.java: Added
+	  methods computeAdvance() and computeFeed() called if artifact is fed or
+	  adance. This overwritten in subclasses to do the state depending calculations.
+
+	* src/main/java/de/intevation/flys/artifacts/states/ComputedDischargeCurveState.java,
+	  src/main/java/de/intevation/flys/artifacts/states/LocationDistanceSelect.java,
+	  src/main/java/de/intevation/flys/artifacts/states/DischargeLongitudinalSection.java,
+	  src/main/java/de/intevation/flys/artifacts/states/DurationCurveState.java,
+	  src/main/java/de/intevation/flys/artifacts/states/WaterlevelState.java: These
+	  states overwrites the computeAdvance() and computeFeed() methods to do
+	  the corresponding WINFO calculations.
+
+	* src/main/java/de/intevation/flys/artifacts/FLYSArtifact.java: Calls 
+	  computeAdvance() and computeFeed() if artifact is fed or advanced. Centralized
+	  the caching mechanism.
+
+	* src/main/java/de/intevation/flys/exports/AbstractExporter.java,
+	  src/main/java/de/intevation/flys/collections/AttributeParser.java,
+	  src/main/java/de/intevation/flys/collections/OutputParser.java,
+	  src/main/java/de/intevation/flys/collections/AttributeWriter.java,
+	  src/main/java/de/intevation/flys/collections/FLYSArtifactCollection.java:
+	  Adjusted the code to cope with the indices of the facets. Used
+	  DOM to access the attributes instead of XPath. Removed smaller bugs
+	  concerning position generation.
+
+	* src/main/java/de/intevation/flys/exports/ChartInfoGenerator.java,
+	  src/main/java/de/intevation/flys/exports/ChartGenerator.java,
+	  src/main/java/de/intevation/flys/exports/OutGenerator.java:
+	  Forwarded facet references.
+
+	* src/main/java/de/intevation/flys/exports/ComputedDischargeCurveExporter.java,
+	  src/main/java/de/intevation/flys/exports/LongitudinalSectionGenerator.java,
+	  src/main/java/de/intevation/flys/exports/DurationCurveExporter.java,
+	  src/main/java/de/intevation/flys/exports/DischargeLongitudinalSectionExporter.java,
+	  src/main/java/de/intevation/flys/exports/ComputedDischargeCurveGenerator.java,
+	  src/main/java/de/intevation/flys/exports/DischargeCurveGenerator.java,
+	  src/main/java/de/intevation/flys/exports/DischargeLongitudinalSectionGenerator.java,
+	  src/main/java/de/intevation/flys/exports/DurationCurveGenerator.java,
+	  src/main/java/de/intevation/flys/exports/WaterlevelExporter.java:
+	  Uses facets to fetch data and generate output now.
+
 2011-06-17  Ingo Weinzierl <ingo@intevation.de>
 
 	* doc/conf/artifacts/winfo.xml: Added a new parameter "wq_free" that
--- a/flys-artifacts/doc/conf/artifacts/winfo.xml	Fri Jun 17 13:00:54 2011 +0000
+++ b/flys-artifacts/doc/conf/artifacts/winfo.xml	Fri Jun 17 16:17:03 2011 +0000
@@ -45,7 +45,6 @@
             <outputmodes>
                 <outputmode name="discharge_curve" description="output.discharge_curve" mime-type="image/png">
                     <facets>
-                        <facet name="discharge_curve.curve" description="facet.discharge_curve.curve"/>
                         <facet name="discharge_curve.w" description="facet.discharge_curve.w"/>
                         <facet name="discharge_curve.q" description="facet.discharge_curve.q"/>
                     </facets>
@@ -131,7 +130,6 @@
             <outputmodes>
                 <outputmode name="computed_discharge_curve" description="output.computed_discharge_curve" mime-type="image/png">
                     <facets>
-                        <facet name="computed_discharge_curve.w" description="facet.computed_discharge_curve.w"/>
                         <facet name="computed_discharge_curve.q" description="facet.computed_discharge_curve.q"/>
                     </facets>
                 </outputmode>
@@ -183,7 +181,7 @@
                 <outputmode name="discharge_longitudinal_section_export" description="output.discharge_longitudinal_section_export" mime-type="text/plain">
                     <facets>
                         <facet name="csv" description="facet.discharge_longitudinal_section_export.csv" />
-                        <facet name="wst" description="facet.discharge_longitudinal_section_export.csv" />
+                        <facet name="wst" description="facet.discharge_longitudinal_section_export.wst" />
                     </facets>
                 </outputmode>
             </outputmodes>
--- a/flys-artifacts/doc/conf/cache.xml	Fri Jun 17 13:00:54 2011 +0000
+++ b/flys-artifacts/doc/conf/cache.xml	Fri Jun 17 16:17:03 2011 +0000
@@ -36,4 +36,14 @@
            timeToLiveSeconds="86400"
            memoryStoreEvictionPolicy="LFU"
            />
+
+    <!-- This one is used to cache the computed values.-->
+    <cache name="computed.values"
+           maxElementsInMemory="1000"
+           eternal="false"
+           timeToLiveSeconds="172800"
+           overflowToDisk="true"
+           diskPersistent="true"
+           memoryStoreEvictionPolicy="LFU"
+           />
 </ehcache>
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/FLYSArtifact.java	Fri Jun 17 13:00:54 2011 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/FLYSArtifact.java	Fri Jun 17 16:17:03 2011 +0000
@@ -4,6 +4,7 @@
 import java.util.Collection;
 import java.util.Collections;
 import java.util.HashMap;
+import java.util.TreeMap;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
@@ -12,6 +13,8 @@
 
 import gnu.trove.TDoubleArrayList;
 
+import net.sf.ehcache.Cache;
+
 import org.apache.log4j.Logger;
 
 import org.w3c.dom.Document;
@@ -28,6 +31,7 @@
 import de.intevation.artifactdatabase.DefaultArtifact;
 import de.intevation.artifactdatabase.data.DefaultStateData;
 import de.intevation.artifactdatabase.data.StateData;
+import de.intevation.artifactdatabase.state.Facet;
 import de.intevation.artifactdatabase.state.State;
 import de.intevation.artifactdatabase.state.StateEngine;
 import de.intevation.artifactdatabase.transition.TransitionEngine;
@@ -40,11 +44,14 @@
 
 import de.intevation.flys.artifacts.context.FLYSContext;
 
+import de.intevation.flys.artifacts.cache.CacheFactory;
+
 import de.intevation.flys.artifacts.model.DischargeTables;
 import de.intevation.flys.artifacts.model.RiverFactory;
 import de.intevation.flys.artifacts.model.Segment;
 
 import de.intevation.flys.artifacts.states.DefaultState;
+import de.intevation.flys.artifacts.states.DefaultState.ComputeType;
 import de.intevation.flys.artifacts.states.LocationDistanceSelect;
 
 
@@ -59,6 +66,8 @@
     private static Logger logger = Logger.getLogger(FLYSArtifact.class);
 
 
+    public static final String COMPUTING_CACHE = "computed.values";
+
     /** The XPath that points to the input data elements of the FEED document.*/
     public static final String XPATH_FEED_INPUT =
         "/art:action/art:data/art:input";
@@ -93,13 +102,17 @@
     /** The data that have been inserted into this artifact.*/
     protected Map<String, StateData> data;
 
+    /** The list of facets supported by this artifact.*/
+    protected Map<String, List<Facet>> facets;
+
 
     /**
      * The default constructor that creates an empty FLYSArtifact.
      */
     public FLYSArtifact() {
-        data             = new HashMap<String, StateData>();
+        data             = new TreeMap<String, StateData>();
         previousStateIds = new ArrayList<String>();
+        facets           = new HashMap<String, List<Facet>>();
     }
 
 
@@ -182,6 +195,9 @@
 
         try {
             saveData(target, XPATH_FEED_INPUT, context);
+
+            compute(context, ComputeType.FEED);
+
             return describe(target, context);
         }
         catch (IllegalArgumentException iae) {
@@ -228,6 +244,9 @@
 
             setCurrentStateId(targetState);
 
+            logger.debug("Compute data for state: " + targetState);
+            compute(context, ComputeType.ADVANCE);
+
             return describe(target, context);
         }
         else if (isPreviousState(targetState, context)) {
@@ -241,6 +260,7 @@
                 String prev = prevs.get(i);
                 logger.debug("Remove state id '" + prev + "'");
                 prevs.remove(prev);
+                facets.remove(prev);
             }
 
             setCurrentStateId(targetState);
@@ -338,6 +358,23 @@
     }
 
 
+    public Facet getNativeFacet(Facet facet) {
+        String name  = facet.getName();
+        int    index = facet.getIndex();
+
+        for (Map.Entry<String, List<Facet>> entry: facets.entrySet()) {
+            for (Facet f: entry.getValue()) {
+                if (f.getIndex() == index && f.getName().equals(name)) {
+                    return f;
+                }
+            }
+        }
+
+        logger.warn("Could not find facet: " + name + " at " + index);
+        return null;
+    }
+
+
     /**
      * This method stores the data that is contained in the FEED document.
      *
@@ -673,8 +710,16 @@
      * @return the gauges based on the selected kilometer range.
      */
     public List<Gauge> getGauges() {
-        River    river = getRiver();
-        double[] dist  = getDistance();
+
+        River river = getRiver();
+        if (river == null) {
+            return null;
+        }
+
+        double [] dist  = getDistance();
+        if (dist == null) {
+            return null;
+        }
 
         return river.determineGauges(dist[0], dist[1]);
     }
@@ -1023,6 +1068,117 @@
     }
 
     /**
+     * Computes the hash code of the entered values.
+     *
+     * @return a hash code.
+     */
+    @Override
+    public String hash() {
+        Set<Map.Entry<String, StateData>> entries = data.entrySet();
+
+        int hash  = 0;
+        int shift = 3;
+
+        for (Map.Entry<String, StateData> entry: entries) {
+            String key   = entry.getKey();
+            Object value = entry.getValue().getValue();
+
+            hash ^= (key.hashCode() << shift) | (value.hashCode() << 2 * shift);
+            shift += 2;
+        }
+
+        return getCurrentStateId() + hash;
+    }
+
+
+    /**
+     * Dispatches the computation request to compute(CallContext context, String
+     * hash) with the current hash value of the artifact which is provided by
+     * hash().
+     *
+     * @param context The CallContext.
+     */
+    public Object compute(CallContext context, ComputeType type) {
+        return compute(context, hash(), type);
+    }
+
+
+    /**
+     * Dispatches computation requests to the current state which needs to
+     * implement a createComputeCallback(String hash, FLYSArtifact artifact)
+     * method.
+     *
+     * @param context The CallContext.
+     * @param hash The hash value which is used to fetch computed data from
+     * cache.
+     *
+     * @return the computed data.
+     */
+    public Object compute(CallContext context, String hash, ComputeType type) {
+        DefaultState current = (DefaultState) getCurrentState(context);
+
+        logger.debug("Create ComputeCallback for state: " + current.getID());
+
+        return compute(context, hash, current, type);
+    }
+
+
+    public Object compute(
+        CallContext   context,
+        String        key,
+        DefaultState  state,
+        ComputeType   type
+    ) {
+        String stateID = state.getID();
+
+        List<Facet> fs = new ArrayList<Facet>();
+
+        try {
+            Cache cache = CacheFactory.getCache(COMPUTING_CACHE);
+
+            Object old = null;
+
+            if (cache != null) {
+                net.sf.ehcache.Element element = cache.get(key);
+                if (element != null) {
+                    logger.debug("Got computation result from cache.");
+                    old = element.getValue();
+                }
+            }
+
+            Object res;
+            switch (type) {
+                case FEED:
+                    res = state.computeFeed(this, key, context, fs, old);
+                    break;
+                case ADVANCE:
+                    res = state.computeAdvance(this, key, context, fs, old);
+                    break;
+                default:
+                    res = null;
+            }
+
+            if (cache != null && old != res && res != null) {
+                logger.debug("Store computation result to cache.");
+                net.sf.ehcache.Element element =
+                    new net.sf.ehcache.Element(key, res);
+                cache.put(element);
+            }
+
+            return res;
+        }
+        finally {
+            if (fs.isEmpty()) {
+                facets.remove(stateID);
+            }
+            else {
+                facets.put(stateID, fs);
+            }
+        }
+    }
+
+
+    /**
      * Method to dump the artifacts state/data.
      */
     protected void dumpArtifact() {
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/WINFOArtifact.java	Fri Jun 17 13:00:54 2011 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/WINFOArtifact.java	Fri Jun 17 16:17:03 2011 +0000
@@ -1,6 +1,10 @@
 package de.intevation.flys.artifacts;
 
+import java.util.ArrayList;
+import java.util.HashSet;
 import java.util.List;
+import java.util.Map;
+import java.util.Set;
 
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
@@ -12,6 +16,8 @@
 import de.intevation.artifacts.CallContext;
 
 import de.intevation.artifactdatabase.ProtocolUtils;
+import de.intevation.artifactdatabase.state.DefaultOutput;
+import de.intevation.artifactdatabase.state.Facet;
 import de.intevation.artifactdatabase.state.Output;
 import de.intevation.artifactdatabase.state.State;
 import de.intevation.artifactdatabase.state.StateEngine;
@@ -25,6 +31,7 @@
 import de.intevation.flys.artifacts.states.DefaultState;
 import de.intevation.flys.artifacts.context.FLYSContext;
 
+import de.intevation.flys.artifacts.model.DischargeTables;
 import de.intevation.flys.artifacts.model.MainValuesFactory;
 import de.intevation.flys.artifacts.model.WQDay;
 import de.intevation.flys.artifacts.model.WQKms;
@@ -177,7 +184,7 @@
 
         for (String stateId: stateIds) {
             logger.debug("Append output modes for state: " + stateId);
-            State state = engine.getState(stateId);
+            DefaultState state = (DefaultState) engine.getState(stateId);
 
             List<Output> list = state.getOutputs();
             if (list == null || list.size() == 0) {
@@ -185,7 +192,17 @@
                 continue;
             }
 
-            ProtocolUtils.appendOutputModes(creator, outs, list);
+            List<Facet>  fs = facets.get(stateId);
+            if (fs == null || fs.size() == 0) {
+                logger.debug("No facets found.");
+                continue;
+            }
+
+            logger.debug("Found " + fs.size() + " facets in previous states.");
+
+            List<Output> generated = generateOutputs(list, fs);
+
+            ProtocolUtils.appendOutputModes(creator, outs, generated);
         }
 
         try {
@@ -196,7 +213,19 @@
                     logger.debug(
                         "Append output modes for state: " + cur.getID());
 
-                    ProtocolUtils.appendOutputModes(creator, outs, list);
+                    List<Facet>  fs = facets.get(cur.getID());
+                    if (fs != null && fs.size() > 0) {
+                        List<Output> generated = generateOutputs(list, fs);
+
+                        logger.debug("Found " + fs.size() + " current facets.");
+
+                        ProtocolUtils.appendOutputModes(
+                            creator, outs, generated);
+                    }
+                    else {
+                        logger.debug("No facets found for the current state.");
+                    }
+
                 }
             }
         }
@@ -206,6 +235,36 @@
     }
 
 
+    protected List<Output> generateOutputs(List<Output> list, List<Facet> fs) {
+        List<Output> generated = new ArrayList<Output>();
+
+        for (Output out: list) {
+            Output o = new DefaultOutput(
+                out.getName(),
+                out.getDescription(),
+                out.getMimeType());
+
+            Set<String> outtype = new HashSet<String>();
+
+            for (Facet f: out.getFacets()) {
+                outtype.add(f.getName());
+            }
+
+            for (Facet f: fs) {
+                String type = f.getName();
+
+                if(outtype.contains(type)) {
+                    o.addFacet(f);
+                }
+            }
+
+            generated.add(o);
+        }
+
+        return generated;
+    }
+
+
     /**
      * This method appends the static data - that has already been inserted by
      * the user - to the static node of the DESCRIBE document.
@@ -380,6 +439,37 @@
 
 
     /**
+     * Returns the data that is used to create discharge curves.
+     *
+     * @return a map where the key is the name of the gauge and a double[][]
+     * which are the values.
+     */
+    public Map<String, double[][]> getDischargeCurveData() {
+        River       river  = getRiver();
+        List<Gauge> gauges = getGauges();
+
+        if (gauges == null) {
+            logger.warn("No gauges found for the current kilometer range.");
+            return null;
+        }
+
+        int num = gauges.size();
+
+        logger.debug("Found " + num + " gauges.");
+
+        String[] gaugeNames = new String[num];
+
+        for (int i = 0; i < num; i++) {
+            gaugeNames[i] = gauges.get(i).getName();
+        }
+
+        DischargeTables dt = new DischargeTables(river.getName(), gaugeNames);
+
+        return dt.getValues(100d);
+    }
+
+
+    /**
      * Returns the data that is computed by a discharge curve computation.
      *
      * @return the data computed by a discharge curve computation.
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/WaterlevelState.java	Fri Jun 17 13:00:54 2011 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,29 +0,0 @@
-package de.intevation.flys.artifacts.states;
-
-import org.apache.log4j.Logger;
-
-import org.w3c.dom.Element;
-
-import de.intevation.artifacts.Artifact;
-import de.intevation.artifacts.CallContext;
-
-import de.intevation.artifacts.common.utils.XMLUtils;
-
-
-public class WaterlevelState extends DefaultState {
-
-    /** The logger that is used in this state.*/
-    private static Logger logger = Logger.getLogger(WaterlevelState.class);
-
-
-    protected Element[] createItems(
-        XMLUtils.ElementCreator cr,
-        Artifact    artifact,
-        String      name,
-        CallContext context)
-    {
-        logger.debug("WaterlevelState.createItems");
-        return null;
-    }
-}
-// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/DataFacet.java	Fri Jun 17 16:17:03 2011 +0000
@@ -0,0 +1,43 @@
+package de.intevation.flys.artifacts.model;
+
+import de.intevation.artifacts.Artifact;
+import de.intevation.artifacts.CallContext;
+
+import de.intevation.artifactdatabase.state.DefaultFacet;
+
+import de.intevation.flys.artifacts.FLYSArtifact;
+
+import de.intevation.flys.artifacts.states.DefaultState.ComputeType;
+
+public class DataFacet
+extends      DefaultFacet
+{
+    protected ComputeType type;
+    protected String      hash;
+
+    public DataFacet(String name, String description) {
+        this(name, description, ComputeType.ADVANCE);
+    }
+
+    public DataFacet(String name, String description, ComputeType type) {
+        this(name, description, type, null);
+    }
+
+    public DataFacet(
+        String      name,
+        String      description, 
+        ComputeType type,
+        String      hash
+    ) {
+        super(name, description);
+        this.type = type;
+        this.hash = hash;
+    }
+
+    public Object getData(Artifact artifact, CallContext context) {
+        FLYSArtifact flys = (FLYSArtifact)artifact;
+        return flys.compute(
+            context, hash != null ? hash : flys.hash(), type);
+    }
+}
+// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/DurationCurveFacet.java	Fri Jun 17 16:17:03 2011 +0000
@@ -0,0 +1,35 @@
+package de.intevation.flys.artifacts.model;
+
+import org.apache.log4j.Logger;
+
+import de.intevation.artifacts.Artifact;
+import de.intevation.artifacts.CallContext;
+
+import de.intevation.artifactdatabase.state.DefaultFacet;
+
+import de.intevation.flys.artifacts.WINFOArtifact;
+
+import de.intevation.flys.artifacts.states.DefaultState.ComputeType;
+
+
+public class DurationCurveFacet extends DefaultFacet {
+
+    private static Logger logger = Logger.getLogger(DurationCurveFacet.class);
+
+
+    public DurationCurveFacet(int index, String name, String description) {
+        super(index, name, description);
+    }
+
+
+    public Object getData(Artifact artifact, CallContext context) {
+        logger.debug("Get data for duration curve data at index: " + index);
+
+        WINFOArtifact winfo = (WINFOArtifact) artifact;
+
+        WQDay[] wqday = (WQDay[]) winfo.compute(context, ComputeType.ADVANCE);
+
+        return wqday[index];
+    }
+}
+// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/FacetTypes.java	Fri Jun 17 16:17:03 2011 +0000
@@ -0,0 +1,20 @@
+package de.intevation.flys.artifacts.model;
+
+public interface FacetTypes {
+
+    String DISCHARGE_LONGITUDINAL_W = "discharge_longitudinal_section.w";
+    String DISCHARGE_LONGITUDINAL_Q = "discharge_longitudinal_section.q";
+    String DISCHARGE_LONGITUDINAL_C = "discharge_longitudinal_section.c";
+
+    String LONGITUDINAL_W = "longitudinal_section.w";
+    String LONGITUDINAL_Q = "longitudinal_section.q";
+
+    String COMPUTED_DISCHARGE_Q = "computed_discharge_curve.q";
+
+    String DURATION_W = "duration_curve.w";
+    String DURATION_Q = "duration_curve.q";
+
+    String CSV = "csv";
+    String WST = "wst";
+}
+// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/ManagedFacet.java	Fri Jun 17 13:00:54 2011 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/ManagedFacet.java	Fri Jun 17 16:17:03 2011 +0000
@@ -8,6 +8,9 @@
     /** The uuid of the owner artifact.*/
     protected String uuid;
 
+    /** The index.*/
+    protected int index;
+
     /** A property that determines the position of this facet.*/
     protected int position;
 
@@ -17,12 +20,13 @@
 
     public ManagedFacet(
         String  name,
+        int     index,
         String  desc,
         String  uuid,
         int     pos,
         int     active)
     {
-        super(name, desc);
+        super(index, name, desc);
 
         this.uuid     = uuid;
         this.position = pos;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/WaterlevelFacet.java	Fri Jun 17 16:17:03 2011 +0000
@@ -0,0 +1,34 @@
+package de.intevation.flys.artifacts.model;
+
+import org.apache.log4j.Logger;
+
+import de.intevation.artifacts.Artifact;
+import de.intevation.artifacts.CallContext;
+
+import de.intevation.artifactdatabase.state.DefaultFacet;
+
+import de.intevation.flys.artifacts.WINFOArtifact;
+
+import de.intevation.flys.artifacts.states.DefaultState.ComputeType;
+
+public class WaterlevelFacet extends DefaultFacet {
+
+    private static Logger logger = Logger.getLogger(WaterlevelFacet.class);
+
+
+    public WaterlevelFacet(int index, String name, String description) {
+        super(index, name, description);
+    }
+
+
+    public Object getData(Artifact artifact, CallContext context) {
+        logger.debug("Get data for waterlevels at index: " + index);
+
+        WINFOArtifact winfo = (WINFOArtifact) artifact;
+
+        WQKms[] wqkms = (WQKms[]) winfo.compute(context, ComputeType.ADVANCE);
+
+        return wqkms[index];
+    }
+}
+// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/ComputedDischargeCurveState.java	Fri Jun 17 13:00:54 2011 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/ComputedDischargeCurveState.java	Fri Jun 17 16:17:03 2011 +0000
@@ -1,20 +1,81 @@
 package de.intevation.flys.artifacts.states;
 
+import java.util.List;
+
 import org.apache.log4j.Logger;
 
+import de.intevation.artifacts.CallContext;
+
+import de.intevation.artifactdatabase.state.Facet;
+
+import de.intevation.flys.artifacts.FLYSArtifact;
+import de.intevation.flys.artifacts.WINFOArtifact;
+
+import de.intevation.flys.artifacts.model.FacetTypes;
+import de.intevation.flys.artifacts.model.WaterlevelFacet;
+import de.intevation.flys.artifacts.model.DataFacet;
+import de.intevation.flys.artifacts.model.WQKms;
+
+import de.intevation.flys.artifacts.resources.Resources;
+
+
 /**
  * The final state that will be reached after the discharge curve calculation
  * mode has been chosen.
  *
  * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a>
  */
-public class ComputedDischargeCurveState extends DefaultState {
-
+public class ComputedDischargeCurveState
+extends      DefaultState
+implements   FacetTypes
+{
     /** The logger that is used in this state.*/
     private static Logger logger =
         Logger.getLogger(ComputedDischargeCurveState.class);
 
     public ComputedDischargeCurveState() {
     }
+
+
+    @Override
+    public Object computeAdvance(
+        FLYSArtifact artifact,
+        String       hash,
+        CallContext  context,
+        List<Facet>  facets, 
+        Object       old
+    ) {
+        WINFOArtifact winfo = (WINFOArtifact)artifact;
+
+        WQKms res;
+
+        if (old instanceof WQKms []) {
+            res = ((WQKms [])old)[0];
+        }
+        else {
+            res = winfo.getComputedDischargeCurveData();
+
+            if (res == null) {
+                logger.debug("No results given.");
+                return null;
+            }
+        }
+
+        Object[] args = new Object[] {
+            winfo.getRiver().getName(),
+            res.getName()
+        };
+
+        String name = Resources.getMsg(
+            context.getMeta(),
+            "chart.computed.discharge.curve.curve.label",
+            "",
+            args);
+
+        facets.add(new WaterlevelFacet(0, COMPUTED_DISCHARGE_Q, name));
+        facets.add(new DataFacet(CSV, "CSV data"));
+
+        return new WQKms[] { res };
+    }
 }
 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/DefaultState.java	Fri Jun 17 13:00:54 2011 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/DefaultState.java	Fri Jun 17 16:17:03 2011 +0000
@@ -4,6 +4,7 @@
 import java.util.Iterator;
 import java.util.Locale;
 import java.util.Map;
+import java.util.List;
 
 import org.apache.log4j.Logger;
 
@@ -19,10 +20,14 @@
 import de.intevation.artifacts.common.utils.XMLUtils;
 
 import de.intevation.artifactdatabase.ProtocolUtils;
+
 import de.intevation.artifactdatabase.data.StateData;
+
 import de.intevation.artifactdatabase.state.AbstractState;
+import de.intevation.artifactdatabase.state.Facet;
 
 import de.intevation.flys.artifacts.FLYSArtifact;
+
 import de.intevation.flys.artifacts.resources.Resources;
 
 
@@ -34,6 +39,9 @@
     /** The logger that is used in this class.*/
     private static Logger logger = Logger.getLogger(DefaultState.class);
 
+    public static enum ComputeType {
+        FEED, ADVANCE
+    }
 
     protected StateData getData(FLYSArtifact artifact,  String name) {
         return artifact.getData(name);
@@ -255,5 +263,25 @@
     protected String getUIProvider() {
         return null;
     }
+
+    public Object computeAdvance(
+        FLYSArtifact artifact,
+        String       hash,
+        CallContext  context, 
+        List<Facet>  facets, 
+        Object       old
+    ) {
+        return null;
+    }
+
+    public Object computeFeed(
+        FLYSArtifact artifact,
+        String       hash,
+        CallContext  context,
+        List<Facet>  facets, 
+        Object       old
+    ) {
+        return null;
+    }
 }
 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/DischargeLongitudinalSection.java	Fri Jun 17 13:00:54 2011 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/DischargeLongitudinalSection.java	Fri Jun 17 16:17:03 2011 +0000
@@ -1,10 +1,96 @@
 package de.intevation.flys.artifacts.states;
 
+import java.util.List;
+
 import org.apache.log4j.Logger;
 
-public class DischargeLongitudinalSection extends DefaultState {
+import de.intevation.artifacts.CallContext;
 
+import de.intevation.artifactdatabase.state.Facet;
+
+import de.intevation.flys.artifacts.FLYSArtifact;
+import de.intevation.flys.artifacts.WINFOArtifact;
+import de.intevation.flys.artifacts.model.FacetTypes;
+import de.intevation.flys.artifacts.model.WaterlevelFacet;
+import de.intevation.flys.artifacts.model.WQKms;
+import de.intevation.flys.artifacts.model.WQCKms;
+
+import de.intevation.flys.artifacts.model.DataFacet;
+
+public class DischargeLongitudinalSection
+extends      DefaultState
+implements   FacetTypes
+{
     private static Logger logger =
         Logger.getLogger(DischargeLongitudinalSection.class);
+
+
+    @Override
+    public Object computeAdvance(
+        FLYSArtifact artifact,
+        String       hash,
+        CallContext  context,
+        List<Facet>  facets, 
+        Object       old
+    ) {
+        WQKms [] res;
+
+        WINFOArtifact winfo = (WINFOArtifact)artifact;
+
+        if (old instanceof WQCKms []) {
+            res = (WQCKms [])old;
+        }
+        else {
+            res = winfo.getDischargeLongitudinalSectionData();
+
+            if (res == null) {
+                logger.debug("No results given.");
+                return null;
+            }
+        }
+
+        for (int i = 0; i < res.length; i++) {
+            String nameW = null;
+            String nameQ = null;
+
+            if (winfo.isQ()) {
+                nameQ = res[i].getName();
+                nameW = "W(" + nameQ + ")";
+            }
+            else {
+                nameW = res[i].getName();
+                nameQ = "Q(" + nameQ + ")";
+            }
+
+            Facet w = new WaterlevelFacet(
+                i, DISCHARGE_LONGITUDINAL_W, nameW);
+
+            Facet q = new WaterlevelFacet(
+                i, DISCHARGE_LONGITUDINAL_Q, nameQ);
+
+            facets.add(w);
+            facets.add(q);
+
+            if (res[i] instanceof WQCKms) {
+                // TODO DO i18n
+
+                String nameC = nameW.replace(
+                    "Benutzerdefiniert",
+                    "Benutzerdefiniert [korrigiert]");
+
+                Facet c = new WaterlevelFacet(
+                    i, DISCHARGE_LONGITUDINAL_C, nameC);
+
+                facets.add(c);
+            }
+        }
+
+        if (res.length > 0) {
+            facets.add(new DataFacet(CSV, "CSV data"));
+            facets.add(new DataFacet(WST, "WST data"));
+        }
+
+        return res;
+    }
 }
 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/DurationCurveState.java	Fri Jun 17 13:00:54 2011 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/DurationCurveState.java	Fri Jun 17 16:17:03 2011 +0000
@@ -1,19 +1,88 @@
 package de.intevation.flys.artifacts.states;
 
+import java.util.List;
+
 import org.apache.log4j.Logger;
 
+import de.intevation.artifacts.CallContext;
+
+import de.intevation.artifactdatabase.state.Facet;
+
+import de.intevation.flys.artifacts.FLYSArtifact;
+import de.intevation.flys.artifacts.WINFOArtifact;
+import de.intevation.flys.artifacts.model.DurationCurveFacet;
+import de.intevation.flys.artifacts.model.FacetTypes;
+import de.intevation.flys.artifacts.model.WQDay;
+import de.intevation.flys.artifacts.resources.Resources;
+
+import de.intevation.flys.artifacts.model.DataFacet;
+
+
 /**
  * The final state that will be reached after the duration curve calculation
  * mode has been chosen.
  *
  * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a>
  */
-public class DurationCurveState extends DefaultState {
-
+public class DurationCurveState
+extends      DefaultState
+implements   FacetTypes
+{
     /** The logger that is used in this state.*/
     private static Logger logger = Logger.getLogger(DurationCurveState.class);
 
     public DurationCurveState() {
     }
+
+
+    @Override
+    public Object computeAdvance(
+        FLYSArtifact artifact,
+        String       hash,
+        CallContext  context,
+        List<Facet>  facets, 
+        Object       old
+    ) {
+        WINFOArtifact winfo = (WINFOArtifact)artifact;
+
+        WQDay res;
+
+        if (old instanceof WQDay []) {
+            res = ((WQDay [])old)[0];
+        }
+        else {
+            res = winfo.getDurationCurveData();
+            if (res == null) {
+                logger.debug("No results given.");
+                return null;
+            }
+        }
+
+        Object[] args = new Object[] {
+            winfo.getRiver().getName()
+        };
+
+        String nameW = Resources.getMsg(
+            context.getMeta(),
+            "chart.duration.curve.curve.w",
+            "",
+            args);
+
+        String nameQ = Resources.getMsg(
+            context.getMeta(),
+            "chart.duration.curve.curve.q",
+            "",
+            args);
+
+        Facet w = new DurationCurveFacet(0, DURATION_W, nameW);
+        Facet q = new DurationCurveFacet(0, DURATION_Q, nameQ);
+
+        facets.add(w);
+        facets.add(q);
+
+        facets.add(new DataFacet(CSV, "CSV data"));
+
+        return new WQDay[] { res };
+    }
 }
 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/LocationDistanceSelect.java	Fri Jun 17 13:00:54 2011 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/LocationDistanceSelect.java	Fri Jun 17 16:17:03 2011 +0000
@@ -1,5 +1,8 @@
 package de.intevation.flys.artifacts.states;
 
+import java.util.List;
+import java.util.Map;
+
 import org.apache.log4j.Logger;
 
 import org.w3c.dom.Element;
@@ -13,11 +16,15 @@
 
 import de.intevation.artifactdatabase.ProtocolUtils;
 import de.intevation.artifactdatabase.data.StateData;
+import de.intevation.artifactdatabase.state.Facet;
 
 import de.intevation.flys.model.River;
 
 import de.intevation.flys.artifacts.FLYSArtifact;
+import de.intevation.flys.artifacts.WINFOArtifact;
+
 import de.intevation.flys.artifacts.model.RiverFactory;
+
 import de.intevation.flys.artifacts.resources.Resources;
 
 /**
@@ -290,5 +297,31 @@
 
         return values.toNativeArray();
     }
+
+
+    @Override
+    public Object computeFeed(
+        FLYSArtifact artifact,
+        String       hash,
+        CallContext  context,
+        List<Facet>  facets, 
+        Object       old
+    ) {
+        WINFOArtifact winfo = (WINFOArtifact)artifact;
+
+        Map<String, double [][]> res;
+
+        if (old instanceof Map<?, ?>) {
+            res = (Map<String, double [][]>)old;
+        }
+        else {
+            res = winfo.getDischargeCurveData();
+        }
+
+        // TODO: Generate facets!
+
+
+        return res;
+    }
 }
 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/WaterlevelState.java	Fri Jun 17 16:17:03 2011 +0000
@@ -0,0 +1,101 @@
+package de.intevation.flys.artifacts.states;
+
+import java.util.List;
+
+import org.apache.log4j.Logger;
+
+import org.w3c.dom.Element;
+
+import de.intevation.artifacts.Artifact;
+import de.intevation.artifacts.CallContext;
+
+import de.intevation.artifacts.common.utils.XMLUtils;
+
+import de.intevation.artifactdatabase.state.Facet;
+
+import de.intevation.flys.artifacts.FLYSArtifact;
+import de.intevation.flys.artifacts.WINFOArtifact;
+import de.intevation.flys.artifacts.model.FacetTypes;
+import de.intevation.flys.artifacts.model.WaterlevelFacet;
+import de.intevation.flys.artifacts.model.WQKms;
+
+import de.intevation.flys.artifacts.model.DataFacet;
+
+
+public class WaterlevelState
+extends      DefaultState
+implements   FacetTypes
+{
+    /** The logger that is used in this state.*/
+    private static Logger logger = Logger.getLogger(WaterlevelState.class);
+
+
+    protected Element[] createItems(
+        XMLUtils.ElementCreator cr,
+        Artifact    artifact,
+        String      name,
+        CallContext context)
+    {
+        logger.debug("WaterlevelState.createItems");
+        return null;
+    }
+
+
+    @Override
+    public Object computeAdvance(
+        FLYSArtifact artifact,
+        String       hash,
+        CallContext  context,
+        List<Facet>  facets, 
+        Object       old
+    ) {
+        WINFOArtifact winfo = (WINFOArtifact)artifact;
+
+        WQKms [] res;
+
+        if (old instanceof WQKms []) {
+            res = (WQKms [])old;
+        }
+        else {
+            res = winfo.getWaterlevelData();
+            if (res == null) {
+                logger.debug("No results given.");
+                return null;
+            }
+        }
+
+        for (int i = 0; i < res.length; i++) {
+            String nameW = null;
+            String nameQ = null;
+
+            if (winfo.isQ()) {
+                nameQ = res[i].getName();
+                nameW = "W(" + nameQ + ")";
+            }
+            else {
+                nameW = res[i].getName();
+                nameQ = "Q(" + nameQ + ")";
+            }
+
+            logger.debug("Create facet: " + nameW);
+            logger.debug("Create facet: " + nameQ);
+
+            Facet w = new WaterlevelFacet(i, LONGITUDINAL_W, nameW);
+            Facet q = new WaterlevelFacet(i, LONGITUDINAL_Q, nameQ);
+
+            facets.add(w);
+            facets.add(q);
+        }
+
+        if (res.length > 0) {
+            Facet wst = new DataFacet(WST, "WST data");
+            Facet csv = new DataFacet(CSV, "CSV data");
+
+            facets.add(wst);
+            facets.add(csv);
+        }
+
+        return res;
+    }
+}
+// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :
--- a/flys-artifacts/src/main/java/de/intevation/flys/collections/AttributeParser.java	Fri Jun 17 13:00:54 2011 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/collections/AttributeParser.java	Fri Jun 17 16:17:03 2011 +0000
@@ -8,6 +8,7 @@
 import org.apache.log4j.Logger;
 
 import org.w3c.dom.Document;
+import org.w3c.dom.Element;
 import org.w3c.dom.Node;
 import org.w3c.dom.NodeList;
 
@@ -99,39 +100,40 @@
 
         logger.debug("Output has " + num + " themes.");
 
-        for (int i = 0; i < num; i++) {
-            Node theme = themes.item(i);
+        String uri = ArtifactNamespaceContext.NAMESPACE_URI;
 
-            String name = XMLUtils.xpathString(
-                theme, "@art:facet", ArtifactNamespaceContext.INSTANCE);
+        for (int i = 0; i < num; i++) {
+            Element theme = (Element) themes.item(i);
 
+            String name  = theme.getAttributeNS(uri, "facet");
             if (name == null || name.length() == 0) {
                 continue;
             }
 
-            String uuid = XMLUtils.xpathString(
-                theme, "@art:artifact", ArtifactNamespaceContext.INSTANCE);
-
+            String uuid  = theme.getAttributeNS(uri, "artifact");
             if (uuid == null || uuid.length() == 0) {
                 continue;
             }
 
-            String pos = XMLUtils.xpathString(
-                theme, "@art:pos", ArtifactNamespaceContext.INSTANCE);
-
+            String pos  = theme.getAttributeNS(uri, "pos");
             if (pos == null || pos.length() == 0) {
                 continue;
             }
 
-            String active = XMLUtils.xpathString(
-                theme, "@art:active", ArtifactNamespaceContext.INSTANCE);
+            String index = theme.getAttributeNS(uri, "index");
+            if (index == null || index.length() == 0) {
+                continue;
+            }
 
+            String active = theme.getAttributeNS(uri, "active");
             if (active == null || active.length() == 0) {
                 continue;
             }
 
+            String description = theme.getAttributeNS(uri, "description");
+
             ManagedFacet item = new ManagedFacet(
-                name, "", uuid,
+                name, Integer.parseInt(index), description, uuid,
                 Integer.parseInt(pos),
                 Integer.parseInt(active));
 
--- a/flys-artifacts/src/main/java/de/intevation/flys/collections/AttributeWriter.java	Fri Jun 17 13:00:54 2011 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/collections/AttributeWriter.java	Fri Jun 17 16:17:03 2011 +0000
@@ -116,7 +116,7 @@
         ManagedFacet   a,
         List<Facet>    list)
     {
-        String name = a.getName();
+        String name = a.getName() + a.getIndex();
 
         if (list == null) {
             logger.debug("No old facets found.");
@@ -124,7 +124,7 @@
         }
 
         for (Facet facet: list) {
-            if (name.equals(facet.getName())) {
+            if (name.equals(facet.getName() + facet.getIndex())) {
                 writeFacet(doc, cr, output, (ManagedFacet) facet);
                 return true;
             }
@@ -145,6 +145,8 @@
         cr.addAttr(theme, "facet", f.getName(), true);
         cr.addAttr(theme, "pos", Integer.toString(f.getPosition()), true);
         cr.addAttr(theme, "active", Integer.toString(f.getActive()), true);
+        cr.addAttr(theme, "index", Integer.toString(f.getIndex()), true);
+        cr.addAttr(theme, "description", f.getDescription(), true);
 
         output.appendChild(theme);
     }
--- a/flys-artifacts/src/main/java/de/intevation/flys/collections/FLYSArtifactCollection.java	Fri Jun 17 13:00:54 2011 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/collections/FLYSArtifactCollection.java	Fri Jun 17 16:17:03 2011 +0000
@@ -234,7 +234,7 @@
 
                 generator.doOut(
                     artifact,
-                    facetName,
+                    theme,
                     getFacetThemeFromAttribute(
                         art,
                         outName,
@@ -719,30 +719,29 @@
                 return;
             }
 
-            for (int i = 0; i < num; i++) {
-                Node theme = themes.item(i);
-
-                String name = XMLUtils.xpathString(
-                    theme, "@art:facet", ArtifactNamespaceContext.INSTANCE);
+            String uri = ArtifactNamespaceContext.NAMESPACE_URI;
 
-                String uuid = XMLUtils.xpathString(
-                    theme, "@art:artifact", ArtifactNamespaceContext.INSTANCE);
+            for (int i = 0; i < num; i++) {
+                Element theme = (Element) themes.item(i);
 
-                String pos = XMLUtils.xpathString(
-                    theme, "@art:pos", ArtifactNamespaceContext.INSTANCE);
+                String name   = theme.getAttributeNS(uri, "facet");
+                String uuid   = theme.getAttributeNS(uri, "artifact");
+                String pos    = theme.getAttributeNS(uri, "pos");
+                String active = theme.getAttributeNS(uri, "active");
+                String idx    = theme.getAttributeNS(uri, "index");
+                String desc   = theme.getAttributeNS(uri, "description");
 
-                String active = XMLUtils.xpathString(
-                    theme, "@art:active", ArtifactNamespaceContext.INSTANCE);
-
-                addTheme(uuid, name, pos, active);
+                addTheme(uuid, name, idx, pos, active, desc);
             }
         }
 
         protected void addTheme(
             String uuid,
             String name,
+            String index,
             String position,
-            String active)
+            String active,
+            String description)
         {
             if (logger.isDebugEnabled()) {
                 logger.debug("Add theme: ");
@@ -755,10 +754,11 @@
             try {
                 int pos = Integer.parseInt(position);
                 int act = Integer.parseInt(active);
+                int idx = Integer.parseInt(index);
 
                 themes.put(
                     new Integer(pos-1),
-                    new ManagedFacet(name, null, uuid, pos, act));
+                    new ManagedFacet(name, idx, description, uuid, pos, act));
             }
             catch (NumberFormatException nfe) {
                 logger.warn(nfe, nfe);
--- a/flys-artifacts/src/main/java/de/intevation/flys/collections/OutputParser.java	Fri Jun 17 13:00:54 2011 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/collections/OutputParser.java	Fri Jun 17 16:17:03 2011 +0000
@@ -8,6 +8,7 @@
 import org.apache.log4j.Logger;
 
 import org.w3c.dom.Document;
+import org.w3c.dom.Element;
 import org.w3c.dom.Node;
 import org.w3c.dom.NodeList;
 
@@ -124,15 +125,19 @@
 
         int num = facets != null ? facets.getLength() : 0;
 
+        String uri = ArtifactNamespaceContext.NAMESPACE_URI;
+
         logger.debug("Output has " + num + " facets.");
 
         for (int i = 0; i < num; i++) {
-            Node facet = facets.item(i);
+            Element facet = (Element) facets.item(i);
 
-            String name = XMLUtils.xpathString(
-                facet, "@art:name", ArtifactNamespaceContext.INSTANCE);
+            String name  = facet.getAttributeNS(uri, "name");
+            String desc  = facet.getAttributeNS(uri, "description");
+            String index = facet.getAttributeNS(uri, "index");
 
-            ManagedFacet item = new ManagedFacet(name, null, uuid, 1, 1);
+            ManagedFacet item = new ManagedFacet(
+                name, Integer.parseInt(index), desc, uuid, 1, 1);
 
             addItem(outname, item);
         }
--- a/flys-artifacts/src/main/java/de/intevation/flys/exports/AbstractExporter.java	Fri Jun 17 13:00:54 2011 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/AbstractExporter.java	Fri Jun 17 16:17:03 2011 +0000
@@ -13,11 +13,15 @@
 import de.intevation.artifacts.Artifact;
 import de.intevation.artifacts.CallContext;
 
+import de.intevation.artifactdatabase.state.Facet;
+
 import de.intevation.artifacts.common.ArtifactNamespaceContext;
 import de.intevation.artifacts.common.utils.XMLUtils;
 
 import de.intevation.flys.artifacts.resources.Resources;
 
+import de.intevation.flys.artifacts.FLYSArtifact;
+
 
 /**
  * An abstract exporter that implements some basic methods for exporting data of
@@ -76,7 +80,7 @@
      * @param artifacts The artifact that stores the data that has to be
      * exported.
      */
-    protected abstract void addData(Artifact artifact);
+    protected abstract void addData(Object data);
 
 
     public void init(Document request, OutputStream out, CallContext context) {
@@ -105,15 +109,23 @@
      * skipped.
      * @param attr The attr document.
      */
-    public void doOut(Artifact artifact, String facet, Document attr) {
-        logger.debug("AbstractExporter.doOut: " + facet);
+    public void doOut(Artifact artifact, Facet facet, Document attr) {
+        String name = facet.getName();
 
-        if (!isFacetValid(facet)) {
-            logger.warn("Facet '" + facet + "' not valid. No output created!");
+        logger.debug("AbstractExporter.doOut: " + name);
+
+        if (!isFacetValid(name)) {
+            logger.warn("Facet '" + name + "' not valid. No output created!");
             return;
         }
 
-        addData(artifact);
+        FLYSArtifact flys = (FLYSArtifact)artifact;
+
+        Facet nativeFacet = flys.getNativeFacet(facet);
+
+        if (nativeFacet != null) {
+            addData(nativeFacet.getData(flys, context));
+        }
     }
 
 
--- a/flys-artifacts/src/main/java/de/intevation/flys/exports/ChartGenerator.java	Fri Jun 17 13:00:54 2011 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/ChartGenerator.java	Fri Jun 17 16:17:03 2011 +0000
@@ -18,6 +18,8 @@
 import de.intevation.artifacts.ArtifactNamespaceContext;
 import de.intevation.artifacts.common.utils.XMLUtils;
 
+import de.intevation.artifactdatabase.state.Facet;
+
 import de.intevation.flys.model.River;
 
 import de.intevation.flys.artifacts.FLYSArtifact;
@@ -243,7 +245,7 @@
     }
 
 
-    public abstract void doOut(Artifact artifact, String facet, Document attr);
+    public abstract void doOut(Artifact artifact, Facet facet, Document attr);
 
     public abstract void generate() throws IOException;
 }
--- a/flys-artifacts/src/main/java/de/intevation/flys/exports/ChartInfoGenerator.java	Fri Jun 17 13:00:54 2011 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/ChartInfoGenerator.java	Fri Jun 17 16:17:03 2011 +0000
@@ -14,6 +14,8 @@
 import de.intevation.artifacts.Artifact;
 import de.intevation.artifacts.CallContext;
 
+import de.intevation.artifactdatabase.state.Facet;
+
 import de.intevation.artifacts.common.utils.XMLUtils;
 
 
@@ -77,7 +79,7 @@
      * @param facet
      * @param attr
      */
-    public void doOut(Artifact artifact, String facet, Document attr) {
+    public void doOut(Artifact artifact, Facet facet, Document attr) {
         generator.doOut(artifact, facet, attr);
     }
 
--- a/flys-artifacts/src/main/java/de/intevation/flys/exports/ComputedDischargeCurveExporter.java	Fri Jun 17 13:00:54 2011 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/ComputedDischargeCurveExporter.java	Fri Jun 17 16:17:03 2011 +0000
@@ -3,6 +3,7 @@
 import java.io.OutputStream;
 import java.text.NumberFormat;
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.List;
 
 import org.w3c.dom.Document;
@@ -11,10 +12,8 @@
 
 import au.com.bytecode.opencsv.CSVWriter;
 
-import de.intevation.artifacts.Artifact;
 import de.intevation.artifacts.CallContext;
 
-import de.intevation.flys.artifacts.WINFOArtifact;
 import de.intevation.flys.artifacts.model.WQKms;
 import de.intevation.flys.utils.Formatter;
 
@@ -51,9 +50,11 @@
     }
 
 
-    protected void addData(Artifact artifact) {
-        WINFOArtifact winfoArtifact = (WINFOArtifact) artifact;
-        data.add(winfoArtifact.getComputedDischargeCurveData());
+    @Override
+    protected void addData(Object d) {
+        if (d instanceof WQKms []) {
+            data.addAll(Arrays.asList((WQKms [])d));
+        }
     }
 
 
--- a/flys-artifacts/src/main/java/de/intevation/flys/exports/ComputedDischargeCurveGenerator.java	Fri Jun 17 13:00:54 2011 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/ComputedDischargeCurveGenerator.java	Fri Jun 17 16:17:03 2011 +0000
@@ -9,7 +9,10 @@
 
 import de.intevation.artifacts.Artifact;
 
-import de.intevation.flys.artifacts.WINFOArtifact;
+import de.intevation.artifactdatabase.state.Facet;
+
+import de.intevation.flys.artifacts.FLYSArtifact;
+import de.intevation.flys.artifacts.model.FacetTypes;
 import de.intevation.flys.artifacts.model.WQKms;
 
 
@@ -18,8 +21,10 @@
  *
  * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a>
  */
-public class ComputedDischargeCurveGenerator extends DischargeCurveGenerator {
-
+public class ComputedDischargeCurveGenerator
+extends      DischargeCurveGenerator
+implements   FacetTypes
+{
     /** The logger used in this generator.*/
     private static Logger logger =
         Logger.getLogger(ComputedDischargeCurveGenerator.class);
@@ -65,11 +70,25 @@
 
 
     @Override
-    public void doOut(Artifact artifact, String facet, Document attr) {
-        logger.debug("ComputedDischargeCurveGenerator.doOut");
+    public void doOut(Artifact artifact, Facet facet, Document attr) {
+        String name = facet != null ? facet.getName() : null;
 
-        WQKms wqkms = getData(artifact);
+        logger.debug("ComputedDischargeCurveGenerator.doOut: " + name);
 
+        FLYSArtifact flys = (FLYSArtifact) artifact;
+        Facet        f    = flys.getNativeFacet(facet);
+
+        if (name != null && name.equals(COMPUTED_DISCHARGE_Q)) {
+            doQOut((WQKms) f.getData(artifact, context));
+        }
+        else {
+            logger.warn("Unknown facet type for computed discharge: " + name);
+            return;
+        }
+    }
+
+
+    protected void doQOut(WQKms wqkms) {
         int size = wqkms.size();
 
         double[][] data = new double[2][size];
@@ -86,15 +105,6 @@
     }
 
 
-    protected WQKms getData(Artifact artifact) {
-        logger.debug("ComputedDischargeCurveGenerator.getData");
-
-        WINFOArtifact winfoArtifact = (WINFOArtifact) artifact;
-
-        return winfoArtifact.getComputedDischargeCurveData();
-    }
-
-
     protected String getSeriesName(WQKms wqkms) {
         Object[] args = new Object[] {
             getRiverName(),
--- a/flys-artifacts/src/main/java/de/intevation/flys/exports/DischargeCurveGenerator.java	Fri Jun 17 13:00:54 2011 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/DischargeCurveGenerator.java	Fri Jun 17 16:17:03 2011 +0000
@@ -15,6 +15,8 @@
 
 import de.intevation.artifacts.Artifact;
 
+import de.intevation.artifactdatabase.state.Facet;
+
 import de.intevation.flys.model.DischargeTable;
 import de.intevation.flys.model.Gauge;
 import de.intevation.flys.model.River;
@@ -92,8 +94,8 @@
     }
 
 
-    public void doOut(Artifact artifact, String facet, Document attr) {
-        logger.debug("DischargeCurveGenerator.doOut: " + facet);
+    public void doOut(Artifact artifact, Facet facet, Document attr) {
+        logger.debug("DischargeCurveGenerator.doOut: " + facet.getName());
 
         if (!(artifact instanceof FLYSArtifact)) {
             logger.error("Artifact is no instance of FLYSArtifact.");
--- a/flys-artifacts/src/main/java/de/intevation/flys/exports/DischargeLongitudinalSectionExporter.java	Fri Jun 17 13:00:54 2011 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/DischargeLongitudinalSectionExporter.java	Fri Jun 17 16:17:03 2011 +0000
@@ -6,9 +6,6 @@
 
 import au.com.bytecode.opencsv.CSVWriter;
 
-import de.intevation.artifacts.Artifact;
-
-import de.intevation.flys.artifacts.WINFOArtifact;
 import de.intevation.flys.artifacts.model.WQCKms;
 import de.intevation.flys.artifacts.model.WQKms;
 
@@ -41,13 +38,10 @@
 
 
     @Override
-    protected void addData(Artifact artifact) {
-        WINFOArtifact winfo = (WINFOArtifact) artifact;
-        WQKms[]       wqkms = winfo.getDischargeLongitudinalSectionData();
-
-        logger.debug("Got " + wqkms != null ? wqkms.length : 0 + " WQKms obj.");
-
-        data.add(wqkms);
+    protected void addData(Object d) {
+        if (d instanceof WQKms []) {
+            data.add((WQKms [])d);
+        }
     }
 
 
--- a/flys-artifacts/src/main/java/de/intevation/flys/exports/DischargeLongitudinalSectionGenerator.java	Fri Jun 17 13:00:54 2011 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/DischargeLongitudinalSectionGenerator.java	Fri Jun 17 16:17:03 2011 +0000
@@ -14,7 +14,9 @@
 
 import de.intevation.artifacts.Artifact;
 
-import de.intevation.flys.artifacts.WINFOArtifact;
+import de.intevation.artifactdatabase.state.Facet;
+
+import de.intevation.flys.artifacts.FLYSArtifact;
 import de.intevation.flys.artifacts.model.WQCKms;
 import de.intevation.flys.artifacts.model.WQKms;
 
@@ -31,13 +33,6 @@
         Logger.getLogger(DischargeLongitudinalSectionGenerator.class);
 
 
-    /** The facet for Ws.*/
-    public static final String FACET_W = "discharge_longitudinal_section.w";
-
-    /** The facet for Qs.*/
-    public static final String FACET_Q = "discharge_longitudinal_section.q";
-
-
     /** The storage for the corrected W series to be drawn in this chart.*/
     protected XYSeriesCollection cw;
 
@@ -92,72 +87,30 @@
 
 
     @Override
-    public void doOut(Artifact artifact, String facet, Document attr) {
+    public void doOut(Artifact artifact, Facet facet, Document attr) {
         logger.debug("DischargeLongitudinalSectionGenerator.doOut");
 
-        if (facet != null && facet.equals(FACET_W)) {
-            doWOut(getDischargeLongitudinalSectionData(artifact));
+        String name = facet != null ? facet.getName() : null;
+
+        FLYSArtifact flys = (FLYSArtifact) artifact;
+        Facet        f    = flys.getNativeFacet(facet);
+
+        if (name != null && name.equals(DISCHARGE_LONGITUDINAL_W)) {
+            doWOut((WQKms) f.getData(artifact, context));
         }
-        else if (facet != null && facet.equals(FACET_Q)) {
-            doQOut(getDischargeLongitudinalSectionData(artifact));
+        else if (name != null && name.equals(DISCHARGE_LONGITUDINAL_Q)) {
+            doQOut((WQKms) f.getData(artifact, context));
+        }
+        else if (name != null && name.equals(DISCHARGE_LONGITUDINAL_C)) {
+            doCorrectedWOut((WQCKms) f.getData(artifact, context));
         }
         else {
-            logger.warn("Unknown facet name: " + facet);
+            logger.warn("Unknown facet name: " + name);
             return;
         }
     }
 
 
-    protected WQKms[] getDischargeLongitudinalSectionData(Artifact artifact) {
-        WINFOArtifact winfoArtifact = (WINFOArtifact) artifact;
-        return winfoArtifact.getDischargeLongitudinalSectionData();
-    }
-
-
-    /**
-     * This method adds new Series for the wqkms objects. If there are instances
-     * of WQCKms in this array, there is a further curve that displays the
-     * corrected W values.
-     *
-     * @param wqkms An array of WQKms objects to be displayed.
-     */
-    protected void doWOut(WQKms[] wqkms) {
-        logger.debug("LongitudinalSectionGenerator.doWOut");
-
-        int idx = 0;
-        for (WQKms tmp: wqkms) {
-            if (tmp instanceof WQCKms) {
-                doCorrectedWOut((WQCKms) tmp);
-            }
-
-            doWOut(tmp);
-        }
-    }
-
-
-    /**
-     * Adds a new series for the W curve.
-     *
-     * @param wqkms The object that contains the W values.
-     */
-    protected void doWOut(WQKms wqkms) {
-        logger.debug("DischargeLongitudinalSectionGenerator.doWOut");
-
-        XYSeries series = new XYSeries(getSeriesName(wqkms, "W"));
-
-        double[] target = new double[4];
-        int      size   = wqkms.size();
-
-        for (int i = 0; i < size; i++) {
-            target = wqkms.get(i, target);
-
-            series.add(target[2], target[0]);
-        }
-
-        w.addSeries(series);
-    }
-
-
     /**
      * Adds a new series for the corrected W curve.
      *
--- a/flys-artifacts/src/main/java/de/intevation/flys/exports/DurationCurveExporter.java	Fri Jun 17 13:00:54 2011 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/DurationCurveExporter.java	Fri Jun 17 16:17:03 2011 +0000
@@ -3,6 +3,7 @@
 import java.io.OutputStream;
 import java.text.NumberFormat;
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.List;
 
 import org.w3c.dom.Document;
@@ -11,10 +12,8 @@
 
 import au.com.bytecode.opencsv.CSVWriter;
 
-import de.intevation.artifacts.Artifact;
 import de.intevation.artifacts.CallContext;
 
-import de.intevation.flys.artifacts.WINFOArtifact;
 import de.intevation.flys.artifacts.model.WQDay;
 import de.intevation.flys.utils.Formatter;
 
@@ -55,9 +54,11 @@
     }
 
 
-    protected void addData(Artifact artifact) {
-        WINFOArtifact winfoArtifact = (WINFOArtifact) artifact;
-        data.add(winfoArtifact.getDurationCurveData());
+    @Override
+    protected void addData(Object d) {
+        if (d instanceof WQDay []) {
+            data.addAll(Arrays.asList((WQDay [])d));
+        }
     }
 
 
--- a/flys-artifacts/src/main/java/de/intevation/flys/exports/DurationCurveGenerator.java	Fri Jun 17 13:00:54 2011 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/DurationCurveGenerator.java	Fri Jun 17 16:17:03 2011 +0000
@@ -16,9 +16,10 @@
 
 import de.intevation.artifacts.Artifact;
 
-import de.intevation.flys.model.River;
+import de.intevation.artifactdatabase.state.Facet;
 
-import de.intevation.flys.artifacts.WINFOArtifact;
+import de.intevation.flys.artifacts.FLYSArtifact;
+import de.intevation.flys.artifacts.model.FacetTypes;
 import de.intevation.flys.artifacts.model.WQDay;
 import de.intevation.flys.artifacts.resources.Resources;
 
@@ -28,11 +29,10 @@
  *
  * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a>
  */
-public class DurationCurveGenerator extends XYChartGenerator {
-
-    public static final String I18N_DURATION_W = "chart.duration.curve.curve.w";
-    public static final String I18N_DURATION_Q = "chart.duration.curve.curve.q";
-
+public class DurationCurveGenerator
+extends      XYChartGenerator
+implements   FacetTypes
+{
     private static Logger logger =
         Logger.getLogger(DurationCurveGenerator.class);
 
@@ -43,11 +43,11 @@
     protected XYSeriesCollection q;
 
 
-    public static final String DURATION_CURVE_W =
-        "duration_curve.w";
+    public static final String I18N_DURATION_W =
+        "chart.duration.curve.curve.w";
 
-    public static final String DURATION_CURVE_Q =
-        "duration_curve.q";
+    public static final String I18N_DURATION_Q =
+        "chart.duration.curve.curve.q";
 
     public static final String I18N_CHART_TITLE =
         "chart.duration.curve.title";
@@ -157,25 +157,28 @@
     }
 
 
-    public void doOut(Artifact artifact, String facet, Document attr) {
-        logger.debug("DurationCurveGenerator.doOut: " + facet);
+    @Override
+    public void doOut(Artifact artifact, Facet facet, Document attr) {
+        String name = facet != null ? facet.getName() : null;
 
-        if (facet == null || facet.length() == 0) {
+        logger.debug("DurationCurveGenerator.doOut: " + name);
+
+        if (name == null || name.length() == 0) {
             logger.error("No facet given. Cannot create dataset.");
             return;
         }
 
-        WINFOArtifact winfo = (WINFOArtifact) artifact;
-        River         river = winfo.getRiver();
+        FLYSArtifact flys = (FLYSArtifact) artifact;
+        Facet        f    = flys.getNativeFacet(facet);
 
-        if (facet.equals(DURATION_CURVE_W)) {
-            doWOut(getDurationCurveData(artifact), river.getName());
+        if (name.equals(DURATION_W)) {
+            doWOut((WQDay) f.getData(artifact, context));
         }
-        else if (facet.equals(DURATION_CURVE_Q)) {
-            doQOut(getDurationCurveData(artifact), river.getName());
+        else if (name.equals(DURATION_Q)) {
+            doQOut((WQDay) f.getData(artifact, context));
         }
         else {
-            logger.warn("Unknown facet name: " + facet);
+            logger.warn("Unknown facet name: " + name);
             return;
         }
     }
@@ -187,12 +190,12 @@
      * @param wqdays The WQDay store that contains the Ws.
      * @param river The name of the river.
      */
-    protected void doWOut(WQDay wqdays, String river) {
+    protected void doWOut(WQDay wqdays) {
         logger.debug("DurationCurveGenerator.doWOut");
 
         // TODO find the correct series name
         XYSeries series = new XYSeries(
-            getSeriesName(river, DURATION_CURVE_W));
+            getSeriesName(getRiverName(), DURATION_W));
 
         int size = wqdays.size();
         for (int i = 0; i < size; i++) {
@@ -212,12 +215,12 @@
      * @param wqdays The WQDay store that contains the Qs.
      * @param river The name of the river.
      */
-    protected void doQOut(WQDay wqdays, String river) {
+    protected void doQOut(WQDay wqdays) {
         logger.debug("DurationCurveGenerator.doQOut");
 
         // TODO find the correct series name
         XYSeries series = new XYSeries(
-            getSeriesName(river, DURATION_CURVE_Q));
+            getSeriesName(getRiverName(), DURATION_Q));
 
         int size = wqdays.size();
         for (int i = 0; i < size; i++) {
@@ -231,20 +234,6 @@
     }
 
 
-    /**
-     * Returns the computed data for a duration curve based on the artifact's
-     * computation method.
-     *
-     * @param artifact The WINFO artifact.
-     *
-     * @return the computed data for a duration curve's W and Q facet.
-     */
-    protected WQDay getDurationCurveData(Artifact artifact) {
-        WINFOArtifact winfoArtifact = (WINFOArtifact) artifact;
-        return winfoArtifact.getDurationCurveData();
-    }
-
-
     protected String getSeriesName(String river, String type) {
         Object[] args = new Object[] { river };
 
@@ -252,14 +241,14 @@
             logger.warn("No duration curve type given.");
             return "n/a";
         }
-        else if (type.equals(DURATION_CURVE_W)) {
+        else if (type.equals(DURATION_W)) {
             return Resources.getMsg(
                 context.getMeta(),
                 I18N_DURATION_W,
                 "W",
                 args);
         }
-        else if (type.equals(DURATION_CURVE_Q)) {
+        else if (type.equals(DURATION_Q)) {
             return Resources.getMsg(
                 context.getMeta(),
                 I18N_DURATION_Q,
--- a/flys-artifacts/src/main/java/de/intevation/flys/exports/LongitudinalSectionGenerator.java	Fri Jun 17 13:00:54 2011 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/LongitudinalSectionGenerator.java	Fri Jun 17 16:17:03 2011 +0000
@@ -17,10 +17,13 @@
 
 import de.intevation.artifacts.Artifact;
 
+import de.intevation.artifactdatabase.state.Facet;
+
 import de.intevation.flys.model.River;
 
 import de.intevation.flys.artifacts.FLYSArtifact;
 import de.intevation.flys.artifacts.WINFOArtifact;
+import de.intevation.flys.artifacts.model.FacetTypes;
 import de.intevation.flys.artifacts.model.WQKms;
 
 
@@ -29,8 +32,10 @@
  *
  * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a>
  */
-public class LongitudinalSectionGenerator extends XYChartGenerator {
-
+public class LongitudinalSectionGenerator
+extends      XYChartGenerator
+implements   FacetTypes
+{
     /** The logger that is used in this generator.*/
     private static Logger logger =
         Logger.getLogger(LongitudinalSectionGenerator.class);
@@ -179,22 +184,31 @@
     }
 
 
-    public void doOut(Artifact artifact, String facet, Document attr) {
-        logger.debug("LongitudinalSectionGenerator.doOut: " + facet);
+    public void doOut(Artifact artifact, Facet facet, Document attr) {
+        String name = facet.getName();
 
-        if (facet == null) {
+        logger.debug("LongitudinalSectionGenerator.doOut: " + name);
+
+        if (name == null) {
             logger.error("No facet name for doOut(). No output generated!");
             return;
         }
 
-        if (facet.equals(LONGITUDINAL_SECTION_W)) {
-            doWOut(getWaterlevelData(artifact));
+        FLYSArtifact flys = (FLYSArtifact) artifact;
+        Facet        f    = flys.getNativeFacet(facet);
+
+        if (f == null) {
+            return;
         }
-        else if (facet.equals(LONGITUDINAL_SECTION_Q)) {
-            doQOut(getWaterlevelData(artifact));
+
+        if (name.equals(LONGITUDINAL_W)) {
+            doWOut((WQKms) f.getData(artifact, context));
+        }
+        else if (name.equals(LONGITUDINAL_Q)) {
+            doQOut((WQKms) f.getData(artifact, context));
         }
         else {
-            logger.warn("Unknown facet name: " + facet);
+            logger.warn("Unknown facet name: " + name);
             return;
         }
     }
@@ -222,33 +236,30 @@
      *
      * @param wqkms An array of WQKms values.
      */
-    protected void doWOut(WQKms[] wqkms) {
+    protected void doWOut(WQKms wqkms) {
         logger.debug("LongitudinalSectionGenerator.doWOut");
 
-        int idx = 0;
-        for (WQKms tmp: wqkms) {
-            XYSeries series = new XYSeries(getSeriesName(tmp, "W"));
-
-            double[] target = new double[3];
-            int      size   = tmp.size();
+        XYSeries series = new XYSeries(getSeriesName(wqkms, "W"));
 
-            if (logger.isDebugEnabled()) {
-                if (tmp.size() > 0) {
-                    logger.debug("Generate series: " + series.getKey());
-                    logger.debug("Start km: " + tmp.getKms(0));
-                    logger.debug("End   km: " + tmp.getKms(size-1));
-                    logger.debug("Values  : " + size);
-                }
+        double[] target = new double[3];
+        int      size   = wqkms.size();
+
+        if (logger.isDebugEnabled()) {
+            if (wqkms.size() > 0) {
+                logger.debug("Generate series: " + series.getKey());
+                logger.debug("Start km: " + wqkms.getKms(0));
+                logger.debug("End   km: " + wqkms.getKms(size-1));
+                logger.debug("Values  : " + size);
             }
-
-            for (int i = 0; i < size; i++) {
-                target = tmp.get(i, target);
+        }
 
-                series.add(target[2], target[0]);
-            }
+        for (int i = 0; i < size; i++) {
+            target = wqkms.get(i, target);
 
-            w.addSeries(series);
+            series.add(target[2], target[0]);
         }
+
+        w.addSeries(series);
     }
 
 
@@ -257,34 +268,31 @@
      *
      * @param wqkms An array of WQKms values.
      */
-    protected void doQOut(WQKms[] wqkms) {
+    protected void doQOut(WQKms wqkms) {
         logger.debug("LongitudinalSectionGenerator.doQOut");
 
-        int idx = 0;
-        for (WQKms tmp: wqkms) {
-            XYSeries series = new XYSeries(getSeriesName(tmp, "Q"));
-
-            double[] target = new double[3];
-            int      size   = tmp.size();
+        XYSeries series = new XYSeries(getSeriesName(wqkms, "Q"));
 
-            if (logger.isDebugEnabled()) {
-                if (tmp.size() > 0) {
-                    logger.debug("Generate series: " + series.getKey());
-                    logger.debug("Start km: " + tmp.getKms(0));
-                    logger.debug("End   km: " + tmp.getKms(size-1));
-                    logger.debug("Values  : " + size);
-                }
-            }
+        double[] target = new double[3];
+        int      size   = wqkms.size();
 
-            for (int i = 0; i < size; i++) {
-                target = tmp.get(i, target);
+        if (logger.isDebugEnabled()) {
+            if (wqkms.size() > 0) {
+                logger.debug("Generate series: " + series.getKey());
+                logger.debug("Start km: " + wqkms.getKms(0));
+                logger.debug("End   km: " + wqkms.getKms(size-1));
+                logger.debug("Values  : " + size);
+            }
+        }
 
-                //logger.debug("++ Q Tuple: " + target[2] + " -> " + target[1]);
-                series.add(target[2], target[1]);
-            }
+        for (int i = 0; i < size; i++) {
+            target = wqkms.get(i, target);
 
-            q.addSeries(series);
+            //logger.debug("++ Q Tuple: " + target[2] + " -> " + target[1]);
+            series.add(target[2], target[1]);
         }
+
+        q.addSeries(series);
     }
 
 
--- a/flys-artifacts/src/main/java/de/intevation/flys/exports/OutGenerator.java	Fri Jun 17 13:00:54 2011 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/OutGenerator.java	Fri Jun 17 16:17:03 2011 +0000
@@ -8,6 +8,8 @@
 import de.intevation.artifacts.Artifact;
 import de.intevation.artifacts.CallContext;
 
+import de.intevation.artifactdatabase.state.Facet;
+
 
 /**
  * An OutGenerator is used to create a collected outputs of a list of Artifacts.
@@ -44,7 +46,7 @@
      * @param attr A document that might contain some attributes used while
      * producing the output.
      */
-    void doOut(Artifact artifact, String facet, Document attr);
+    void doOut(Artifact artifact, Facet facet, Document attr);
 
     /**
      * Writes the collected output of all artifacts specified in the
--- a/flys-artifacts/src/main/java/de/intevation/flys/exports/WaterlevelExporter.java	Fri Jun 17 13:00:54 2011 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/WaterlevelExporter.java	Fri Jun 17 16:17:03 2011 +0000
@@ -77,8 +77,11 @@
     }
 
 
-    protected void addData(Artifact artifact) {
-        data.add(getWaterlevelData(artifact));
+    @Override
+    protected void addData(Object d) {
+        if (d instanceof WQKms []) {
+            data.add((WQKms [])d);
+        }
     }
 
 
@@ -99,6 +102,7 @@
     }
 
 
+    @Override
     protected void writeCSVData(CSVWriter writer) {
         logger.info("WaterlevelExporter.writeData");
 

http://dive4elements.wald.intevation.org