diff flys-artifacts/src/main/java/de/intevation/flys/collections/CollectionAttribute.java @ 2079:ca6ccf722c24

#447 removed empty Outputs from Collection's attribute. flys-artifacts/trunk@3595 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Thu, 05 Jan 2012 13:39:58 +0000
parents 85132c9edd64
children 2a8919e0ed28
line wrap: on
line diff
--- a/flys-artifacts/src/main/java/de/intevation/flys/collections/CollectionAttribute.java	Thu Jan 05 10:46:32 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/collections/CollectionAttribute.java	Thu Jan 05 13:39:58 2012 +0000
@@ -58,6 +58,29 @@
     }
 
 
+    public void cleanEmptyOutputs() {
+        if (outputMap == null) {
+            return;
+        }
+
+        List<String> removeUs = new ArrayList<String>();
+
+        Set<Map.Entry<String, Output>> entries = outputMap.entrySet();
+        for (Map.Entry<String, Output> entry: entries) {
+            Output o = entry.getValue();
+
+            List<Facet> facets = o.getFacets();
+            if (facets == null || facets.isEmpty()) {
+                removeUs.add(entry.getKey());
+            }
+        }
+
+        for (String key: removeUs) {
+            outputMap.remove(key);
+        }
+    }
+
+
     public void setSettings(String outputKey, Settings settings) {
         if (settings == null) {
             logger.warn("Tried to set empty Settings for '" + outputKey + "'");

http://dive4elements.wald.intevation.org