# HG changeset patch # User Ingo Weinzierl # Date 1301044769 0 # Node ID 74257b95567bae7cabd2f6e33b8c2b2cc1b102c6 # Parent a361ce81abcf2a2fd26c6ed3f2f5d9889e9e48b7 Added CollectionItems and Facets and replaced Artifact references in Collection with CollectionItems. flys-client/trunk@1567 c6561f87-3c4e-4783-a992-168aeb5c3f6f diff -r a361ce81abcf -r 74257b95567b flys-client/ChangeLog --- 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 + + * 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 * src/main/java/de/intevation/flys/client/client/ui/MainMenu.java: Set styles diff -r a361ce81abcf -r 74257b95567b flys-client/src/main/java/de/intevation/flys/client/shared/model/Collection.java --- 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 Ingo Weinzierl */ -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 getOutputModes(); } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : diff -r a361ce81abcf -r 74257b95567b flys-client/src/main/java/de/intevation/flys/client/shared/model/CollectionItem.java --- /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 Ingo Weinzierl + */ +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 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 getFacets(String outputmode); +} +// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : diff -r a361ce81abcf -r 74257b95567b flys-client/src/main/java/de/intevation/flys/client/shared/model/DefaultCollection.java --- 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 artifacts; + protected List 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(); + this.uuid = uuid; + this.items = new ArrayList(); } @@ -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 getOutputModes() { + Map modes = new HashMap(); + + for (CollectionItem item: items) { + List 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 : diff -r a361ce81abcf -r 74257b95567b flys-client/src/main/java/de/intevation/flys/client/shared/model/DefaultCollectionItem.java --- /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 Ingo Weinzierl + */ +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 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 modes) { + this.identifier = identifier; + this.outputModes = modes; + } + + + public String identifier() { + return identifier; + } + + + public List getOutputModes() { + return outputModes; + } + + + public List 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 : diff -r a361ce81abcf -r 74257b95567b flys-client/src/main/java/de/intevation/flys/client/shared/model/DefaultFacet.java --- /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 Ingo Weinzierl + */ +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 : diff -r a361ce81abcf -r 74257b95567b flys-client/src/main/java/de/intevation/flys/client/shared/model/Facet.java --- /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 Ingo Weinzierl + */ +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 :