Mercurial > dive4elements > river
diff flys-artifacts/src/main/java/de/intevation/flys/artifacts/FLYSArtifact.java @ 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 | f6a190f6aaff |
children | 9d5f339d83a3 |
line wrap: on
line diff
--- 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>();