001
014
015 package com.liferay.portlet.messageboards.model.impl;
016
017 import com.liferay.portal.kernel.bean.AutoEscapeBeanHandler;
018 import com.liferay.portal.kernel.exception.SystemException;
019 import com.liferay.portal.kernel.util.DateUtil;
020 import com.liferay.portal.kernel.util.GetterUtil;
021 import com.liferay.portal.kernel.util.StringBundler;
022 import com.liferay.portal.kernel.util.StringPool;
023 import com.liferay.portal.kernel.workflow.WorkflowConstants;
024 import com.liferay.portal.model.impl.BaseModelImpl;
025 import com.liferay.portal.service.ServiceContext;
026 import com.liferay.portal.util.PortalUtil;
027
028 import com.liferay.portlet.expando.model.ExpandoBridge;
029 import com.liferay.portlet.expando.util.ExpandoBridgeFactoryUtil;
030 import com.liferay.portlet.messageboards.model.MBMessage;
031 import com.liferay.portlet.messageboards.model.MBMessageModel;
032 import com.liferay.portlet.messageboards.model.MBMessageSoap;
033
034 import java.io.Serializable;
035
036 import java.lang.reflect.Proxy;
037
038 import java.sql.Types;
039
040 import java.util.ArrayList;
041 import java.util.Date;
042 import java.util.List;
043
044
061 public class MBMessageModelImpl extends BaseModelImpl<MBMessage>
062 implements MBMessageModel {
063 public static final String TABLE_NAME = "MBMessage";
064 public static final Object[][] TABLE_COLUMNS = {
065 { "uuid_", new Integer(Types.VARCHAR) },
066 { "messageId", new Integer(Types.BIGINT) },
067 { "groupId", new Integer(Types.BIGINT) },
068 { "companyId", new Integer(Types.BIGINT) },
069 { "userId", new Integer(Types.BIGINT) },
070 { "userName", new Integer(Types.VARCHAR) },
071 { "createDate", new Integer(Types.TIMESTAMP) },
072 { "modifiedDate", new Integer(Types.TIMESTAMP) },
073 { "classNameId", new Integer(Types.BIGINT) },
074 { "classPK", new Integer(Types.BIGINT) },
075 { "categoryId", new Integer(Types.BIGINT) },
076 { "threadId", new Integer(Types.BIGINT) },
077 { "rootMessageId", new Integer(Types.BIGINT) },
078 { "parentMessageId", new Integer(Types.BIGINT) },
079 { "subject", new Integer(Types.VARCHAR) },
080 { "body", new Integer(Types.CLOB) },
081 { "attachments", new Integer(Types.BOOLEAN) },
082 { "anonymous", new Integer(Types.BOOLEAN) },
083 { "priority", new Integer(Types.DOUBLE) },
084 { "allowPingbacks", new Integer(Types.BOOLEAN) },
085 { "status", new Integer(Types.INTEGER) },
086 { "statusByUserId", new Integer(Types.BIGINT) },
087 { "statusByUserName", new Integer(Types.VARCHAR) },
088 { "statusDate", new Integer(Types.TIMESTAMP) }
089 };
090 public static final String TABLE_SQL_CREATE = "create table MBMessage (uuid_ VARCHAR(75) null,messageId LONG not null primary key,groupId LONG,companyId LONG,userId LONG,userName VARCHAR(75) null,createDate DATE null,modifiedDate DATE null,classNameId LONG,classPK LONG,categoryId LONG,threadId LONG,rootMessageId LONG,parentMessageId LONG,subject VARCHAR(75) null,body TEXT null,attachments BOOLEAN,anonymous BOOLEAN,priority DOUBLE,allowPingbacks BOOLEAN,status INTEGER,statusByUserId LONG,statusByUserName VARCHAR(75) null,statusDate DATE null)";
091 public static final String TABLE_SQL_DROP = "drop table MBMessage";
092 public static final String ORDER_BY_JPQL = " ORDER BY mbMessage.createDate ASC, mbMessage.messageId ASC";
093 public static final String ORDER_BY_SQL = " ORDER BY MBMessage.createDate ASC, MBMessage.messageId ASC";
094 public static final String DATA_SOURCE = "liferayDataSource";
095 public static final String SESSION_FACTORY = "liferaySessionFactory";
096 public static final String TX_MANAGER = "liferayTransactionManager";
097 public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
098 "value.object.entity.cache.enabled.com.liferay.portlet.messageboards.model.MBMessage"),
099 true);
100 public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
101 "value.object.finder.cache.enabled.com.liferay.portlet.messageboards.model.MBMessage"),
102 true);
103
104
110 public static MBMessage toModel(MBMessageSoap soapModel) {
111 MBMessage model = new MBMessageImpl();
112
113 model.setUuid(soapModel.getUuid());
114 model.setMessageId(soapModel.getMessageId());
115 model.setGroupId(soapModel.getGroupId());
116 model.setCompanyId(soapModel.getCompanyId());
117 model.setUserId(soapModel.getUserId());
118 model.setUserName(soapModel.getUserName());
119 model.setCreateDate(soapModel.getCreateDate());
120 model.setModifiedDate(soapModel.getModifiedDate());
121 model.setClassNameId(soapModel.getClassNameId());
122 model.setClassPK(soapModel.getClassPK());
123 model.setCategoryId(soapModel.getCategoryId());
124 model.setThreadId(soapModel.getThreadId());
125 model.setRootMessageId(soapModel.getRootMessageId());
126 model.setParentMessageId(soapModel.getParentMessageId());
127 model.setSubject(soapModel.getSubject());
128 model.setBody(soapModel.getBody());
129 model.setAttachments(soapModel.getAttachments());
130 model.setAnonymous(soapModel.getAnonymous());
131 model.setPriority(soapModel.getPriority());
132 model.setAllowPingbacks(soapModel.getAllowPingbacks());
133 model.setStatus(soapModel.getStatus());
134 model.setStatusByUserId(soapModel.getStatusByUserId());
135 model.setStatusByUserName(soapModel.getStatusByUserName());
136 model.setStatusDate(soapModel.getStatusDate());
137
138 return model;
139 }
140
141
147 public static List<MBMessage> toModels(MBMessageSoap[] soapModels) {
148 List<MBMessage> models = new ArrayList<MBMessage>(soapModels.length);
149
150 for (MBMessageSoap soapModel : soapModels) {
151 models.add(toModel(soapModel));
152 }
153
154 return models;
155 }
156
157 public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
158 "lock.expiration.time.com.liferay.portlet.messageboards.model.MBMessage"));
159
160 public MBMessageModelImpl() {
161 }
162
163 public long getPrimaryKey() {
164 return _messageId;
165 }
166
167 public void setPrimaryKey(long pk) {
168 setMessageId(pk);
169 }
170
171 public Serializable getPrimaryKeyObj() {
172 return new Long(_messageId);
173 }
174
175 public String getUuid() {
176 if (_uuid == null) {
177 return StringPool.BLANK;
178 }
179 else {
180 return _uuid;
181 }
182 }
183
184 public void setUuid(String uuid) {
185 _uuid = uuid;
186
187 if (_originalUuid == null) {
188 _originalUuid = uuid;
189 }
190 }
191
192 public String getOriginalUuid() {
193 return GetterUtil.getString(_originalUuid);
194 }
195
196 public long getMessageId() {
197 return _messageId;
198 }
199
200 public void setMessageId(long messageId) {
201 _messageId = messageId;
202 }
203
204 public long getGroupId() {
205 return _groupId;
206 }
207
208 public void setGroupId(long groupId) {
209 _groupId = groupId;
210
211 if (!_setOriginalGroupId) {
212 _setOriginalGroupId = true;
213
214 _originalGroupId = groupId;
215 }
216 }
217
218 public long getOriginalGroupId() {
219 return _originalGroupId;
220 }
221
222 public long getCompanyId() {
223 return _companyId;
224 }
225
226 public void setCompanyId(long companyId) {
227 _companyId = companyId;
228 }
229
230 public long getUserId() {
231 return _userId;
232 }
233
234 public void setUserId(long userId) {
235 _userId = userId;
236 }
237
238 public String getUserUuid() throws SystemException {
239 return PortalUtil.getUserValue(getUserId(), "uuid", _userUuid);
240 }
241
242 public void setUserUuid(String userUuid) {
243 _userUuid = userUuid;
244 }
245
246 public String getUserName() {
247 if (_userName == null) {
248 return StringPool.BLANK;
249 }
250 else {
251 return _userName;
252 }
253 }
254
255 public void setUserName(String userName) {
256 _userName = userName;
257 }
258
259 public Date getCreateDate() {
260 return _createDate;
261 }
262
263 public void setCreateDate(Date createDate) {
264 _createDate = createDate;
265 }
266
267 public Date getModifiedDate() {
268 return _modifiedDate;
269 }
270
271 public void setModifiedDate(Date modifiedDate) {
272 _modifiedDate = modifiedDate;
273 }
274
275 public String getClassName() {
276 if (getClassNameId() <= 0) {
277 return StringPool.BLANK;
278 }
279
280 return PortalUtil.getClassName(getClassNameId());
281 }
282
283 public long getClassNameId() {
284 return _classNameId;
285 }
286
287 public void setClassNameId(long classNameId) {
288 _classNameId = classNameId;
289 }
290
291 public long getClassPK() {
292 return _classPK;
293 }
294
295 public void setClassPK(long classPK) {
296 _classPK = classPK;
297 }
298
299 public long getCategoryId() {
300 return _categoryId;
301 }
302
303 public void setCategoryId(long categoryId) {
304 _categoryId = categoryId;
305 }
306
307 public long getThreadId() {
308 return _threadId;
309 }
310
311 public void setThreadId(long threadId) {
312 _threadId = threadId;
313 }
314
315 public long getRootMessageId() {
316 return _rootMessageId;
317 }
318
319 public void setRootMessageId(long rootMessageId) {
320 _rootMessageId = rootMessageId;
321 }
322
323 public long getParentMessageId() {
324 return _parentMessageId;
325 }
326
327 public void setParentMessageId(long parentMessageId) {
328 _parentMessageId = parentMessageId;
329 }
330
331 public String getSubject() {
332 if (_subject == null) {
333 return StringPool.BLANK;
334 }
335 else {
336 return _subject;
337 }
338 }
339
340 public void setSubject(String subject) {
341 _subject = subject;
342 }
343
344 public String getBody() {
345 if (_body == null) {
346 return StringPool.BLANK;
347 }
348 else {
349 return _body;
350 }
351 }
352
353 public void setBody(String body) {
354 _body = body;
355 }
356
357 public boolean getAttachments() {
358 return _attachments;
359 }
360
361 public boolean isAttachments() {
362 return _attachments;
363 }
364
365 public void setAttachments(boolean attachments) {
366 _attachments = attachments;
367 }
368
369 public boolean getAnonymous() {
370 return _anonymous;
371 }
372
373 public boolean isAnonymous() {
374 return _anonymous;
375 }
376
377 public void setAnonymous(boolean anonymous) {
378 _anonymous = anonymous;
379 }
380
381 public double getPriority() {
382 return _priority;
383 }
384
385 public void setPriority(double priority) {
386 _priority = priority;
387 }
388
389 public boolean getAllowPingbacks() {
390 return _allowPingbacks;
391 }
392
393 public boolean isAllowPingbacks() {
394 return _allowPingbacks;
395 }
396
397 public void setAllowPingbacks(boolean allowPingbacks) {
398 _allowPingbacks = allowPingbacks;
399 }
400
401 public int getStatus() {
402 return _status;
403 }
404
405 public void setStatus(int status) {
406 _status = status;
407 }
408
409 public long getStatusByUserId() {
410 return _statusByUserId;
411 }
412
413 public void setStatusByUserId(long statusByUserId) {
414 _statusByUserId = statusByUserId;
415 }
416
417 public String getStatusByUserUuid() throws SystemException {
418 return PortalUtil.getUserValue(getStatusByUserId(), "uuid",
419 _statusByUserUuid);
420 }
421
422 public void setStatusByUserUuid(String statusByUserUuid) {
423 _statusByUserUuid = statusByUserUuid;
424 }
425
426 public String getStatusByUserName() {
427 if (_statusByUserName == null) {
428 return StringPool.BLANK;
429 }
430 else {
431 return _statusByUserName;
432 }
433 }
434
435 public void setStatusByUserName(String statusByUserName) {
436 _statusByUserName = statusByUserName;
437 }
438
439 public Date getStatusDate() {
440 return _statusDate;
441 }
442
443 public void setStatusDate(Date statusDate) {
444 _statusDate = statusDate;
445 }
446
447 public boolean isApproved() {
448 if (getStatus() == WorkflowConstants.STATUS_APPROVED) {
449 return true;
450 }
451 else {
452 return false;
453 }
454 }
455
456 public boolean isDraft() {
457 if (getStatus() == WorkflowConstants.STATUS_DRAFT) {
458 return true;
459 }
460 else {
461 return false;
462 }
463 }
464
465 public boolean isExpired() {
466 if (getStatus() == WorkflowConstants.STATUS_EXPIRED) {
467 return true;
468 }
469 else {
470 return false;
471 }
472 }
473
474 public boolean isPending() {
475 if (getStatus() == WorkflowConstants.STATUS_PENDING) {
476 return true;
477 }
478 else {
479 return false;
480 }
481 }
482
483 public MBMessage toEscapedModel() {
484 if (isEscapedModel()) {
485 return (MBMessage)this;
486 }
487 else {
488 return (MBMessage)Proxy.newProxyInstance(MBMessage.class.getClassLoader(),
489 new Class[] { MBMessage.class }, new AutoEscapeBeanHandler(this));
490 }
491 }
492
493 public ExpandoBridge getExpandoBridge() {
494 if (_expandoBridge == null) {
495 _expandoBridge = ExpandoBridgeFactoryUtil.getExpandoBridge(getCompanyId(),
496 MBMessage.class.getName(), getPrimaryKey());
497 }
498
499 return _expandoBridge;
500 }
501
502 public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
503 getExpandoBridge().setAttributes(serviceContext);
504 }
505
506 public Object clone() {
507 MBMessageImpl clone = new MBMessageImpl();
508
509 clone.setUuid(getUuid());
510 clone.setMessageId(getMessageId());
511 clone.setGroupId(getGroupId());
512 clone.setCompanyId(getCompanyId());
513 clone.setUserId(getUserId());
514 clone.setUserName(getUserName());
515 clone.setCreateDate(getCreateDate());
516 clone.setModifiedDate(getModifiedDate());
517 clone.setClassNameId(getClassNameId());
518 clone.setClassPK(getClassPK());
519 clone.setCategoryId(getCategoryId());
520 clone.setThreadId(getThreadId());
521 clone.setRootMessageId(getRootMessageId());
522 clone.setParentMessageId(getParentMessageId());
523 clone.setSubject(getSubject());
524 clone.setBody(getBody());
525 clone.setAttachments(getAttachments());
526 clone.setAnonymous(getAnonymous());
527 clone.setPriority(getPriority());
528 clone.setAllowPingbacks(getAllowPingbacks());
529 clone.setStatus(getStatus());
530 clone.setStatusByUserId(getStatusByUserId());
531 clone.setStatusByUserName(getStatusByUserName());
532 clone.setStatusDate(getStatusDate());
533
534 return clone;
535 }
536
537 public int compareTo(MBMessage mbMessage) {
538 int value = 0;
539
540 value = DateUtil.compareTo(getCreateDate(), mbMessage.getCreateDate());
541
542 if (value != 0) {
543 return value;
544 }
545
546 if (getMessageId() < mbMessage.getMessageId()) {
547 value = -1;
548 }
549 else if (getMessageId() > mbMessage.getMessageId()) {
550 value = 1;
551 }
552 else {
553 value = 0;
554 }
555
556 if (value != 0) {
557 return value;
558 }
559
560 return 0;
561 }
562
563 public boolean equals(Object obj) {
564 if (obj == null) {
565 return false;
566 }
567
568 MBMessage mbMessage = null;
569
570 try {
571 mbMessage = (MBMessage)obj;
572 }
573 catch (ClassCastException cce) {
574 return false;
575 }
576
577 long pk = mbMessage.getPrimaryKey();
578
579 if (getPrimaryKey() == pk) {
580 return true;
581 }
582 else {
583 return false;
584 }
585 }
586
587 public int hashCode() {
588 return (int)getPrimaryKey();
589 }
590
591 public String toString() {
592 StringBundler sb = new StringBundler(49);
593
594 sb.append("{uuid=");
595 sb.append(getUuid());
596 sb.append(", messageId=");
597 sb.append(getMessageId());
598 sb.append(", groupId=");
599 sb.append(getGroupId());
600 sb.append(", companyId=");
601 sb.append(getCompanyId());
602 sb.append(", userId=");
603 sb.append(getUserId());
604 sb.append(", userName=");
605 sb.append(getUserName());
606 sb.append(", createDate=");
607 sb.append(getCreateDate());
608 sb.append(", modifiedDate=");
609 sb.append(getModifiedDate());
610 sb.append(", classNameId=");
611 sb.append(getClassNameId());
612 sb.append(", classPK=");
613 sb.append(getClassPK());
614 sb.append(", categoryId=");
615 sb.append(getCategoryId());
616 sb.append(", threadId=");
617 sb.append(getThreadId());
618 sb.append(", rootMessageId=");
619 sb.append(getRootMessageId());
620 sb.append(", parentMessageId=");
621 sb.append(getParentMessageId());
622 sb.append(", subject=");
623 sb.append(getSubject());
624 sb.append(", body=");
625 sb.append(getBody());
626 sb.append(", attachments=");
627 sb.append(getAttachments());
628 sb.append(", anonymous=");
629 sb.append(getAnonymous());
630 sb.append(", priority=");
631 sb.append(getPriority());
632 sb.append(", allowPingbacks=");
633 sb.append(getAllowPingbacks());
634 sb.append(", status=");
635 sb.append(getStatus());
636 sb.append(", statusByUserId=");
637 sb.append(getStatusByUserId());
638 sb.append(", statusByUserName=");
639 sb.append(getStatusByUserName());
640 sb.append(", statusDate=");
641 sb.append(getStatusDate());
642 sb.append("}");
643
644 return sb.toString();
645 }
646
647 public String toXmlString() {
648 StringBundler sb = new StringBundler(76);
649
650 sb.append("<model><model-name>");
651 sb.append("com.liferay.portlet.messageboards.model.MBMessage");
652 sb.append("</model-name>");
653
654 sb.append(
655 "<column><column-name>uuid</column-name><column-value><![CDATA[");
656 sb.append(getUuid());
657 sb.append("]]></column-value></column>");
658 sb.append(
659 "<column><column-name>messageId</column-name><column-value><![CDATA[");
660 sb.append(getMessageId());
661 sb.append("]]></column-value></column>");
662 sb.append(
663 "<column><column-name>groupId</column-name><column-value><![CDATA[");
664 sb.append(getGroupId());
665 sb.append("]]></column-value></column>");
666 sb.append(
667 "<column><column-name>companyId</column-name><column-value><![CDATA[");
668 sb.append(getCompanyId());
669 sb.append("]]></column-value></column>");
670 sb.append(
671 "<column><column-name>userId</column-name><column-value><![CDATA[");
672 sb.append(getUserId());
673 sb.append("]]></column-value></column>");
674 sb.append(
675 "<column><column-name>userName</column-name><column-value><![CDATA[");
676 sb.append(getUserName());
677 sb.append("]]></column-value></column>");
678 sb.append(
679 "<column><column-name>createDate</column-name><column-value><![CDATA[");
680 sb.append(getCreateDate());
681 sb.append("]]></column-value></column>");
682 sb.append(
683 "<column><column-name>modifiedDate</column-name><column-value><![CDATA[");
684 sb.append(getModifiedDate());
685 sb.append("]]></column-value></column>");
686 sb.append(
687 "<column><column-name>classNameId</column-name><column-value><![CDATA[");
688 sb.append(getClassNameId());
689 sb.append("]]></column-value></column>");
690 sb.append(
691 "<column><column-name>classPK</column-name><column-value><![CDATA[");
692 sb.append(getClassPK());
693 sb.append("]]></column-value></column>");
694 sb.append(
695 "<column><column-name>categoryId</column-name><column-value><![CDATA[");
696 sb.append(getCategoryId());
697 sb.append("]]></column-value></column>");
698 sb.append(
699 "<column><column-name>threadId</column-name><column-value><![CDATA[");
700 sb.append(getThreadId());
701 sb.append("]]></column-value></column>");
702 sb.append(
703 "<column><column-name>rootMessageId</column-name><column-value><![CDATA[");
704 sb.append(getRootMessageId());
705 sb.append("]]></column-value></column>");
706 sb.append(
707 "<column><column-name>parentMessageId</column-name><column-value><![CDATA[");
708 sb.append(getParentMessageId());
709 sb.append("]]></column-value></column>");
710 sb.append(
711 "<column><column-name>subject</column-name><column-value><![CDATA[");
712 sb.append(getSubject());
713 sb.append("]]></column-value></column>");
714 sb.append(
715 "<column><column-name>body</column-name><column-value><![CDATA[");
716 sb.append(getBody());
717 sb.append("]]></column-value></column>");
718 sb.append(
719 "<column><column-name>attachments</column-name><column-value><![CDATA[");
720 sb.append(getAttachments());
721 sb.append("]]></column-value></column>");
722 sb.append(
723 "<column><column-name>anonymous</column-name><column-value><![CDATA[");
724 sb.append(getAnonymous());
725 sb.append("]]></column-value></column>");
726 sb.append(
727 "<column><column-name>priority</column-name><column-value><![CDATA[");
728 sb.append(getPriority());
729 sb.append("]]></column-value></column>");
730 sb.append(
731 "<column><column-name>allowPingbacks</column-name><column-value><![CDATA[");
732 sb.append(getAllowPingbacks());
733 sb.append("]]></column-value></column>");
734 sb.append(
735 "<column><column-name>status</column-name><column-value><![CDATA[");
736 sb.append(getStatus());
737 sb.append("]]></column-value></column>");
738 sb.append(
739 "<column><column-name>statusByUserId</column-name><column-value><![CDATA[");
740 sb.append(getStatusByUserId());
741 sb.append("]]></column-value></column>");
742 sb.append(
743 "<column><column-name>statusByUserName</column-name><column-value><![CDATA[");
744 sb.append(getStatusByUserName());
745 sb.append("]]></column-value></column>");
746 sb.append(
747 "<column><column-name>statusDate</column-name><column-value><![CDATA[");
748 sb.append(getStatusDate());
749 sb.append("]]></column-value></column>");
750
751 sb.append("</model>");
752
753 return sb.toString();
754 }
755
756 private String _uuid;
757 private String _originalUuid;
758 private long _messageId;
759 private long _groupId;
760 private long _originalGroupId;
761 private boolean _setOriginalGroupId;
762 private long _companyId;
763 private long _userId;
764 private String _userUuid;
765 private String _userName;
766 private Date _createDate;
767 private Date _modifiedDate;
768 private long _classNameId;
769 private long _classPK;
770 private long _categoryId;
771 private long _threadId;
772 private long _rootMessageId;
773 private long _parentMessageId;
774 private String _subject;
775 private String _body;
776 private boolean _attachments;
777 private boolean _anonymous;
778 private double _priority;
779 private boolean _allowPingbacks;
780 private int _status;
781 private long _statusByUserId;
782 private String _statusByUserUuid;
783 private String _statusByUserName;
784 private Date _statusDate;
785 private transient ExpandoBridge _expandoBridge;
786 }