# HG changeset patch # User Felix Wolfsteller # Date 1321368357 0 # Node ID 1be3a4636ee363f115f96ef705b9c57dbc02cc81 # Parent d5e51cc7da230c3c6bacca540f3c1a999eff22d2 New convenience function to copy data from one artifact to another. flys-artifacts/trunk@3255 c6561f87-3c4e-4783-a992-168aeb5c3f6f diff -r d5e51cc7da23 -r 1be3a4636ee3 flys-artifacts/ChangeLog --- 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 + + * 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 * src/main/java/de/intevation/flys/artifacts/model/WstValueTableFactory.java diff -r d5e51cc7da23 -r 1be3a4636ee3 flys-artifacts/src/main/java/de/intevation/flys/artifacts/FLYSArtifact.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(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 cloneData() { Map copy = new TreeMap();