[Dive4elements-commits] [PATCH 8 of 8] Added new states and transitions to UESK calculation and adjusted states and UI

Wald Commits scm-commit at wald.intevation.org
Thu Mar 14 17:27:36 CET 2013


# HG changeset patch
# User Raimund Renkert <rrenkert at intevation.de>
# Date 1363278300 -3600
# Node ID 2c1045a1e3fe181c681690f792995509bddcaac0
# Parent  ff9dfc58d0cb441bb27f1905acbd4ceeeaa77a37
Added new states and transitions to UESK calculation and adjusted states and UI.
TODO: Some refactoring and code cleanup.

diff -r ff9dfc58d0cb -r 2c1045a1e3fe flys-artifacts/doc/conf/artifacts/winfo.xml
--- a/flys-artifacts/doc/conf/artifacts/winfo.xml	Thu Mar 14 17:21:00 2013 +0100
+++ b/flys-artifacts/doc/conf/artifacts/winfo.xml	Thu Mar 14 17:25:00 2013 +0100
@@ -496,12 +496,51 @@
 
         <state id="state.winfo.uesk.scenario" description="state.winfo.uesk.scenario" state="de.intevation.flys.artifacts.states.ScenarioSelect" helpText="help.state.winfo.uesk.scenario">
             <data name="scenario" type="String" />
+        </state>
+
+        <transition transition="de.intevation.flys.artifacts.transitions.ValueCompareTransition">
+            <from state="state.winfo.uesk.scenario"/>
+            <to state="state.winfo.uesk.uesk"/>
+            <condition data="scenario" value="scenario.current" operator="equal"/>
+        </transition>
+
+        <transition transition="de.intevation.flys.artifacts.transitions.ValueCompareTransition">
+            <from state="state.winfo.uesk.scenario"/>
+            <to state="state.winfo.uesk.uesk"/>
+            <condition data="scenario" value="scenario.potentiel" operator="equal"/>
+        </transition>
+
+        <transition transition="de.intevation.flys.artifacts.transitions.ValueCompareTransition">
+            <from state="state.winfo.uesk.scenario"/>
+            <to state="state.winfo.uesk.dc-hws"/>
+            <condition data="scenario" value="scenario.scenario" operator="equal"/>
+        </transition>
+
+        <state id="state.winfo.uesk.dc-hws" description="state.winfo.uesk.dc-hws" state="de.intevation.flys.artifacts.states.HWSDatacageState" helpText="help.state.winfo.uesk.dc-hws">
+            <data name="uesk.hws" type="String" />
+        </state>
+
+        <transition transition="de.intevation.flys.artifacts.transitions.DefaultTransition">
+            <from state="state.winfo.uesk.dc-hws" />
+            <to state="state.winfo.uesk.user-rgd" />
+        </transition>
+
+        <state id="state.winfo.uesk.user-rgd" description="state.winfo.uesk.user-rgd" state="de.intevation.flys.artifacts.states.UserRGDState" helpText="help.state.winfo.uesk.user-rgd">
+            <data name="uesk.user-rgd" type="String" />
+        </state>
+
+        <transition transition="de.intevation.flys.artifacts.transitions.DefaultTransition">
+            <from state="state.winfo.uesk.user-rgd" />
+            <to state="state.winfo.uesk.barriers" />
+        </transition>
+
+        <state id="state.winfo.uesk.barriers" description="state.winfo.uesk.barriers" state="de.intevation.flys.artifacts.states.HWSBarriersState" helpText="help.state.winfo.uesk.barriers">
             <data name="uesk.barriers" type="String" />
         </state>
 
         <transition transition="de.intevation.flys.artifacts.transitions.DefaultTransition">
-            <from state="state.winfo.uesk.scenario"/>
-            <to state="state.winfo.uesk.uesk"/>
+            <from state="state.winfo.uesk.barriers" />
+            <to state="state.winfo.uesk.uesk" />
         </transition>
 
         <state id="state.winfo.uesk.uesk" description="state.winfo.uesk.uesk" state="de.intevation.flys.artifacts.states.FloodMapState" helpText="help.state.winfo.uesk.uesk">
diff -r ff9dfc58d0cb -r 2c1045a1e3fe flys-artifacts/doc/conf/meta-data.xml
--- a/flys-artifacts/doc/conf/meta-data.xml	Thu Mar 14 17:21:00 2013 +0100
+++ b/flys-artifacts/doc/conf/meta-data.xml	Thu Mar 14 17:25:00 2013 +0100
@@ -937,7 +937,7 @@
               </discharge_table_nn>
           </dc:if>
 
-          <dc:if test="dc:contains($artifact-outs, 'floodmap')">
+          <dc:if test="dc:contains($artifact-outs, 'floodmap') or dc:contains($artifact-outs, 'floodmap-hws')">
               <floodmap>
               <dc:choose>
                   <dc:when test="dc:contains($parameters, 'recommended')">
