Mercurial > dive4elements > river
diff flys-client/src/main/java/de/intevation/flys/client/shared/model/DefaultCollection.java @ 809:e9337488bac3
The Collection now knows its already loaded recommendations - the CollectionView will not load recommendations that have already been loaded before.
flys-client/trunk@2397 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Fri, 22 Jul 2011 12:23:36 +0000 |
parents | 14e5e51a7de4 |
children | 18fc7afe0251 |
line wrap: on
line diff
--- a/flys-client/src/main/java/de/intevation/flys/client/shared/model/DefaultCollection.java Thu Jul 21 16:06:29 2011 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/shared/model/DefaultCollection.java Fri Jul 22 12:23:36 2011 +0000 @@ -30,6 +30,8 @@ /** The list of artifacts that are managed by this Collection.*/ protected List<CollectionItem> items; + protected List<Recommendation> recommendations; + protected Map<String, ThemeList> themeLists; @@ -40,11 +42,6 @@ } - /** - * Creates a new DefaultCollection with a UUID. - * - * @param uuid The UUID. - */ public DefaultCollection(String uuid, long ttl) { this.uuid = uuid; this.ttl = ttl; @@ -53,13 +50,27 @@ } + /** + * Creates a new DefaultCollection with a UUID. + * + * @param uuid The UUID. + */ + public DefaultCollection(String uuid, long ttl, List<Recommendation> recs) { + this(uuid, ttl); + + this.recommendations = recs; + } + + public DefaultCollection( String uuid, long ttl, + List<Recommendation> recommendations, Map<String, ThemeList> themeLists) { - this(uuid, ttl); - this.themeLists = themeLists; + this(uuid, ttl, new ArrayList<Recommendation>()); + this.recommendations = recommendations; + this.themeLists = themeLists; } @@ -70,7 +81,7 @@ * @param name The name of this collection. */ public DefaultCollection(String uuid, long ttl, String name) { - this(uuid, ttl); + this(uuid, ttl, new ArrayList<Recommendation>()); this.name = name; } @@ -174,5 +185,37 @@ return null; } + + + public List<Recommendation> getRecommendations() { + return recommendations; + } + + + public void addRecommendation(Recommendation recommendation) { + recommendations.add(recommendation); + } + + + public void addRecommendations(List<Recommendation> recommendations) { + this.recommendations.addAll(recommendations); + } + + + public boolean loadedRecommendation(Recommendation recommendation) { + String factory = recommendation.getFactory(); + String dbids = recommendation.getIDs(); + + for (Recommendation in: recommendations) { + String inFactory = in.getFactory(); + String inDbids = in.getIDs(); + + if (factory.equals(inFactory) && dbids.equals(inDbids)) { + return true; + } + } + + return false; + } } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :