Mercurial > dive4elements > river
view flys-client/src/main/java/de/intevation/flys/client/shared/model/DefaultCollection.java @ 524:ba238f917b94
The theme list information stored in the attribute of a collection is read and added in form of Themes and ThemeLists to the Collection.
flys-client/trunk@2003 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Wed, 25 May 2011 13:42:04 +0000 |
parents | e2abb6b9dc7e |
children | 53ad6dd2cb2b |
line wrap: on
line source
package de.intevation.flys.client.shared.model; import java.util.ArrayList; import java.util.Date; import java.util.HashMap; import java.util.List; import java.util.Map; /** * The default implementation of a {@link Collection}. * * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a> */ public class DefaultCollection implements Collection { /** The uuid of the collection. */ protected String uuid; /** The name of the collection.*/ protected String name; /** The creation time of this collection.*/ protected Date creation; /** The list of artifacts that are managed by this Collection.*/ protected List<CollectionItem> items; protected Map<String, ThemeList> themeLists; /** * Constructor without arguments is necessary for GWT. */ public DefaultCollection() { } /** * Creates a new DefaultCollection with a UUID. * * @param uuid The UUID. */ public DefaultCollection(String uuid) { this.uuid = uuid; this.items = new ArrayList<CollectionItem>(); this.themeLists = new HashMap<String, ThemeList>(); } public DefaultCollection(String uuid, Map<String, ThemeList> themeLists) { this(uuid); this.themeLists = themeLists; } /** * Creates a new DefaultCollection with uuid and name. * * @param uuid The identifier of this collection. * @param name The name of this collection. */ public DefaultCollection(String uuid, String name) { this(uuid); this.name = name; } /** * Creates a new DefaultCollection with uuid and name. * * @param uuid The identifier of this collection. * @param name The name of this collection. * @param creation The creation time. */ public DefaultCollection(String uuid, String name, Date creation) { this(uuid, name); this.creation = creation; } public String identifier() { return uuid; } public Date getCreationTime() { return creation; } public Date getLastAccess() { return new Date(); } public String getName() { return name; } public void addItem(CollectionItem item) { if (item != null) { items.add(item); } } public int getItemLength() { return items.size(); } 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; } public ThemeList getThemeList(String outName) { if (themeLists != null) { return themeLists.get(outName); } return null; } } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :