[PATCH 5 of 5] issue1458: Avoid facet duplicates

Wald Commits scm-commit at wald.intevation.org
Wed Sep 4 08:06:22 CEST 2013


# HG changeset patch
# User Felix Wolfsteller <felix.wolfsteller at intevation.de>
# Date 1378237918 -7200
# Node ID 6bc333c162d1fc624b355412f87ae9934876becd
# Parent  7aa5ac17d72880cfb7b20aa383a9ea66e3c82517
issue1458: Avoid facet duplicates.

diff -r 7aa5ac17d728 -r 6bc333c162d1 artifacts/src/main/java/org/dive4elements/river/collections/AttributeWriter.java
--- 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.


More information about the Dive4elements-commits mailing list