diff flys-client/src/main/java/de/intevation/flys/client/shared/model/ThemeList.java @ 1435:f6fbfdc813f0

Allow client to access artifacts data via CollectionItems and Themes. flys-client/trunk@3396 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Felix Wolfsteller <felix.wolfsteller@intevation.de>
date Tue, 13 Dec 2011 09:51:47 +0000
parents 39d9291513cc
children 1d82a2c695a6
line wrap: on
line diff
--- a/flys-client/src/main/java/de/intevation/flys/client/shared/model/ThemeList.java	Tue Dec 13 09:13:03 2011 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/shared/model/ThemeList.java	Tue Dec 13 09:51:47 2011 +0000
@@ -2,10 +2,12 @@
 
 import java.io.Serializable;
 
+import java.util.LinkedHashMap;
 import java.util.List;
 
 
 /**
+ * Data Model for list of themes (shown facets).
  * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a>
  */
 public class ThemeList implements Serializable {
@@ -96,5 +98,51 @@
             }
         }
     }
+
+
+    /**
+     * Create a map from index to description of facets that have a given name.
+     * Only visible facets are taken into account.
+     * @param facetName name to match against facets whose info to put in map.
+     * @return mapping of index to description
+     */
+    public LinkedHashMap<String, String> toMapIndexDescription(String facetName) {
+        int count = getThemeCount();
+        LinkedHashMap<String, String> valueMap = new LinkedHashMap<String, String>();
+        for (int i = 0; i < count; i++) {
+            Theme theme = getThemeAt(i + 1);
+
+            if (theme == null || theme.getVisible() == 0) {
+                continue;
+            }
+
+            if (theme.getFacet().equals(facetName)) {
+                valueMap.put(String.valueOf(theme.getIndex()),
+                    theme.getDescription());
+            }
+        }
+        return valueMap;
+    }
+
+
+    public LinkedHashMap<String, String>
+        toMapArtifactUUIDDescription(String facetName
+    ) {
+        int count = getThemeCount();
+        LinkedHashMap<String, String> valueMap = new LinkedHashMap<String, String>();
+        for (int i = 0; i < count; i++) {
+            Theme theme = getThemeAt(i + 1);
+
+            if (theme == null || theme.getVisible() == 0) {
+                continue;
+            }
+
+            if (theme.getFacet().equals(facetName)) {
+                valueMap.put(theme.getArtifact(),
+                    theme.getDescription());
+            }
+        }
+        return valueMap;
+    }
 }
 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org