Mercurial > dive4elements > river
diff flys-client/src/main/java/de/intevation/flys/client/shared/model/DefaultCollection.java @ 67:74257b95567b
Added CollectionItems and Facets and replaced Artifact references in Collection with CollectionItems.
flys-client/trunk@1567 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Fri, 25 Mar 2011 09:19:29 +0000 |
parents | 6cb8aff3cd6b |
children | e2abb6b9dc7e |
line wrap: on
line diff
--- a/flys-client/src/main/java/de/intevation/flys/client/shared/model/DefaultCollection.java Thu Mar 24 15:48:13 2011 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/shared/model/DefaultCollection.java Fri Mar 25 09:19:29 2011 +0000 @@ -2,7 +2,9 @@ import java.util.ArrayList; import java.util.Date; +import java.util.HashMap; import java.util.List; +import java.util.Map; /** @@ -16,7 +18,14 @@ protected String uuid; /** The list of artifacts that are managed by this Collection.*/ - protected List<Artifact> artifacts; + protected List<CollectionItem> items; + + + /** + * Constructor without arguments is necessary for GWT. + */ + public DefaultCollection() { + } /** @@ -25,8 +34,8 @@ * @param uuid The UUID. */ public DefaultCollection(String uuid) { - this.uuid = uuid; - this.artifacts = new ArrayList<Artifact>(); + this.uuid = uuid; + this.items = new ArrayList<CollectionItem>(); } @@ -45,20 +54,45 @@ } - public void addArtifact(Artifact artifact) { - if (artifact != null) { - artifacts.add(artifact); + public void addItem(CollectionItem item) { + if (item != null) { + items.add(item); } } - public int getArtifactLength() { - return artifacts.size(); + public int getItemLength() { + return items.size(); } - public Artifact getArtifact(int idx) { - return artifacts.get(idx); + public CollectionItem getItem(int idx) { + if (idx >= getItemLength()) { + return null; + } + + return items.get(idx); + } + + + public Map<String, OutputMode> getOutputModes() { + Map<String, OutputMode> modes = new HashMap<String, OutputMode>(); + + for (CollectionItem item: items) { + List<OutputMode> itemModes = item.getOutputModes(); + + if (itemModes != null) { + for (OutputMode itemMode: itemModes) { + String name = itemMode.getName(); + if (!modes.containsKey(name)) { + // we dont want duplicated OutputModes in our result. + modes.put(name, itemMode); + } + } + } + } + + return modes; } } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :