diff gnv-artifacts/src/main/java/de/intevation/gnv/state/profile/horizontalcrosssection/HorizontalCrossSectionMeshOutputState.java @ 804:9058c08eac3a

Added more Javadoc in some classes of state.profile. gnv-artifacts/trunk@886 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Thu, 08 Apr 2010 10:10:04 +0000
parents c4156275c1e1
children bb7afd783321
line wrap: on
line diff
--- a/gnv-artifacts/src/main/java/de/intevation/gnv/state/profile/horizontalcrosssection/HorizontalCrossSectionMeshOutputState.java	Wed Apr 07 07:52:27 2010 +0000
+++ b/gnv-artifacts/src/main/java/de/intevation/gnv/state/profile/horizontalcrosssection/HorizontalCrossSectionMeshOutputState.java	Thu Apr 08 10:10:04 2010 +0000
@@ -92,8 +92,16 @@
     public static final boolean USE_INDEX_BUFFER =
         Boolean.getBoolean("gnv.horizontal.cross.section.mesh.index.buffer");
 
+    /**
+     * Shapefile name for isolines.
+     */
     public static final String ISOLINES_NAME  = "isolines.shp";
+
+    /**
+     * Shapefile name for polygons.
+     */
     public static final String POLYGON_NAME   = "polygons.shp";
+
     public static final String LAYER_MODEL    = "horizontalcrosssection";
 
     private String ijkQueryID;
@@ -108,6 +116,7 @@
     public HorizontalCrossSectionMeshOutputState() {
     }
 
+    @Override
     public void initialize(String uuid, CallContext callContext)
     throws StateException {
         super.initialize(uuid, callContext);
@@ -118,18 +127,33 @@
         getResult(uuid, callContext);
     }
 
+    /**
+     * Returns the shapefile directory path.
+     *
+     * @return the shapefile path.
+     */
     public String getShapeFilePath() {
         synchronized (shapeFileLock) {
             return shapeFilePath;
         }
     }
 
+    /**
+     * Set the shapefile path.
+     *
+     * @param shapeFilePath Destination path to write shapefiles.
+     */
     public void setShapeFilePath(String shapeFilePath) {
         synchronized (shapeFileLock) {
             this.shapeFilePath = shapeFilePath;
         }
     }
 
+    /**
+     * Method to reset the shapefile path.
+     *
+     * @return the old path.
+     */
     public String resetShapeFilePath() {
         synchronized (shapeFileLock) {
             String path = shapeFilePath;
@@ -138,11 +162,20 @@
         }
     }
 
+
+    /**
+     * This method removes all shapefiles which might have been written by this
+     * artifact and resets the shapefile path.
+     *
+     * @param globalContext CallContext
+     */
+    @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();
@@ -171,6 +204,23 @@
         }.start();
     }
 
+
+    /**
+     * This out target has two options:<br>
+     * <ol>
+     *  <li>zip: Write the resulting data to shapefiles and export them as
+     * zip-archive.</li>
+     *  <li>wms: Write the resulting data to shapefiles and feed a map service
+     * with a layer displaying these shapefiles.</li>
+     * </ol>
+     *
+     * @param format
+     * @param inputData
+     * @param outputStream
+     * @param uuid
+     * @param callContext
+     * @throws StateException
+     */
     public void out(
         Document              format,
         Collection<InputData> inputData,
@@ -206,6 +256,15 @@
         }
     }
 
+    /**
+     * 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.
+     * @throws StateException if an error occured while zipfile creation.
+     */
     protected void writeZip(
         String       uuid,
         CallContext  callContext,
@@ -236,6 +295,18 @@
         }
     }
 
+    /**
+     * 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 inputData A collection with some input data.
+     * @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,
@@ -312,6 +383,13 @@
         return document;
     }
 
+    /**
+     * Find the parameter name which is used during mapfile creation in
+     * MapfileGenerator.
+     * 
+     * @param callContext The CallContext object.
+     * @return the parameter name of the current parameterization.
+     */
     protected String findParameterType(CallContext callContext) {
         InputData inputParam = inputData.get("parameterid");
 
@@ -330,6 +408,12 @@
     }
 
 
+    /**
+     * Find the title for a wms layer specified by the user.
+     *
+     * @param inputData A collection with InputData objects.
+     * @return the title.
+     */
     protected String getLayerTitle(Collection<InputData> inputData) {
         for (InputData data: inputData) {
             String name = data.getName();
@@ -341,6 +425,14 @@
         return null;
     }
 
+    /**
+     * Write the resulting data to shapefiles.
+     *
+     * @param uuid The UUID of the current artifact.
+     * @param result The finalized data used for shapefile creation.
+     * @param callContext The CallContext object.
+     * @return the shapefile path.
+     */
     protected String writeToShapeFile(
         String             uuid,
         AttributedPoint2ds result,
@@ -411,6 +503,14 @@
     }
 
 
+    /**
+     * Return the processed results ready for being written to shapefile.
+     *
+     * @param uuid The UUID of the current artifacts.
+     * @param callContext The CallContext object.
+     * @return the processed data.
+     * @throws StateException if an error occured while processing data.
+     */
     protected AttributedPoint2ds getResult(String uuid, CallContext callContext)
     throws StateException
     {
@@ -433,6 +533,14 @@
         return result;
     }
 
+    /**
+     * Query the database for result data and turn it into a useful format to
+     * write this data into shapefiles.
+     *
+     * @param callContext The CallContext object.
+     * @return the processed data.
+     * @throws StateException if an error occured while processing data.
+     */
     protected AttributedPoint2ds produceResult(CallContext callContext)
     throws StateException
     {
@@ -502,6 +610,13 @@
         throw new StateException("no result produced");
     }
 
+    /**
+     * First step of finalizing the data returned from database.
+     *
+     * @param results Resulting data from database.
+     * @return the pre-processed data which is still not useful for being
+     * written to shapefiles.
+     */
     public AttributedPoint2ds preProcess(Collection<Result> results) {
 
         boolean debug = log.isDebugEnabled();
@@ -567,6 +682,16 @@
         return ap2ds;
     }
 
+    /**
+     * The last step of finalizing the data. The returned data is useful for
+     * shapefile creation.
+     *
+     * @param boundingBox The bounding box.
+     * @param polygon A polygon.
+     * @param callContext CallContext.
+     * @param input The pre-processed data.
+     * @return the finalized data ready for shapefile creation.
+     */
     public AttributedPoint2ds process(
         Envelope           boundingBox,
         Polygon            polygon,

http://dive4elements.wald.intevation.org