changeset 1061:b1b0a0b61845

Made facets cloneable with the right type. flys-artifacts/trunk@2533 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Tue, 23 Aug 2011 13:17:21 +0000
parents 2d60a875e28c
children ee105e5d5ead
files flys-artifacts/ChangeLog flys-artifacts/src/main/java/de/intevation/flys/artifacts/MainValuesArtifact.java flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/AnnotationFacet.java flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/DataFacet.java flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/DurationCurveFacet.java flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/ManagedFacet.java flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/ManagedFacetAdapter.java flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/ReportFacet.java flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/WMSLayerFacet.java flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/WSPLGENFacet.java flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/WaterlevelFacet.java flys-artifacts/src/main/java/de/intevation/flys/artifacts/services/MapInfoService.java
diffstat 12 files changed, 137 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/flys-artifacts/ChangeLog	Tue Aug 23 13:05:54 2011 +0000
+++ b/flys-artifacts/ChangeLog	Tue Aug 23 13:17:21 2011 +0000
@@ -1,3 +1,20 @@
+2011-08-23  Sascha L. Teichmann <sascha.teichmann@intevation.de>
+
+	* src/main/java/de/intevation/flys/artifacts/model/WMSLayerFacet.java,
+	  src/main/java/de/intevation/flys/artifacts/model/DataFacet.java,
+	  src/main/java/de/intevation/flys/artifacts/model/WaterlevelFacet.java,
+	  src/main/java/de/intevation/flys/artifacts/model/ReportFacet.java,
+	  src/main/java/de/intevation/flys/artifacts/model/DurationCurveFacet.java,
+	  src/main/java/de/intevation/flys/artifacts/model/ManagedFacet.java,
+	  src/main/java/de/intevation/flys/artifacts/model/ManagedFacetAdapter.java,
+	  src/main/java/de/intevation/flys/artifacts/model/AnnotationFacet.java,
+	  src/main/java/de/intevation/flys/artifacts/model/WSPLGENFacet.java:
+	  Made facets cloneable with the right type.
+
+	* src/main/java/de/intevation/flys/artifacts/services/MapInfoService.java,
+	  src/main/java/de/intevation/flys/artifacts/MainValuesArtifact.java:
+	  Removed superfluous imports.
+
 2011-08-23  Ingo Weinzierl <ingo@intevation.de>
 
 	* src/main/java/de/intevation/flys/collections/FLYSArtifactCollection.java:
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/MainValuesArtifact.java	Tue Aug 23 13:05:54 2011 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/MainValuesArtifact.java	Tue Aug 23 13:17:21 2011 +0000
@@ -7,9 +7,7 @@
 
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
-import org.w3c.dom.Node;
 
-import de.intevation.artifacts.Artifact;
 import de.intevation.artifacts.ArtifactFactory;
 import de.intevation.artifacts.ArtifactNamespaceContext;
 import de.intevation.artifacts.CallContext;
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/AnnotationFacet.java	Tue Aug 23 13:05:54 2011 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/AnnotationFacet.java	Tue Aug 23 13:17:21 2011 +0000
@@ -8,6 +8,7 @@
 import de.intevation.flys.artifacts.AnnotationArtifact;
 
 import de.intevation.artifactdatabase.state.DefaultFacet;
+import de.intevation.artifactdatabase.state.Facet;
 
 /**
  * Facet to access Annotations of a river.
@@ -18,6 +19,9 @@
     /** Logger for this class. */
     private static final Logger logger = Logger.getLogger(AnnotationFacet.class);
 
