Rev 108 | Rev 195 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 108 | Rev 194 | ||
---|---|---|---|
Line 2... | Line 2... | ||
2 | 2 | ||
3 | import java.text.SimpleDateFormat; |
3 | import java.text.SimpleDateFormat; |
4 | import java.util.Date; |
4 | import java.util.Date; |
5 | import java.util.Locale; |
5 | import java.util.Locale; |
6 | 6 | ||
- | 7 | /**
|
|
- | 8 | * Model class Page.
|
|
- | 9 | *
|
|
- | 10 | * @author Sergio Oliveira
|
|
- | 11 | *
|
|
- | 12 | */
|
|
7 | public class Page { |
13 | public class Page { |
8 | - | ||
9 | private static final SimpleDateFormat FORMATTER = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss"); |
- | |
10 | - | ||
11 | public static final String LEFT_COLUMN = "LeftColumn"; |
- | |
12 | public static final String CSS = "CSS"; |
- | |
13 | public static final String PRINT_CSS = "PrintCSS"; |
- | |
14 | public static final String LOGO = "logo"; |
- | |
15 | public static final String JAVASCRIPT = "JavaScript"; |
- | |
16 | - | ||
17 | private int id; |
- | |
18 | private String name; |
- | |
19 | private String title; |
- | |
20 | private String body; |
- | |
21 | private boolean isSystemPage; |
- | |
22 | private int languageId; |
- | |
23 | private int modifiedById; |
- | |
24 | private User modifiedBy; |
- | |
25 | private Date modifiedOn; |
- | |
26 | private int createdById; |
- | |
27 | private User createdBy; |
- | |
28 | private Date createdOn; |
- | |
29 | private boolean isFrontPage; |
- | |
30 | private Boolean isDeleted; |
- | |
31 | private boolean isPreview; |
- | |
32 | private boolean isNew; |
- | |
33 | private boolean isRevision; |
- | |
34 | private int revisionNumber; |
- | |
35 | private String comment; |
- | |
36 | - | ||
37 | public Page() { } |
- | |
38 | - | ||
39 | public void setPreview(Preview preview) { |
- | |
40 | this.isPreview = true; |
- | |
41 | this.title = preview.getTitle(); |
- | |
42 | this.body = preview.getBody(); |
- | |
43 | }
|
- | |
44 | - | ||
45 | public void setComment(String s) { |
- | |
46 | this.comment = s; |
- | |
47 | }
|
- | |
48 | - | ||
49 | public String getComment() { |
- | |
50 | return comment; |
- | |
51 | }
|
- | |
52 | 14 | ||
53 | public boolean isRevision() { |
- | |
54 | return isRevision; |
- | |
- | 15 | /** Attribute FORMATTER of Page. */
|
|
- | 16 | private static final SimpleDateFormat FORMATTER = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss"); |
|
- | 17 | ||
- | 18 | /** Attribute LEFT_COLUMN of Page. */
|
|
- | 19 | public static final String LEFT_COLUMN = "LeftColumn"; |
|
- | 20 | /** Attribute CSS of Page. */
|
|
- | 21 | public static final String CSS = "CSS"; |
|
- | 22 | /** Attribute PRINT_CSS of Page. */
|
|
- | 23 | public static final String PRINT_CSS = "PrintCSS"; |
|
- | 24 | /** Attribute LOGO of Page. */
|
|
- | 25 | public static final String LOGO = "logo"; |
|
- | 26 | /** Attribute JAVASCRIPT of Page. */
|
|
- | 27 | public static final String JAVASCRIPT = "JavaScript"; |
|
- | 28 | ||
- | 29 | /** Attribute id of Page. */
|
|
- | 30 | private int id; |
|
- | 31 | /** Attribute name of Page. */
|
|
- | 32 | private String name; |
|
- | 33 | /** Attribute title of Page. */
|
|
- | 34 | private String title; |
|
- | 35 | /** Attribute body of Page. */
|
|
- | 36 | private String body; |
|
- | 37 | /** Attribute isSystemPage of Page. */
|
|
- | 38 | private boolean isSystemPage; |
|
- | 39 | /** Attribute languageId of Page. */
|
|
- | 40 | private int languageId; |
|
- | 41 | /** Attribute modifiedById of Page. */
|
|
- | 42 | private int modifiedById; |
|
- | 43 | /** Attribute modifiedBy of Page. */
|
|
- | 44 | private User modifiedBy; |
|
- | 45 | /** Attribute modifiedOn of Page. */
|
|
- | 46 | private Date modifiedOn; |
|
- | 47 | /** Attribute createdById of Page. */
|
|
- | 48 | private int createdById; |
|
- | 49 | /** Attribute createdBy of Page. */
|
|
- | 50 | private User createdBy; |
|
- | 51 | /** Attribute createdOn of Page. */
|
|
- | 52 | private Date createdOn; |
|
- | 53 | /** Attribute isFrontPage of Page. */
|
|
- | 54 | private boolean isFrontPage; |
|
- | 55 | /** Attribute isDeleted of Page. */
|
|
- | 56 | private Boolean isDeleted; |
|
- | 57 | /** Attribute isPreview of Page. */
|
|
- | 58 | private boolean isPreview; |
|
- | 59 | /** Attribute isNew of Page. */
|
|
- | 60 | private boolean isNew; |
|
- | 61 | /** Attribute isRevision of Page. */
|
|
- | 62 | private boolean isRevision; |
|
- | 63 | /** Attribute revisionNumber of Page. */
|
|
- | 64 | private int revisionNumber; |
|
- | 65 | /** Attribute comment of Page. */
|
|
- | 66 | private String comment; |
|
- | 67 | ||
- | 68 | public Page() { } |
|
- | 69 | ||
- | 70 | public void setPreview(Preview preview) { |
|
- | 71 | this.isPreview = true; |
|
- | 72 | this.title = preview.getTitle(); |
|
- | 73 | this.body = preview.getBody(); |
|
55 | }
|
74 | }
|
56 | 75 | ||
57 | public void setRevision(boolean isRevision) { |
- | |
58 | this.isRevision = isRevision; |
- | |
- | 76 | public void setComment(String s) { |
|
- | 77 | this.comment = s; |
|
59 | }
|
78 | }
|
60 | 79 | ||
61 | public int getRevisionNumber() { |
- | |
62 | return revisionNumber; |
- | |
- | 80 | public String getComment() { |
|
- | 81 | return comment; |
|
63 | }
|
82 | }
|
64 | 83 | ||
65 | public void setRevisionNumber(int revisionNumber) { |
- | |
66 | this.revisionNumber = revisionNumber; |
- | |
- | 84 | public boolean isRevision() { |
|
- | 85 | return isRevision; |
|
67 | }
|
86 | }
|
68 | 87 | ||
69 | public int getId() { |
- | |
70 | return id; |
- | |
- | 88 | public void setRevision(boolean isRevision) { |
|
- | 89 | this.isRevision = isRevision; |
|
71 | }
|
90 | }
|
72 | 91 | ||
73 | public void setId(int id) { |
- | |
74 | this.id = id; |
- | |
- | 92 | public int getRevisionNumber() { |
|
- | 93 | return revisionNumber; |
|
75 | }
|
94 | }
|
76 | 95 | ||
77 | public String getName() { |
- | |
78 | return name; |
- | |
- | 96 | public void setRevisionNumber(int revisionNumber) { |
|
- | 97 | this.revisionNumber = revisionNumber; |
|
79 | }
|
98 | }
|
80 | 99 | ||
81 | public void setName(String name) { |
- | |
82 | this.name = name; |
- | |
- | 100 | public int getId() { |
|
- | 101 | return id; |
|
83 | }
|
102 | }
|
84 | 103 | ||
85 | public String getTitle() { |
- | |
86 | return title; |
- | |
- | 104 | public void setId(int id) { |
|
- | 105 | this.id = id; |
|
87 | }
|
106 | }
|
88 | 107 | ||
89 | public void setTitle(String title) { |
- | |
90 | this.title = title; |
- | |
- | 108 | public String getName() { |
|
- | 109 | return name; |
|
91 | }
|
110 | }
|
92 | 111 | ||
93 | public String getBody() { |
- | |
94 | return body; |
- | |
- | 112 | public void setName(String name) { |
|
- | 113 | this.name = name; |
|
95 | }
|
114 | }
|
96 | 115 | ||
97 | public void setBody(String body) { |
- | |
98 | this.body = body; |
- | |
- | 116 | public String getTitle() { |
|
- | 117 | return title; |
|
99 | }
|
118 | }
|
100 | 119 | ||
101 | public boolean isSystemPage() { |
- | |
102 | return isSystemPage; |
- | |
- | 120 | public void setTitle(String title) { |
|
- | 121 | this.title = title; |
|
103 | }
|
122 | }
|
104 | 123 | ||
105 | public void setSystemPage(boolean isSystemPage) { |
- | |
106 | this.isSystemPage = isSystemPage; |
- | |
- | 124 | public String getBody() { |
|
- | 125 | return body; |
|
107 | }
|
126 | }
|
108 | 127 | ||
109 | public int getLanguageId() { |
- | |
110 | return languageId; |
- | |
- | 128 | public void setBody(String body) { |
|
- | 129 | this.body = body; |
|
111 | }
|
130 | }
|
112 | 131 | ||
113 | public void setLanguageId(int languageId) { |
- | |
114 | this.languageId = languageId; |
- | |
- | 132 | public boolean isSystemPage() { |
|
- | 133 | return isSystemPage; |
|
115 | }
|
134 | }
|
116 | - | ||
117 | public Language getLanguage() { |
- | |
118 | return Language.fromId(languageId); |
- | |
119 | }
|
- | |
120 | - | ||
121 | public Locale getLocale() { |
- | |
122 | return getLanguage() != null ? getLanguage().getLocale() : null; |
- | |
123 | }
|
- | |
124 | - | ||
125 | public String getLang() { |
- | |
126 | return getLocale() != null ? getLocale().toString() : null; |
- | |
127 | }
|
- | |
128 | 135 | ||
129 | public int getModifiedById() { |
- | |
130 | return modifiedById; |
- | |
- | 136 | public void setSystemPage(boolean isSystemPage) { |
|
- | 137 | this.isSystemPage = isSystemPage; |
|
131 | }
|
138 | }
|
132 | - | ||
133 | public boolean isModified() { |
- | |
134 | return modifiedById > 0; |
- | |
135 | }
|
- | |
136 | 139 | ||
137 | public void setModifiedById(int modifiedById) { |
- | |
138 | this.modifiedById = modifiedById; |
- | |
- | 140 | public int getLanguageId() { |
|
- | 141 | return languageId; |
|
139 | }
|
142 | }
|
140 | 143 | ||
141 | public Date getModifiedOn() { |
- | |
142 | return modifiedOn; |
- | |
- | 144 | public void setLanguageId(int languageId) { |
|
- | 145 | this.languageId = languageId; |
|
143 | }
|
146 | }
|
144 | - | ||
145 | public String getFormattedModifiedOn() { |
- | |
146 | return modifiedOn != null ? FORMATTER.format(modifiedOn) : null; |
- | |
147 | }
|
- | |
148 | 147 | ||
149 | public void setModifiedOn(Date modifiedOn) { |
- | |
150 | this.modifiedOn = modifiedOn; |
- | |
- | 148 | public Language getLanguage() { |
|
- | 149 | return Language.fromId(languageId); |
|
151 | }
|
150 | }
|
152 | 151 | ||
153 | public int getCreatedById() { |
- | |
154 | return createdById; |
- | |
- | 152 | public Locale getLocale() { |
|
- | 153 | return getLanguage() != null ? getLanguage().getLocale() : null; |
|
155 | }
|
154 | }
|
156 | 155 | ||
157 | public void setCreatedById(int createdById) { |
- | |
158 | this.createdById = createdById; |
- | |
- | 156 | public String getLang() { |
|
- | 157 | return getLocale() != null ? getLocale().toString() : null; |
|
159 | }
|
158 | }
|
160 | 159 | ||
161 | public Date getCreatedOn() { |
- | |
162 | return createdOn; |
- | |
- | 160 | public int getModifiedById() { |
|
- | 161 | return modifiedById; |
|
163 | }
|
162 | }
|
164 | - | ||
165 | public String getFormattedCreatedOn() { |
- | |
166 | return createdOn != null ? FORMATTER.format(createdOn) : null; |
- | |
167 | }
|
- | |
168 | 163 | ||
169 | public void setCreatedOn(Date createdOn) { |
- | |
170 | this.createdOn = createdOn; |
- | |
- | 164 | public boolean isModified() { |
|
- | 165 | return modifiedById > 0; |
|
171 | }
|
166 | }
|
172 | - | ||
173 | public void setFrontPage(boolean isFrontPage) { |
- | |
174 | this.isFrontPage = isFrontPage; |
- | |
175 | }
|
- | |
176 | - | ||
177 | public boolean isFrontPage() { |
- | |
178 | return isFrontPage; |
- | |
179 | }
|
- | |
180 | - | ||
181 | public User getModifiedBy() { |
- | |
182 | return modifiedBy; |
- | |
- | 167 | ||
- | 168 | public void setModifiedById(int modifiedById) { |
|
- | 169 | this.modifiedById = modifiedById; |
|
183 | }
|
170 | }
|
184 | 171 | ||
185 | public void setModifiedBy(User modifiedBy) { |
- | |
186 | this.modifiedBy = modifiedBy; |
- | |
- | 172 | public Date getModifiedOn() { |
|
- | 173 | return modifiedOn; |
|
187 | }
|
174 | }
|
188 | 175 | ||
189 | public User getCreatedBy() { |
- | |
190 | return createdBy; |
- | |
- | 176 | public String getFormattedModifiedOn() { |
|
- | 177 | return modifiedOn != null ? FORMATTER.format(modifiedOn) : null; |
|
191 | }
|
178 | }
|
192 | 179 | ||
193 | public void setCreatedBy(User createdBy) { |
- | |
194 | this.createdBy = createdBy; |
- | |
- | 180 | public void setModifiedOn(Date modifiedOn) { |
|
- | 181 | this.modifiedOn = modifiedOn; |
|
195 | }
|
182 | }
|
196 | - | ||
197 | public boolean isCSS() { |
- | |
198 | return name.equals(CSS) || name.equals(PRINT_CSS); |
- | |
199 | }
|
- | |
200 | - | ||
201 | public Boolean isDeleted() { |
- | |
202 | return isDeleted; |
- | |
203 | }
|
- | |
204 | - | ||
205 | public boolean getDeleted() { |
- | |
206 | return isDeleted != null ? isDeleted : false; |
- | |
207 | }
|
- | |
208 | - | ||
209 | public void setDeleted(Boolean b) { |
- | |
210 | this.isDeleted = b; |
- | |
211 | }
|
- | |
212 | - | ||
213 | public void setPreview(boolean b) { |
- | |
214 | this.isPreview = b; |
- | |
215 | }
|
- | |
216 | - | ||
217 | public boolean isPreview() { |
- | |
218 | return isPreview; |
- | |
219 | }
|
- | |
220 | - | ||
221 | public boolean isNew() { |
- | |
222 | return isNew; |
- | |
223 | }
|
- | |
224 | - | ||
225 | public void setNew(boolean b) { |
- | |
226 | this.isNew = b; |
- | |
227 | }
|
- | |
228 | 183 | ||
229 | @Override |
- | |
- | 184 | public int getCreatedById() { |
|
- | 185 | return createdById; |
|
- | 186 | }
|
|
- | 187 | ||
- | 188 | public void setCreatedById(int createdById) { |
|
- | 189 | this.createdById = createdById; |
|
- | 190 | }
|
|
- | 191 | ||
- | 192 | public Date getCreatedOn() { |
|
- | 193 | return createdOn; |
|
- | 194 | }
|
|
- | 195 | ||
- | 196 | public String getFormattedCreatedOn() { |
|
- | 197 | return createdOn != null ? FORMATTER.format(createdOn) : null; |
|
- | 198 | }
|
|
- | 199 | ||
- | 200 | public void setCreatedOn(Date createdOn) { |
|
- | 201 | this.createdOn = createdOn; |
|
- | 202 | }
|
|
- | 203 | ||
- | 204 | public void setFrontPage(boolean isFrontPage) { |
|
- | 205 | this.isFrontPage = isFrontPage; |
|
- | 206 | }
|
|
- | 207 | ||
- | 208 | public boolean isFrontPage() { |
|
- | 209 | return isFrontPage; |
|
- | 210 | }
|
|
- | 211 | ||
- | 212 | public User getModifiedBy() { |
|
- | 213 | return modifiedBy; |
|
- | 214 | }
|
|
- | 215 | ||
- | 216 | public void setModifiedBy(User modifiedBy) { |
|
- | 217 | this.modifiedBy = modifiedBy; |
|
- | 218 | }
|
|
- | 219 | ||
- | 220 | public User getCreatedBy() { |
|
- | 221 | return createdBy; |
|
- | 222 | }
|
|
- | 223 | ||
- | 224 | public void setCreatedBy(User createdBy) { |
|
- | 225 | this.createdBy = createdBy; |
|
- | 226 | }
|
|
- | 227 | ||
- | 228 | public boolean isCSS() { |
|
- | 229 | return name.equals(CSS) || name.equals(PRINT_CSS); |
|
- | 230 | }
|
|
- | 231 | ||
- | 232 | public Boolean isDeleted() { |
|
- | 233 | return isDeleted; |
|
- | 234 | }
|
|
- | 235 | ||
- | 236 | public boolean getDeleted() { |
|
- | 237 | return isDeleted != null ? isDeleted : false; |
|
- | 238 | }
|
|
- | 239 | ||
- | 240 | public void setDeleted(Boolean b) { |
|
- | 241 | this.isDeleted = b; |
|
- | 242 | }
|
|
- | 243 | ||
- | 244 | public void setPreview(boolean b) { |
|
- | 245 | this.isPreview = b; |
|
- | 246 | }
|
|
- | 247 | ||
- | 248 | public boolean isPreview() { |
|
- | 249 | return isPreview; |
|
- | 250 | }
|
|
- | 251 | ||
- | 252 | public boolean isNew() { |
|
- | 253 | return isNew; |
|
- | 254 | }
|
|
- | 255 | ||
- | 256 | public void setNew(boolean b) { |
|
- | 257 | this.isNew = b; |
|
- | 258 | }
|
|
- | 259 | ||
- | 260 | @Override |
|
230 | public String toString() { |
261 | public String toString() { |
231 | return "Page:[name=" + name + ";language=" + getLanguage() + "]"; |
- | |
- | 262 | return "Page:[name=" + name + ";language=" + getLanguage() + "]"; |
|
232 | }
|
263 | }
|
233 | - | ||
234 | }
|
264 | |
- | 265 | }
|