Mercurial > dive4elements > river
comparison artifacts/src/main/java/org/dive4elements/river/collections/AttributeWriter.java @ 6961:6bc333c162d1
issue1458: Avoid facet duplicates.
author | Felix Wolfsteller <felix.wolfsteller@intevation.de> |
---|---|
date | Tue, 03 Sep 2013 21:51:58 +0200 |
parents | d2bf655bd278 |
children | 12248d9eb326 |
comparison
equal
deleted
inserted
replaced
6960:7aa5ac17d728 | 6961:6bc333c162d1 |
---|---|
209 } | 209 } |
210 | 210 |
211 ManagedFacet picked = pickFacet(facet, oldFacets); | 211 ManagedFacet picked = pickFacet(facet, oldFacets); |
212 | 212 |
213 if (facet.equals(picked)) { | 213 if (facet.equals(picked)) { |
214 genuinelyNewFacets.add(picked); | 214 if (!facetInTwoOuts(facet, genuinelyNewFacets)) { |
215 genuinelyNewFacets.add(picked); | |
216 } | |
217 else { | |
218 logger.debug("Skip clone facet that shall be present in two outs"); | |
219 } | |
215 } | 220 } |
216 else { | 221 else { |
217 currentFacets.add(picked); | 222 currentFacets.add(picked); |
218 } | 223 } |
219 } | 224 } |
290 | 295 |
291 return !currentFacets.isEmpty(); | 296 return !currentFacets.isEmpty(); |
292 } | 297 } |
293 | 298 |
294 | 299 |
300 /** Returns true if a likely clone of facet is | |
301 * contained in genuinelyNewFacets, as happens when same facet is defined | |
302 * for two outs. */ | |
303 private boolean facetInTwoOuts(ManagedFacet facet, List<ManagedFacet> genuinelyNewFacets) { | |
304 for (ManagedFacet otherFacet: genuinelyNewFacets) { | |
305 if (facet.isSame(otherFacet)) { | |
306 return true; | |
307 } | |
308 } | |
309 return false; | |
310 } | |
311 | |
312 | |
295 /** | 313 /** |
296 * Returns the facet to be added to Document. | 314 * Returns the facet to be added to Document. |
297 * Return the new facet only if the "same" facet was not present before. | 315 * Return the new facet only if the "same" facet was not present before. |
298 * Return the "old" facet otherwise (user-defined information sticks | 316 * Return the "old" facet otherwise (user-defined information sticks |
299 * to it). | 317 * to it). |