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