# HG changeset patch # User Raimund Renkert # Date 1331737230 0 # Node ID a71fc8f2030c796344129ac38d79069a356dd42b # Parent 5d5457a1bd5ffe8507a5ba92a6c82227fcf764fc Issue 640. Remove all unnecessary output settings from attributes. flys-artifacts/trunk@4140 c6561f87-3c4e-4783-a992-168aeb5c3f6f diff -r 5d5457a1bd5f -r a71fc8f2030c flys-artifacts/ChangeLog --- a/flys-artifacts/ChangeLog Fri Mar 09 12:57:23 2012 +0000 +++ b/flys-artifacts/ChangeLog Wed Mar 14 15:00:30 2012 +0000 @@ -1,3 +1,10 @@ +2012-03-14 Raimund Renkert + + Issue 640. + + * src/main/java/de/intevation/flys/collections/FLYSArtifactCollection.java: + Remove all unnecessary output settings from attributes. + 2012-03-09 Felix Wolfsteller Partial for flys/issue358, rough stub for legenditem aggregation. diff -r 5d5457a1bd5f -r a71fc8f2030c flys-artifacts/src/main/java/de/intevation/flys/collections/FLYSArtifactCollection.java --- a/flys-artifacts/src/main/java/de/intevation/flys/collections/FLYSArtifactCollection.java Fri Mar 09 12:57:23 2012 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/collections/FLYSArtifactCollection.java Wed Mar 14 15:00:30 2012 +0000 @@ -92,6 +92,10 @@ try { String[] aUUIDs = getArtifactUUIDs(context); + + oldAttrs = removeAttributes(oldAttrs, context); + parser = new AttributeParser(oldAttrs); + CollectionAttribute newAttr = mergeAttributes( db, context, parser, aUUIDs); @@ -144,6 +148,39 @@ } + protected Document removeAttributes(Document attrs, CallContext context) { + FLYSArtifact master = getMasterArtifact(context); + List outList = master.getOutputs(context); + + Document doc = XMLUtils.newDocument(); + XMLUtils.ElementCreator ec = new XMLUtils.ElementCreator( + doc, + ArtifactNamespaceContext.NAMESPACE_URI, + ArtifactNamespaceContext.NAMESPACE_PREFIX); + + Element root = ec.create("attribute"); + doc.appendChild(root); + + if (outList.size() > 0) { + Element outs = ec.create("outputs"); + root.appendChild(outs); + + for (Output o : outList) { + Node n = (Node) XMLUtils.xpath( + attrs, + "/art:attribute/art:outputs/art:output[@name='" + o.getName() + "']", + XPathConstants.NODE, + ArtifactNamespaceContext.INSTANCE); + if (n != null) { + Node clone = doc.importNode(n, true); + outs.appendChild(clone); + } + } + } + + return doc; + } + /** * @param db The ArtifactDatabase which is required to save the attribute * into.