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