Mercurial > dive4elements > river
changeset 2585:a71fc8f2030c
Issue 640.
Remove all unnecessary output settings from attributes.
flys-artifacts/trunk@4140 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Raimund Renkert <raimund.renkert@intevation.de> |
---|---|
date | Wed, 14 Mar 2012 15:00:30 +0000 |
parents | 5d5457a1bd5f |
children | 8cd6358eb7f8 |
files | flys-artifacts/ChangeLog flys-artifacts/src/main/java/de/intevation/flys/collections/FLYSArtifactCollection.java |
diffstat | 2 files changed, 44 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- 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 <raimund.renkert@intevation.de> + + Issue 640. + + * src/main/java/de/intevation/flys/collections/FLYSArtifactCollection.java: + Remove all unnecessary output settings from attributes. + 2012-03-09 Felix Wolfsteller <felix.wolfsteller@intevation.de> Partial for flys/issue358, rough stub for legenditem aggregation.
--- 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<Output> 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.