diff gnv-artifacts/src/main/java/de/intevation/gnv/state/layer/LayerOutputState.java @ 813:79c1db3ca7cc

Added some more javadocs. gnv-artifacts/trunk@897 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Fri, 09 Apr 2010 13:09:25 +0000
parents feae2f9d6c6f
children ac1b9f00603f
line wrap: on
line diff
--- a/gnv-artifacts/src/main/java/de/intevation/gnv/state/layer/LayerOutputState.java	Fri Apr 09 13:00:38 2010 +0000
+++ b/gnv-artifacts/src/main/java/de/intevation/gnv/state/layer/LayerOutputState.java	Fri Apr 09 13:09:25 2010 +0000
@@ -89,11 +89,7 @@
         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 {
@@ -123,19 +119,23 @@
     }
 
     /**
-     * @param outputStream
+     * Writes an exception to an output stream.
+     *
+     * @param outputStream The output stream used to write the exception to.
      */
+    @SuppressWarnings("static-access")
     private void writeExceptionReport2Stream(OutputStream outputStream) {
         Document document = XMLUtils.newDocument();
-        new ArtifactXMLUtilities().
+        ArtifactXMLUtilities.
         createExceptionReport("No Data to Export", document);
         XMLUtils.toStream(document,outputStream);
     }
 
 
     /**
-     * Fetches the Data from the Databasebackend
-     * @return
+     * Fetches the Data from the Databasebackend.
+     * 
+     * @return the resulting data.
      */
     protected Collection<Result> fetchData(){
         log.debug("LayerOutputState.fetchData");
@@ -246,6 +246,14 @@
         return data;
     }
 
+
+    /**
+     * This method determines the geometry type on basis of a table name.
+     *
+     * @param tableName Name of the table in the database.
+     * @param queryExecutor The QueryExecutor.
+     * @return the geometry type as string (e.g. MultiPolygon, Polygon, etc).
+     */
     private String getGeometryType(String tableName,
                                    QueryExecutor queryExecutor){
         String returnValue = null;
@@ -286,6 +294,14 @@
 
         return returnValue;
     }
+
+
+    /**
+     * Fetch the columns of a specific table.
+     *
+     * @param tableName The name of the table.
+     * @return the columns as string.
+     */
     private String fetchColumns(String tableName){
         String returnValue = null;
         try {
@@ -318,6 +334,8 @@
         }
         return returnValue;
     }
+
+
     @Override
     public void setup(Node configuration) {
         log.debug("LayerOutputState.setup");
@@ -334,6 +352,16 @@
         this.geometryTypeQueryID = "geometry_type";
     }
 
+
+    /**
+     * Write the resulting data to shapefiles.
+     *
+     * @param uuid The UUID of the current artifact.
+     * @param data The finalized data used for shapefile creation.
+     * @param callContext The CallContext object.
+     * @param geometryType The geometry type.
+     * @return the shapefile path.
+     */
     protected String writeToShapeFile(
                                       String             uuid,
                                       Collection<Result> data,
@@ -382,6 +410,18 @@
         }
     }
 
+
+    /**
+     * Create a zip archive with the shapefiles of the given shapefiles path and
+     * write it to <code>output</code>.
+     *
+     * @param uuid The UUID of the current artifact.
+     * @param callContext The CallContext object.
+     * @param output The output stream.
+     * @param data The data to be written to shapefile.
+     * @param geometryType The geometry type.
+     * @throws StateException if an error occured while zipfile creation.
+     */
     protected void writeZip(
             String       uuid,
             CallContext  callContext,
@@ -411,12 +451,18 @@
             }
         }
 
+    /**
+     * Returns the shapefile path.
+     *
+     * @return the shapefile path.
+     */
     public String getShapeFilePath() {
         synchronized (shapeFileLock) {
             return shapeFilePath;
         }
     }
 
+    
     private static File shapefileDirectory(CallContext callContext) {
         // TODO: Refactoring nessessary it should be used only one Shapefilepath
         //       for alle Modes. Code was taken from HorizontalCrossSectionMeshOutputState
@@ -429,15 +475,14 @@
             : GNVArtifactContext.DEFAULT_HORIZONTAL_CROSS_SECTION_PROFILE_SHAPEFILE_PATH;
     }
 
-    /**
-     * @see de.intevation.gnv.state.StateBase#endOfLife(java.lang.Object)
-     */
+
     @Override
     public void endOfLife(Object globalContext) {
         super.endOfLife(globalContext);
 
         // do it in background
         new Thread() {
+            @Override
             public void run() {
                 // TODO: Do the un-publishing WMS stuff.
                 String path = resetShapeFilePath();
@@ -466,6 +511,7 @@
         }.start();
     }
 
+    
     public String resetShapeFilePath() {
         synchronized (shapeFileLock) {
             String path = shapeFilePath;
@@ -474,6 +520,21 @@
             return path;
         }
     }
+
+
+    /**
+     * Write data to shapefiles and feed a map service with information about
+     * these shapefiles. The map service can be queried for displaying
+     * corresponding layers as WMS.
+     *
+     * @param uuid The UUID of the current artifact.
+     * @param callContext The CallContext object.
+     * @param data A collection with some input data.
+     * @param geometryType The geometry type.
+     * @return a document with some meta information (shapefile path, geometry
+     * type, time to live of the current artifact, etc).
+     * @throws StateException if an error occured while shapefile writing.
+     */
     protected Document getWMS(String uuid,
                               CallContext callContext,
                               Collection<Result> data,
@@ -518,6 +579,14 @@
         return document;
     }
 
+
+    /**
+     * Turns the geometry type into a form used for the templating mechanism
+     * while mapfile generation.
+     * 
+     * @param geometryType The original geometry type.
+     * @return a valid geometry type fpr the template mechanism.
+     */
     private String determineGeometryType(String geometryType){
 
         String returnValue = geometryType.toLowerCase();
@@ -532,6 +601,14 @@
         return returnValue;
     }
 
+
+    /**
+     * Determine the default template name if no special template is existing
+     * for this layer.
+     *
+     * @param geometryType The geometry type.
+     * @return a default geometry fitting to the original geometry type.
+     */
     private String determineDefaultTemplateName(String geometryType){
 
         String returnValue = geometryType.toLowerCase();
@@ -546,3 +623,4 @@
         return returnValue;
     }
 }
+// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
\ No newline at end of file

http://dive4elements.wald.intevation.org