Mercurial > dive4elements > river
comparison flys-client/src/main/java/org/dive4elements/river/client/shared/model/CollectionRecord.java @ 5834:f507086aa94b
Repaired internal references.
author | Sascha L. Teichmann <teichmann@intevation.de> |
---|---|
date | Thu, 25 Apr 2013 12:31:32 +0200 |
parents | flys-client/src/main/java/de/intevation/flys/client/shared/model/CollectionRecord.java@80626c4a5bbf |
children | 821a02bbfb4e |
comparison
equal
deleted
inserted
replaced
5833:a2bdc0f524e8 | 5834:f507086aa94b |
---|---|
1 package de.intevation.flys.client.shared.model; | |
2 | |
3 import java.util.Date; | |
4 | |
5 import com.google.gwt.safehtml.shared.SafeHtml; | |
6 import com.google.gwt.safehtml.shared.SafeHtmlBuilder; | |
7 | |
8 import com.smartgwt.client.widgets.grid.ListGridRecord; | |
9 | |
10 | |
11 /** | |
12 * The CollectionRecord is a wrapper to put Collection objects into a ListGrid. | |
13 * | |
14 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a> | |
15 */ | |
16 public class CollectionRecord extends ListGridRecord { | |
17 | |
18 /** The artifact collection. */ | |
19 protected Collection collection; | |
20 | |
21 | |
22 /** | |
23 * The default constructor. | |
24 * | |
25 * @param collection The artifact collection. | |
26 */ | |
27 public CollectionRecord(Collection collection) { | |
28 this.collection = collection; | |
29 | |
30 setCreationTime(collection.getCreationTime()); | |
31 | |
32 String name = collection.getName(); | |
33 setName(name != null && name.length() > 0 | |
34 ? name | |
35 : collection.identifier()); | |
36 | |
37 setTTL(collection.getTTL()); | |
38 } | |
39 | |
40 | |
41 /** | |
42 * Sets the creation time. | |
43 * | |
44 * @param creationTime The creation time. | |
45 */ | |
46 public void setCreationTime(Date creationTime) { | |
47 setAttribute("creationTime", creationTime); | |
48 } | |
49 | |
50 | |
51 /** | |
52 * Returns the date of the creation. | |
53 * | |
54 * @return the creation time. | |
55 */ | |
56 public Date getCreationTime() { | |
57 return getAttributeAsDate("creationTime"); | |
58 } | |
59 | |
60 | |
61 /** | |
62 * Returns the name of the collection. | |
63 * | |
64 * @return the name of the collection. | |
65 */ | |
66 public void setName(String name) { | |
67 SafeHtmlBuilder b = new SafeHtmlBuilder(); | |
68 b.appendEscaped(name); | |
69 | |
70 SafeHtml html = b.toSafeHtml(); | |
71 | |
72 setAttribute("name", html.asString()); | |
73 } | |
74 | |
75 | |
76 /** | |
77 * Returns the name of the collection or the uuid if no name is specified. | |
78 * | |
79 * @return the name of the collection. | |
80 */ | |
81 public String getName() { | |
82 return getAttributeAsString("name"); | |
83 } | |
84 | |
85 | |
86 public void setTTL(long ttl) { | |
87 if (ttl == 0) { | |
88 setAttribute("ttl", "star_gold"); | |
89 } | |
90 else { | |
91 setAttribute("ttl", "star_silver"); | |
92 } | |
93 } | |
94 | |
95 | |
96 public String getTTL() { | |
97 return getAttribute("ttl"); | |
98 } | |
99 | |
100 | |
101 /** | |
102 * Returns the collection objects itself. | |
103 * | |
104 * @return the collection object. | |
105 */ | |
106 public Collection getCollection() { | |
107 return collection; | |
108 } | |
109 } | |
110 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |