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