001
014
015 package com.liferay.portlet.messageboards.model.impl;
016
017 import aQute.bnd.annotation.ProviderType;
018
019 import com.liferay.portal.NoSuchModelException;
020 import com.liferay.portal.kernel.bean.AutoEscapeBeanHandler;
021 import com.liferay.portal.kernel.exception.PortalException;
022 import com.liferay.portal.kernel.json.JSON;
023 import com.liferay.portal.kernel.lar.StagedModelType;
024 import com.liferay.portal.kernel.trash.TrashHandler;
025 import com.liferay.portal.kernel.trash.TrashHandlerRegistryUtil;
026 import com.liferay.portal.kernel.util.DateUtil;
027 import com.liferay.portal.kernel.util.GetterUtil;
028 import com.liferay.portal.kernel.util.ProxyUtil;
029 import com.liferay.portal.kernel.util.StringBundler;
030 import com.liferay.portal.kernel.util.StringPool;
031 import com.liferay.portal.kernel.util.Validator;
032 import com.liferay.portal.kernel.workflow.WorkflowConstants;
033 import com.liferay.portal.model.CacheModel;
034 import com.liferay.portal.model.ContainerModel;
035 import com.liferay.portal.model.TrashedModel;
036 import com.liferay.portal.model.User;
037 import com.liferay.portal.model.impl.BaseModelImpl;
038 import com.liferay.portal.service.ServiceContext;
039 import com.liferay.portal.service.UserLocalServiceUtil;
040 import com.liferay.portal.util.PortalUtil;
041
042 import com.liferay.portlet.expando.model.ExpandoBridge;
043 import com.liferay.portlet.expando.util.ExpandoBridgeFactoryUtil;
044 import com.liferay.portlet.messageboards.model.MBThread;
045 import com.liferay.portlet.messageboards.model.MBThreadModel;
046 import com.liferay.portlet.messageboards.model.MBThreadSoap;
047 import com.liferay.portlet.trash.model.TrashEntry;
048 import com.liferay.portlet.trash.service.TrashEntryLocalServiceUtil;
049
050 import java.io.Serializable;
051
052 import java.sql.Types;
053
054 import java.util.ArrayList;
055 import java.util.Date;
056 import java.util.HashMap;
057 import java.util.List;
058 import java.util.Map;
059
060
073 @JSON(strict = true)
074 @ProviderType
075 public class MBThreadModelImpl extends BaseModelImpl<MBThread>
076 implements MBThreadModel {
077
082 public static final String TABLE_NAME = "MBThread";
083 public static final Object[][] TABLE_COLUMNS = {
084 { "uuid_", Types.VARCHAR },
085 { "threadId", Types.BIGINT },
086 { "groupId", Types.BIGINT },
087 { "companyId", Types.BIGINT },
088 { "userId", Types.BIGINT },
089 { "userName", Types.VARCHAR },
090 { "createDate", Types.TIMESTAMP },
091 { "modifiedDate", Types.TIMESTAMP },
092 { "categoryId", Types.BIGINT },
093 { "rootMessageId", Types.BIGINT },
094 { "rootMessageUserId", Types.BIGINT },
095 { "messageCount", Types.INTEGER },
096 { "viewCount", Types.INTEGER },
097 { "lastPostByUserId", Types.BIGINT },
098 { "lastPostDate", Types.TIMESTAMP },
099 { "priority", Types.DOUBLE },
100 { "question", Types.BOOLEAN },
101 { "status", Types.INTEGER },
102 { "statusByUserId", Types.BIGINT },
103 { "statusByUserName", Types.VARCHAR },
104 { "statusDate", Types.TIMESTAMP }
105 };
106 public static final String TABLE_SQL_CREATE = "create table MBThread (uuid_ VARCHAR(75) null,threadId LONG not null primary key,groupId LONG,companyId LONG,userId LONG,userName VARCHAR(75) null,createDate DATE null,modifiedDate DATE null,categoryId LONG,rootMessageId LONG,rootMessageUserId LONG,messageCount INTEGER,viewCount INTEGER,lastPostByUserId LONG,lastPostDate DATE null,priority DOUBLE,question BOOLEAN,status INTEGER,statusByUserId LONG,statusByUserName VARCHAR(75) null,statusDate DATE null)";
107 public static final String TABLE_SQL_DROP = "drop table MBThread";
108 public static final String ORDER_BY_JPQL = " ORDER BY mbThread.priority DESC, mbThread.lastPostDate DESC";
109 public static final String ORDER_BY_SQL = " ORDER BY MBThread.priority DESC, MBThread.lastPostDate DESC";
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 ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
114 "value.object.entity.cache.enabled.com.liferay.portlet.messageboards.model.MBThread"),
115 true);
116 public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
117 "value.object.finder.cache.enabled.com.liferay.portlet.messageboards.model.MBThread"),
118 true);
119 public static final boolean COLUMN_BITMASK_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
120 "value.object.column.bitmask.enabled.com.liferay.portlet.messageboards.model.MBThread"),
121 true);
122 public static final long CATEGORYID_COLUMN_BITMASK = 1L;
123 public static final long COMPANYID_COLUMN_BITMASK = 2L;
124 public static final long GROUPID_COLUMN_BITMASK = 4L;
125 public static final long LASTPOSTDATE_COLUMN_BITMASK = 8L;
126 public static final long PRIORITY_COLUMN_BITMASK = 16L;
127 public static final long ROOTMESSAGEID_COLUMN_BITMASK = 32L;
128 public static final long STATUS_COLUMN_BITMASK = 64L;
129 public static final long UUID_COLUMN_BITMASK = 128L;
130
131
137 public static MBThread toModel(MBThreadSoap soapModel) {
138 if (soapModel == null) {
139 return null;
140 }
141
142 MBThread model = new MBThreadImpl();
143
144 model.setUuid(soapModel.getUuid());
145 model.setThreadId(soapModel.getThreadId());
146 model.setGroupId(soapModel.getGroupId());
147 model.setCompanyId(soapModel.getCompanyId());
148 model.setUserId(soapModel.getUserId());
149 model.setUserName(soapModel.getUserName());
150 model.setCreateDate(soapModel.getCreateDate());
151 model.setModifiedDate(soapModel.getModifiedDate());
152 model.setCategoryId(soapModel.getCategoryId());
153 model.setRootMessageId(soapModel.getRootMessageId());
154 model.setRootMessageUserId(soapModel.getRootMessageUserId());
155 model.setMessageCount(soapModel.getMessageCount());
156 model.setViewCount(soapModel.getViewCount());
157 model.setLastPostByUserId(soapModel.getLastPostByUserId());
158 model.setLastPostDate(soapModel.getLastPostDate());
159 model.setPriority(soapModel.getPriority());
160 model.setQuestion(soapModel.getQuestion());
161 model.setStatus(soapModel.getStatus());
162 model.setStatusByUserId(soapModel.getStatusByUserId());
163 model.setStatusByUserName(soapModel.getStatusByUserName());
164 model.setStatusDate(soapModel.getStatusDate());
165
166 return model;
167 }
168
169
175 public static List<MBThread> toModels(MBThreadSoap[] soapModels) {
176 if (soapModels == null) {
177 return null;
178 }
179
180 List<MBThread> models = new ArrayList<MBThread>(soapModels.length);
181
182 for (MBThreadSoap soapModel : soapModels) {
183 models.add(toModel(soapModel));
184 }
185
186 return models;
187 }
188
189 public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
190 "lock.expiration.time.com.liferay.portlet.messageboards.model.MBThread"));
191
192 public MBThreadModelImpl() {
193 }
194
195 @Override
196 public long getPrimaryKey() {
197 return _threadId;
198 }
199
200 @Override
201 public void setPrimaryKey(long primaryKey) {
202 setThreadId(primaryKey);
203 }
204
205 @Override
206 public Serializable getPrimaryKeyObj() {
207 return _threadId;
208 }
209
210 @Override
211 public void setPrimaryKeyObj(Serializable primaryKeyObj) {
212 setPrimaryKey(((Long)primaryKeyObj).longValue());
213 }
214
215 @Override
216 public Class<?> getModelClass() {
217 return MBThread.class;
218 }
219
220 @Override
221 public String getModelClassName() {
222 return MBThread.class.getName();
223 }
224
225 @Override
226 public Map<String, Object> getModelAttributes() {
227 Map<String, Object> attributes = new HashMap<String, Object>();
228
229 attributes.put("uuid", getUuid());
230 attributes.put("threadId", getThreadId());
231 attributes.put("groupId", getGroupId());
232 attributes.put("companyId", getCompanyId());
233 attributes.put("userId", getUserId());
234 attributes.put("userName", getUserName());
235 attributes.put("createDate", getCreateDate());
236 attributes.put("modifiedDate", getModifiedDate());
237 attributes.put("categoryId", getCategoryId());
238 attributes.put("rootMessageId", getRootMessageId());
239 attributes.put("rootMessageUserId", getRootMessageUserId());
240 attributes.put("messageCount", getMessageCount());
241 attributes.put("viewCount", getViewCount());
242 attributes.put("lastPostByUserId", getLastPostByUserId());
243 attributes.put("lastPostDate", getLastPostDate());
244 attributes.put("priority", getPriority());
245 attributes.put("question", getQuestion());
246 attributes.put("status", getStatus());
247 attributes.put("statusByUserId", getStatusByUserId());
248 attributes.put("statusByUserName", getStatusByUserName());
249 attributes.put("statusDate", getStatusDate());
250
251 attributes.put("entityCacheEnabled", isEntityCacheEnabled());
252 attributes.put("finderCacheEnabled", isFinderCacheEnabled());
253
254 return attributes;
255 }
256
257 @Override
258 public void setModelAttributes(Map<String, Object> attributes) {
259 String uuid = (String)attributes.get("uuid");
260
261 if (uuid != null) {
262 setUuid(uuid);
263 }
264
265 Long threadId = (Long)attributes.get("threadId");
266
267 if (threadId != null) {
268 setThreadId(threadId);
269 }
270
271 Long groupId = (Long)attributes.get("groupId");
272
273 if (groupId != null) {
274 setGroupId(groupId);
275 }
276
277 Long companyId = (Long)attributes.get("companyId");
278
279 if (companyId != null) {
280 setCompanyId(companyId);
281 }
282
283 Long userId = (Long)attributes.get("userId");
284
285 if (userId != null) {
286 setUserId(userId);
287 }
288
289 String userName = (String)attributes.get("userName");
290
291 if (userName != null) {
292 setUserName(userName);
293 }
294
295 Date createDate = (Date)attributes.get("createDate");
296
297 if (createDate != null) {
298 setCreateDate(createDate);
299 }
300
301 Date modifiedDate = (Date)attributes.get("modifiedDate");
302
303 if (modifiedDate != null) {
304 setModifiedDate(modifiedDate);
305 }
306
307 Long categoryId = (Long)attributes.get("categoryId");
308
309 if (categoryId != null) {
310 setCategoryId(categoryId);
311 }
312
313 Long rootMessageId = (Long)attributes.get("rootMessageId");
314
315 if (rootMessageId != null) {
316 setRootMessageId(rootMessageId);
317 }
318
319 Long rootMessageUserId = (Long)attributes.get("rootMessageUserId");
320
321 if (rootMessageUserId != null) {
322 setRootMessageUserId(rootMessageUserId);
323 }
324
325 Integer messageCount = (Integer)attributes.get("messageCount");
326
327 if (messageCount != null) {
328 setMessageCount(messageCount);
329 }
330
331 Integer viewCount = (Integer)attributes.get("viewCount");
332
333 if (viewCount != null) {
334 setViewCount(viewCount);
335 }
336
337 Long lastPostByUserId = (Long)attributes.get("lastPostByUserId");
338
339 if (lastPostByUserId != null) {
340 setLastPostByUserId(lastPostByUserId);
341 }
342
343 Date lastPostDate = (Date)attributes.get("lastPostDate");
344
345 if (lastPostDate != null) {
346 setLastPostDate(lastPostDate);
347 }
348
349 Double priority = (Double)attributes.get("priority");
350
351 if (priority != null) {
352 setPriority(priority);
353 }
354
355 Boolean question = (Boolean)attributes.get("question");
356
357 if (question != null) {
358 setQuestion(question);
359 }
360
361 Integer status = (Integer)attributes.get("status");
362
363 if (status != null) {
364 setStatus(status);
365 }
366
367 Long statusByUserId = (Long)attributes.get("statusByUserId");
368
369 if (statusByUserId != null) {
370 setStatusByUserId(statusByUserId);
371 }
372
373 String statusByUserName = (String)attributes.get("statusByUserName");
374
375 if (statusByUserName != null) {
376 setStatusByUserName(statusByUserName);
377 }
378
379 Date statusDate = (Date)attributes.get("statusDate");
380
381 if (statusDate != null) {
382 setStatusDate(statusDate);
383 }
384 }
385
386 @JSON
387 @Override
388 public String getUuid() {
389 if (_uuid == null) {
390 return StringPool.BLANK;
391 }
392 else {
393 return _uuid;
394 }
395 }
396
397 @Override
398 public void setUuid(String uuid) {
399 if (_originalUuid == null) {
400 _originalUuid = _uuid;
401 }
402
403 _uuid = uuid;
404 }
405
406 public String getOriginalUuid() {
407 return GetterUtil.getString(_originalUuid);
408 }
409
410 @JSON
411 @Override
412 public long getThreadId() {
413 return _threadId;
414 }
415
416 @Override
417 public void setThreadId(long threadId) {
418 _threadId = threadId;
419 }
420
421 @JSON
422 @Override
423 public long getGroupId() {
424 return _groupId;
425 }
426
427 @Override
428 public void setGroupId(long groupId) {
429 _columnBitmask |= GROUPID_COLUMN_BITMASK;
430
431 if (!_setOriginalGroupId) {
432 _setOriginalGroupId = true;
433
434 _originalGroupId = _groupId;
435 }
436
437 _groupId = groupId;
438 }
439
440 public long getOriginalGroupId() {
441 return _originalGroupId;
442 }
443
444 @JSON
445 @Override
446 public long getCompanyId() {
447 return _companyId;
448 }
449
450 @Override
451 public void setCompanyId(long companyId) {
452 _columnBitmask |= COMPANYID_COLUMN_BITMASK;
453
454 if (!_setOriginalCompanyId) {
455 _setOriginalCompanyId = true;
456
457 _originalCompanyId = _companyId;
458 }
459
460 _companyId = companyId;
461 }
462
463 public long getOriginalCompanyId() {
464 return _originalCompanyId;
465 }
466
467 @JSON
468 @Override
469 public long getUserId() {
470 return _userId;
471 }
472
473 @Override
474 public void setUserId(long userId) {
475 _userId = userId;
476 }
477
478 @Override
479 public String getUserUuid() {
480 try {
481 User user = UserLocalServiceUtil.getUserById(getUserId());
482
483 return user.getUuid();
484 }
485 catch (PortalException pe) {
486 return StringPool.BLANK;
487 }
488 }
489
490 @Override
491 public void setUserUuid(String userUuid) {
492 }
493
494 @JSON
495 @Override
496 public String getUserName() {
497 if (_userName == null) {
498 return StringPool.BLANK;
499 }
500 else {
501 return _userName;
502 }
503 }
504
505 @Override
506 public void setUserName(String userName) {
507 _userName = userName;
508 }
509
510 @JSON
511 @Override
512 public Date getCreateDate() {
513 return _createDate;
514 }
515
516 @Override
517 public void setCreateDate(Date createDate) {
518 _createDate = createDate;
519 }
520
521 @JSON
522 @Override
523 public Date getModifiedDate() {
524 return _modifiedDate;
525 }
526
527 @Override
528 public void setModifiedDate(Date modifiedDate) {
529 _modifiedDate = modifiedDate;
530 }
531
532 @JSON
533 @Override
534 public long getCategoryId() {
535 return _categoryId;
536 }
537
538 @Override
539 public void setCategoryId(long categoryId) {
540 _columnBitmask |= CATEGORYID_COLUMN_BITMASK;
541
542 if (!_setOriginalCategoryId) {
543 _setOriginalCategoryId = true;
544
545 _originalCategoryId = _categoryId;
546 }
547
548 _categoryId = categoryId;
549 }
550
551 public long getOriginalCategoryId() {
552 return _originalCategoryId;
553 }
554
555 @JSON
556 @Override
557 public long getRootMessageId() {
558 return _rootMessageId;
559 }
560
561 @Override
562 public void setRootMessageId(long rootMessageId) {
563 _columnBitmask |= ROOTMESSAGEID_COLUMN_BITMASK;
564
565 if (!_setOriginalRootMessageId) {
566 _setOriginalRootMessageId = true;
567
568 _originalRootMessageId = _rootMessageId;
569 }
570
571 _rootMessageId = rootMessageId;
572 }
573
574 public long getOriginalRootMessageId() {
575 return _originalRootMessageId;
576 }
577
578 @JSON
579 @Override
580 public long getRootMessageUserId() {
581 return _rootMessageUserId;
582 }
583
584 @Override
585 public void setRootMessageUserId(long rootMessageUserId) {
586 _rootMessageUserId = rootMessageUserId;
587 }
588
589 @Override
590 public String getRootMessageUserUuid() {
591 try {
592 User user = UserLocalServiceUtil.getUserById(getRootMessageUserId());
593
594 return user.getUuid();
595 }
596 catch (PortalException pe) {
597 return StringPool.BLANK;
598 }
599 }
600
601 @Override
602 public void setRootMessageUserUuid(String rootMessageUserUuid) {
603 }
604
605 @JSON
606 @Override
607 public int getMessageCount() {
608 return _messageCount;
609 }
610
611 @Override
612 public void setMessageCount(int messageCount) {
613 _messageCount = messageCount;
614 }
615
616 @JSON
617 @Override
618 public int getViewCount() {
619 return _viewCount;
620 }
621
622 @Override
623 public void setViewCount(int viewCount) {
624 _viewCount = viewCount;
625 }
626
627 @JSON
628 @Override
629 public long getLastPostByUserId() {
630 return _lastPostByUserId;
631 }
632
633 @Override
634 public void setLastPostByUserId(long lastPostByUserId) {
635 _lastPostByUserId = lastPostByUserId;
636 }
637
638 @Override
639 public String getLastPostByUserUuid() {
640 try {
641 User user = UserLocalServiceUtil.getUserById(getLastPostByUserId());
642
643 return user.getUuid();
644 }
645 catch (PortalException pe) {
646 return StringPool.BLANK;
647 }
648 }
649
650 @Override
651 public void setLastPostByUserUuid(String lastPostByUserUuid) {
652 }
653
654 @JSON
655 @Override
656 public Date getLastPostDate() {
657 return _lastPostDate;
658 }
659
660 @Override
661 public void setLastPostDate(Date lastPostDate) {
662 _columnBitmask = -1L;
663
664 if (_originalLastPostDate == null) {
665 _originalLastPostDate = _lastPostDate;
666 }
667
668 _lastPostDate = lastPostDate;
669 }
670
671 public Date getOriginalLastPostDate() {
672 return _originalLastPostDate;
673 }
674
675 @JSON
676 @Override
677 public double getPriority() {
678 return _priority;
679 }
680
681 @Override
682 public void setPriority(double priority) {
683 _columnBitmask = -1L;
684
685 if (!_setOriginalPriority) {
686 _setOriginalPriority = true;
687
688 _originalPriority = _priority;
689 }
690
691 _priority = priority;
692 }
693
694 public double getOriginalPriority() {
695 return _originalPriority;
696 }
697
698 @JSON
699 @Override
700 public boolean getQuestion() {
701 return _question;
702 }
703
704 @Override
705 public boolean isQuestion() {
706 return _question;
707 }
708
709 @Override
710 public void setQuestion(boolean question) {
711 _question = question;
712 }
713
714 @JSON
715 @Override
716 public int getStatus() {
717 return _status;
718 }
719
720 @Override
721 public void setStatus(int status) {
722 _columnBitmask |= STATUS_COLUMN_BITMASK;
723
724 if (!_setOriginalStatus) {
725 _setOriginalStatus = true;
726
727 _originalStatus = _status;
728 }
729
730 _status = status;
731 }
732
733 public int getOriginalStatus() {
734 return _originalStatus;
735 }
736
737 @JSON
738 @Override
739 public long getStatusByUserId() {
740 return _statusByUserId;
741 }
742
743 @Override
744 public void setStatusByUserId(long statusByUserId) {
745 _statusByUserId = statusByUserId;
746 }
747
748 @Override
749 public String getStatusByUserUuid() {
750 try {
751 User user = UserLocalServiceUtil.getUserById(getStatusByUserId());
752
753 return user.getUuid();
754 }
755 catch (PortalException pe) {
756 return StringPool.BLANK;
757 }
758 }
759
760 @Override
761 public void setStatusByUserUuid(String statusByUserUuid) {
762 }
763
764 @JSON
765 @Override
766 public String getStatusByUserName() {
767 if (_statusByUserName == null) {
768 return StringPool.BLANK;
769 }
770 else {
771 return _statusByUserName;
772 }
773 }
774
775 @Override
776 public void setStatusByUserName(String statusByUserName) {
777 _statusByUserName = statusByUserName;
778 }
779
780 @JSON
781 @Override
782 public Date getStatusDate() {
783 return _statusDate;
784 }
785
786 @Override
787 public void setStatusDate(Date statusDate) {
788 _statusDate = statusDate;
789 }
790
791 @Override
792 public long getContainerModelId() {
793 return getThreadId();
794 }
795
796 @Override
797 public void setContainerModelId(long containerModelId) {
798 _threadId = containerModelId;
799 }
800
801 @Override
802 public long getParentContainerModelId() {
803 return getCategoryId();
804 }
805
806 @Override
807 public void setParentContainerModelId(long parentContainerModelId) {
808 _categoryId = parentContainerModelId;
809 }
810
811 @Override
812 public String getContainerModelName() {
813 return String.valueOf(getContainerModelId());
814 }
815
816 @Override
817 public StagedModelType getStagedModelType() {
818 return new StagedModelType(PortalUtil.getClassNameId(
819 MBThread.class.getName()));
820 }
821
822 @Override
823 public TrashEntry getTrashEntry() throws PortalException {
824 if (!isInTrash()) {
825 return null;
826 }
827
828 TrashEntry trashEntry = TrashEntryLocalServiceUtil.fetchEntry(getModelClassName(),
829 getTrashEntryClassPK());
830
831 if (trashEntry != null) {
832 return trashEntry;
833 }
834
835 TrashHandler trashHandler = getTrashHandler();
836
837 if (!Validator.isNull(trashHandler.getContainerModelClassName(
838 getPrimaryKey()))) {
839 ContainerModel containerModel = null;
840
841 try {
842 containerModel = trashHandler.getParentContainerModel(this);
843 }
844 catch (NoSuchModelException nsme) {
845 return null;
846 }
847
848 while (containerModel != null) {
849 if (containerModel instanceof TrashedModel) {
850 TrashedModel trashedModel = (TrashedModel)containerModel;
851
852 return trashedModel.getTrashEntry();
853 }
854
855 trashHandler = TrashHandlerRegistryUtil.getTrashHandler(trashHandler.getContainerModelClassName(
856 containerModel.getContainerModelId()));
857
858 if (trashHandler == null) {
859 return null;
860 }
861
862 containerModel = trashHandler.getContainerModel(containerModel.getParentContainerModelId());
863 }
864 }
865
866 return null;
867 }
868
869 @Override
870 public long getTrashEntryClassPK() {
871 return getPrimaryKey();
872 }
873
874 @Override
875 public TrashHandler getTrashHandler() {
876 return TrashHandlerRegistryUtil.getTrashHandler(getModelClassName());
877 }
878
879 @Override
880 public boolean isInTrash() {
881 if (getStatus() == WorkflowConstants.STATUS_IN_TRASH) {
882 return true;
883 }
884 else {
885 return false;
886 }
887 }
888
889 @Override
890 public boolean isInTrashContainer() {
891 TrashHandler trashHandler = getTrashHandler();
892
893 if ((trashHandler == null) ||
894 Validator.isNull(trashHandler.getContainerModelClassName(
895 getPrimaryKey()))) {
896 return false;
897 }
898
899 try {
900 ContainerModel containerModel = trashHandler.getParentContainerModel(this);
901
902 if (containerModel == null) {
903 return false;
904 }
905
906 if (containerModel instanceof TrashedModel) {
907 return ((TrashedModel)containerModel).isInTrash();
908 }
909 }
910 catch (Exception e) {
911 }
912
913 return false;
914 }
915
916 @Override
917 public boolean isInTrashExplicitly() {
918 if (!isInTrash()) {
919 return false;
920 }
921
922 TrashEntry trashEntry = TrashEntryLocalServiceUtil.fetchEntry(getModelClassName(),
923 getTrashEntryClassPK());
924
925 if (trashEntry != null) {
926 return true;
927 }
928
929 return false;
930 }
931
932 @Override
933 public boolean isInTrashImplicitly() {
934 if (!isInTrash()) {
935 return false;
936 }
937
938 TrashEntry trashEntry = TrashEntryLocalServiceUtil.fetchEntry(getModelClassName(),
939 getTrashEntryClassPK());
940
941 if (trashEntry != null) {
942 return false;
943 }
944
945 return true;
946 }
947
948
951 @Deprecated
952 @Override
953 public boolean getApproved() {
954 return isApproved();
955 }
956
957 @Override
958 public boolean isApproved() {
959 if (getStatus() == WorkflowConstants.STATUS_APPROVED) {
960 return true;
961 }
962 else {
963 return false;
964 }
965 }
966
967 @Override
968 public boolean isDenied() {
969 if (getStatus() == WorkflowConstants.STATUS_DENIED) {
970 return true;
971 }
972 else {
973 return false;
974 }
975 }
976
977 @Override
978 public boolean isDraft() {
979 if (getStatus() == WorkflowConstants.STATUS_DRAFT) {
980 return true;
981 }
982 else {
983 return false;
984 }
985 }
986
987 @Override
988 public boolean isExpired() {
989 if (getStatus() == WorkflowConstants.STATUS_EXPIRED) {
990 return true;
991 }
992 else {
993 return false;
994 }
995 }
996
997 @Override
998 public boolean isInactive() {
999 if (getStatus() == WorkflowConstants.STATUS_INACTIVE) {
1000 return true;
1001 }
1002 else {
1003 return false;
1004 }
1005 }
1006
1007 @Override
1008 public boolean isIncomplete() {
1009 if (getStatus() == WorkflowConstants.STATUS_INCOMPLETE) {
1010 return true;
1011 }
1012 else {
1013 return false;
1014 }
1015 }
1016
1017 @Override
1018 public boolean isPending() {
1019 if (getStatus() == WorkflowConstants.STATUS_PENDING) {
1020 return true;
1021 }
1022 else {
1023 return false;
1024 }
1025 }
1026
1027 @Override
1028 public boolean isScheduled() {
1029 if (getStatus() == WorkflowConstants.STATUS_SCHEDULED) {
1030 return true;
1031 }
1032 else {
1033 return false;
1034 }
1035 }
1036
1037 public long getColumnBitmask() {
1038 return _columnBitmask;
1039 }
1040
1041 @Override
1042 public ExpandoBridge getExpandoBridge() {
1043 return ExpandoBridgeFactoryUtil.getExpandoBridge(getCompanyId(),
1044 MBThread.class.getName(), getPrimaryKey());
1045 }
1046
1047 @Override
1048 public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
1049 ExpandoBridge expandoBridge = getExpandoBridge();
1050
1051 expandoBridge.setAttributes(serviceContext);
1052 }
1053
1054 @Override
1055 public MBThread toEscapedModel() {
1056 if (_escapedModel == null) {
1057 _escapedModel = (MBThread)ProxyUtil.newProxyInstance(_classLoader,
1058 _escapedModelInterfaces, new AutoEscapeBeanHandler(this));
1059 }
1060
1061 return _escapedModel;
1062 }
1063
1064 @Override
1065 public Object clone() {
1066 MBThreadImpl mbThreadImpl = new MBThreadImpl();
1067
1068 mbThreadImpl.setUuid(getUuid());
1069 mbThreadImpl.setThreadId(getThreadId());
1070 mbThreadImpl.setGroupId(getGroupId());
1071 mbThreadImpl.setCompanyId(getCompanyId());
1072 mbThreadImpl.setUserId(getUserId());
1073 mbThreadImpl.setUserName(getUserName());
1074 mbThreadImpl.setCreateDate(getCreateDate());
1075 mbThreadImpl.setModifiedDate(getModifiedDate());
1076 mbThreadImpl.setCategoryId(getCategoryId());
1077 mbThreadImpl.setRootMessageId(getRootMessageId());
1078 mbThreadImpl.setRootMessageUserId(getRootMessageUserId());
1079 mbThreadImpl.setMessageCount(getMessageCount());
1080 mbThreadImpl.setViewCount(getViewCount());
1081 mbThreadImpl.setLastPostByUserId(getLastPostByUserId());
1082 mbThreadImpl.setLastPostDate(getLastPostDate());
1083 mbThreadImpl.setPriority(getPriority());
1084 mbThreadImpl.setQuestion(getQuestion());
1085 mbThreadImpl.setStatus(getStatus());
1086 mbThreadImpl.setStatusByUserId(getStatusByUserId());
1087 mbThreadImpl.setStatusByUserName(getStatusByUserName());
1088 mbThreadImpl.setStatusDate(getStatusDate());
1089
1090 mbThreadImpl.resetOriginalValues();
1091
1092 return mbThreadImpl;
1093 }
1094
1095 @Override
1096 public int compareTo(MBThread mbThread) {
1097 int value = 0;
1098
1099 if (getPriority() < mbThread.getPriority()) {
1100 value = -1;
1101 }
1102 else if (getPriority() > mbThread.getPriority()) {
1103 value = 1;
1104 }
1105 else {
1106 value = 0;
1107 }
1108
1109 value = value * -1;
1110
1111 if (value != 0) {
1112 return value;
1113 }
1114
1115 value = DateUtil.compareTo(getLastPostDate(), mbThread.getLastPostDate());
1116
1117 value = value * -1;
1118
1119 if (value != 0) {
1120 return value;
1121 }
1122
1123 return 0;
1124 }
1125
1126 @Override
1127 public boolean equals(Object obj) {
1128 if (this == obj) {
1129 return true;
1130 }
1131
1132 if (!(obj instanceof MBThread)) {
1133 return false;
1134 }
1135
1136 MBThread mbThread = (MBThread)obj;
1137
1138 long primaryKey = mbThread.getPrimaryKey();
1139
1140 if (getPrimaryKey() == primaryKey) {
1141 return true;
1142 }
1143 else {
1144 return false;
1145 }
1146 }
1147
1148 @Override
1149 public int hashCode() {
1150 return (int)getPrimaryKey();
1151 }
1152
1153 @Override
1154 public boolean isEntityCacheEnabled() {
1155 return ENTITY_CACHE_ENABLED;
1156 }
1157
1158 @Override
1159 public boolean isFinderCacheEnabled() {
1160 return FINDER_CACHE_ENABLED;
1161 }
1162
1163 @Override
1164 public void resetOriginalValues() {
1165 MBThreadModelImpl mbThreadModelImpl = this;
1166
1167 mbThreadModelImpl._originalUuid = mbThreadModelImpl._uuid;
1168
1169 mbThreadModelImpl._originalGroupId = mbThreadModelImpl._groupId;
1170
1171 mbThreadModelImpl._setOriginalGroupId = false;
1172
1173 mbThreadModelImpl._originalCompanyId = mbThreadModelImpl._companyId;
1174
1175 mbThreadModelImpl._setOriginalCompanyId = false;
1176
1177 mbThreadModelImpl._originalCategoryId = mbThreadModelImpl._categoryId;
1178
1179 mbThreadModelImpl._setOriginalCategoryId = false;
1180
1181 mbThreadModelImpl._originalRootMessageId = mbThreadModelImpl._rootMessageId;
1182
1183 mbThreadModelImpl._setOriginalRootMessageId = false;
1184
1185 mbThreadModelImpl._originalLastPostDate = mbThreadModelImpl._lastPostDate;
1186
1187 mbThreadModelImpl._originalPriority = mbThreadModelImpl._priority;
1188
1189 mbThreadModelImpl._setOriginalPriority = false;
1190
1191 mbThreadModelImpl._originalStatus = mbThreadModelImpl._status;
1192
1193 mbThreadModelImpl._setOriginalStatus = false;
1194
1195 mbThreadModelImpl._columnBitmask = 0;
1196 }
1197
1198 @Override
1199 public CacheModel<MBThread> toCacheModel() {
1200 MBThreadCacheModel mbThreadCacheModel = new MBThreadCacheModel();
1201
1202 mbThreadCacheModel.uuid = getUuid();
1203
1204 String uuid = mbThreadCacheModel.uuid;
1205
1206 if ((uuid != null) && (uuid.length() == 0)) {
1207 mbThreadCacheModel.uuid = null;
1208 }
1209
1210 mbThreadCacheModel.threadId = getThreadId();
1211
1212 mbThreadCacheModel.groupId = getGroupId();
1213
1214 mbThreadCacheModel.companyId = getCompanyId();
1215
1216 mbThreadCacheModel.userId = getUserId();
1217
1218 mbThreadCacheModel.userName = getUserName();
1219
1220 String userName = mbThreadCacheModel.userName;
1221
1222 if ((userName != null) && (userName.length() == 0)) {
1223 mbThreadCacheModel.userName = null;
1224 }
1225
1226 Date createDate = getCreateDate();
1227
1228 if (createDate != null) {
1229 mbThreadCacheModel.createDate = createDate.getTime();
1230 }
1231 else {
1232 mbThreadCacheModel.createDate = Long.MIN_VALUE;
1233 }
1234
1235 Date modifiedDate = getModifiedDate();
1236
1237 if (modifiedDate != null) {
1238 mbThreadCacheModel.modifiedDate = modifiedDate.getTime();
1239 }
1240 else {
1241 mbThreadCacheModel.modifiedDate = Long.MIN_VALUE;
1242 }
1243
1244 mbThreadCacheModel.categoryId = getCategoryId();
1245
1246 mbThreadCacheModel.rootMessageId = getRootMessageId();
1247
1248 mbThreadCacheModel.rootMessageUserId = getRootMessageUserId();
1249
1250 mbThreadCacheModel.messageCount = getMessageCount();
1251
1252 mbThreadCacheModel.viewCount = getViewCount();
1253
1254 mbThreadCacheModel.lastPostByUserId = getLastPostByUserId();
1255
1256 Date lastPostDate = getLastPostDate();
1257
1258 if (lastPostDate != null) {
1259 mbThreadCacheModel.lastPostDate = lastPostDate.getTime();
1260 }
1261 else {
1262 mbThreadCacheModel.lastPostDate = Long.MIN_VALUE;
1263 }
1264
1265 mbThreadCacheModel.priority = getPriority();
1266
1267 mbThreadCacheModel.question = getQuestion();
1268
1269 mbThreadCacheModel.status = getStatus();
1270
1271 mbThreadCacheModel.statusByUserId = getStatusByUserId();
1272
1273 mbThreadCacheModel.statusByUserName = getStatusByUserName();
1274
1275 String statusByUserName = mbThreadCacheModel.statusByUserName;
1276
1277 if ((statusByUserName != null) && (statusByUserName.length() == 0)) {
1278 mbThreadCacheModel.statusByUserName = null;
1279 }
1280
1281 Date statusDate = getStatusDate();
1282
1283 if (statusDate != null) {
1284 mbThreadCacheModel.statusDate = statusDate.getTime();
1285 }
1286 else {
1287 mbThreadCacheModel.statusDate = Long.MIN_VALUE;
1288 }
1289
1290 return mbThreadCacheModel;
1291 }
1292
1293 @Override
1294 public String toString() {
1295 StringBundler sb = new StringBundler(43);
1296
1297 sb.append("{uuid=");
1298 sb.append(getUuid());
1299 sb.append(", threadId=");
1300 sb.append(getThreadId());
1301 sb.append(", groupId=");
1302 sb.append(getGroupId());
1303 sb.append(", companyId=");
1304 sb.append(getCompanyId());
1305 sb.append(", userId=");
1306 sb.append(getUserId());
1307 sb.append(", userName=");
1308 sb.append(getUserName());
1309 sb.append(", createDate=");
1310 sb.append(getCreateDate());
1311 sb.append(", modifiedDate=");
1312 sb.append(getModifiedDate());
1313 sb.append(", categoryId=");
1314 sb.append(getCategoryId());
1315 sb.append(", rootMessageId=");
1316 sb.append(getRootMessageId());
1317 sb.append(", rootMessageUserId=");
1318 sb.append(getRootMessageUserId());
1319 sb.append(", messageCount=");
1320 sb.append(getMessageCount());
1321 sb.append(", viewCount=");
1322 sb.append(getViewCount());
1323 sb.append(", lastPostByUserId=");
1324 sb.append(getLastPostByUserId());
1325 sb.append(", lastPostDate=");
1326 sb.append(getLastPostDate());
1327 sb.append(", priority=");
1328 sb.append(getPriority());
1329 sb.append(", question=");
1330 sb.append(getQuestion());
1331 sb.append(", status=");
1332 sb.append(getStatus());
1333 sb.append(", statusByUserId=");
1334 sb.append(getStatusByUserId());
1335 sb.append(", statusByUserName=");
1336 sb.append(getStatusByUserName());
1337 sb.append(", statusDate=");
1338 sb.append(getStatusDate());
1339 sb.append("}");
1340
1341 return sb.toString();
1342 }
1343
1344 @Override
1345 public String toXmlString() {
1346 StringBundler sb = new StringBundler(67);
1347
1348 sb.append("<model><model-name>");
1349 sb.append("com.liferay.portlet.messageboards.model.MBThread");
1350 sb.append("</model-name>");
1351
1352 sb.append(
1353 "<column><column-name>uuid</column-name><column-value><![CDATA[");
1354 sb.append(getUuid());
1355 sb.append("]]></column-value></column>");
1356 sb.append(
1357 "<column><column-name>threadId</column-name><column-value><![CDATA[");
1358 sb.append(getThreadId());
1359 sb.append("]]></column-value></column>");
1360 sb.append(
1361 "<column><column-name>groupId</column-name><column-value><![CDATA[");
1362 sb.append(getGroupId());
1363 sb.append("]]></column-value></column>");
1364 sb.append(
1365 "<column><column-name>companyId</column-name><column-value><![CDATA[");
1366 sb.append(getCompanyId());
1367 sb.append("]]></column-value></column>");
1368 sb.append(
1369 "<column><column-name>userId</column-name><column-value><![CDATA[");
1370 sb.append(getUserId());
1371 sb.append("]]></column-value></column>");
1372 sb.append(
1373 "<column><column-name>userName</column-name><column-value><![CDATA[");
1374 sb.append(getUserName());
1375 sb.append("]]></column-value></column>");
1376 sb.append(
1377 "<column><column-name>createDate</column-name><column-value><![CDATA[");
1378 sb.append(getCreateDate());
1379 sb.append("]]></column-value></column>");
1380 sb.append(
1381 "<column><column-name>modifiedDate</column-name><column-value><![CDATA[");
1382 sb.append(getModifiedDate());
1383 sb.append("]]></column-value></column>");
1384 sb.append(
1385 "<column><column-name>categoryId</column-name><column-value><![CDATA[");
1386 sb.append(getCategoryId());
1387 sb.append("]]></column-value></column>");
1388 sb.append(
1389 "<column><column-name>rootMessageId</column-name><column-value><![CDATA[");
1390 sb.append(getRootMessageId());
1391 sb.append("]]></column-value></column>");
1392 sb.append(
1393 "<column><column-name>rootMessageUserId</column-name><column-value><![CDATA[");
1394 sb.append(getRootMessageUserId());
1395 sb.append("]]></column-value></column>");
1396 sb.append(
1397 "<column><column-name>messageCount</column-name><column-value><![CDATA[");
1398 sb.append(getMessageCount());
1399 sb.append("]]></column-value></column>");
1400 sb.append(
1401 "<column><column-name>viewCount</column-name><column-value><![CDATA[");
1402 sb.append(getViewCount());
1403 sb.append("]]></column-value></column>");
1404 sb.append(
1405 "<column><column-name>lastPostByUserId</column-name><column-value><![CDATA[");
1406 sb.append(getLastPostByUserId());
1407 sb.append("]]></column-value></column>");
1408 sb.append(
1409 "<column><column-name>lastPostDate</column-name><column-value><![CDATA[");
1410 sb.append(getLastPostDate());
1411 sb.append("]]></column-value></column>");
1412 sb.append(
1413 "<column><column-name>priority</column-name><column-value><![CDATA[");
1414 sb.append(getPriority());
1415 sb.append("]]></column-value></column>");
1416 sb.append(
1417 "<column><column-name>question</column-name><column-value><![CDATA[");
1418 sb.append(getQuestion());
1419 sb.append("]]></column-value></column>");
1420 sb.append(
1421 "<column><column-name>status</column-name><column-value><![CDATA[");
1422 sb.append(getStatus());
1423 sb.append("]]></column-value></column>");
1424 sb.append(
1425 "<column><column-name>statusByUserId</column-name><column-value><![CDATA[");
1426 sb.append(getStatusByUserId());
1427 sb.append("]]></column-value></column>");
1428 sb.append(
1429 "<column><column-name>statusByUserName</column-name><column-value><![CDATA[");
1430 sb.append(getStatusByUserName());
1431 sb.append("]]></column-value></column>");
1432 sb.append(
1433 "<column><column-name>statusDate</column-name><column-value><![CDATA[");
1434 sb.append(getStatusDate());
1435 sb.append("]]></column-value></column>");
1436
1437 sb.append("</model>");
1438
1439 return sb.toString();
1440 }
1441
1442 private static final ClassLoader _classLoader = MBThread.class.getClassLoader();
1443 private static final Class<?>[] _escapedModelInterfaces = new Class[] {
1444 MBThread.class
1445 };
1446 private String _uuid;
1447 private String _originalUuid;
1448 private long _threadId;
1449 private long _groupId;
1450 private long _originalGroupId;
1451 private boolean _setOriginalGroupId;
1452 private long _companyId;
1453 private long _originalCompanyId;
1454 private boolean _setOriginalCompanyId;
1455 private long _userId;
1456 private String _userName;
1457 private Date _createDate;
1458 private Date _modifiedDate;
1459 private long _categoryId;
1460 private long _originalCategoryId;
1461 private boolean _setOriginalCategoryId;
1462 private long _rootMessageId;
1463 private long _originalRootMessageId;
1464 private boolean _setOriginalRootMessageId;
1465 private long _rootMessageUserId;
1466 private int _messageCount;
1467 private int _viewCount;
1468 private long _lastPostByUserId;
1469 private Date _lastPostDate;
1470 private Date _originalLastPostDate;
1471 private double _priority;
1472 private double _originalPriority;
1473 private boolean _setOriginalPriority;
1474 private boolean _question;
1475 private int _status;
1476 private int _originalStatus;
1477 private boolean _setOriginalStatus;
1478 private long _statusByUserId;
1479 private String _statusByUserName;
1480 private Date _statusDate;
1481 private long _columnBitmask;
1482 private MBThread _escapedModel;
1483 }