changeset 7740:72d0cec59c78

Implement deepCopy on WMSLayerFacet WMSDBLayerFacet and WSPLGENLayerFacet This fixes double map-out and dissappearance of visible floodmap if cloning happened.
author Felix Wolfsteller <felix.wolfsteller@intevation.de>
date Thu, 06 Feb 2014 14:47:29 +0100
parents 44a9233c62eb
children 869f54874c3c
files artifacts/src/main/java/org/dive4elements/river/artifacts/model/map/WMSDBLayerFacet.java artifacts/src/main/java/org/dive4elements/river/artifacts/model/map/WMSLayerFacet.java artifacts/src/main/java/org/dive4elements/river/artifacts/model/map/WSPLGENLayerFacet.java
diffstat 3 files changed, 55 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/model/map/WMSDBLayerFacet.java	Thu Feb 06 13:22:10 2014 +0100
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/model/map/WMSDBLayerFacet.java	Thu Feb 06 14:47:29 2014 +0100
@@ -9,6 +9,7 @@
 package org.dive4elements.river.artifacts.model.map;
 
 import org.dive4elements.river.artifacts.states.DefaultState.ComputeType;
+import org.dive4elements.artifactdatabase.state.Facet;
 
 
 public class WMSDBLayerFacet extends WMSLayerFacet {
@@ -110,5 +111,27 @@
     public boolean isQueryable() {
         return true;
     }
+
+    /** Clone Facet-bound data. */
+    protected void cloneData(WMSDBLayerFacet copy) {
+        super.cloneData(copy);
+        copy.setFilter(this.getFilter());
+        copy.setData(this.getData());
+        copy.setGeometryType(this.getGeometryType());
+        copy.setConnection(this.getConnection());
+        copy.setConnectionType(this.getConnectionType());
+        copy.setLabelItem(this.getLabelItem());
+    }
+
+    /** Copy deeply. */
+    @Override
+    public Facet deepCopy() {
+        WMSDBLayerFacet copy = new WMSDBLayerFacet();
+        copy.set(this);
+
+        cloneData(copy);
+
+        return copy;
+    }
 }
 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/model/map/WMSLayerFacet.java	Thu Feb 06 13:22:10 2014 +0100
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/model/map/WMSLayerFacet.java	Thu Feb 06 14:47:29 2014 +0100
@@ -173,18 +173,30 @@
     }
 
 
+    /** Clone facet-bound data. */
+    protected void cloneData(WMSLayerFacet copy) {
+        copy.type    = type;
+        copy.stateId = stateId;
+        copy.hash    = hash;
+
+        if (layers != null) {
+            copy.layers  = new ArrayList<String>(layers);
+        }
+        else {
+            copy.layers = new ArrayList<String>();
+        }
+
+        copy.url     = url;
+        copy.extent  = extent;
+        copy.srid    = srid;
+    }
+
     @Override
     public Facet deepCopy() {
         WMSLayerFacet copy = new WMSLayerFacet();
         copy.set(this);
 
-        copy.type    = type;
-        copy.layers  = new ArrayList<String>(layers);
-        copy.stateId = stateId;
-        copy.hash    = hash;
-        copy.url     = url;
-        copy.extent  = extent;
-        copy.srid    = srid;
+        cloneData(copy);
 
         return copy;
     }
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/model/map/WSPLGENLayerFacet.java	Thu Feb 06 13:22:10 2014 +0100
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/model/map/WSPLGENLayerFacet.java	Thu Feb 06 14:47:29 2014 +0100
@@ -9,6 +9,7 @@
 package org.dive4elements.river.artifacts.model.map;
 
 import org.dive4elements.river.artifacts.states.DefaultState.ComputeType;
+import org.dive4elements.artifactdatabase.state.Facet;
 
 public class WSPLGENLayerFacet
 extends      WMSLayerFacet
@@ -50,5 +51,17 @@
     public boolean isQueryable() {
         return true;
     }
+
+
+    /** Copy deeply. */
+    @Override
+    public Facet deepCopy() {
+        WSPLGENLayerFacet copy = new WSPLGENLayerFacet();
+        copy.set(this);
+
+        cloneData(copy);
+
+        return copy;
+    }
 }
 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org