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