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.setNew(isNew());
336 model.setEscapedModel(true);
337
338 model.setUuid(HtmlUtil.escape(getUuid()));
339 model.setMessageId(getMessageId());
340 model.setCompanyId(getCompanyId());
341 model.setUserId(getUserId());
342 model.setUserName(HtmlUtil.escape(getUserName()));
343 model.setCreateDate(getCreateDate());
344 model.setModifiedDate(getModifiedDate());
345 model.setCategoryId(getCategoryId());
346 model.setThreadId(getThreadId());
347 model.setParentMessageId(getParentMessageId());
348 model.setSubject(HtmlUtil.escape(getSubject()));
349 model.setBody(HtmlUtil.escape(getBody()));
350 model.setAttachments(getAttachments());
351 model.setAnonymous(getAnonymous());
352
353 model = (MBMessage)Proxy.newProxyInstance(MBMessage.class.getClassLoader(),
354 new Class[] { MBMessage.class },
355 new ReadOnlyBeanHandler(model));
356
357 return model;
358 }
359 }
360
361 public Object clone() {
362 MBMessageImpl clone = new MBMessageImpl();
363
364 clone.setUuid(getUuid());
365 clone.setMessageId(getMessageId());
366 clone.setCompanyId(getCompanyId());
367 clone.setUserId(getUserId());
368 clone.setUserName(getUserName());
369 clone.setCreateDate(getCreateDate());
370 clone.setModifiedDate(getModifiedDate());
371 clone.setCategoryId(getCategoryId());
372 clone.setThreadId(getThreadId());
373 clone.setParentMessageId(getParentMessageId());
374 clone.setSubject(getSubject());
375 clone.setBody(getBody());
376 clone.setAttachments(getAttachments());
377 clone.setAnonymous(getAnonymous());
378
379 return clone;
380 }
381
382 public int compareTo(Object obj) {
383 if (obj == null) {
384 return -1;
385 }
386
387 MBMessageImpl mbMessage = (MBMessageImpl)obj;
388
389 int value = 0;
390
391 value = DateUtil.compareTo(getCreateDate(), mbMessage.getCreateDate());
392
393 if (value != 0) {
394 return value;
395 }
396
397 if (getMessageId() < mbMessage.getMessageId()) {
398 value = -1;
399 }
400 else if (getMessageId() > mbMessage.getMessageId()) {
401 value = 1;
402 }
403 else {
404 value = 0;
405 }
406
407 if (value != 0) {
408 return value;
409 }
410
411 return 0;
412 }
413
414 public boolean equals(Object obj) {
415 if (obj == null) {
416 return false;
417 }
418
419 MBMessageImpl mbMessage = null;
420
421 try {
422 mbMessage = (MBMessageImpl)obj;
423 }
424 catch (ClassCastException cce) {
425 return false;
426 }
427
428 long pk = mbMessage.getPrimaryKey();
429
430 if (getPrimaryKey() == pk) {
431 return true;
432 }
433 else {
434 return false;
435 }
436 }
437
438 public int hashCode() {
439 return (int)getPrimaryKey();
440 }
441
442 private String _uuid;
443 private long _messageId;
444 private long _companyId;
445 private long _userId;
446 private String _userName;
447 private Date _createDate;
448 private Date _modifiedDate;
449 private long _categoryId;
450 private long _threadId;
451 private long _parentMessageId;
452 private String _subject;
453 private String _body;
454 private boolean _attachments;
455 private boolean _anonymous;
456 }