# HG changeset patch # User Ingo Weinzierl # Date 1324027151 0 # Node ID 85132c9edd64fef305075575464948d31fd62f1e # Parent e1c9f28e2675147feb2234975d31d9492a0039e9 Make reuse of the old CollectionAttribute during the describe() operation of FLYSArtifactCollection - remove the old facets only. flys-artifacts/trunk@3430 c6561f87-3c4e-4783-a992-168aeb5c3f6f diff -r e1c9f28e2675 -r 85132c9edd64 flys-artifacts/ChangeLog --- a/flys-artifacts/ChangeLog Fri Dec 16 07:28:17 2011 +0000 +++ b/flys-artifacts/ChangeLog Fri Dec 16 09:19:11 2011 +0000 @@ -1,3 +1,17 @@ +2011-12-16 Ingo Weinzierl + + * src/main/java/de/intevation/flys/collections/CollectionAttribute.java: + Added a method to set a new Settings object for a specific Output and a + method to clear the list of Facets of a specific Output. + + * src/main/java/de/intevation/flys/collections/AttributeWriter.java: The + AttributeWriter no longer creates new CollectionAttributes - it only + modifies the old CollectionAttribute. At first, it clears the Facets of + all Outputs. Finally, the merged Facets are added to the Outputs. + + * src/main/java/de/intevation/flys/collections/FLYSArtifactCollection.java: + Added the CollectionAttribute to the AttributeWriters constructor. + 2011-12-16 Ingo Weinzierl * src/main/java/de/intevation/flys/exports/DoubleAttribute.java: New. An diff -r e1c9f28e2675 -r 85132c9edd64 flys-artifacts/src/main/java/de/intevation/flys/collections/AttributeWriter.java --- a/flys-artifacts/src/main/java/de/intevation/flys/collections/AttributeWriter.java Fri Dec 16 07:28:17 2011 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/collections/AttributeWriter.java Fri Dec 16 09:19:11 2011 +0000 @@ -61,6 +61,7 @@ */ public AttributeWriter( ArtifactDatabase db, + CollectionAttribute attribute, Map oldAttr, List oldFacets, Map newAttr, @@ -68,6 +69,7 @@ Map> matrix) { this.db = db; + this.attribute = attribute; this.oldAttr = oldAttr; this.newAttr = newAttr; this.oldFacets = oldFacets; @@ -88,12 +90,9 @@ * @return document with merged outputs as described. */ protected CollectionAttribute write() { - attribute = new CollectionAttribute(); - for (String outName: newAttr.keySet()) { Output a = newAttr.get(outName); - - attribute.addOutput(a.getName(), a); + attribute.clearFacets(outName); writeOutput(a.getName(), newFacets, oldFacets); } diff -r e1c9f28e2675 -r 85132c9edd64 flys-artifacts/src/main/java/de/intevation/flys/collections/CollectionAttribute.java --- a/flys-artifacts/src/main/java/de/intevation/flys/collections/CollectionAttribute.java Fri Dec 16 07:28:17 2011 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/collections/CollectionAttribute.java Fri Dec 16 09:19:11 2011 +0000 @@ -58,6 +58,28 @@ } + public void setSettings(String outputKey, Settings settings) { + if (settings == null) { + logger.warn("Tried to set empty Settings for '" + outputKey + "'"); + return; + } + + if (outputMap == null) { + logger.warn("Tried to add facet but no Outputs are existing yet."); + return; + } + + Output output = outputMap.get(outputKey); + + if (output == null) { + logger.warn("Tried to add facet for unknown Output: " + outputKey); + return; + } + + output.setSettings(settings); + } + + public void addFacet(String outputKey, Facet facet) { if (facet == null) { logger.warn("Tried to add empty facet."); @@ -87,6 +109,27 @@ } + public void clearFacets(String outputKey) { + if (outputKey == null || outputKey.length() == 0) { + logger.warn("Tried to clear Facets, but no Output key specified!"); + return; + } + + if (outputMap == null) { + logger.warn("Tried to clear Facets, but no Outputs existing!"); + return; + } + + Output output = outputMap.get(outputKey); + if (output == null) { + logger.warn("Tried to clear Facets for unknown Out: " + outputKey); + return; + } + + output.setFacets(new ArrayList()); + } + + public Document toXML() { Document doc = XMLUtils.newDocument(); diff -r e1c9f28e2675 -r 85132c9edd64 flys-artifacts/src/main/java/de/intevation/flys/collections/FLYSArtifactCollection.java --- a/flys-artifacts/src/main/java/de/intevation/flys/collections/FLYSArtifactCollection.java Fri Dec 16 07:28:17 2011 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/collections/FLYSArtifactCollection.java Fri Dec 16 09:19:11 2011 +0000 @@ -507,6 +507,7 @@ return new AttributeWriter( db, + aParser.getCollectionAttribute(), aParser.getOuts(), aParser.getFacets(), oParser.getOuts(),