comparison flys-client/src/main/java/de/intevation/flys/client/shared/model/DefaultCollection.java @ 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 6cb8aff3cd6b
children e2abb6b9dc7e
comparison
equal deleted inserted replaced
66:a361ce81abcf 67:74257b95567b
1 package de.intevation.flys.client.shared.model; 1 package de.intevation.flys.client.shared.model;
2 2
3 import java.util.ArrayList; 3 import java.util.ArrayList;
4 import java.util.Date; 4 import java.util.Date;
5 import java.util.HashMap;
5 import java.util.List; 6 import java.util.List;
7 import java.util.Map;
6 8
7 9
8 /** 10 /**
9 * The default implementation of a {@link Collection}. 11 * The default implementation of a {@link Collection}.
10 * 12 *
14 16
15 /** The uuid of the collection. */ 17 /** The uuid of the collection. */
16 protected String uuid; 18 protected String uuid;
17 19
18 /** The list of artifacts that are managed by this Collection.*/ 20 /** The list of artifacts that are managed by this Collection.*/
19 protected List<Artifact> artifacts; 21 protected List<CollectionItem> items;
22
23
24 /**
25 * Constructor without arguments is necessary for GWT.
26 */
27 public DefaultCollection() {
28 }
20 29
21 30
22 /** 31 /**
23 * Creates a new DefaultCollection with a UUID. 32 * Creates a new DefaultCollection with a UUID.
24 * 33 *
25 * @param uuid The UUID. 34 * @param uuid The UUID.
26 */ 35 */
27 public DefaultCollection(String uuid) { 36 public DefaultCollection(String uuid) {
28 this.uuid = uuid; 37 this.uuid = uuid;
29 this.artifacts = new ArrayList<Artifact>(); 38 this.items = new ArrayList<CollectionItem>();
30 } 39 }
31 40
32 41
33 public String identifier() { 42 public String identifier() {
34 return uuid; 43 return uuid;
43 public String getName() { 52 public String getName() {
44 return uuid; 53 return uuid;
45 } 54 }
46 55
47 56
48 public void addArtifact(Artifact artifact) { 57 public void addItem(CollectionItem item) {
49 if (artifact != null) { 58 if (item != null) {
50 artifacts.add(artifact); 59 items.add(item);
51 } 60 }
52 } 61 }
53 62
54 63
55 public int getArtifactLength() { 64 public int getItemLength() {
56 return artifacts.size(); 65 return items.size();
57 } 66 }
58 67
59 68
60 public Artifact getArtifact(int idx) { 69 public CollectionItem getItem(int idx) {
61 return artifacts.get(idx); 70 if (idx >= getItemLength()) {
71 return null;
72 }
73
74 return items.get(idx);
75 }
76
77
78 public Map<String, OutputMode> getOutputModes() {
79 Map<String, OutputMode> modes = new HashMap<String, OutputMode>();
80
81 for (CollectionItem item: items) {
82 List<OutputMode> itemModes = item.getOutputModes();
83
84 if (itemModes != null) {
85 for (OutputMode itemMode: itemModes) {
86 String name = itemMode.getName();
87 if (!modes.containsKey(name)) {
88 // we dont want duplicated OutputModes in our result.
89 modes.put(name, itemMode);
90 }
91 }
92 }
93 }
94
95 return modes;
62 } 96 }
63 } 97 }
64 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : 98 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org