changeset 1895:1be3a4636ee3

New convenience function to copy data from one artifact to another. flys-artifacts/trunk@3255 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Felix Wolfsteller <felix.wolfsteller@intevation.de>
date Tue, 15 Nov 2011 14:45:57 +0000
parents d5e51cc7da23
children 2e2ca95459d2
files flys-artifacts/ChangeLog flys-artifacts/src/main/java/de/intevation/flys/artifacts/FLYSArtifact.java
diffstat 2 files changed, 25 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/flys-artifacts/ChangeLog	Tue Nov 15 14:43:50 2011 +0000
+++ b/flys-artifacts/ChangeLog	Tue Nov 15 14:45:57 2011 +0000
@@ -1,3 +1,9 @@
+2011-11-15  Felix Wolfsteller <felix.wolfsteller@intevation.de>
+
+	* src/main/java/de/intevation/flys/artifacts/FLYSArtifact.java:
+	  (importData): New function to copy data from one artifact to
+			another.
+
 2011-11-15  Felix Wolfsteller <felix.wolfsteller@intevation.de>
 
 	* src/main/java/de/intevation/flys/artifacts/model/WstValueTableFactory.java
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/FLYSArtifact.java	Tue Nov 15 14:43:50 2011 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/FLYSArtifact.java	Tue Nov 15 14:45:57 2011 +0000
@@ -183,6 +183,25 @@
         return new ArrayList<String>(previousStateIds);
     }
 
+    /**
+     * Copies data item from other artifact to this artifact.
+     * @param other Artifact from which to get data.
+     * @param name  Name of data.
+     */
+    protected void importData(FLYSArtifact other, final String name) {
+        if (other == null) {
+            logger.error("No other art. to import data " + name + " from.");
+        }
+
+        StateData sd = other.getData(name);
+
+        if (sd == null) {
+            logger.warn("Other artifact has no data " + name + ".");
+            return;
+        }
+
+        this.addData(name, sd);
+    }
 
     protected Map<String, StateData> cloneData() {
         Map<String, StateData> copy = new TreeMap<String, StateData>();

http://dive4elements.wald.intevation.org