1
22
23 package com.liferay.portlet.messageboards.model.impl;
24
25 import com.liferay.portal.kernel.util.DateUtil;
26 import com.liferay.portal.kernel.util.GetterUtil;
27 import com.liferay.portal.model.impl.BaseModelImpl;
28 import com.liferay.portal.util.PropsUtil;
29
30 import com.liferay.util.XSSUtil;
31
32 import java.io.Serializable;
33
34 import java.sql.Types;
35
36 import java.util.Date;
37
38
58 public class MBMessageModelImpl extends BaseModelImpl {
59 public static String TABLE_NAME = "MBMessage";
60 public static Object[][] TABLE_COLUMNS = {
61 { "messageId", new Integer(Types.BIGINT) },
62 { "companyId", new Integer(Types.BIGINT) },
63 { "userId", new Integer(Types.BIGINT) },
64 { "userName", new Integer(Types.VARCHAR) },
65 { "createDate", new Integer(Types.TIMESTAMP) },
66 { "modifiedDate", new Integer(Types.TIMESTAMP) },
67 { "categoryId", new Integer(Types.BIGINT) },
68 { "threadId", new Integer(Types.BIGINT) },
69 { "parentMessageId", new Integer(Types.BIGINT) },
70 { "subject", new Integer(Types.VARCHAR) },
71 { "body", new Integer(Types.CLOB) },
72 { "attachments", new Integer(Types.BOOLEAN) },
73 { "anonymous", new Integer(Types.BOOLEAN) }
74 };
75 public static String TABLE_SQL_CREATE = "create table MBMessage (messageId LONG not null primary key,companyId LONG,userId LONG,userName VARCHAR(75) null,createDate DATE null,modifiedDate DATE null,categoryId LONG,threadId LONG,parentMessageId LONG,subject VARCHAR(75) null,body TEXT null,attachments BOOLEAN,anonymous BOOLEAN)";
76 public static String TABLE_SQL_DROP = "drop table MBMessage";
77 public static boolean XSS_ALLOW_BY_MODEL = GetterUtil.getBoolean(PropsUtil.get(
78 "xss.allow.com.liferay.portlet.messageboards.model.MBMessage"),
79 XSS_ALLOW);
80 public static boolean XSS_ALLOW_USERNAME = GetterUtil.getBoolean(PropsUtil.get(
81 "xss.allow.com.liferay.portlet.messageboards.model.MBMessage.userName"),
82 XSS_ALLOW_BY_MODEL);
83 public static boolean XSS_ALLOW_SUBJECT = GetterUtil.getBoolean(PropsUtil.get(
84 "xss.allow.com.liferay.portlet.messageboards.model.MBMessage.subject"),
85 XSS_ALLOW_BY_MODEL);
86 public static boolean XSS_ALLOW_BODY = GetterUtil.getBoolean(PropsUtil.get(
87 "xss.allow.com.liferay.portlet.messageboards.model.MBMessage.body"),
88 XSS_ALLOW_BY_MODEL);
89 public static long LOCK_EXPIRATION_TIME = GetterUtil.getLong(PropsUtil.get(
90 "lock.expiration.time.com.liferay.portlet.messageboards.model.MBMessageModel"));
91
92 public MBMessageModelImpl() {
93 }
94
95 public long getPrimaryKey() {
96 return _messageId;
97 }
98
99 public void setPrimaryKey(long pk) {
100 setMessageId(pk);
101 }
102
103 public Serializable getPrimaryKeyObj() {
104 return new Long(_messageId);
105 }
106
107 public long getMessageId() {
108 return _messageId;
109 }
110
111 public void setMessageId(long messageId) {
112 if (messageId != _messageId) {
113 _messageId = messageId;
114 }
115 }
116
117 public long getCompanyId() {
118 return _companyId;
119 }
120
121 public void setCompanyId(long companyId) {
122 if (companyId != _companyId) {
123 _companyId = companyId;
124 }
125 }
126
127 public long getUserId() {
128 return _userId;
129 }
130
131 public void setUserId(long userId) {
132 if (userId != _userId) {
133 _userId = userId;
134 }
135 }
136
137 public String getUserName() {
138 return GetterUtil.getString(_userName);
139 }
140
141 public void setUserName(String userName) {
142 if (((userName == null) && (_userName != null)) ||
143 ((userName != null) && (_userName == null)) ||
144 ((userName != null) && (_userName != null) &&
145 !userName.equals(_userName))) {
146 if (!XSS_ALLOW_USERNAME) {
147 userName = XSSUtil.strip(userName);
148 }
149
150 _userName = userName;
151 }
152 }
153
154 public Date getCreateDate() {
155 return _createDate;
156 }
157
158 public void setCreateDate(Date createDate) {
159 if (((createDate == null) && (_createDate != null)) ||
160 ((createDate != null) && (_createDate == null)) ||
161 ((createDate != null) && (_createDate != null) &&
162 !createDate.equals(_createDate))) {
163 _createDate = createDate;
164 }
165 }
166
167 public Date getModifiedDate() {
168 return _modifiedDate;
169 }
170
171 public void setModifiedDate(Date modifiedDate) {
172 if (((modifiedDate == null) && (_modifiedDate != null)) ||
173 ((modifiedDate != null) && (_modifiedDate == null)) ||
174 ((modifiedDate != null) && (_modifiedDate != null) &&
175 !modifiedDate.equals(_modifiedDate))) {
176 _modifiedDate = modifiedDate;
177 }
178 }
179
180 public long getCategoryId() {
181 return _categoryId;
182 }
183
184 public void setCategoryId(long categoryId) {
185 if (categoryId != _categoryId) {
186 _categoryId = categoryId;
187 }
188 }
189
190 public long getThreadId() {
191 return _threadId;
192 }
193
194 public void setThreadId(long threadId) {
195 if (threadId != _threadId) {
196 _threadId = threadId;
197 }
198 }
199
200 public long getParentMessageId() {
201 return _parentMessageId;
202 }
203
204 public void setParentMessageId(long parentMessageId) {
205 if (parentMessageId != _parentMessageId) {
206 _parentMessageId = parentMessageId;
207 }
208 }
209
210 public String getSubject() {
211 return GetterUtil.getString(_subject);
212 }
213
214 public void setSubject(String subject) {
215 if (((subject == null) && (_subject != null)) ||
216 ((subject != null) && (_subject == null)) ||
217 ((subject != null) && (_subject != null) &&
218 !subject.equals(_subject))) {
219 if (!XSS_ALLOW_SUBJECT) {
220 subject = XSSUtil.strip(subject);
221 }
222
223 _subject = subject;
224 }
225 }
226
227 public String getBody() {
228 return GetterUtil.getString(_body);
229 }
230
231 public void setBody(String body) {
232 if (((body == null) && (_body != null)) ||
233 ((body != null) && (_body == null)) ||
234 ((body != null) && (_body != null) && !body.equals(_body))) {
235 if (!XSS_ALLOW_BODY) {
236 body = XSSUtil.strip(body);
237 }
238
239 _body = body;
240 }
241 }
242
243 public boolean getAttachments() {
244 return _attachments;
245 }
246
247 public boolean isAttachments() {
248 return _attachments;
249 }
250
251 public void setAttachments(boolean attachments) {
252 if (attachments != _attachments) {
253 _attachments = attachments;
254 }
255 }
256
257 public boolean getAnonymous() {
258 return _anonymous;
259 }
260
261 public boolean isAnonymous() {
262 return _anonymous;
263 }
264
265 public void setAnonymous(boolean anonymous) {
266 if (anonymous != _anonymous) {
267 _anonymous = anonymous;
268 }
269 }
270
271 public Object clone() {
272 MBMessageImpl clone = new MBMessageImpl();
273 clone.setMessageId(getMessageId());
274 clone.setCompanyId(getCompanyId());
275 clone.setUserId(getUserId());
276 clone.setUserName(getUserName());
277 clone.setCreateDate(getCreateDate());
278 clone.setModifiedDate(getModifiedDate());
279 clone.setCategoryId(getCategoryId());
280 clone.setThreadId(getThreadId());
281 clone.setParentMessageId(getParentMessageId());
282 clone.setSubject(getSubject());
283 clone.setBody(getBody());
284 clone.setAttachments(getAttachments());
285 clone.setAnonymous(getAnonymous());
286
287 return clone;
288 }
289
290 public int compareTo(Object obj) {
291 if (obj == null) {
292 return -1;
293 }
294
295 MBMessageImpl mbMessage = (MBMessageImpl)obj;
296 int value = 0;
297 value = DateUtil.compareTo(getCreateDate(), mbMessage.getCreateDate());
298
299 if (value != 0) {
300 return value;
301 }
302
303 if (getMessageId() < mbMessage.getMessageId()) {
304 value = -1;
305 }
306 else if (getMessageId() > mbMessage.getMessageId()) {
307 value = 1;
308 }
309 else {
310 value = 0;
311 }
312
313 if (value != 0) {
314 return value;
315 }
316
317 return 0;
318 }
319
320 public boolean equals(Object obj) {
321 if (obj == null) {
322 return false;
323 }
324
325 MBMessageImpl mbMessage = null;
326
327 try {
328 mbMessage = (MBMessageImpl)obj;
329 }
330 catch (ClassCastException cce) {
331 return false;
332 }
333
334 long pk = mbMessage.getPrimaryKey();
335
336 if (getPrimaryKey() == pk) {
337 return true;
338 }
339 else {
340 return false;
341 }
342 }
343
344 public int hashCode() {
345 return (int)getPrimaryKey();
346 }
347
348 private long _messageId;
349 private long _companyId;
350 private long _userId;
351 private String _userName;
352 private Date _createDate;
353 private Date _modifiedDate;
354 private long _categoryId;
355 private long _threadId;
356 private long _parentMessageId;
357 private String _subject;
358 private String _body;
359 private boolean _attachments;
360 private boolean _anonymous;
361 }