Kawai Wiki

Rev

Rev 194 | Rev 206 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
11 soliveira 1
package org.kawai.model;
2
 
52 soliveira 3
import java.text.SimpleDateFormat;
22 soliveira 4
import java.util.Date;
41 soliveira 5
import java.util.Locale;
22 soliveira 6
 
194 helio.frota 7
/**
8
 * Model class Page.
9
 *
10
 * @author Sergio Oliveira
11
 *
12
 */
11 soliveira 13
public class Page {
14
 
194 helio.frota 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
 
195 helio.frota 68
    /**
69
     * Default constructor.
70
     */
194 helio.frota 71
    public Page() { }
72
 
195 helio.frota 73
    /**
74
     * Sets the preview object of Page.
75
     * @param preview Preview
76
     */
194 helio.frota 77
    public void setPreview(Preview preview) {
78
        this.isPreview = true;
79
        this.title = preview.getTitle();
80
        this.body = preview.getBody();
86 soliveira 81
    }
82
 
195 helio.frota 83
    /**
84
     * Sets the comment of Page.
85
     * @param s String
86
     */
194 helio.frota 87
    public void setComment(String s) {
88
        this.comment = s;
86 soliveira 89
    }
90
 
195 helio.frota 91
    /**
92
     * Gets the comment of Page.
93
     * @return String
94
     */
194 helio.frota 95
    public String getComment() {
96
        return comment;
86 soliveira 97
    }
98
 
195 helio.frota 99
    /**
100
     * Return true if isRevision of Page.
101
     * @return boolean
102
     */
194 helio.frota 103
    public boolean isRevision() {
104
        return isRevision;
86 soliveira 105
    }
106
 
195 helio.frota 107
    /**
108
     * Sets isRevision of Page.
109
     * @param isRevision boolean
110
     */
194 helio.frota 111
    public void setRevision(boolean isRevision) {
112
        this.isRevision = isRevision;
11 soliveira 113
    }
114
 
195 helio.frota 115
    /**
116
     * Gets the revisionNumber of Page.
117
     * @return int
118
     */
194 helio.frota 119
    public int getRevisionNumber() {
120
        return revisionNumber;
11 soliveira 121
    }
122
 
195 helio.frota 123
    /**
124
     * Sets the revisionNumber of Page.
125
     * @param revisionNumber int
126
     */
194 helio.frota 127
    public void setRevisionNumber(int revisionNumber) {
128
        this.revisionNumber = revisionNumber;
11 soliveira 129
    }
130
 
195 helio.frota 131
    /**
132
     * Gets the id of Page.
133
     * @return int
134
     */
194 helio.frota 135
    public int getId() {
136
        return id;
11 soliveira 137
    }
138
 
195 helio.frota 139
    /**
140
     * Sets the id of Page.
141
     * @param id int
142
     */
194 helio.frota 143
    public void setId(int id) {
144
        this.id = id;
11 soliveira 145
    }
146
 
195 helio.frota 147
    /**
148
     * Gets the name of Page.
149
     * @return String
150
     */
194 helio.frota 151
    public String getName() {
152
        return name;
11 soliveira 153
    }
154
 
195 helio.frota 155
    /**
156
     * Sets the name of Page.
157
     * @param name String
158
     */
194 helio.frota 159
    public void setName(String name) {
160
        this.name = name;
11 soliveira 161
    }
162
 
195 helio.frota 163
    /**
164
     * Gets the title of Page.
165
     * @return String
166
     */
194 helio.frota 167
    public String getTitle() {
168
        return title;
11 soliveira 169
    }
22 soliveira 170
 
195 helio.frota 171
    /**
172
     * Sets the title of Page.
173
     * @param title String
174
     */
194 helio.frota 175
    public void setTitle(String title) {
176
        this.title = title;
22 soliveira 177
    }
178
 
195 helio.frota 179
    /**
180
     * Gets the body of Page.
181
     * @return String
182
     */
194 helio.frota 183
    public String getBody() {
184
        return body;
22 soliveira 185
    }
186
 
195 helio.frota 187
    /**
188
     * Sets the body of Page.
189
     * @param body String
190
     */
194 helio.frota 191
    public void setBody(String body) {
192
        this.body = body;
22 soliveira 193
    }
194
 
195 helio.frota 195
    /**
196
     * Return true if isSystemPage of Page.
197
     * @return boolean
198
     */
194 helio.frota 199
    public boolean isSystemPage() {
200
        return isSystemPage;
22 soliveira 201
    }
202
 
195 helio.frota 203
    /**
204
     * Sets isSystemPage of Page.
205
     * @param isSystemPage boolean
206
     */
194 helio.frota 207
    public void setSystemPage(boolean isSystemPage) {
208
        this.isSystemPage = isSystemPage;
22 soliveira 209
    }
210
 
195 helio.frota 211
    /**
212
     * Gets the languageId of Page.
213
     * @return int
214
     */
194 helio.frota 215
    public int getLanguageId() {
216
        return languageId;
22 soliveira 217
    }
218
 
195 helio.frota 219
    /**
220
     * Sets the languageId of Page.
221
     * @param languageId int
222
     */
194 helio.frota 223
    public void setLanguageId(int languageId) {
224
        this.languageId = languageId;
22 soliveira 225
    }
226
 
195 helio.frota 227
    /**
228
     * Gets the language of Page.
229
     * @return Language
230
     */
194 helio.frota 231
    public Language getLanguage() {
232
        return Language.fromId(languageId);
22 soliveira 233
    }
234
 
195 helio.frota 235
    /**
236
     * Gets the locale of Page.
237
     * @return Locale
238
     */
194 helio.frota 239
    public Locale getLocale() {
240
        return getLanguage() != null ? getLanguage().getLocale() : null;
22 soliveira 241
    }
242
 
195 helio.frota 243
    /**
244
     * Gets the lang of Page.
245
     * @return String
246
     */
194 helio.frota 247
    public String getLang() {
248
        return getLocale() != null ? getLocale().toString() : null;
22 soliveira 249
    }
250
 
195 helio.frota 251
    /**
252
     * Gets the modifiedById of Page.
253
     * @return int
254
     */
194 helio.frota 255
    public int getModifiedById() {
256
        return modifiedById;
22 soliveira 257
    }
258
 
195 helio.frota 259
    /**
260
     * Return true if modifiedById is not negative or different from zero.
261
     * @return boolean
262
     */
194 helio.frota 263
    public boolean isModified() {
264
        return modifiedById > 0;
22 soliveira 265
    }
194 helio.frota 266
 
195 helio.frota 267
    /**
268
     * Sets the modifiedById attribute of Page.
269
     * @param modifiedById int
270
     */
194 helio.frota 271
    public void setModifiedById(int modifiedById) {
272
        this.modifiedById = modifiedById;
25 soliveira 273
    }
22 soliveira 274
 
195 helio.frota 275
    /**
276
     * Gets the modifiedOn date of Page.
277
     * @return Date
278
     */
194 helio.frota 279
    public Date getModifiedOn() {
280
        return modifiedOn;
25 soliveira 281
    }
282
 
195 helio.frota 283
    /**
284
     * Gets the formatted modifiedOn date of Page.
285
     * @return String
286
     */
194 helio.frota 287
    public String getFormattedModifiedOn() {
288
        return modifiedOn != null ? FORMATTER.format(modifiedOn) : null;
25 soliveira 289
    }
290
 
195 helio.frota 291
    /**
292
     * Sets the modifiedOn date of Page.
293
     * @param modifiedOn
294
     */
194 helio.frota 295
    public void setModifiedOn(Date modifiedOn) {
296
        this.modifiedOn = modifiedOn;
25 soliveira 297
    }
298
 
195 helio.frota 299
    /**
300
     * Gets the createdById attribute of Page.
301
     * @return int
302
     */
194 helio.frota 303
    public int getCreatedById() {
304
        return createdById;
305
    }
306
 
195 helio.frota 307
    /**
308
     * Sets the createdById attribute of Page.
309
     * @param createdById int
310
     */
194 helio.frota 311
    public void setCreatedById(int createdById) {
312
        this.createdById = createdById;
313
    }
314
 
195 helio.frota 315
    /**
316
     * Gets the createdOn date of Page.
317
     * @return Date
318
     */
194 helio.frota 319
    public Date getCreatedOn() {
320
        return createdOn;
321
    }
322
 
195 helio.frota 323
    /**
324
     * Gets the formatted createdOn date of Page.
325
     * @return String
326
     */
194 helio.frota 327
    public String getFormattedCreatedOn() {
328
        return createdOn != null ? FORMATTER.format(createdOn) : null;
329
    }
330
 
195 helio.frota 331
    /**
332
     * Sets the createdOn date of Page.
333
     * @param createdOn Date
334
     */
194 helio.frota 335
    public void setCreatedOn(Date createdOn) {
336
        this.createdOn = createdOn;
337
    }
338
 
195 helio.frota 339
    /**
340
     * Sets isFrontPage attribute of Page.
341
     * @param isFrontPage boolean
342
     */
194 helio.frota 343
    public void setFrontPage(boolean isFrontPage) {
344
        this.isFrontPage = isFrontPage;
345
    }
346
 
195 helio.frota 347
    /**
348
     * Returns true if isFrontPage.
349
     * @return boolean
350
     */
194 helio.frota 351
    public boolean isFrontPage() {
352
        return isFrontPage;
353
    }
354
 
195 helio.frota 355
    /**
356
     * Gets the modifiedBy user of Page.
357
     * @return User
358
     */
194 helio.frota 359
    public User getModifiedBy() {
360
        return modifiedBy;
361
    }
362
 
195 helio.frota 363
    /**
364
     * Sets the modifiedBy user of Page.
365
     * @param modifiedBy User
366
     */
194 helio.frota 367
    public void setModifiedBy(User modifiedBy) {
368
        this.modifiedBy = modifiedBy;
369
    }
370
 
195 helio.frota 371
    /**
372
     * Gets the createdBy user of Page.
373
     * @return User
374
     */
194 helio.frota 375
    public User getCreatedBy() {
376
        return createdBy;
377
    }
378
 
195 helio.frota 379
    /**
380
     * Sets the createdBy user of Page.
381
     * @param createdBy User
382
     */
194 helio.frota 383
    public void setCreatedBy(User createdBy) {
384
        this.createdBy = createdBy;
385
    }
386
 
195 helio.frota 387
    /**
388
     * Return true if name is css.
389
     * @return boolean
390
     */
194 helio.frota 391
    public boolean isCSS() {
392
        return name.equals(CSS) || name.equals(PRINT_CSS);
393
    }
394
 
195 helio.frota 395
    /**
396
     * Return true if isDeleted Page.
397
     * @return Boolean
398
     */
194 helio.frota 399
    public Boolean isDeleted() {
400
        return isDeleted;
401
    }
402
 
195 helio.frota 403
    /**
404
     * Return true if isDeleted Page.
405
     * @return Boolean
406
     */
194 helio.frota 407
    public boolean getDeleted() {
408
        return isDeleted != null ? isDeleted : false;
409
    }
410
 
195 helio.frota 411
    /**
412
     * Sets the isDeleted attribute of Page.
413
     * @param b Boolean
414
     */
194 helio.frota 415
    public void setDeleted(Boolean b) {
416
        this.isDeleted = b;
417
    }
418
 
195 helio.frota 419
    /**
420
     * Sets the isPreview of Page.
421
     * @param b boolean
422
     */
194 helio.frota 423
    public void setPreview(boolean b) {
424
        this.isPreview = b;
425
    }
426
 
195 helio.frota 427
    /**
428
     * Returns true if isPreview Page.
429
     * @return boolean
430
     */
194 helio.frota 431
    public boolean isPreview() {
432
        return isPreview;
433
    }
434
 
195 helio.frota 435
    /**
436
     * Return true if isNew Page.
437
     * @return boolean
438
     */
194 helio.frota 439
    public boolean isNew() {
440
        return isNew;
441
    }
442
 
195 helio.frota 443
    /**
444
     * Sets isNew of Page.
445
     * @param b boolean
446
     */
194 helio.frota 447
    public void setNew(boolean b) {
448
        this.isNew = b;
449
    }
450
 
195 helio.frota 451
    /**
452
     * {@inheritDoc}
453
     */
194 helio.frota 454
    @Override
22 soliveira 455
    public String toString() {
194 helio.frota 456
        return "Page:[name=" + name + ";language=" + getLanguage() + "]";
22 soliveira 457
    }
194 helio.frota 458
 
459
}