Mercurial > dive4elements > river
comparison 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 |
comparison
equal
deleted
inserted
replaced
808:3187b268b311 | 809:e9337488bac3 |
---|---|
28 protected long ttl; | 28 protected long ttl; |
29 | 29 |
30 /** The list of artifacts that are managed by this Collection.*/ | 30 /** The list of artifacts that are managed by this Collection.*/ |
31 protected List<CollectionItem> items; | 31 protected List<CollectionItem> items; |
32 | 32 |
33 protected List<Recommendation> recommendations; | |
34 | |
33 protected Map<String, ThemeList> themeLists; | 35 protected Map<String, ThemeList> themeLists; |
34 | 36 |
35 | 37 |
36 /** | 38 /** |
37 * Constructor without arguments is necessary for GWT. | 39 * Constructor without arguments is necessary for GWT. |
38 */ | 40 */ |
39 public DefaultCollection() { | 41 public DefaultCollection() { |
40 } | 42 } |
41 | 43 |
42 | 44 |
43 /** | |
44 * Creates a new DefaultCollection with a UUID. | |
45 * | |
46 * @param uuid The UUID. | |
47 */ | |
48 public DefaultCollection(String uuid, long ttl) { | 45 public DefaultCollection(String uuid, long ttl) { |
49 this.uuid = uuid; | 46 this.uuid = uuid; |
50 this.ttl = ttl; | 47 this.ttl = ttl; |
51 this.items = new ArrayList<CollectionItem>(); | 48 this.items = new ArrayList<CollectionItem>(); |
52 this.themeLists = new HashMap<String, ThemeList>(); | 49 this.themeLists = new HashMap<String, ThemeList>(); |
53 } | 50 } |
54 | 51 |
55 | 52 |
53 /** | |
54 * Creates a new DefaultCollection with a UUID. | |
55 * | |
56 * @param uuid The UUID. | |
57 */ | |
58 public DefaultCollection(String uuid, long ttl, List<Recommendation> recs) { | |
59 this(uuid, ttl); | |
60 | |
61 this.recommendations = recs; | |
62 } | |
63 | |
64 | |
56 public DefaultCollection( | 65 public DefaultCollection( |
57 String uuid, | 66 String uuid, |
58 long ttl, | 67 long ttl, |
68 List<Recommendation> recommendations, | |
59 Map<String, ThemeList> themeLists) | 69 Map<String, ThemeList> themeLists) |
60 { | 70 { |
61 this(uuid, ttl); | 71 this(uuid, ttl, new ArrayList<Recommendation>()); |
62 this.themeLists = themeLists; | 72 this.recommendations = recommendations; |
73 this.themeLists = themeLists; | |
63 } | 74 } |
64 | 75 |
65 | 76 |
66 /** | 77 /** |
67 * Creates a new DefaultCollection with uuid and name. | 78 * Creates a new DefaultCollection with uuid and name. |
68 * | 79 * |
69 * @param uuid The identifier of this collection. | 80 * @param uuid The identifier of this collection. |
70 * @param name The name of this collection. | 81 * @param name The name of this collection. |
71 */ | 82 */ |
72 public DefaultCollection(String uuid, long ttl, String name) { | 83 public DefaultCollection(String uuid, long ttl, String name) { |
73 this(uuid, ttl); | 84 this(uuid, ttl, new ArrayList<Recommendation>()); |
74 | 85 |
75 this.name = name; | 86 this.name = name; |
76 } | 87 } |
77 | 88 |
78 | 89 |
172 return themeLists.get(outName); | 183 return themeLists.get(outName); |
173 } | 184 } |
174 | 185 |
175 return null; | 186 return null; |
176 } | 187 } |
188 | |
189 | |
190 public List<Recommendation> getRecommendations() { | |
191 return recommendations; | |
192 } | |
193 | |
194 | |
195 public void addRecommendation(Recommendation recommendation) { | |
196 recommendations.add(recommendation); | |
197 } | |
198 | |
199 | |
200 public void addRecommendations(List<Recommendation> recommendations) { | |
201 this.recommendations.addAll(recommendations); | |
202 } | |
203 | |
204 | |
205 public boolean loadedRecommendation(Recommendation recommendation) { | |
206 String factory = recommendation.getFactory(); | |
207 String dbids = recommendation.getIDs(); | |
208 | |
209 for (Recommendation in: recommendations) { | |
210 String inFactory = in.getFactory(); | |
211 String inDbids = in.getIDs(); | |
212 | |
213 if (factory.equals(inFactory) && dbids.equals(inDbids)) { | |
214 return true; | |
215 } | |
216 } | |
217 | |
218 return false; | |
219 } | |
177 } | 220 } |
178 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : | 221 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |