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