@@ -946,6 +946,10 @@
                   <dc:when test="dc:contains($parameters, 'dem')">
                     <dc:call-macro name="flood-map-dem"/>
                   </dc:when>
+                  <dc:when test="dc:contains($parameters, 'hws')">
+                    <dc:call-macro name="flood-map-hws-lines" />
+                    <dc:call-macro name="flood-map-hws-points" />
+                  </dc:when>
                   <dc:otherwise>
                     <dc:call-macro name="flood-map-complete"/>
                   </dc:otherwise>
@@ -993,6 +997,138 @@
                   </dc:context>
                 </dems>
               </dc:macro>
+              <dc:macro name="flood-map-hws-lines">
+                <dc:context>
+                  <dc:statement>
+                    SELECT DISTINCT
+                           name AS hws_name,
+                           official AS hws_official,
+                           kind_id AS hws_kind
+                    FROM hws_lines
+                    WHERE river_id = ${river_id}
+                  </dc:statement>
+                  <lines>
+                    <official>
+                      <Durchlass>
+                        <dc:elements filter="$hws_kind=1 and $hws_official=1">
+                            <hws>
+                              <dc:attribute name="factory" value="hwsfactory"/>
+                              <dc:attribute name="name" value="${hws_name}"/>
+                            </hws>
+                        </dc:elements>
+                      </Durchlass>
+                      <Damm>
+                        <dc:elements filter="$hws_kind=2 and $hws_official=1">
+                            <hws>
+                              <dc:attribute name="factory" value="hwsfactory"/>
+                              <dc:attribute name="name" value="${hws_name}"/>
+                            </hws>
+                        </dc:elements>
+                      </Damm>
+                      <Graben>
+                        <dc:elements filter="$hws_kind=3 and $hws_official=1">
+                          <hws>
+                            <dc:attribute name="factory" value="hwsfactory"/>
+                            <dc:attribute name="name" value="${hws_name}"/>
+                          </hws>
+                        </dc:elements>
+                      </Graben>
+                    </official>
+                    <inofficial>
+                      <Durchlass>
+                        <dc:elements filter="$hws_kind=1 and $hws_official=0">
+                          <hws>
+                            <dc:attribute name="factory" value="hwsfactory"/>
+                            <dc:attribute name="name" value="${hws_name}"/>
+                          </hws>
+                        </dc:elements>
+                      </Durchlass>
+                      <Damn>
+                        <dc:elements filter="$hws_kind=2 and $hws_official=0">
+                          <hws>
+                            <dc:attribute name="factory" value="hwsfactory"/>
+                            <dc:attribute name="name" value="${hws_name}"/>
+                          </hws>
+                        </dc:elements>
+                      </Damn>
+                      <Graben>
+                        <dc:elements filter="$hws_kind=3 and $hws_official=0">
+                          <hws>
+                            <dc:attribute name="factory" value="hwsfactory"/>
+                            <dc:attribute name="name" value="${hws_name}"/>
+                          </hws>
+                        </dc:elements>
+                      </Graben>
+                    </inofficial>
+                  </lines>
+                </dc:context>
+              </dc:macro>
+              <dc:macro name="flood-map-hws-points">
+                <dc:context>
+                  <dc:statement>
+                    SELECT DISTINCT
+                           name AS hws_points_name,
+                           official AS hws_points_official,
+                           kind_id AS hws_points_kind
+                    FROM hws_points
+                    WHERE river_id = ${river_id}
+                  </dc:statement>
+                  <points>
+                    <official>
+                      <Durchlass>
+                        <dc:elements filter="$hws_points_kind=1 and $hws_points_official=1">
+                          <hws>
+                            <dc:attribute name="factory" value="hwsfactory"/>
+                            <dc:attribute name="name" value="${hws_points_name}"/>
+                          </hws>
+                        </dc:elements>
+                      </Durchlass>
+                      <Damm>
+                        <dc:elements filter="$hws_points_kind=2 and $hws_points_official=1">
+                          <hws>
+                            <dc:attribute name="factory" value="hwsfactory"/>
+                            <dc:attribute name="name" value="${hws_points_name}"/>
+                          </hws>
+                        </dc:elements>
+                      </Damm>
+                      <Graben>
+                        <dc:elements filter="$hws_kind=3 and $hws_official=1">
+                          <hws>
+                            <dc:attribute name="factory" value="hwsfactory"/>
+                            <dc:attribute name="name" value="${hws_points_name}"/>
+                          </hws>
+                        </dc:elements>
+                      </Graben>
+                    </official>
+                    <inofficial>
+                      <Durchlass>
+                        <dc:elements filter="$hws_points_kind=1 and $hws_points_official=0">
+                          <hws>
+                            <dc:attribute name="factory" value="hwsfactory"/>
+                            <dc:attribute name="name" value="${hws_points_name}"/>
+                          </hws>
+                        </dc:elements>
+                      </Durchlass>
+                      <Damm>
+                        <dc:elements filter="$hws_points_kind=2 and $hws_points_official=0">
+                          <hws>
+                            <dc:attribute name="factory" value="hwsfactory"/>
+                            <dc:attribute name="name" value="${hws_points_name}"/>
+                          </hws>
+                        </dc:elements>
+                      </Damm>
+                      <Graben>
+                        <dc:elements filter="$hws_points_kind=3 and $hws_points_official=0">
+                          <hws>
+                            <dc:attribute name="factory" value="hwsfactory"/>
+                            <dc:attribute name="name" value="${hws_points_name}"/>
+                          </hws>
+                        </dc:elements>
+                      </Graben>
+                    </inofficial>
+                  </points>
+                </dc:context>
+              </dc:macro>
               <dc:macro name="flood-map-km">
                 <dc:context>
                   <dc:statement>
