# HG changeset patch # User Sascha L. Teichmann # Date 1314097641 0 # Node ID fdb0f4ef96f01337725ad88c9f5f2d4d84b3f390 # Parent c37084f31c84bab60b197f8e4f1f6fd9dc3a0567 Made FLYS artifacts cloneable. flys-artifacts/trunk@2531 c6561f87-3c4e-4783-a992-168aeb5c3f6f diff -r c37084f31c84 -r fdb0f4ef96f0 flys-artifacts/ChangeLog --- a/flys-artifacts/ChangeLog Tue Aug 23 07:53:41 2011 +0000 +++ b/flys-artifacts/ChangeLog Tue Aug 23 11:07:21 2011 +0000 @@ -1,3 +1,12 @@ +2011-08-23 Sascha L. Teichmann + + * src/main/java/de/intevation/flys/artifacts/MainValuesArtifact.java: + Removed facet interface. + + * src/main/java/de/intevation/flys/artifacts/FLYSArtifact.java: + Make artifacts cloneable. TODO: Override deepCopy() in subclassed + states and facets. + 2011-08-23 Ingo Weinzierl * doc/conf/conf.xml: Added the MapInfoService and adapted the floodmap diff -r c37084f31c84 -r fdb0f4ef96f0 flys-artifacts/src/main/java/de/intevation/flys/artifacts/FLYSArtifact.java --- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/FLYSArtifact.java Tue Aug 23 07:53:41 2011 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/FLYSArtifact.java Tue Aug 23 11:07:21 2011 +0000 @@ -121,8 +121,9 @@ * * @return the name of the concrete artifact. */ - public abstract String getName(); - + public String getName() { + return name; + } /** * Returns the FLYSContext from context object. @@ -190,13 +191,52 @@ filterFacets = buildFilterFacets(data); } + protected List clonePreviousStateIds() { + return new ArrayList(previousStateIds); + } + + protected Map cloneData() { + Map copy = new TreeMap(); + + for (Map.Entry entry: data.entrySet()) { + copy.put(entry.getKey(), entry.getValue().deepCopy()); + } + + return copy; + } + + protected Map> cloneFacets() { + Map copy = new HashMap>(); + + for (Map.Entry> entry: facets.entrySet()) { + List facets = entry.getValue(); + List facetCopies = new ArrayList(facets.size()); + for (Facet facet: facets) { + facetCopies.add(facet.deepCopy()); + } + copy.put(entry.getKey(), facetCopies); + } + + return copy; + } protected void initialize( Artifact artifact, Object context, CallMeta callMeta) { - // do nothing here + if (!(artifact instanceof FLYSArtifact)) { + return; + } + + FLYSArtifact flys = (FLYSArtifact)artifact; + + currentStateId = flys.currentStateId; + previousStateIds = flys.clonePreviousStateIds(); + name = flys.name; + data = flys.cloneData(); + facets = flys.cloneFacets(); + // Do not clone filter facets! } protected Map> buildFilterFacets(Document document) { diff -r c37084f31c84 -r fdb0f4ef96f0 flys-artifacts/src/main/java/de/intevation/flys/artifacts/MainValuesArtifact.java --- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/MainValuesArtifact.java Tue Aug 23 07:53:41 2011 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/MainValuesArtifact.java Tue Aug 23 11:07:21 2011 +0000 @@ -29,8 +29,7 @@ */ public class MainValuesArtifact extends StaticFLYSArtifact -implements Facet { - +{ /** The logger for this class. */ private static Logger logger = Logger.getLogger(WINFOArtifact.class); @@ -54,7 +53,6 @@ Document data) { logger.warn("MainValuesArtifact.setup"); - ; } /** @@ -180,65 +178,4 @@ // state is not valid, so we do not append its outputs. } } - - - /* FACET IMPLEMENTATION */ - - - // TODO implement; what is index used for? - /** - * Returns the index of this facet. - * - * @return the index of this facet. - */ - public int getIndex() { - return 0; - } - - - /** - * Returns the name of this facet. - * - * @return the name of this facet. - */ - public String getName() { - // TODO define, static - return "FACETNAME"; - } - - - /** - * Returns the description of this facet. - * - * @return the description of this facet. - */ - public String getDescription() { - return null; - } - - - /** - * Returns the data this facet requires. - * - * @param artifact The owner artifact. - * @param context The CallContext. - * - * @return the data. - */ - public Object getData(Artifact artifact, CallContext context) { - return null; - } - - - /** - * Write the internal representation of a facet to a node. - * - * @param doc A Document. - * - * @return the representation as Node. - */ - public Node toXML(Document doc) { - return null; - } - }