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.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
918 @Deprecated
919 @Override
920 public boolean getApproved() {
921 return isApproved();
922 }
923
924 @Override
925 public boolean isApproved() {
926 if (getStatus() == WorkflowConstants.STATUS_APPROVED) {
927 return true;
928 }
929 else {
930 return false;
931 }
932 }
933
934 @Override
935 public boolean isDenied() {
936 if (getStatus() == WorkflowConstants.STATUS_DENIED) {
937 return true;
938 }
939 else {
940 return false;
941 }
942 }
943
944 @Override
945 public boolean isDraft() {
946 if (getStatus() == WorkflowConstants.STATUS_DRAFT) {
947 return true;
948 }
949 else {
950 return false;
951 }
952 }
953
954 @Override
955 public boolean isExpired() {
956 if (getStatus() == WorkflowConstants.STATUS_EXPIRED) {
957 return true;
958 }
959 else {
960 return false;
961 }
962 }
963
964 @Override
965 public boolean isInactive() {
966 if (getStatus() == WorkflowConstants.STATUS_INACTIVE) {
967 return true;
968 }
969 else {
970 return false;
971 }
972 }
973
974 @Override
975 public boolean isIncomplete() {
976 if (getStatus() == WorkflowConstants.STATUS_INCOMPLETE) {
977 return true;
978 }
979 else {
980 return false;
981 }
982 }
983
984 @Override
985 public boolean isPending() {
986 if (getStatus() == WorkflowConstants.STATUS_PENDING) {
987 return true;
988 }
989 else {
990 return false;
991 }
992 }
993
994 @Override
995 public boolean isScheduled() {
996 if (getStatus() == WorkflowConstants.STATUS_SCHEDULED) {
997 return true;
998 }
999 else {
1000 return false;
1001 }
1002 }
1003
1004 public long getColumnBitmask() {
1005 return _columnBitmask;
1006 }
1007
1008 @Override
1009 public ExpandoBridge getExpandoBridge() {
1010 return ExpandoBridgeFactoryUtil.getExpandoBridge(getCompanyId(),
1011 MBCategory.class.getName(), getPrimaryKey());
1012 }
1013
1014 @Override
1015 public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
1016 ExpandoBridge expandoBridge = getExpandoBridge();
1017
1018 expandoBridge.setAttributes(serviceContext);
1019 }
1020
1021 @Override
1022 public MBCategory toEscapedModel() {
1023 if (_escapedModel == null) {
1024 _escapedModel = (MBCategory)ProxyUtil.newProxyInstance(_classLoader,
1025 _escapedModelInterfaces, new AutoEscapeBeanHandler(this));
1026 }
1027
1028 return _escapedModel;
1029 }
1030
1031 @Override
1032 public Object clone() {
1033 MBCategoryImpl mbCategoryImpl = new MBCategoryImpl();
1034
1035 mbCategoryImpl.setUuid(getUuid());
1036 mbCategoryImpl.setCategoryId(getCategoryId());
1037 mbCategoryImpl.setGroupId(getGroupId());
1038 mbCategoryImpl.setCompanyId(getCompanyId());
1039 mbCategoryImpl.setUserId(getUserId());
1040 mbCategoryImpl.setUserName(getUserName());
1041 mbCategoryImpl.setCreateDate(getCreateDate());
1042 mbCategoryImpl.setModifiedDate(getModifiedDate());
1043 mbCategoryImpl.setParentCategoryId(getParentCategoryId());
1044 mbCategoryImpl.setName(getName());
1045 mbCategoryImpl.setDescription(getDescription());
1046 mbCategoryImpl.setDisplayStyle(getDisplayStyle());
1047 mbCategoryImpl.setThreadCount(getThreadCount());
1048 mbCategoryImpl.setMessageCount(getMessageCount());
1049 mbCategoryImpl.setLastPostDate(getLastPostDate());
1050 mbCategoryImpl.setLastPublishDate(getLastPublishDate());
1051 mbCategoryImpl.setStatus(getStatus());
1052 mbCategoryImpl.setStatusByUserId(getStatusByUserId());
1053 mbCategoryImpl.setStatusByUserName(getStatusByUserName());
1054 mbCategoryImpl.setStatusDate(getStatusDate());
1055
1056 mbCategoryImpl.resetOriginalValues();
1057
1058 return mbCategoryImpl;
1059 }
1060
1061 @Override
1062 public int compareTo(MBCategory mbCategory) {
1063 int value = 0;
1064
1065 if (getParentCategoryId() < mbCategory.getParentCategoryId()) {
1066 value = -1;
1067 }
1068 else if (getParentCategoryId() > mbCategory.getParentCategoryId()) {
1069 value = 1;
1070 }
1071 else {
1072 value = 0;
1073 }
1074
1075 if (value != 0) {
1076 return value;
1077 }
1078
1079 value = getName().compareToIgnoreCase(mbCategory.getName());
1080
1081 if (value != 0) {
1082 return value;
1083 }
1084
1085 return 0;
1086 }
1087
1088 @Override
1089 public boolean equals(Object obj) {
1090 if (this == obj) {
1091 return true;
1092 }
1093
1094 if (!(obj instanceof MBCategory)) {
1095 return false;
1096 }
1097
1098 MBCategory mbCategory = (MBCategory)obj;
1099
1100 long primaryKey = mbCategory.getPrimaryKey();
1101
1102 if (getPrimaryKey() == primaryKey) {
1103 return true;
1104 }
1105 else {
1106 return false;
1107 }
1108 }
1109
1110 @Override
1111 public int hashCode() {
1112 return (int)getPrimaryKey();
1113 }
1114
1115 @Override
1116 public boolean isEntityCacheEnabled() {
1117 return ENTITY_CACHE_ENABLED;
1118 }
1119
1120 @Override
1121 public boolean isFinderCacheEnabled() {
1122 return FINDER_CACHE_ENABLED;
1123 }
1124
1125 @Override
1126 public void resetOriginalValues() {
1127 MBCategoryModelImpl mbCategoryModelImpl = this;
1128
1129 mbCategoryModelImpl._originalUuid = mbCategoryModelImpl._uuid;
1130
1131 mbCategoryModelImpl._originalCategoryId = mbCategoryModelImpl._categoryId;
1132
1133 mbCategoryModelImpl._setOriginalCategoryId = false;
1134
1135 mbCategoryModelImpl._originalGroupId = mbCategoryModelImpl._groupId;
1136
1137 mbCategoryModelImpl._setOriginalGroupId = false;
1138
1139 mbCategoryModelImpl._originalCompanyId = mbCategoryModelImpl._companyId;
1140
1141 mbCategoryModelImpl._setOriginalCompanyId = false;
1142
1143 mbCategoryModelImpl._setModifiedDate = false;
1144
1145 mbCategoryModelImpl._originalParentCategoryId = mbCategoryModelImpl._parentCategoryId;
1146
1147 mbCategoryModelImpl._setOriginalParentCategoryId = false;
1148
1149 mbCategoryModelImpl._originalStatus = mbCategoryModelImpl._status;
1150
1151 mbCategoryModelImpl._setOriginalStatus = false;
1152
1153 mbCategoryModelImpl._columnBitmask = 0;
1154 }
1155
1156 @Override
1157 public CacheModel<MBCategory> toCacheModel() {
1158 MBCategoryCacheModel mbCategoryCacheModel = new MBCategoryCacheModel();
1159
1160 mbCategoryCacheModel.uuid = getUuid();
1161
1162 String uuid = mbCategoryCacheModel.uuid;
1163
1164 if ((uuid != null) && (uuid.length() == 0)) {
1165 mbCategoryCacheModel.uuid = null;
1166 }
1167
1168 mbCategoryCacheModel.categoryId = getCategoryId();
1169
1170 mbCategoryCacheModel.groupId = getGroupId();
1171
1172 mbCategoryCacheModel.companyId = getCompanyId();
1173
1174 mbCategoryCacheModel.userId = getUserId();
1175
1176 mbCategoryCacheModel.userName = getUserName();
1177
1178 String userName = mbCategoryCacheModel.userName;
1179
1180 if ((userName != null) && (userName.length() == 0)) {
1181 mbCategoryCacheModel.userName = null;
1182 }
1183
1184 Date createDate = getCreateDate();
1185
1186 if (createDate != null) {
1187 mbCategoryCacheModel.createDate = createDate.getTime();
1188 }
1189 else {
1190 mbCategoryCacheModel.createDate = Long.MIN_VALUE;
1191 }
1192
1193 Date modifiedDate = getModifiedDate();
1194
1195 if (modifiedDate != null) {
1196 mbCategoryCacheModel.modifiedDate = modifiedDate.getTime();
1197 }
1198 else {
1199 mbCategoryCacheModel.modifiedDate = Long.MIN_VALUE;
1200 }
1201
1202 mbCategoryCacheModel.parentCategoryId = getParentCategoryId();
1203
1204 mbCategoryCacheModel.name = getName();
1205
1206 String name = mbCategoryCacheModel.name;
1207
1208 if ((name != null) && (name.length() == 0)) {
1209 mbCategoryCacheModel.name = null;
1210 }
1211
1212 mbCategoryCacheModel.description = getDescription();
1213
1214 String description = mbCategoryCacheModel.description;
1215
1216 if ((description != null) && (description.length() == 0)) {
1217 mbCategoryCacheModel.description = null;
1218 }
1219
1220 mbCategoryCacheModel.displayStyle = getDisplayStyle();
1221
1222 String displayStyle = mbCategoryCacheModel.displayStyle;
1223
1224 if ((displayStyle != null) && (displayStyle.length() == 0)) {
1225 mbCategoryCacheModel.displayStyle = null;
1226 }
1227
1228 mbCategoryCacheModel.threadCount = getThreadCount();
1229
1230 mbCategoryCacheModel.messageCount = getMessageCount();
1231
1232 Date lastPostDate = getLastPostDate();
1233
1234 if (lastPostDate != null) {
1235 mbCategoryCacheModel.lastPostDate = lastPostDate.getTime();
1236 }
1237 else {
1238 mbCategoryCacheModel.lastPostDate = Long.MIN_VALUE;
1239 }
1240
1241 Date lastPublishDate = getLastPublishDate();
1242
1243 if (lastPublishDate != null) {
1244 mbCategoryCacheModel.lastPublishDate = lastPublishDate.getTime();
1245 }
1246 else {
1247 mbCategoryCacheModel.lastPublishDate = Long.MIN_VALUE;
1248 }
1249
1250 mbCategoryCacheModel.status = getStatus();
1251
1252 mbCategoryCacheModel.statusByUserId = getStatusByUserId();
1253
1254 mbCategoryCacheModel.statusByUserName = getStatusByUserName();
1255
1256 String statusByUserName = mbCategoryCacheModel.statusByUserName;
1257
1258 if ((statusByUserName != null) && (statusByUserName.length() == 0)) {
1259 mbCategoryCacheModel.statusByUserName = null;
1260 }
1261
1262 Date statusDate = getStatusDate();
1263
1264 if (statusDate != null) {
1265 mbCategoryCacheModel.statusDate = statusDate.getTime();
1266 }
1267 else {
1268 mbCategoryCacheModel.statusDate = Long.MIN_VALUE;
1269 }
1270
1271 return mbCategoryCacheModel;
1272 }
1273
1274 @Override
1275 public String toString() {
1276 StringBundler sb = new StringBundler(41);
1277
1278 sb.append("{uuid=");
1279 sb.append(getUuid());
1280 sb.append(", categoryId=");
1281 sb.append(getCategoryId());
1282 sb.append(", groupId=");
1283 sb.append(getGroupId());
1284 sb.append(", companyId=");
1285 sb.append(getCompanyId());
1286 sb.append(", userId=");
1287 sb.append(getUserId());
1288 sb.append(", userName=");
1289 sb.append(getUserName());
1290 sb.append(", createDate=");
1291 sb.append(getCreateDate());
1292 sb.append(", modifiedDate=");
1293 sb.append(getModifiedDate());
1294 sb.append(", parentCategoryId=");
1295 sb.append(getParentCategoryId());
1296 sb.append(", name=");
1297 sb.append(getName());
1298 sb.append(", description=");
1299 sb.append(getDescription());
1300 sb.append(", displayStyle=");
1301 sb.append(getDisplayStyle());
1302 sb.append(", threadCount=");
1303 sb.append(getThreadCount());
1304 sb.append(", messageCount=");
1305 sb.append(getMessageCount());
1306 sb.append(", lastPostDate=");
1307 sb.append(getLastPostDate());
1308 sb.append(", lastPublishDate=");
1309 sb.append(getLastPublishDate());
1310 sb.append(", status=");
1311 sb.append(getStatus());
1312 sb.append(", statusByUserId=");
1313 sb.append(getStatusByUserId());
1314 sb.append(", statusByUserName=");
1315 sb.append(getStatusByUserName());
1316 sb.append(", statusDate=");
1317 sb.append(getStatusDate());
1318 sb.append("}");
1319
1320 return sb.toString();
1321 }
1322
1323 @Override
1324 public String toXmlString() {
1325 StringBundler sb = new StringBundler(64);
1326
1327 sb.append("<model><model-name>");
1328 sb.append("com.liferay.portlet.messageboards.model.MBCategory");
1329 sb.append("</model-name>");
1330
1331 sb.append(
1332 "<column><column-name>uuid</column-name><column-value><![CDATA[");
1333 sb.append(getUuid());
1334 sb.append("]]></column-value></column>");
1335 sb.append(
1336 "<column><column-name>categoryId</column-name><column-value><![CDATA[");
1337 sb.append(getCategoryId());
1338 sb.append("]]></column-value></column>");
1339 sb.append(
1340 "<column><column-name>groupId</column-name><column-value><![CDATA[");
1341 sb.append(getGroupId());
1342 sb.append("]]></column-value></column>");
1343 sb.append(
1344 "<column><column-name>companyId</column-name><column-value><![CDATA[");
1345 sb.append(getCompanyId());
1346 sb.append("]]></column-value></column>");
1347 sb.append(
1348 "<column><column-name>userId</column-name><column-value><![CDATA[");
1349 sb.append(getUserId());
1350 sb.append("]]></column-value></column>");
1351 sb.append(
1352 "<column><column-name>userName</column-name><column-value><![CDATA[");
1353 sb.append(getUserName());
1354 sb.append("]]></column-value></column>");
1355 sb.append(
1356 "<column><column-name>createDate</column-name><column-value><![CDATA[");
1357 sb.append(getCreateDate());
1358 sb.append("]]></column-value></column>");
1359 sb.append(
1360 "<column><column-name>modifiedDate</column-name><column-value><![CDATA[");
1361 sb.append(getModifiedDate());
1362 sb.append("]]></column-value></column>");
1363 sb.append(
1364 "<column><column-name>parentCategoryId</column-name><column-value><![CDATA[");
1365 sb.append(getParentCategoryId());
1366 sb.append("]]></column-value></column>");
1367 sb.append(
1368 "<column><column-name>name</column-name><column-value><![CDATA[");
1369 sb.append(getName());
1370 sb.append("]]></column-value></column>");
1371 sb.append(
1372 "<column><column-name>description</column-name><column-value><![CDATA[");
1373 sb.append(getDescription());
1374 sb.append("]]></column-value></column>");
1375 sb.append(
1376 "<column><column-name>displayStyle</column-name><column-value><![CDATA[");
1377 sb.append(getDisplayStyle());
1378 sb.append("]]></column-value></column>");
1379 sb.append(
1380 "<column><column-name>threadCount</column-name><column-value><![CDATA[");
1381 sb.append(getThreadCount());
1382 sb.append("]]></column-value></column>");
1383 sb.append(
1384 "<column><column-name>messageCount</column-name><column-value><![CDATA[");
1385 sb.append(getMessageCount());
1386 sb.append("]]></column-value></column>");
1387 sb.append(
1388 "<column><column-name>lastPostDate</column-name><column-value><![CDATA[");
1389 sb.append(getLastPostDate());
1390 sb.append("]]></column-value></column>");
1391 sb.append(
1392 "<column><column-name>lastPublishDate</column-name><column-value><![CDATA[");
1393 sb.append(getLastPublishDate());
1394 sb.append("]]></column-value></column>");
1395 sb.append(
1396 "<column><column-name>status</column-name><column-value><![CDATA[");
1397 sb.append(getStatus());
1398 sb.append("]]></column-value></column>");
1399 sb.append(
1400 "<column><column-name>statusByUserId</column-name><column-value><![CDATA[");
1401 sb.append(getStatusByUserId());
1402 sb.append("]]></column-value></column>");
1403 sb.append(
1404 "<column><column-name>statusByUserName</column-name><column-value><![CDATA[");
1405 sb.append(getStatusByUserName());
1406 sb.append("]]></column-value></column>");
1407 sb.append(
1408 "<column><column-name>statusDate</column-name><column-value><![CDATA[");
1409 sb.append(getStatusDate());
1410 sb.append("]]></column-value></column>");
1411
1412 sb.append("</model>");
1413
1414 return sb.toString();
1415 }
1416
1417 private static final ClassLoader _classLoader = MBCategory.class.getClassLoader();
1418 private static final Class<?>[] _escapedModelInterfaces = new Class[] {
1419 MBCategory.class
1420 };
1421 private String _uuid;
1422 private String _originalUuid;
1423 private long _categoryId;
1424 private long _originalCategoryId;
1425 private boolean _setOriginalCategoryId;
1426 private long _groupId;
1427 private long _originalGroupId;
1428 private boolean _setOriginalGroupId;
1429 private long _companyId;
1430 private long _originalCompanyId;
1431 private boolean _setOriginalCompanyId;
1432 private long _userId;
1433 private String _userName;
1434 private Date _createDate;
1435 private Date _modifiedDate;
1436 private boolean _setModifiedDate;
1437 private long _parentCategoryId;
1438 private long _originalParentCategoryId;
1439 private boolean _setOriginalParentCategoryId;
1440 private String _name;
1441 private String _description;
1442 private String _displayStyle;
1443 private int _threadCount;
1444 private int _messageCount;
1445 private Date _lastPostDate;
1446 private Date _lastPublishDate;
1447 private int _status;
1448 private int _originalStatus;
1449 private boolean _setOriginalStatus;
1450 private long _statusByUserId;
1451 private String _statusByUserName;
1452 private Date _statusDate;
1453 private long _columnBitmask;
1454 private MBCategory _escapedModel;
1455 }