@@ -1988,6 +2124,36 @@
           </fix_vollmer_wq_curve>
         </dc:macro>
 
+        <dc:macro name="floodmap-hws-user">
+                  <dc:context>
+                    <dc:statement>
+                      SELECT id AS out_id
+                      FROM outs
+                      WHERE artifact_id = ${a_id} AND name = 'floodmap'
+                    </dc:statement>
+                    <dc:elements>
+                      <dc:context>
+                        <dc:statement>
+                          SELECT name AS facet_name, num as facet_num, description AS facet_description
+                          FROM facets
+                          WHERE out_id = ${out_id} and name = 'floodmap.usershape'
+                          ORDER BY num ASC, name DESC
+                        </dc:statement>
+                        <own-hws>
+                          <dc:elements>
+                            <dc:element name="${facet_name}">
+                              <dc:attribute name="description" value="${facet_description}"/>
+                              <dc:attribute name="ids"         value="${facet_num}"/>
+                              <dc:attribute name="factory"     value="winfo"/>
+                              <dc:attribute name="artifact-id" value="${a_gid}"/>
+                              <dc:attribute name="out"         value="floodmap"/>
+                            </dc:element>
+                          </dc:elements>
+                        </own-hws>
+                      </dc:context>
+                    </dc:elements>
+                  </dc:context>
+        </dc:macro>
         <dc:if test="dc:contains($artifact-outs, 'longitudinal_section') or (dc:contains($artifact-outs, 'discharge_longitudinal_section') or (dc:contains($artifact-outs, 'w_differences')))">
           <dc:call-macro name="longitudinal"/>
         </dc:if>
@@ -2030,7 +2196,9 @@
         <dc:if test="dc:contains($artifact-outs, 'bedheight_middle')">
           <dc:call-macro name="bed-height"/>
         </dc:if>
-
+        <dc:if test="dc:contains($artifact-outs, 'floodmap-hws')">
+          <dc:call-macro name="floodmap-hws-user"/>
+        </dc:if>
       </dc:context>
   </dc:call-macro>
 
diff -r ff9dfc58d0cb -r 2c1045a1e3fe flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/FloodMapState.java
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/FloodMapState.java	Thu Mar 14 17:21:00 2013 +0100
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/FloodMapState.java	Thu Mar 14 17:25:00 2013 +0100
@@ -43,8 +43,11 @@
 import de.intevation.flys.artifacts.model.CalculationMessage;
 import de.intevation.flys.artifacts.model.CalculationResult;
 import de.intevation.flys.artifacts.model.FacetTypes;
+import de.intevation.flys.artifacts.model.LayerInfo;
 import de.intevation.flys.artifacts.model.WQKms;
-
+import de.intevation.flys.artifacts.model.map.HWS;
+import de.intevation.flys.artifacts.model.map.HWSContainer;
+import de.intevation.flys.artifacts.model.map.HWSFactory;
 import de.intevation.flys.artifacts.model.map.WMSLayerFacet;
 import de.intevation.flys.artifacts.model.map.WSPLGENCalculation;
 import de.intevation.flys.artifacts.model.map.WSPLGENJob;
@@ -68,6 +71,26 @@
 import de.intevation.flys.wsplgen.JobObserver;
 import de.intevation.flys.wsplgen.Scheduler;
 
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import javax.naming.Context;
+
+import org.apache.log4j.Logger;
+import org.apache.velocity.Template;
+import org.geotools.feature.FeatureCollection;
+import org.geotools.feature.FeatureCollections;
+import org.geotools.feature.simple.SimpleFeatureBuilder;
+import org.hibernate.HibernateException;
+import org.opengis.feature.simple.SimpleFeature;
+import org.opengis.feature.simple.SimpleFeatureType;
+
+
 public class FloodMapState
 extends      DefaultState
 implements   FacetTypes
