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