# HG changeset patch # User Felix Wolfsteller # Date 1320407948 0 # Node ID 490ab097f58c98ddc6ce2ef2e75fbde47cee9828 # Parent 7bb5bfd3b51f7d0488ad4c93fade7151628c8fbb Prevent empty output-nodes in flyscollections attributes. flys-artifacts/trunk@3167 c6561f87-3c4e-4783-a992-168aeb5c3f6f diff -r 7bb5bfd3b51f -r 490ab097f58c flys-artifacts/ChangeLog --- a/flys-artifacts/ChangeLog Fri Nov 04 10:58:44 2011 +0000 +++ b/flys-artifacts/ChangeLog Fri Nov 04 11:59:08 2011 +0000 @@ -1,3 +1,14 @@ +2011-11-04 Felix Wolfsteller + + For a Flys-Collection, add outputt to attributes-part of describe + document only if they contain facets. -> Prevent empty output nodes + in flys-collections outputs. + + * src/main/java/de/intevation/flys/collections/AttributeWriter.java: + (writeFacets): Added return type to indicate whether any facet was + written. Decide whether to add an output-node depending on this + return value. + 2011-11-04 Ingo Weinzierl * src/main/java/de/intevation/flys/utils/MapfileGenerator.java: Create diff -r 7bb5bfd3b51f -r 490ab097f58c flys-artifacts/src/main/java/de/intevation/flys/collections/AttributeWriter.java --- a/flys-artifacts/src/main/java/de/intevation/flys/collections/AttributeWriter.java Fri Nov 04 10:58:44 2011 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/collections/AttributeWriter.java Fri Nov 04 11:59:08 2011 +0000 @@ -134,11 +134,16 @@ Element output = cr.create("output"); cr.addAttr(output, "name", outputName); - outs.appendChild(output); List compatibleFacets = this.compatibilities.get(outputName); try { - writeFacets(doc, cr, output, newOutFacets, oldOutFacets, compatibleFacets); + if (writeFacets( + doc, cr, output, newOutFacets, oldOutFacets, + compatibleFacets)) + { + // Add output element only if it contains facets. + outs.appendChild(output); + } } catch (ArtifactDatabaseException ade) { logger.error(ade, ade); @@ -153,8 +158,9 @@ * @param newFacets the new facets * @param oldFacets the old facets * @param compatibleFacets List of facets to accept + * @return true if any facets are written to the out. */ - protected void writeFacets( + protected boolean writeFacets( Document doc, ElementCreator cr, Element output, @@ -165,7 +171,7 @@ { if (compatibleFacets == null) { logger.warn("No compatible facets, not generating out."); - return; + return false; } int num = newFacets.size(); @@ -253,6 +259,8 @@ output.appendChild(node); } } + + return currentFacets.size() > 0; }