+    public AnnotationFacet() {
+    }
+
 
     /**
      * Trivial Constructor for a AnnotationFacet.
@@ -42,4 +46,11 @@
         AnnotationArtifact annotationArtifact  = (AnnotationArtifact) artifact;
         return annotationArtifact.getAnnotations();
     }
+
+    @Override
+    public Facet deepCopy() {
+        AnnotationFacet copy = new AnnotationFacet();
+        copy.set(this);
+        return copy;
+    }
 }
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/DataFacet.java	Tue Aug 23 13:05:54 2011 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/DataFacet.java	Tue Aug 23 13:17:21 2011 +0000
@@ -4,6 +4,7 @@
 import de.intevation.artifacts.CallContext;
 
 import de.intevation.artifactdatabase.state.DefaultFacet;
+import de.intevation.artifactdatabase.state.Facet;
 
 import de.intevation.flys.artifacts.FLYSArtifact;
 
@@ -16,6 +17,9 @@
     protected String      hash;
     protected String      stateId;
 
+    public DataFacet() {
+    }
+
     public DataFacet(String name, String description) {
         this(name, description, ComputeType.ADVANCE);
     }
@@ -49,6 +53,7 @@
         this.stateId = stateId;
     }
 
+    @Override
     public Object getData(Artifact artifact, CallContext context) {
         FLYSArtifact flys = (FLYSArtifact)artifact;
         String    theHash = hash != null ? hash : flys.hash();
@@ -57,5 +62,15 @@
             ? flys.compute(context, stateId, theHash, type, false)
             : flys.compute(context, theHash, type, false);
     }
+
+    @Override
+    public Facet deepCopy() {
+        DataFacet copy = new DataFacet();
+        copy.set(this);
+        copy.type    = type;
+        copy.hash    = hash;
+        copy.stateId = stateId;
+        return copy;
+    }
 }
 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/DurationCurveFacet.java	Tue Aug 23 13:05:54 2011 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/DurationCurveFacet.java	Tue Aug 23 13:17:21 2011 +0000
@@ -6,6 +6,7 @@
 import de.intevation.artifacts.CallContext;
 
 import de.intevation.artifactdatabase.state.DefaultFacet;
+import de.intevation.artifactdatabase.state.Facet;
 
 import de.intevation.flys.artifacts.WINFOArtifact;
 
@@ -16,6 +17,8 @@
 
     private static Logger logger = Logger.getLogger(DurationCurveFacet.class);
 
+    public DurationCurveFacet() {
+    }
 
     public DurationCurveFacet(String name, String description) {
         super(0, name, description);
@@ -32,5 +35,12 @@
 
         return cr.getData();
     }
+
+    @Override 
+    public Facet deepCopy() {
+        DurationCurveFacet copy = new DurationCurveFacet();
+        copy.set(this);
+        return copy;
+    }
 }
 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/ManagedFacet.java	Tue Aug 23 13:05:54 2011 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/ManagedFacet.java	Tue Aug 23 13:17:21 2011 +0000
@@ -9,7 +9,7 @@
 import de.intevation.artifacts.common.utils.XMLUtils.ElementCreator;
 
 import de.intevation.artifactdatabase.state.DefaultFacet;
-
+import de.intevation.artifactdatabase.state.Facet;
 
 public class ManagedFacet extends DefaultFacet {
 
@@ -22,6 +22,8 @@
     /** A property that determines if this facet is active or not.*/
     protected int active;
 
+    public ManagedFacet() {
+    }
 
     public ManagedFacet(
         String  name,
@@ -80,5 +82,19 @@
 
         return facet;
     }
+
+    public void set(ManagedFacet other) {
+        uuid     = other.uuid;
+        position = other.position;
+        active   = other.active;
+    }
+
+    @Override 
+    public Facet deepCopy() {
+        ManagedFacet copy = new ManagedFacet();
+        copy.set((DefaultFacet)this);
+        copy.set((ManagedFacet)this);
+        return copy;
+    }
 }
 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/ManagedFacetAdapter.java	Tue Aug 23 13:05:54 2011 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/ManagedFacetAdapter.java	Tue Aug 23 13:17:21 2011 +0000
@@ -6,6 +6,7 @@
 
 import de.intevation.artifacts.ArtifactNamespaceContext;
 
+import de.intevation.artifactdatabase.state.DefaultFacet;
 import de.intevation.artifactdatabase.state.Facet;
 
 import de.intevation.artifacts.common.utils.XMLUtils.ElementCreator;
@@ -15,6 +16,8 @@
 
     protected Facet facet;
 
+    public ManagedFacetAdapter() {
+    }
 
     public ManagedFacetAdapter(Facet facet, String uuid, int pos, int active) {
         super(
@@ -44,4 +47,13 @@
 
         return e;
     }
+
+    @Override
+    public Facet deepCopy() {
+        ManagedFacetAdapter copy = new ManagedFacetAdapter();
+        copy.set((DefaultFacet)this);
+        copy.set((ManagedFacet)this);
+        copy.facet = facet.deepCopy();
+        return facet;
+    }
 }
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/ReportFacet.java	Tue Aug 23 13:05:54 2011 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/ReportFacet.java	Tue Aug 23 13:17:21 2011 +0000
@@ -4,6 +4,7 @@
 import de.intevation.artifacts.CallContext;
 
 import de.intevation.artifactdatabase.state.DefaultFacet;
