changeset 6961:6bc333c162d1

issue1458: Avoid facet duplicates.
author Felix Wolfsteller <felix.wolfsteller@intevation.de>
date Tue, 03 Sep 2013 21:51:58 +0200
parents 7aa5ac17d728
children 234b1a3b527d
files artifacts/src/main/java/org/dive4elements/river/collections/AttributeWriter.java
diffstat 1 files changed, 19 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/artifacts/src/main/java/org/dive4elements/river/collections/AttributeWriter.java	Tue Sep 03 21:50:23 2013 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/collections/AttributeWriter.java	Tue Sep 03 21:51:58 2013 +0200
@@ -211,7 +211,12 @@
             ManagedFacet picked = pickFacet(facet, oldFacets);
 
             if (facet.equals(picked)) {
-                genuinelyNewFacets.add(picked);
+                if (!facetInTwoOuts(facet, genuinelyNewFacets)) {
+                    genuinelyNewFacets.add(picked);
+                }
+                else {
+                    logger.debug("Skip clone facet that shall be present in two outs");
+                }
             }
             else {
                 currentFacets.add(picked);
@@ -292,6 +297,19 @@
     }
 
 
+    /** Returns true if a likely clone of facet is
+     * contained in genuinelyNewFacets, as happens when same facet is defined
+     * for two outs. */
+    private boolean facetInTwoOuts(ManagedFacet facet, List<ManagedFacet> genuinelyNewFacets) {
+        for (ManagedFacet otherFacet: genuinelyNewFacets) {
+            if (facet.isSame(otherFacet)) {
+                return true;
+            }
+        }
+        return false;
+    }
+
+
     /**
      * Returns the facet to be added to Document.
      * Return the new facet only if the "same" facet was not present before.

http://dive4elements.wald.intevation.org