Mercurial > dive4elements > river
comparison flys-artifacts/src/main/java/de/intevation/flys/collections/AttributeWriter.java @ 1831:490ab097f58c
Prevent empty output-nodes in flyscollections attributes.
flys-artifacts/trunk@3167 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Felix Wolfsteller <felix.wolfsteller@intevation.de> |
---|---|
date | Fri, 04 Nov 2011 11:59:08 +0000 |
parents | 193a916d1ab5 |
children | 0b466bd4ab24 |
comparison
equal
deleted
inserted
replaced
1830:7bb5bfd3b51f | 1831:490ab097f58c |
---|---|
132 List<Facet> oldOutFacets) | 132 List<Facet> oldOutFacets) |
133 { | 133 { |
134 Element output = cr.create("output"); | 134 Element output = cr.create("output"); |
135 cr.addAttr(output, "name", outputName); | 135 cr.addAttr(output, "name", outputName); |
136 | 136 |
137 outs.appendChild(output); | |
138 | 137 |
139 List<String> compatibleFacets = this.compatibilities.get(outputName); | 138 List<String> compatibleFacets = this.compatibilities.get(outputName); |
140 try { | 139 try { |
141 writeFacets(doc, cr, output, newOutFacets, oldOutFacets, compatibleFacets); | 140 if (writeFacets( |
141 doc, cr, output, newOutFacets, oldOutFacets, | |
142 compatibleFacets)) | |
143 { | |
144 // Add output element only if it contains facets. | |
145 outs.appendChild(output); | |
146 } | |
142 } | 147 } |
143 catch (ArtifactDatabaseException ade) { | 148 catch (ArtifactDatabaseException ade) { |
144 logger.error(ade, ade); | 149 logger.error(ade, ade); |
145 } | 150 } |
146 } | 151 } |
151 * @param cr ElementCreator to use with output/doc | 156 * @param cr ElementCreator to use with output/doc |
152 * @param output Node in Document to add facet nodes to | 157 * @param output Node in Document to add facet nodes to |
153 * @param newFacets the new facets | 158 * @param newFacets the new facets |
154 * @param oldFacets the old facets | 159 * @param oldFacets the old facets |
155 * @param compatibleFacets List of facets to accept | 160 * @param compatibleFacets List of facets to accept |
156 */ | 161 * @return true if any facets are written to the out. |
157 protected void writeFacets( | 162 */ |
163 protected boolean writeFacets( | |
158 Document doc, | 164 Document doc, |
159 ElementCreator cr, | 165 ElementCreator cr, |
160 Element output, | 166 Element output, |
161 List<Facet> newFacets, | 167 List<Facet> newFacets, |
162 List<Facet> oldFacets, | 168 List<Facet> oldFacets, |
163 List<String> compatibleFacets) | 169 List<String> compatibleFacets) |
164 throws ArtifactDatabaseException | 170 throws ArtifactDatabaseException |
165 { | 171 { |
166 if (compatibleFacets == null) { | 172 if (compatibleFacets == null) { |
167 logger.warn("No compatible facets, not generating out."); | 173 logger.warn("No compatible facets, not generating out."); |
168 return; | 174 return false; |
169 } | 175 } |
170 | 176 |
171 int num = newFacets.size(); | 177 int num = newFacets.size(); |
172 | 178 |
173 // Add all new Facets either in their old state or (if really | 179 // Add all new Facets either in their old state or (if really |
251 Node node = oldMF.toXML(doc); | 257 Node node = oldMF.toXML(doc); |
252 if (node != null) { | 258 if (node != null) { |
253 output.appendChild(node); | 259 output.appendChild(node); |
254 } | 260 } |
255 } | 261 } |
262 | |
263 return currentFacets.size() > 0; | |
256 } | 264 } |
257 | 265 |
258 | 266 |
259 /** | 267 /** |
260 * Returns the facet to be added to Document. | 268 * Returns the facet to be added to Document. |