+import de.intevation.artifactdatabase.state.Facet;
 
 import de.intevation.flys.artifacts.states.DefaultState.ComputeType;
 
@@ -49,5 +50,15 @@
 
         return cr.getReport();
     }
+
+    @Override
+    public Facet deepCopy() {
+        ReportFacet copy = new ReportFacet();
+        copy.set(this);
+        copy.type    = type;
+        copy.hash    = hash;
+        copy.stateId = stateId;
+        return copy;
+    }
 }
 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/WMSLayerFacet.java	Tue Aug 23 13:05:54 2011 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/WMSLayerFacet.java	Tue Aug 23 13:17:21 2011 +0000
@@ -17,6 +17,7 @@
 import de.intevation.artifacts.common.utils.XMLUtils.ElementCreator;
 
 import de.intevation.artifactdatabase.state.DefaultFacet;
+import de.intevation.artifactdatabase.state.Facet;
 
 import de.intevation.flys.artifacts.states.DefaultState.ComputeType;
 
@@ -34,6 +35,9 @@
 
     private static final Logger logger = Logger.getLogger(WMSLayerFacet.class);
 
+    public WMSLayerFacet() {
+    }
+
 
     public WMSLayerFacet(int index, String name, String description) {
         this(index, name, description, ComputeType.FEED, null, null);
@@ -115,5 +119,21 @@
 
         return facet;
     }
+
+    @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;
+
+        return copy;
+    }
 }
 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/WSPLGENFacet.java	Tue Aug 23 13:05:54 2011 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/WSPLGENFacet.java	Tue Aug 23 13:17:21 2011 +0000
@@ -1,11 +1,22 @@
 package de.intevation.flys.artifacts.model;
 
 import de.intevation.artifactdatabase.state.DefaultFacet;
+import de.intevation.artifactdatabase.state.Facet;
 
 public class WSPLGENFacet extends DefaultFacet {
 
+    public WSPLGENFacet() {
+    }
+
     public WSPLGENFacet(int idx, String name, String description) {
         super(idx, name, description);
     }
+
+    @Override 
+    public Facet deepCopy() {
+        WSPLGENFacet copy = new WSPLGENFacet();
+        copy.set(this);
+        return copy;
+    }
 }
 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/WaterlevelFacet.java	Tue Aug 23 13:05:54 2011 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/WaterlevelFacet.java	Tue Aug 23 13:17:21 2011 +0000
@@ -6,6 +6,7 @@
 import de.intevation.artifacts.CallContext;
 
 import de.intevation.artifactdatabase.state.DefaultFacet;
+import de.intevation.artifactdatabase.state.Facet;
 
 import de.intevation.flys.artifacts.WINFOArtifact;
 
@@ -23,6 +24,9 @@
         this(index, name, description, ComputeType.ADVANCE, null, null);
     }
 
+    public WaterlevelFacet() {
+    }
+
     public WaterlevelFacet(
         int         index,
         String      name,
@@ -50,5 +54,14 @@
 
         return wqkms[index];
     }
+
+    public Facet deepCopy() {
+        WaterlevelFacet copy = new WaterlevelFacet();
+        copy.set(this);
+        copy.type    = type;
+        copy.stateID = stateID;
+        copy.hash    = hash;
+        return copy;
+    }
 }
 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/services/MapInfoService.java	Tue Aug 23 13:05:54 2011 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/services/MapInfoService.java	Tue Aug 23 13:17:21 2011 +0000
@@ -17,15 +17,11 @@
 
 import de.intevation.artifactdatabase.DefaultService;
 
-import de.intevation.flys.backend.SessionHolder;
 import de.intevation.flys.model.River;
 
 import de.intevation.flys.model.RiverAxis;
-import de.intevation.flys.artifacts.model.RiverFactory;
 import de.intevation.flys.utils.GeometryUtils;
 
-import org.hibernate.Session;
-
 /**
  * This service provides information about the supported rivers by this
  * application.

http://dive4elements.wald.intevation.org