diff gnv-artifacts/src/main/java/de/intevation/gnv/state/layer/LayerOutputState.java @ 616:93978859fa9e

Added the Configuration and the Classes for the new Product Layer. The Product does not generate any output at this Time. gnv-artifacts/trunk@686 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Tim Englich <tim.englich@intevation.de>
date Fri, 12 Feb 2010 18:04:58 +0000
parents
children 4fc97074eb90
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/gnv-artifacts/src/main/java/de/intevation/gnv/state/layer/LayerOutputState.java	Fri Feb 12 18:04:58 2010 +0000
@@ -0,0 +1,101 @@
+/**
+ *
+ */
+package de.intevation.gnv.state.layer;
+
+import java.io.OutputStream;
+import java.util.Collection;
+import java.util.Iterator;
+
+import org.apache.log4j.Logger;
+import org.w3c.dom.Document;
+import org.w3c.dom.Node;
+
+import de.intevation.artifactdatabase.Config;
+import de.intevation.artifactdatabase.XMLUtils;
+import de.intevation.artifacts.ArtifactNamespaceContext;
+import de.intevation.artifacts.CallContext;
+import de.intevation.gnv.geobackend.base.Result;
+import de.intevation.gnv.state.InputData;
+import de.intevation.gnv.state.OutputStateBase;
+import de.intevation.gnv.state.exception.StateException;
+
+/**
+ * @author Tim Englich <tim.englich@intevation.de>
+ *
+ */
+public class LayerOutputState extends OutputStateBase {
+
+    /**
+     * the logger, used to log exceptions and additonaly information
+     */
+    private static Logger log = Logger.getLogger(LayerOutputState.class);
+    
+    /**
+     * The UID of this Class.
+     */
+    private static final long serialVersionUID = 9180957321704424049L;
+
+    /**
+     * The ID for the Query fetching the Layer from the DB
+     */
+    private String dataQueryID = null; 
+    /**
+     * Constructor
+     */
+    public LayerOutputState() {
+        super();
+    }
+
+    /**
+     * @see de.intevation.gnv.state.OutputState#out(org.w3c.dom.Document, 
+     *      java.util.Collection, java.io.OutputStream, 
+     *      java.lang.String, de.intevation.artifacts.CallContext)
+     */
+    public void out(Document format, Collection<InputData> inputData,
+                    OutputStream outputStream, String uuid,
+                    CallContext callContext) throws StateException {
+        
+        log.debug("LayerOutputState.out");
+        String outputMode = XMLUtils.xpathString(
+                format, XPATH_OUTPUT_MODE, ArtifactNamespaceContext.INSTANCE);
+        if (outputMode.equalsIgnoreCase("wms")) {
+            Collection<Result> data = this.fetchData();
+            // TODO USE ME
+        }else if (outputMode.equalsIgnoreCase("zip")){
+            Collection<Result> data = this.fetchData();
+            // TODO USE ME
+        }
+    }
+    
+    
+    protected Collection<Result> fetchData(){
+        log.debug("LayerOutputState.fetchData");
+        // TODO PUT ALL in CACHE
+        Collection<Result> result = this.getData(this.queryID);
+        Collection<Result> data = null;
+        if (result != null){
+            Iterator<Result> it = result.iterator();
+            String table = null;
+            String where = null;
+            if (it.hasNext()){
+                Result resultValue = it.next();
+                table = resultValue.getString(0);
+                where = resultValue.getString(1);
+                // TODO ADD SpatialFilter if Geometry is available
+            }
+            
+            data = null; // TODO Fetch the Data for the Layer and Trim the Geometries
+                         //      using the Geometry if on is available.
+        }
+        return data;
+    }
+
+    @Override
+    public void setup(Node configuration) {
+        log.debug("LayerOutputState.setup");
+        super.setup(configuration);
+        this.dataQueryID = Config.getStringXPath(configuration,"queryID-layerdata");
+    }
+
+}

http://dive4elements.wald.intevation.org