Mercurial > dive4elements > river
changeset 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 | a361ce81abcf |
children | 157f7bea6299 |
files | flys-client/ChangeLog flys-client/src/main/java/de/intevation/flys/client/shared/model/Collection.java flys-client/src/main/java/de/intevation/flys/client/shared/model/CollectionItem.java flys-client/src/main/java/de/intevation/flys/client/shared/model/DefaultCollection.java flys-client/src/main/java/de/intevation/flys/client/shared/model/DefaultCollectionItem.java flys-client/src/main/java/de/intevation/flys/client/shared/model/DefaultFacet.java flys-client/src/main/java/de/intevation/flys/client/shared/model/Facet.java |
diffstat | 7 files changed, 233 insertions(+), 14 deletions(-) [+] |
line wrap: on
line diff
--- a/flys-client/ChangeLog Thu Mar 24 15:48:13 2011 +0000 +++ b/flys-client/ChangeLog Fri Mar 25 09:19:29 2011 +0000 @@ -1,3 +1,26 @@ +2011-03-25 Ingo Weinzierl <ingo@intevation.de> + + * src/main/java/de/intevation/flys/client/shared/model/Facet.java, + src/main/java/de/intevation/flys/client/shared/model/DefaultFacet.java: + New. An interface and its default implementation that provide methods + to get information about facets. Currently, the only information that is + supported is the name of the facet. + + * src/main/java/de/intevation/flys/client/shared/model/CollectionItem.java, + src/main/java/de/intevation/flys/client/shared/model/DefaultCollectionItem.java: + New. An interface and its default implementation that provide methods to + get information about the available output modes and its facets of + artifacts -> a CollectionItem is related to an artifact - both have the + same identifier. + + * src/main/java/de/intevation/flys/client/shared/model/DefaultCollection.java, + src/main/java/de/intevation/flys/client/shared/model/Collection.java: + The Collection no longer stores references to artifacts, but to + CollectionItems. I have changed this, because the artifact contains a + lot more information we need for the Collections. So, I decided to + create CollectionItems that are related to artiacts but just know about + the possible outputmodes and facets. + 2011-03-24 Raimund Renkert <rrenkert@intevation.de> * src/main/java/de/intevation/flys/client/client/ui/MainMenu.java: Set styles
--- a/flys-client/src/main/java/de/intevation/flys/client/shared/model/Collection.java Thu Mar 24 15:48:13 2011 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/shared/model/Collection.java Fri Mar 25 09:19:29 2011 +0000 @@ -1,6 +1,8 @@ package de.intevation.flys.client.shared.model; +import java.io.Serializable; import java.util.Date; +import java.util.Map; /** @@ -8,7 +10,7 @@ * * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a> */ -public interface Collection { +public interface Collection extends Serializable { public String identifier(); @@ -16,10 +18,12 @@ public Date getLastAccess(); - public void addArtifact(Artifact artifact); + public void addItem(CollectionItem item); - public int getArtifactLength(); + public int getItemLength(); - public Artifact getArtifact(int idx); + public CollectionItem getItem(int idx); + + public Map<String, OutputMode> getOutputModes(); } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/shared/model/CollectionItem.java Fri Mar 25 09:19:29 2011 +0000 @@ -0,0 +1,41 @@ +package de.intevation.flys.client.shared.model; + +import java.io.Serializable; +import java.util.List; + + +/** + * The CollectionItem interface that provides methods to get information about + * artifacts and its output modes. + * + * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a> + */ +public interface CollectionItem extends Serializable { + + /** + * Returns the identifier of the wrapped artifact. + * + * @return the identifier of the wrapped artifact. + */ + String identifier(); + + + /** + * Returns the output modes of the wrapped artifact. + * + * @return the output modes of the wrapped artifact. + */ + List<OutputMode> getOutputModes(); + + + /** + * Returns the facets of the wrapped artifact for a specific output mode. + * + * @param outputmode The name of an output mode that is supported by this + * item. + * + * @return the facets of the wrapped artifact for a specific output mode. + */ + List<Facet> getFacets(String outputmode); +} +// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- 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 :
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/shared/model/DefaultCollectionItem.java Fri Mar 25 09:19:29 2011 +0000 @@ -0,0 +1,61 @@ +package de.intevation.flys.client.shared.model; + +import java.util.List; + + +/** + * The default implementation of a CollectionItem. + * + * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a> + */ +public class DefaultCollectionItem implements CollectionItem { + + /** The identifier that specifies the artifact related to this item.*/ + protected String identifier; + + /** The list of output modes supported by the artifact of this item.*/ + protected List<OutputMode> outputModes; + + + /** + * An empty constructor. + */ + public DefaultCollectionItem() { + } + + + /** + * The default constructor to create a new CollectionItem related to an + * artifact with output modes. + * + * @param identifier The identifier of an artifact. + * @param outputModes The output modes supported by this item. + */ + public DefaultCollectionItem(String identifier, List<OutputMode> modes) { + this.identifier = identifier; + this.outputModes = modes; + } + + + public String identifier() { + return identifier; + } + + + public List<OutputMode> getOutputModes() { + return outputModes; + } + + + public List<Facet> getFacets(String outputmode) { + for (OutputMode mode: outputModes) { + if (outputmode.equals(mode.getName())) { + // TODO Return facets, but facets are not implemented for + // OutputModes yet! + } + } + + return null; + } +} +// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/shared/model/DefaultFacet.java Fri Mar 25 09:19:29 2011 +0000 @@ -0,0 +1,36 @@ +package de.intevation.flys.client.shared.model; + + +/** + * The default implementation of a Facet. + * + * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a> + */ +public class DefaultFacet implements Facet { + + /** The name of the facet.*/ + protected String name; + + + /** + * An empty constructor. + */ + public DefaultFacet() { + } + + + /** + * The default constructor to create new DefaultFacets. + * + * @param name The name of the facet. + */ + public DefaultFacet(String name) { + this.name = name; + } + + + public String getName() { + return name; + } +} +// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/shared/model/Facet.java Fri Mar 25 09:19:29 2011 +0000 @@ -0,0 +1,20 @@ +package de.intevation.flys.client.shared.model; + +import java.io.Serializable; + + +/** + * The interface that provides methods to retrieve information about a Facet. + * + * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a> + */ +public interface Facet extends Serializable { + + /** + * Returns the name of a facet. + * + * @return the name of a facet. + */ + String getName(); +} +// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :