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.trash.TrashHandler;
024 import com.liferay.portal.kernel.trash.TrashHandlerRegistryUtil;
025 import com.liferay.portal.kernel.util.DateUtil;
026 import com.liferay.portal.kernel.util.GetterUtil;
027 import com.liferay.portal.kernel.util.ProxyUtil;
028 import com.liferay.portal.kernel.util.StringBundler;
029 import com.liferay.portal.kernel.util.StringPool;
030 import com.liferay.portal.kernel.util.Validator;
031 import com.liferay.portal.kernel.workflow.WorkflowConstants;
032 import com.liferay.portal.model.CacheModel;
033 import com.liferay.portal.model.ContainerModel;
034 import com.liferay.portal.model.TrashedModel;
035 import com.liferay.portal.model.User;
036 import com.liferay.portal.model.impl.BaseModelImpl;
037 import com.liferay.portal.service.ServiceContext;
038 import com.liferay.portal.service.UserLocalServiceUtil;
039 import com.liferay.portal.util.PortalUtil;
040
041 import com.liferay.portlet.expando.model.ExpandoBridge;
042 import com.liferay.portlet.expando.util.ExpandoBridgeFactoryUtil;
043 import com.liferay.portlet.exportimport.lar.StagedModelType;
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 public boolean hasSetModifiedDate() {
528 return _setModifiedDate;
529 }
530
531 @Override
532 public void setModifiedDate(Date modifiedDate) {
533 _setModifiedDate = true;
534
535 _modifiedDate = modifiedDate;
536 }
537
538 @JSON
539 @Override
540 public long getCategoryId() {
541 return _categoryId;
542 }
543
544 @Override
545 public void setCategoryId(long categoryId) {
546 _columnBitmask |= CATEGORYID_COLUMN_BITMASK;
547
548 if (!_setOriginalCategoryId) {
549 _setOriginalCategoryId = true;
550
551 _originalCategoryId = _categoryId;
552 }
553
554 _categoryId = categoryId;
555 }
556
557 public long getOriginalCategoryId() {
558 return _originalCategoryId;
559 }
560
561 @JSON
562 @Override
563 public long getRootMessageId() {
564 return _rootMessageId;
565 }
566
567 @Override
568 public void setRootMessageId(long rootMessageId) {
569 _columnBitmask |= ROOTMESSAGEID_COLUMN_BITMASK;
570
571 if (!_setOriginalRootMessageId) {
572 _setOriginalRootMessageId = true;
573
574 _originalRootMessageId = _rootMessageId;
575 }
576
577 _rootMessageId = rootMessageId;
578 }
579
580 public long getOriginalRootMessageId() {
581 return _originalRootMessageId;
582 }
583
584 @JSON
585 @Override
586 public long getRootMessageUserId() {
587 return _rootMessageUserId;
588 }
589
590 @Override
591 public void setRootMessageUserId(long rootMessageUserId) {
592 _rootMessageUserId = rootMessageUserId;
593 }
594
595 @Override
596 public String getRootMessageUserUuid() {
597 try {
598 User user = UserLocalServiceUtil.getUserById(getRootMessageUserId());
599
600 return user.getUuid();
601 }
602 catch (PortalException pe) {
603 return StringPool.BLANK;
604 }
605 }
606
607 @Override
608 public void setRootMessageUserUuid(String rootMessageUserUuid) {
609 }
610
611 @JSON
612 @Override
613 public int getMessageCount() {
614 return _messageCount;
615 }
616
617 @Override
618 public void setMessageCount(int messageCount) {
619 _messageCount = messageCount;
620 }
621
622 @JSON
623 @Override
624 public int getViewCount() {
625 return _viewCount;
626 }
627
628 @Override
629 public void setViewCount(int viewCount) {
630 _viewCount = viewCount;
631 }
632
633 @JSON
634 @Override
635 public long getLastPostByUserId() {
636 return _lastPostByUserId;
637 }
638
639 @Override
640 public void setLastPostByUserId(long lastPostByUserId) {
641 _lastPostByUserId = lastPostByUserId;
642 }
643
644 @Override
645 public String getLastPostByUserUuid() {
646 try {
647 User user = UserLocalServiceUtil.getUserById(getLastPostByUserId());
648
649 return user.getUuid();
650 }
651 catch (PortalException pe) {
652 return StringPool.BLANK;
653 }
654 }
655
656 @Override
657 public void setLastPostByUserUuid(String lastPostByUserUuid) {
658 }
659
660 @JSON
661 @Override
662 public Date getLastPostDate() {
663 return _lastPostDate;
664 }
665
666 @Override
667 public void setLastPostDate(Date lastPostDate) {
668 _columnBitmask = -1L;
669
670 if (_originalLastPostDate == null) {
671 _originalLastPostDate = _lastPostDate;
672 }
673
674 _lastPostDate = lastPostDate;
675 }
676
677 public Date getOriginalLastPostDate() {
678 return _originalLastPostDate;
679 }
680
681 @JSON
682 @Override
683 public double getPriority() {
684 return _priority;
685 }
686
687 @Override
688 public void setPriority(double priority) {
689 _columnBitmask = -1L;
690
691 if (!_setOriginalPriority) {
692 _setOriginalPriority = true;
693
694 _originalPriority = _priority;
695 }
696
697 _priority = priority;
698 }
699
700 public double getOriginalPriority() {
701 return _originalPriority;
702 }
703
704 @JSON
705 @Override
706 public boolean getQuestion() {
707 return _question;
708 }
709
710 @Override
711 public boolean isQuestion() {
712 return _question;
713 }
714
715 @Override
716 public void setQuestion(boolean question) {
717 _question = question;
718 }
719
720 @JSON
721 @Override
722 public int getStatus() {
723 return _status;
724 }
725
726 @Override
727 public void setStatus(int status) {
728 _columnBitmask |= STATUS_COLUMN_BITMASK;
729
730 if (!_setOriginalStatus) {
731 _setOriginalStatus = true;
732
733 _originalStatus = _status;
734 }
735
736 _status = status;
737 }
738
739 public int getOriginalStatus() {
740 return _originalStatus;
741 }
742
743 @JSON
744 @Override
745 public long getStatusByUserId() {
746 return _statusByUserId;
747 }
748
749 @Override
750 public void setStatusByUserId(long statusByUserId) {
751 _statusByUserId = statusByUserId;
752 }
753
754 @Override
755 public String getStatusByUserUuid() {
756 try {
757 User user = UserLocalServiceUtil.getUserById(getStatusByUserId());
758
759 return user.getUuid();
760 }
761 catch (PortalException pe) {
762 return StringPool.BLANK;
763 }
764 }
765
766 @Override
767 public void setStatusByUserUuid(String statusByUserUuid) {
768 }
769
770 @JSON
771 @Override
772 public String getStatusByUserName() {
773 if (_statusByUserName == null) {
774 return StringPool.BLANK;
775 }
776 else {
777 return _statusByUserName;
778 }
779 }
780
781 @Override
782 public void setStatusByUserName(String statusByUserName) {
783 _statusByUserName = statusByUserName;
784 }
785
786 @JSON
787 @Override
788 public Date getStatusDate() {
789 return _statusDate;
790 }
791
792 @Override
793 public void setStatusDate(Date statusDate) {
794 _statusDate = statusDate;
795 }
796
797 @Override
798 public long getContainerModelId() {
799 return getThreadId();
800 }
801
802 @Override
803 public void setContainerModelId(long containerModelId) {
804 _threadId = containerModelId;
805 }
806
807 @Override
808 public long getParentContainerModelId() {
809 return getCategoryId();
810 }
811
812 @Override
813 public void setParentContainerModelId(long parentContainerModelId) {
814 _categoryId = parentContainerModelId;
815 }
816
817 @Override
818 public String getContainerModelName() {
819 return String.valueOf(getContainerModelId());
820 }
821
822 @Override
823 public StagedModelType getStagedModelType() {
824 return new StagedModelType(PortalUtil.getClassNameId(
825 MBThread.class.getName()));
826 }
827
828 @Override
829 public TrashEntry getTrashEntry() throws PortalException {
830 if (!isInTrash()) {
831 return null;
832 }
833
834 TrashEntry trashEntry = TrashEntryLocalServiceUtil.fetchEntry(getModelClassName(),
835 getTrashEntryClassPK());
836
837 if (trashEntry != null) {
838 return trashEntry;
839 }
840
841 TrashHandler trashHandler = getTrashHandler();
842
843 if (!Validator.isNull(trashHandler.getContainerModelClassName(
844 getPrimaryKey()))) {
845 ContainerModel containerModel = null;
846
847 try {
848 containerModel = trashHandler.getParentContainerModel(this);
849 }
850 catch (NoSuchModelException nsme) {
851 return null;
852 }
853
854 while (containerModel != null) {
855 if (containerModel instanceof TrashedModel) {
856 TrashedModel trashedModel = (TrashedModel)containerModel;
857
858 return trashedModel.getTrashEntry();
859 }
860
861 trashHandler = TrashHandlerRegistryUtil.getTrashHandler(trashHandler.getContainerModelClassName(
862 containerModel.getContainerModelId()));
863
864 if (trashHandler == null) {
865 return null;
866 }
867
868 containerModel = trashHandler.getContainerModel(containerModel.getParentContainerModelId());
869 }
870 }
871
872 return null;
873 }
874
875 @Override
876 public long getTrashEntryClassPK() {
877 return getPrimaryKey();
878 }
879
880 @Override
881 public TrashHandler getTrashHandler() {
882 return TrashHandlerRegistryUtil.getTrashHandler(getModelClassName());
883 }
884
885 @Override
886 public boolean isInTrash() {
887 if (getStatus() == WorkflowConstants.STATUS_IN_TRASH) {
888 return true;
889 }
890 else {
891 return false;
892 }
893 }
894
895 @Override
896 public boolean isInTrashContainer() {
897 TrashHandler trashHandler = getTrashHandler();
898
899 if ((trashHandler == null) ||
900 Validator.isNull(trashHandler.getContainerModelClassName(
901 getPrimaryKey()))) {
902 return false;
903 }
904
905 try {
906 ContainerModel containerModel = trashHandler.getParentContainerModel(this);
907
908 if (containerModel == null) {
909 return false;
910 }
911
912 if (containerModel instanceof TrashedModel) {
913 return ((TrashedModel)containerModel).isInTrash();
914 }
915 }
916 catch (Exception e) {
917 }
918
919 return false;
920 }
921
922 @Override
923 public boolean isInTrashExplicitly() {
924 if (!isInTrash()) {
925 return false;
926 }
927
928 TrashEntry trashEntry = TrashEntryLocalServiceUtil.fetchEntry(getModelClassName(),
929 getTrashEntryClassPK());
930
931 if (trashEntry != null) {
932 return true;
933 }
934
935 return false;
936 }
937
938 @Override
939 public boolean isInTrashImplicitly() {
940 if (!isInTrash()) {
941 return false;
942 }
943
944 TrashEntry trashEntry = TrashEntryLocalServiceUtil.fetchEntry(getModelClassName(),
945 getTrashEntryClassPK());
946
947 if (trashEntry != null) {
948 return false;
949 }
950
951 return true;
952 }
953
954
957 @Deprecated
958 @Override
959 public boolean getApproved() {
960 return isApproved();
961 }
962
963 @Override
964 public boolean isApproved() {
965 if (getStatus() == WorkflowConstants.STATUS_APPROVED) {
966 return true;
967 }
968 else {
969 return false;
970 }
971 }
972
973 @Override
974 public boolean isDenied() {
975 if (getStatus() == WorkflowConstants.STATUS_DENIED) {
976 return true;
977 }
978 else {
979 return false;
980 }
981 }
982
983 @Override
984 public boolean isDraft() {
985 if (getStatus() == WorkflowConstants.STATUS_DRAFT) {
986 return true;
987 }
988 else {
989 return false;
990 }
991 }
992
993 @Override
994 public boolean isExpired() {
995 if (getStatus() == WorkflowConstants.STATUS_EXPIRED) {
996 return true;
997 }
998 else {
999 return false;
1000 }
1001 }
1002
1003 @Override
1004 public boolean isInactive() {
1005 if (getStatus() == WorkflowConstants.STATUS_INACTIVE) {
1006 return true;
1007 }
1008 else {
1009 return false;
1010 }
1011 }
1012
1013 @Override
1014 public boolean isIncomplete() {
1015 if (getStatus() == WorkflowConstants.STATUS_INCOMPLETE) {
1016 return true;
1017 }
1018 else {
1019 return false;
1020 }
1021 }
1022
1023 @Override
1024 public boolean isPending() {
1025 if (getStatus() == WorkflowConstants.STATUS_PENDING) {
1026 return true;
1027 }
1028 else {
1029 return false;
1030 }
1031 }
1032
1033 @Override
1034 public boolean isScheduled() {
1035 if (getStatus() == WorkflowConstants.STATUS_SCHEDULED) {
1036 return true;
1037 }
1038 else {
1039 return false;
1040 }
1041 }
1042
1043 public long getColumnBitmask() {
1044 return _columnBitmask;
1045 }
1046
1047 @Override
1048 public ExpandoBridge getExpandoBridge() {
1049 return ExpandoBridgeFactoryUtil.getExpandoBridge(getCompanyId(),
1050 MBThread.class.getName(), getPrimaryKey());
1051 }
1052
1053 @Override
1054 public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
1055 ExpandoBridge expandoBridge = getExpandoBridge();
1056
1057 expandoBridge.setAttributes(serviceContext);
1058 }
1059
1060 @Override
1061 public MBThread toEscapedModel() {
1062 if (_escapedModel == null) {
1063 _escapedModel = (MBThread)ProxyUtil.newProxyInstance(_classLoader,
1064 _escapedModelInterfaces, new AutoEscapeBeanHandler(this));
1065 }
1066
1067 return _escapedModel;
1068 }
1069
1070 @Override
1071 public Object clone() {
1072 MBThreadImpl mbThreadImpl = new MBThreadImpl();
1073
1074 mbThreadImpl.setUuid(getUuid());
1075 mbThreadImpl.setThreadId(getThreadId());
1076 mbThreadImpl.setGroupId(getGroupId());
1077 mbThreadImpl.setCompanyId(getCompanyId());
1078 mbThreadImpl.setUserId(getUserId());
1079 mbThreadImpl.setUserName(getUserName());
1080 mbThreadImpl.setCreateDate(getCreateDate());
1081 mbThreadImpl.setModifiedDate(getModifiedDate());
1082 mbThreadImpl.setCategoryId(getCategoryId());
1083 mbThreadImpl.setRootMessageId(getRootMessageId());
1084 mbThreadImpl.setRootMessageUserId(getRootMessageUserId());
1085 mbThreadImpl.setMessageCount(getMessageCount());
1086 mbThreadImpl.setViewCount(getViewCount());
1087 mbThreadImpl.setLastPostByUserId(getLastPostByUserId());
1088 mbThreadImpl.setLastPostDate(getLastPostDate());
1089 mbThreadImpl.setPriority(getPriority());
1090 mbThreadImpl.setQuestion(getQuestion());
1091 mbThreadImpl.setStatus(getStatus());
1092 mbThreadImpl.setStatusByUserId(getStatusByUserId());
1093 mbThreadImpl.setStatusByUserName(getStatusByUserName());
1094 mbThreadImpl.setStatusDate(getStatusDate());
1095
1096 mbThreadImpl.resetOriginalValues();
1097
1098 return mbThreadImpl;
1099 }
1100
1101 @Override
1102 public int compareTo(MBThread mbThread) {
1103 int value = 0;
1104
1105 if (getPriority() < mbThread.getPriority()) {
1106 value = -1;
1107 }
1108 else if (getPriority() > mbThread.getPriority()) {
1109 value = 1;
1110 }
1111 else {
1112 value = 0;
1113 }
1114
1115 value = value * -1;
1116
1117 if (value != 0) {
1118 return value;
1119 }
1120
1121 value = DateUtil.compareTo(getLastPostDate(), mbThread.getLastPostDate());
1122
1123 value = value * -1;
1124
1125 if (value != 0) {
1126 return value;
1127 }
1128
1129 return 0;
1130 }
1131
1132 @Override
1133 public boolean equals(Object obj) {
1134 if (this == obj) {
1135 return true;
1136 }
1137
1138 if (!(obj instanceof MBThread)) {
1139 return false;
1140 }
1141
1142 MBThread mbThread = (MBThread)obj;
1143
1144 long primaryKey = mbThread.getPrimaryKey();
1145
1146 if (getPrimaryKey() == primaryKey) {
1147 return true;
1148 }
1149 else {
1150 return false;
1151 }
1152 }
1153
1154 @Override
1155 public int hashCode() {
1156 return (int)getPrimaryKey();
1157 }
1158
1159 @Override
1160 public boolean isEntityCacheEnabled() {
1161 return ENTITY_CACHE_ENABLED;
1162 }
1163
1164 @Override
1165 public boolean isFinderCacheEnabled() {
1166 return FINDER_CACHE_ENABLED;
1167 }
1168
1169 @Override
1170 public void resetOriginalValues() {
1171 MBThreadModelImpl mbThreadModelImpl = this;
1172
1173 mbThreadModelImpl._originalUuid = mbThreadModelImpl._uuid;
1174
1175 mbThreadModelImpl._originalGroupId = mbThreadModelImpl._groupId;
1176
1177 mbThreadModelImpl._setOriginalGroupId = false;
1178
1179 mbThreadModelImpl._originalCompanyId = mbThreadModelImpl._companyId;
1180
1181 mbThreadModelImpl._setOriginalCompanyId = false;
1182
1183 mbThreadModelImpl._setModifiedDate = false;
1184
1185 mbThreadModelImpl._originalCategoryId = mbThreadModelImpl._categoryId;
1186
1187 mbThreadModelImpl._setOriginalCategoryId = false;
1188
1189 mbThreadModelImpl._originalRootMessageId = mbThreadModelImpl._rootMessageId;
1190
1191 mbThreadModelImpl._setOriginalRootMessageId = false;
1192
1193 mbThreadModelImpl._originalLastPostDate = mbThreadModelImpl._lastPostDate;
1194
1195 mbThreadModelImpl._originalPriority = mbThreadModelImpl._priority;
1196
1197 mbThreadModelImpl._setOriginalPriority = false;
1198
1199 mbThreadModelImpl._originalStatus = mbThreadModelImpl._status;
1200
1201 mbThreadModelImpl._setOriginalStatus = false;
1202
1203 mbThreadModelImpl._columnBitmask = 0;
1204 }
1205
1206 @Override
1207 public CacheModel<MBThread> toCacheModel() {
1208 MBThreadCacheModel mbThreadCacheModel = new MBThreadCacheModel();
1209
1210 mbThreadCacheModel.uuid = getUuid();
1211
1212 String uuid = mbThreadCacheModel.uuid;
1213
1214 if ((uuid != null) && (uuid.length() == 0)) {
1215 mbThreadCacheModel.uuid = null;
1216 }
1217
1218 mbThreadCacheModel.threadId = getThreadId();
1219
1220 mbThreadCacheModel.groupId = getGroupId();
1221
1222 mbThreadCacheModel.companyId = getCompanyId();
1223
1224 mbThreadCacheModel.userId = getUserId();
1225
1226 mbThreadCacheModel.userName = getUserName();
1227
1228 String userName = mbThreadCacheModel.userName;
1229
1230 if ((userName != null) && (userName.length() == 0)) {
1231 mbThreadCacheModel.userName = null;
1232 }
1233
1234 Date createDate = getCreateDate();
1235
1236 if (createDate != null) {
1237 mbThreadCacheModel.createDate = createDate.getTime();
1238 }
1239 else {
1240 mbThreadCacheModel.createDate = Long.MIN_VALUE;
1241 }
1242
1243 Date modifiedDate = getModifiedDate();
1244
1245 if (modifiedDate != null) {
1246 mbThreadCacheModel.modifiedDate = modifiedDate.getTime();
1247 }
1248 else {
1249 mbThreadCacheModel.modifiedDate = Long.MIN_VALUE;
1250 }
1251
1252 mbThreadCacheModel.categoryId = getCategoryId();
1253
1254 mbThreadCacheModel.rootMessageId = getRootMessageId();
1255
1256 mbThreadCacheModel.rootMessageUserId = getRootMessageUserId();
1257
1258 mbThreadCacheModel.messageCount = getMessageCount();
1259
1260 mbThreadCacheModel.viewCount = getViewCount();
1261
1262 mbThreadCacheModel.lastPostByUserId = getLastPostByUserId();
1263
1264 Date lastPostDate = getLastPostDate();
1265
1266 if (lastPostDate != null) {
1267 mbThreadCacheModel.lastPostDate = lastPostDate.getTime();
1268 }
1269 else {
1270 mbThreadCacheModel.lastPostDate = Long.MIN_VALUE;
1271 }
1272
1273 mbThreadCacheModel.priority = getPriority();
1274
1275 mbThreadCacheModel.question = getQuestion();
1276
1277 mbThreadCacheModel.status = getStatus();
1278
1279 mbThreadCacheModel.statusByUserId = getStatusByUserId();
1280
1281 mbThreadCacheModel.statusByUserName = getStatusByUserName();
1282
1283 String statusByUserName = mbThreadCacheModel.statusByUserName;
1284
1285 if ((statusByUserName != null) && (statusByUserName.length() == 0)) {
1286 mbThreadCacheModel.statusByUserName = null;
1287 }
1288
1289 Date statusDate = getStatusDate();
1290
1291 if (statusDate != null) {
1292 mbThreadCacheModel.statusDate = statusDate.getTime();
1293 }
1294 else {
1295 mbThreadCacheModel.statusDate = Long.MIN_VALUE;
1296 }
1297
1298 return mbThreadCacheModel;
1299 }
1300
1301 @Override
1302 public String toString() {
1303 StringBundler sb = new StringBundler(43);
1304
1305 sb.append("{uuid=");
1306 sb.append(getUuid());
1307 sb.append(", threadId=");
1308 sb.append(getThreadId());
1309 sb.append(", groupId=");
1310 sb.append(getGroupId());
1311 sb.append(", companyId=");
1312 sb.append(getCompanyId());
1313 sb.append(", userId=");
1314 sb.append(getUserId());
1315 sb.append(", userName=");
1316 sb.append(getUserName());
1317 sb.append(", createDate=");
1318 sb.append(getCreateDate());
1319 sb.append(", modifiedDate=");
1320 sb.append(getModifiedDate());
1321 sb.append(", categoryId=");
1322 sb.append(getCategoryId());
1323 sb.append(", rootMessageId=");
1324 sb.append(getRootMessageId());
1325 sb.append(", rootMessageUserId=");
1326 sb.append(getRootMessageUserId());
1327 sb.append(", messageCount=");
1328 sb.append(getMessageCount());
1329 sb.append(", viewCount=");
1330 sb.append(getViewCount());
1331 sb.append(", lastPostByUserId=");
1332 sb.append(getLastPostByUserId());
1333 sb.append(", lastPostDate=");
1334 sb.append(getLastPostDate());
1335 sb.append(", priority=");
1336 sb.append(getPriority());
1337 sb.append(", question=");
1338 sb.append(getQuestion());
1339 sb.append(", status=");
1340 sb.append(getStatus());
1341 sb.append(", statusByUserId=");
1342 sb.append(getStatusByUserId());
1343 sb.append(", statusByUserName=");
1344 sb.append(getStatusByUserName());
1345 sb.append(", statusDate=");
1346 sb.append(getStatusDate());
1347 sb.append("}");
1348
1349 return sb.toString();
1350 }
1351
1352 @Override
1353 public String toXmlString() {
1354 StringBundler sb = new StringBundler(67);
1355
1356 sb.append("<model><model-name>");
1357 sb.append("com.liferay.portlet.messageboards.model.MBThread");
1358 sb.append("</model-name>");
1359
1360 sb.append(
1361 "<column><column-name>uuid</column-name><column-value><![CDATA[");
1362 sb.append(getUuid());
1363 sb.append("]]></column-value></column>");
1364 sb.append(
1365 "<column><column-name>threadId</column-name><column-value><![CDATA[");
1366 sb.append(getThreadId());
1367 sb.append("]]></column-value></column>");
1368 sb.append(
1369 "<column><column-name>groupId</column-name><column-value><![CDATA[");
1370 sb.append(getGroupId());
1371 sb.append("]]></column-value></column>");
1372 sb.append(
1373 "<column><column-name>companyId</column-name><column-value><![CDATA[");
1374 sb.append(getCompanyId());
1375 sb.append("]]></column-value></column>");
1376 sb.append(
1377 "<column><column-name>userId</column-name><column-value><![CDATA[");
1378 sb.append(getUserId());
1379 sb.append("]]></column-value></column>");
1380 sb.append(
1381 "<column><column-name>userName</column-name><column-value><![CDATA[");
1382 sb.append(getUserName());
1383 sb.append("]]></column-value></column>");
1384 sb.append(
1385 "<column><column-name>createDate</column-name><column-value><![CDATA[");
1386 sb.append(getCreateDate());
1387 sb.append("]]></column-value></column>");
1388 sb.append(
1389 "<column><column-name>modifiedDate</column-name><column-value><![CDATA[");
1390 sb.append(getModifiedDate());
1391 sb.append("]]></column-value></column>");
1392 sb.append(
1393 "<column><column-name>categoryId</column-name><column-value><![CDATA[");
1394 sb.append(getCategoryId());
1395 sb.append("]]></column-value></column>");
1396 sb.append(
1397 "<column><column-name>rootMessageId</column-name><column-value><![CDATA[");
1398 sb.append(getRootMessageId());
1399 sb.append("]]></column-value></column>");
1400 sb.append(
1401 "<column><column-name>rootMessageUserId</column-name><column-value><![CDATA[");
1402 sb.append(getRootMessageUserId());
1403 sb.append("]]></column-value></column>");
1404 sb.append(
1405 "<column><column-name>messageCount</column-name><column-value><![CDATA[");
1406 sb.append(getMessageCount());
1407 sb.append("]]></column-value></column>");
1408 sb.append(
1409 "<column><column-name>viewCount</column-name><column-value><![CDATA[");
1410 sb.append(getViewCount());
1411 sb.append("]]></column-value></column>");
1412 sb.append(
1413 "<column><column-name>lastPostByUserId</column-name><column-value><![CDATA[");
1414 sb.append(getLastPostByUserId());
1415 sb.append("]]></column-value></column>");
1416 sb.append(
1417 "<column><column-name>lastPostDate</column-name><column-value><![CDATA[");
1418 sb.append(getLastPostDate());
1419 sb.append("]]></column-value></column>");
1420 sb.append(
1421 "<column><column-name>priority</column-name><column-value><![CDATA[");
1422 sb.append(getPriority());
1423 sb.append("]]></column-value></column>");
1424 sb.append(
1425 "<column><column-name>question</column-name><column-value><![CDATA[");
1426 sb.append(getQuestion());
1427 sb.append("]]></column-value></column>");
1428 sb.append(
1429 "<column><column-name>status</column-name><column-value><![CDATA[");
1430 sb.append(getStatus());
1431 sb.append("]]></column-value></column>");
1432 sb.append(
1433 "<column><column-name>statusByUserId</column-name><column-value><![CDATA[");
1434 sb.append(getStatusByUserId());
1435 sb.append("]]></column-value></column>");
1436 sb.append(
1437 "<column><column-name>statusByUserName</column-name><column-value><![CDATA[");
1438 sb.append(getStatusByUserName());
1439 sb.append("]]></column-value></column>");
1440 sb.append(
1441 "<column><column-name>statusDate</column-name><column-value><![CDATA[");
1442 sb.append(getStatusDate());
1443 sb.append("]]></column-value></column>");
1444
1445 sb.append("</model>");
1446
1447 return sb.toString();
1448 }
1449
1450 private static final ClassLoader _classLoader = MBThread.class.getClassLoader();
1451 private static final Class<?>[] _escapedModelInterfaces = new Class[] {
1452 MBThread.class
1453 };
1454 private String _uuid;
1455 private String _originalUuid;
1456 private long _threadId;
1457 private long _groupId;
1458 private long _originalGroupId;
1459 private boolean _setOriginalGroupId;
1460 private long _companyId;
1461 private long _originalCompanyId;
1462 private boolean _setOriginalCompanyId;
1463 private long _userId;
1464 private String _userName;
1465 private Date _createDate;
1466 private Date _modifiedDate;
1467 private boolean _setModifiedDate;
1468 private long _categoryId;
1469 private long _originalCategoryId;
1470 private boolean _setOriginalCategoryId;
1471 private long _rootMessageId;
1472 private long _originalRootMessageId;
1473 private boolean _setOriginalRootMessageId;
1474 private long _rootMessageUserId;
1475 private int _messageCount;
1476 private int _viewCount;
1477 private long _lastPostByUserId;
1478 private Date _lastPostDate;
1479 private Date _originalLastPostDate;
1480 private double _priority;
1481 private double _originalPriority;
1482 private boolean _setOriginalPriority;
1483 private boolean _question;
1484 private int _status;
1485 private int _originalStatus;
1486 private boolean _setOriginalStatus;
1487 private long _statusByUserId;
1488 private String _statusByUserName;
1489 private Date _statusDate;
1490 private long _columnBitmask;
1491 private MBThread _escapedModel;
1492 }