@@ -102,6 +125,13 @@
 
     public static final int WSPLGEN_DEFAULT_OUTPUT = 0;
 
+    private static final String HWS_LINES_SHAPE = "hws-lines.shp";
+
+    private static final String I18N_HWS_POINTS = "floodmap.hws.points";
+    private static final String I18N_HWS_LINES = "floodmap.hws.lines";
+    private static final String HWS_LINES = "hws-lines";
+    private static final String HWS_POINT_SHAPE = "hws-points.shp";
+    private static final String HWS_POINTS = "hws-points";
 
     /**
      * @param orig
@@ -305,6 +335,7 @@
         WSPLGENCalculation calculation
     ) {
         logger.debug("FloodMapState.prepareWSPLGENJob");
+        String scenario = artifact.getDataAsString("scenario");
 
         WSPLGENJob job = new WSPLGENJob(
             artifact,
@@ -320,15 +351,20 @@
         setDelta(artifact, job);
         setGel(artifact, job);
         setDist(artifact, job);
-        setLine(artifact, facetCreator, artifactDir, job);
-        setUserShape(artifact, facetCreator, artifactDir, job);
         setAxis(artifact, artifactDir, job);
         setPro(artifact, artifactDir, job);
         setDgm(artifact, job, context);
         setArea(artifact, artifactDir, job);
         setOutFile(artifact, job);
         setWsp(artifact, context, artifactDir, job);    // WSP
-
+        if (scenario.equals("scenario.current")) {
+            setOfficialHWS(artifact, facetCreator, artifactDir, job);
+        }
+        else if (scenario.equals("scenario.scenario")) {
+            setAdditionalHWS(artifact, facetCreator, artifactDir, job);
+            setLine(artifact, facetCreator, artifactDir, job);
+            setUserShape(artifact, facetCreator, artifactDir, job);
+        }
         // TODO
         // setWspTag(artifact, job);
 
@@ -348,6 +384,106 @@
     }
 
 
+    private void setAdditionalHWS(
+        FLYSArtifact artifact,
+        FacetCreator facetCreator,
+        File dir,
+        WSPLGENJob job) {
+        File line = new File(dir, HWS_LINES_SHAPE);
+        boolean lines = line.exists();
+        logger.debug("shp file exists: " + lines);
+        if (lines) {
+            job.addLin(dir + "/" + HWS_LINES_SHAPE);
+            facetCreator.createShapeFacet(I18N_HWS_LINES,
+                MapfileGenerator.MS_LAYER_PREFIX + HWS_LINES,
+                FLOODMAP_LINES, 2);
+        }
+        File point = new File(dir, HWS_POINT_SHAPE);
+        boolean points = point.exists();
+        logger.debug("shp file exists: " + points);
+        if (points) {
+            facetCreator.createShapeFacet(I18N_HWS_POINTS,
+                MapfileGenerator.MS_LAYER_PREFIX + HWS_POINTS,
+                FLOODMAP_FIXPOINTS, 3);
+        }
+    }
+
+
+    private void setOfficialHWS(
+        FLYSArtifact artifact,
+        FacetCreator facetCreator,
+        File artifactDir,
+        WSPLGENJob job) {
+        String river = artifact.getDataAsString("river");
+
+        HWSContainer hwsLines = HWSFactory.getHWSLines(river);
+        List<HWS> selectedLines = hwsLines.getOfficialHWS();
+
+        FeatureCollection collectionLines = FeatureCollections.newCollection();
+        SimpleFeatureType lineType = null;
+        for (HWS h : selectedLines) {
+            lineType = h.getFeatureType();
+            collectionLines.add(h.getFeature());
+        }
+        boolean successLines = false;
+        if (lineType != null && collectionLines.size() > 0) {
+            File shapeLines = new File(artifactDir, HWS_LINES_SHAPE);
+            successLines = GeometryUtils.writeShapefile(
+                shapeLines, lineType, collectionLines);
+        }
+       if (successLines) {
+            createMapfile(
+                artifact,
+                artifactDir,
+                MapfileGenerator.MS_LAYER_PREFIX + "hws-lines",
+                HWS_LINES_SHAPE,
+                "LINE",
+                "31467",
+                "hws");
+            job.addLin(artifactDir + "/" + HWS_LINES_SHAPE);
+            facetCreator.createShapeFacet(I18N_HWS_LINES,
+                MapfileGenerator.MS_LAYER_PREFIX + HWS_LINES,
+                FLOODMAP_HWS,2);
+        }
+    }
+
+
+    private void createMapfile(
+        FLYSArtifact artifact,
+        File artifactDir,
+        String name,
+        String hwsShapefile,
+        String type,
+        String srid,
+        String group
+    ) {
+        LayerInfo info = new LayerInfo();
+        info.setName(name + artifact.identifier());
+        info.setType(type);
+        info.setDirectory(artifact.identifier());
+        info.setTitle(name);
+        info.setData(hwsShapefile);
+        info.setSrid(srid);
+        info.setGroupTitle(group);
+        MapfileGenerator generator = new ArtifactMapfileGenerator();
+        Template tpl = generator.getTemplateByName(MapfileGenerator.SHP_LAYER_TEMPLATE);
+        try {
+            File layer = new File(artifactDir.getCanonicalPath() + "/" + name);
+            generator.writeLayer(info, layer, tpl);
+            List<String> layers = new ArrayList<String>();
+            layers.add(layer.getAbsolutePath());
+            generator.generate();
+        }
+        catch(FileNotFoundException fnfe) {
+            logger.warn("Could not find mapfile for hws layer");
+        }
+        catch (Exception ioe) {
+            logger.warn("Could not create mapfile for hws layer");
+            logger.warn(Arrays.toString(ioe.getStackTrace()));
+        }
+    }
+
+
     protected void setOut(FLYSArtifact artifact, WSPLGENJob job) {
         job.setOut(WSPLGEN_DEFAULT_OUTPUT);
     }
@@ -464,6 +600,14 @@
             logger.debug(
                 "Successfully created barrier line shapefile. " +
                 "Write shapefile path into WSPLGEN job.");
+            createMapfile(
+                artifact,
+                dir,
+                MapfileGenerator.MS_LAYER_PREFIX + "barriers-lines",
+                WSPLGEN_BARRIERS_LINES,
+                "LINE",
+                srid,
+                "barriers");
 
             if (scenario.equals(WSPLGENJob.GEL_NOSPERRE)) {
                 logger.debug("WSPLGEN will not use barrier features.");
@@ -478,10 +622,19 @@
             GeometryUtils.buildFeatureType("polygons", srs, Polygon.class, obj),
             fcs[1]);
 
+
         if (p) {
             logger.debug(
                 "Successfully created barrier polygon shapefile. " +
                 "Write shapefile path into WSPLGEN job.");
+            createMapfile(
+                artifact,
+                dir,
+                MapfileGenerator.MS_LAYER_PREFIX + "barriers-poly",
+                shapePolys.getAbsolutePath(),
+                "POLYGON",
+                srid,
+                "barriers");
 
             if (scenario.equals(WSPLGENJob.GEL_NOSPERRE)) {
                 logger.debug("WSPLGEN will not use barrier features.");
@@ -503,22 +656,15 @@
         File         dir,
         WSPLGENJob   job
     ) {
-        File archive = new File(dir, WSPLGEN_USER_ZIP);
+        File archive = new File(dir, WSPLGEN_USER_SHAPE);
         boolean exists = archive.exists();
-        logger.debug("Zip file exists: " + exists);
+        logger.debug("shp file exists: " + exists);
         if (exists) {
-            try {
-                File tmpDir = new File(dir, "usr_tmp");
-                FileTools.extractArchive(archive, tmpDir);
-                moveFiles(tmpDir, dir);
-            }
-            catch (IOException ioe) {
-                logger.warn("Zip archive " + dir + "/" + WSPLGEN_USER_ZIP + " could not be extracted.");
-                return;
-            }
-
             job.addLin(dir + "/" + WSPLGEN_USER_SHAPE);
-            facetCreator.createUserShapeFacet();
+            facetCreator.createShapeFacet(FacetCreator.I18N_USERSHAPE,
+                MapfileGenerator.MS_LAYER_PREFIX + "user-rgd",
+                FLOODMAP_USERSHAPE,
+                4);
         }
     }
 
@@ -883,41 +1029,6 @@
     }
 
 
-    protected void moveFiles(File source, final File target)
-    throws IOException
-    {
-        if (!source.exists()) {
-            return;
-        }
-        if (!target.exists()) {
-            target.mkdir();
-        }
-        FileTools.walkTree(source, new FileTools.FileVisitor() {
-            @Override
-            public boolean visit(File file) {
-                if (!file.isDirectory()) {
-                    String name = file.getName();
-                    String suffix = "";
-                    int pos = name.lastIndexOf('.');
-                    if (pos > 0 && pos < name.length() - 1) {
-                        suffix = name.substring(pos + 1);
-                    }
-                    else {
-                        return true;
-                    }
-                    try {
-                        FileTools.copyFile(file, new File(target, WSPLGEN_USER_FILENAME + "." + suffix));
-                    }
-                    catch (IOException ioe) {
-                        logger.warn ("Error while copying file " + file.getName());
-                        return true;
-                    }
-                }
-                return true;
-            }
-        });
 
-        FileTools.deleteRecursive(source);
-    }
 }
 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :
diff -r ff9dfc58d0cb -r 2c1045a1e3fe flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/ScenarioSelect.java
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/ScenarioSelect.java	Thu Mar 14 17:21:00 2013 +0100
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/ScenarioSelect.java	Thu Mar 14 17:25:00 2013 +0100
@@ -26,7 +26,6 @@
 
 
     public static final String FIELD_MODE     = "scenario";
-    public static final String FIELD_BARRIERS = "uesk.barriers";
 
     public static final String SCENARIO_CURRENT   = "scenario.current";
     public static final String SCENARIO_POTENTIEL = "scenario.potentiel";
@@ -38,30 +37,11 @@
         SCENARIO_SCENRAIO };
 
 
-
     @Override
     protected String getUIProvider() {
-        return "map_digitize";
+        return "";
     }
 
-
-    @Override
-    protected void appendStaticData(
-        FLYSArtifact   flys,
-        CallContext    cc,
-        ElementCreator creator,
-        Element        ui,
-        String         name
-    ) {
-        if (name != null && name.equals(FIELD_BARRIERS)) {
-            return;
-        }
-        else {
-            super.appendStaticData(flys, cc, creator, ui, name);
-        }
-    }
-
-
     @Override
     protected Element[] createItems(
         XMLUtils.ElementCreator cr,
diff -r ff9dfc58d0cb -r 2c1045a1e3fe flys-artifacts/src/main/java/de/intevation/flys/wsplgen/FacetCreator.java
--- a/flys-artifacts/src/main/java/de/intevation/flys/wsplgen/FacetCreator.java	Thu Mar 14 17:21:00 2013 +0100
+++ b/flys-artifacts/src/main/java/de/intevation/flys/wsplgen/FacetCreator.java	Thu Mar 14 17:25:00 2013 +0100
@@ -159,8 +159,11 @@
             hash,
             getUrl());
 
-        barriers.addLayer(
-            MapfileGenerator.MS_BARRIERS_PREFIX + artifact.identifier());
+        barriers.addLayer(MapfileGenerator.MS_LAYER_PREFIX +
+            MapfileGenerator.MS_BARRIERS_PREFIX + "lines" + artifact.identifier());
+        barriers.addLayer( MapfileGenerator.MS_LAYER_PREFIX +
+            MapfileGenerator.MS_BARRIERS_PREFIX + "poly" + artifact.identifier());
+ 
         barriers.setSrid(getSrid());
         barriers.setExtent(getBounds());
 
@@ -168,13 +171,17 @@
     }
 
 
-    public void createUserShapeFacet() {
+    public void createShapeFacet(
+        String desc,
+        String layer,
+        String type,
+        int ndx) {
         WMSLayerFacet shape = new WMSLayerFacet(
             1,
-            FLOODMAP_USERSHAPE,
+            type,
             Resources.getMsg(
                 cc.getMeta(),
-                I18N_USERSHAPE,
+                desc,
                 I18N_USERSHAPE_DEFAULT),
             ComputeType.ADVANCE,
             stateId,
@@ -182,7 +189,7 @@
             getUrl());
 
         shape.addLayer(
-            MapfileGenerator.MS_USERSHAPE_PREFIX + artifact.identifier());
+            layer + artifact.identifier());
         shape.setSrid(getSrid());
         shape.setExtent(getBounds());
 
diff -r ff9dfc58d0cb -r 2c1045a1e3fe flys-client/src/main/java/de/intevation/flys/client/client/ui/DigitizePanel.java
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/DigitizePanel.java	Thu Mar 14 17:21:00 2013 +0100
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/DigitizePanel.java	Thu Mar 14 17:25:00 2013 +0100
@@ -1,22 +1,21 @@
 package de.intevation.flys.client.client.ui;
 
+import java.util.List;
+
+import org.gwtopenmaps.openlayers.client.Map;
+import org.gwtopenmaps.openlayers.client.control.Attribution;
+import org.gwtopenmaps.openlayers.client.layer.WMS;
+import org.gwtopenmaps.openlayers.client.layer.WMSOptions;
+import org.gwtopenmaps.openlayers.client.layer.WMSParams;
+
 import com.google.gwt.core.client.GWT;
 import com.google.gwt.user.client.rpc.AsyncCallback;
-
-import com.smartgwt.client.types.Encoding;
 import com.smartgwt.client.types.VerticalAlignment;
 import com.smartgwt.client.util.SC;
-import com.smartgwt.client.widgets.Button;
 import com.smartgwt.client.widgets.Canvas;
-import com.smartgwt.client.widgets.HTMLPane;
 import com.smartgwt.client.widgets.Label;
-import com.smartgwt.client.widgets.events.ClickEvent;
-import com.smartgwt.client.widgets.events.ClickHandler;
 import com.smartgwt.client.widgets.events.VisibilityChangedEvent;
 import com.smartgwt.client.widgets.events.VisibilityChangedHandler;
-import com.smartgwt.client.widgets.form.DynamicForm;
-import com.smartgwt.client.widgets.form.fields.SelectItem;
-import com.smartgwt.client.widgets.form.fields.UploadItem;
 import com.smartgwt.client.widgets.layout.VLayout;
 import com.smartgwt.client.widgets.tab.events.TabSelectedEvent;
 import com.smartgwt.client.widgets.tab.events.TabSelectedHandler;
@@ -35,17 +34,6 @@
 import de.intevation.flys.client.shared.model.DefaultDataItem;
 import de.intevation.flys.client.shared.model.MapInfo;
 
-import java.util.LinkedHashMap;
-import java.util.List;
-
-import org.gwtopenmaps.openlayers.client.Map;
-import org.gwtopenmaps.openlayers.client.control.Attribution;
-import org.gwtopenmaps.openlayers.client.feature.VectorFeature;
-import org.gwtopenmaps.openlayers.client.format.GeoJSON;
-import org.gwtopenmaps.openlayers.client.layer.WMS;
-import org.gwtopenmaps.openlayers.client.layer.WMSOptions;
-import org.gwtopenmaps.openlayers.client.layer.WMSParams;
-
 
 public class DigitizePanel
 extends SelectProvider
@@ -71,37 +59,17 @@
     @Override
     public Canvas create(DataList list) {
         List<Data> data = list.getAll();
-
         helperContainer.addVisibilityChangedHandler(this);
 
-        Data barriers = null;
-        for (int i = data.size()-1; i >= 0; i--) {
-            Data d = data.get(i);
-            if (d.getLabel().equals(UESK_BARRIERS)) {
-                barriers = d;
-                data.remove(d);
-            }
-        }
-
         DataList clone = (DataList) list.clone();
         List<Data> all = clone.getAll();
         all.remove(UESK_BARRIERS);
 
-        Canvas selectBox = super.create(clone);
+        Canvas widget = createWidget(list);
 
         final Config cfg    = Config.getInstance();
         final String locale = cfg.getLocale();
 
-        DataItem[] obj = barriers.getItems();
-
-        final String[] geojson = new String[1];
-        for (DataItem item: obj) {
-            if (item.getLabel().equals(UESK_BARRIERS)) {
-                geojson[0] = item.getStringValue();
-                break;
-            }
-        }
-
         String river = getDataValue("state.winfo.river", "river");
         mapInfo.getMapInfo(locale, river, new AsyncCallback<MapInfo>() {
             @Override
@@ -114,11 +82,11 @@
 
             @Override
             public void onSuccess(MapInfo info) {
-                createMapWidget(info, geojson[0]);
+                createMapWidget(info);
             }
         });
 
-        return selectBox;
+        return widget;
     }
 
 
@@ -137,10 +105,6 @@
         layout.setAlign(VerticalAlignment.TOP);
         layout.setHeight(25);
 
-        LinkedHashMap<String, String> initial = new LinkedHashMap<String, String>();
-
-        form = new DynamicForm();
-
         int size = data.size();
 
         for (int i = 0; i < size; i++) {
@@ -151,74 +115,10 @@
             label.setHeight(20);
             label.setWidth(400);
 
-            SelectItem combobox = new SelectItem(d.getLabel());
-            combobox.setWidth(250);
-
-            LinkedHashMap<String, String> it = new LinkedHashMap<String, String>();
-
-            boolean  defaultSet = false;
-            boolean  first      = true;
-
-            DataItem def      = d.getDefault();
-            String   defValue = def != null ? def.getStringValue() : null;
-
-            if (defValue != null && defValue.length() > 0) {
-                initial.put(d.getLabel(), def.getStringValue());
-                defaultSet = true;
-            }
-
-            for (DataItem item: d.getItems()) {
-                if (!defaultSet && first) {
-                    initial.put(d.getLabel(), item.getStringValue());
-                    first = false;
-                }
-
-                it.put(item.getStringValue(), item.getLabel());
-            }
-
-            label.setWidth(50);
-            combobox.setValueMap(it);
-            combobox.setShowTitle(false);
-            form.setItems(combobox);
-
-            HTMLPane uploadTargetFrame = new HTMLPane();
-            uploadTargetFrame.setWidth("200px");
-            uploadTargetFrame.setHeight("50px");
-            uploadTargetFrame.setContents(
-                    "<iframe id='uploadTarget' name='uploadTarget' scrolling='no' width=200 height=50 style='border: 0px'></iframe>");
-            uploadTargetFrame.setBorder("0px");
-            uploadTargetFrame.setScrollbarSize(0);
-
-            final DynamicForm uploadForm = new DynamicForm();
-            uploadForm.setAction("flys/fileupload?uuid=" + artifact.getUuid());
-            uploadForm.setTarget("uploadTarget");
-            uploadForm.setEncoding(Encoding.MULTIPART);
-            Label uploadLabel = new Label(MSG.shape_file_upload());
-            uploadLabel.setHeight(20);
-            UploadItem uploadItem = new UploadItem();
-            uploadItem.setShowTitle(false);
-            uploadForm.setFields(uploadItem);
-            Button submit = new Button(MSG.upload_file());
-            submit.addClickHandler(new ClickHandler() {
-                @Override
-                public void onClick(ClickEvent e) {
-                    uploadForm.submitForm();
-                }
-            });
-
             layout.addMember(label);
-            layout.addMember(form);
-            layout.addMember(uploadLabel);
-            layout.addMember(uploadForm);
-            layout.addMember(submit);
             layout.addMember(getNextButton());
-
-            layout.setMembersMargin(10);
-            layout.addMember(uploadTargetFrame);
         }
 
-        form.setValues(initial);
-
         layout.setAlign(VerticalAlignment.TOP);
 
         return layout;
@@ -227,14 +127,12 @@
 
     @Override
     protected Data[] getData() {
-        Data[] data  = super.getData();
-        Data[] total = new Data[2];
+        Data[] total = new Data[1];
 
         if (floodMap != null) {
             DataItem item = new DefaultDataItem(
                 UESK_BARRIERS, UESK_BARRIERS, floodMap.getFeaturesAsGeoJSON());
-            total[0] = data[0];
-            total[1] = new DefaultData(
+            total[0] = new DefaultData(
                 UESK_BARRIERS, null, null, new DataItem[] { item });
         }
         else {
@@ -246,7 +144,7 @@
     }
 
 
-    public void createMapWidget(MapInfo mapInfo, String geojson) {
+    public void createMapWidget(MapInfo mapInfo) {
         mapPanel = new MapPanel(mapInfo, true);
 
         floodMap = mapPanel.getFloodMap();
@@ -266,9 +164,25 @@
         map.addLayer(back);
         map.addLayer(axis);
 
-        if (geojson != null && geojson.length() > 0) {
-            VectorFeature[] features = new GeoJSON().read(geojson);
-            floodMap.getBarrierLayer().addFeatures(features);
+        String hws = getDataValue("state.winfo.uesk.dc-hws", "uesk.hws");
+        if (hws != null && hws.length() > 0) {
+            WMS hwsLayer = getLayer(
+            //TODO: Use Mapinfo to get hws layer infos.
+                mapInfo.getWmsUrl().replace("river", "user"),
+                "ms_layer-hws-lines" + artifact.getUuid(),
+                mapInfo.getProjection(),
+                false);
+            map.addLayer(hwsLayer);
+        }
+        String userRgd = getDataValue("state.winfo.uesk.user-rgd", "uesk.user-rgd");
+        if (userRgd != null && userRgd.length() > 0) {
+            WMS userLayer = getLayer(
+            //TODO: Use Mapinfo to get hws layer infos.
+                mapInfo.getWmsUrl().replace("river", "user"),
+                "ms_layer-user-rgd" + artifact.getUuid(),
+                mapInfo.getProjection(),
+                false);
+            map.addLayer(userLayer);
         }
         map.addControl(new Attribution());
         map.zoomToMaxExtent();
diff -r ff9dfc58d0cb -r 2c1045a1e3fe flys-client/src/main/java/de/intevation/flys/client/client/ui/UIProviderFactory.java
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/UIProviderFactory.java	Thu Mar 14 17:21:00 2013 +0100
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/UIProviderFactory.java	Thu Mar 14 17:25:00 2013 +0100
@@ -1,5 +1,7 @@
 package de.intevation.flys.client.client.ui;
 
+import com.google.gwt.core.client.GWT;
+
 import de.intevation.flys.client.client.ui.fixation.FixEventSelect;
 import de.intevation.flys.client.client.ui.fixation.FixFunctionSelect;
 import de.intevation.flys.client.client.ui.fixation.FixGaugeSelectPanel;
@@ -174,6 +176,12 @@
         else if (uiProvider.equals("minfo.sedimentload_offepoch_select")) {
             return new SedLoadOffEpochPanel();
         }
+        else if (uiProvider.equals("hws_datacage_panel")) {
+            return new HWSDatacagePanel(user);
+        }
+        else if (uiProvider.equals("user_rgd_panel")) {
+            return new UserRGDProvider();
+        }
         else {
             //GWT.log("Picked default provider.");
             return new SelectProvider();


More information about the Dive4elements-commits mailing list