Rev 961 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
924 | dev | 1 | package ak.hostadmiral.core.model; |
919 | dev | 2 | |
3 | import java.util.Date; |
||
924 | dev | 4 | import ak.hostadmiral.util.ModelException; |
5 | import ak.hostadmiral.util.ModelSecurityException; |
||
919 | dev | 6 | |
7 | public abstract class GeneralModelObject |
||
8 | implements ModelObject |
||
9 | { |
||
945 | dev | 10 | private Long id; |
919 | dev | 11 | private Boolean enabled; |
12 | private String comment; |
||
13 | private Date modStamp; |
||
918 | dev | 14 | private User modUser; |
919 | dev | 15 | |
1010 | dev | 16 | protected GeneralModelObject() |
17 | { |
||
18 | } |
||
19 | |||
20 | protected GeneralModelObject(GeneralModelObject origin) |
||
21 | { |
||
22 | this.id = origin.id; |
||
23 | this.enabled = origin.enabled; |
||
24 | this.comment = origin.comment; |
||
25 | this.modStamp = origin.modStamp; |
||
26 | this.modUser = origin.modUser; |
||
27 | } |
||
28 | |||
29 | /** |
||
30 | * @return true if the object is not yet saved in DB |
||
31 | */ |
||
32 | public boolean isNew() |
||
33 | { |
||
34 | return (id == null); |
||
35 | } |
||
36 | |||
918 | dev | 37 | /** |
38 | * |
||
945 | dev | 39 | * @hibernate.id generator-class="native" |
40 | */ |
||
41 | public Long getId() |
||
42 | { |
||
43 | return id; |
||
44 | } |
||
45 | |||
46 | protected void setId(Long id) |
||
47 | { |
||
48 | this.id = id; |
||
49 | } |
||
50 | |||
51 | /** |
||
52 | * |
||
919 | dev | 53 | * @hibernate.property |
54 | */ |
||
55 | public Boolean getEnabled() |
||
56 | { |
||
57 | return enabled; |
||
58 | } |
||
59 | |||
921 | dev | 60 | protected void setEnabled(Boolean enabled) |
919 | dev | 61 | { |
62 | this.enabled = enabled; |
||
63 | } |
||
64 | |||
65 | public void setEnabled(User editor, Boolean enabled) |
||
66 | throws ModelException |
||
67 | { |
||
68 | if(!editableBy(editor)) |
||
69 | throw new ModelSecurityException(); |
||
70 | |||
71 | this.enabled = enabled; |
||
72 | } |
||
73 | |||
74 | /** |
||
75 | * |
||
76 | * @hibernate.property |
||
77 | */ |
||
78 | public String getComment() |
||
79 | { |
||
80 | return comment; |
||
81 | } |
||
82 | |||
921 | dev | 83 | protected void setComment(String comment) |
919 | dev | 84 | { |
85 | this.comment = comment; |
||
86 | } |
||
87 | |||
88 | public void setComment(User editor, String comment) |
||
89 | throws ModelException |
||
90 | { |
||
91 | if(!editableBy(editor)) |
||
92 | throw new ModelSecurityException(); |
||
93 | |||
94 | this.comment = comment; |
||
95 | } |
||
96 | |||
97 | /** |
||
98 | * |
||
99 | * @hibernate.timestamp column="mod_stamp" |
||
100 | */ |
||
101 | public Date getModStamp() |
||
102 | { |
||
103 | return modStamp; |
||
104 | } |
||
105 | |||
106 | protected void setModStamp(Date modStamp) |
||
107 | { |
||
108 | this.modStamp = modStamp; |
||
109 | } |
||
110 | |||
111 | /** |
||
112 | * |
||
918 | dev | 113 | * @hibernate.many-to-one column="mod_user" |
114 | */ |
||
115 | public User getModUser() |
||
116 | { |
||
117 | return modUser; |
||
118 | } |
||
119 | |||
120 | protected void setModUser(User modUser) |
||
121 | { |
||
122 | this.modUser = modUser; |
||
123 | } |
||
919 | dev | 124 | } |