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                                    getPrimaryKey());
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 TrashHandler getTrashHandler() {
746                    return TrashHandlerRegistryUtil.getTrashHandler(getModelClassName());
747            }
748    
749            @Override
750            public boolean isInTrash() {
751                    if (getStatus() == WorkflowConstants.STATUS_IN_TRASH) {
752                            return true;
753                    }
754                    else {
755                            return false;
756                    }
757            }
758    
759            @Override
760            public boolean isInTrashContainer() {
761                    TrashHandler trashHandler = getTrashHandler();
762    
763                    if ((trashHandler == null) ||
764                                    Validator.isNull(trashHandler.getContainerModelClassName())) {
765                            return false;
766                    }
767    
768                    try {
769                            ContainerModel containerModel = trashHandler.getParentContainerModel(this);
770    
771                            if (containerModel == null) {
772                                    return false;
773                            }
774    
775                            if (containerModel instanceof TrashedModel) {
776                                    return ((TrashedModel)containerModel).isInTrash();
777                            }
778                    }
779                    catch (Exception e) {
780                    }
781    
782                    return false;
783            }
784    
785            /**
786             * @deprecated As of 6.1.0, replaced by {@link #isApproved}
787             */
788            @Override
789            public boolean getApproved() {
790                    return isApproved();
791            }
792    
793            @Override
794            public boolean isApproved() {
795                    if (getStatus() == WorkflowConstants.STATUS_APPROVED) {
796                            return true;
797                    }
798                    else {
799                            return false;
800                    }
801            }
802    
803            @Override
804            public boolean isDenied() {
805                    if (getStatus() == WorkflowConstants.STATUS_DENIED) {
806                            return true;
807                    }
808                    else {
809                            return false;
810                    }
811            }
812    
813            @Override
814            public boolean isDraft() {
815                    if (getStatus() == WorkflowConstants.STATUS_DRAFT) {
816                            return true;
817                    }
818                    else {
819                            return false;
820                    }
821            }
822    
823            @Override
824            public boolean isExpired() {
825                    if (getStatus() == WorkflowConstants.STATUS_EXPIRED) {
826                            return true;
827                    }
828                    else {
829                            return false;
830                    }
831            }
832    
833            @Override
834            public boolean isInactive() {
835                    if (getStatus() == WorkflowConstants.STATUS_INACTIVE) {
836                            return true;
837                    }
838                    else {
839                            return false;
840                    }
841            }
842    
843            @Override
844            public boolean isIncomplete() {
845                    if (getStatus() == WorkflowConstants.STATUS_INCOMPLETE) {
846                            return true;
847                    }
848                    else {
849                            return false;
850                    }
851            }
852    
853            @Override
854            public boolean isPending() {
855                    if (getStatus() == WorkflowConstants.STATUS_PENDING) {
856                            return true;
857                    }
858                    else {
859                            return false;
860                    }
861            }
862    
863            @Override
864            public boolean isScheduled() {
865                    if (getStatus() == WorkflowConstants.STATUS_SCHEDULED) {
866                            return true;
867                    }
868                    else {
869                            return false;
870                    }
871            }
872    
873            public long getColumnBitmask() {
874                    return _columnBitmask;
875            }
876    
877            @Override
878            public ExpandoBridge getExpandoBridge() {
879                    return ExpandoBridgeFactoryUtil.getExpandoBridge(getCompanyId(),
880                            MBCategory.class.getName(), getPrimaryKey());
881            }
882    
883            @Override
884            public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
885                    ExpandoBridge expandoBridge = getExpandoBridge();
886    
887                    expandoBridge.setAttributes(serviceContext);
888            }
889    
890            @Override
891            public MBCategory toEscapedModel() {
892                    if (_escapedModel == null) {
893                            _escapedModel = (MBCategory)ProxyUtil.newProxyInstance(_classLoader,
894                                            _escapedModelInterfaces, new AutoEscapeBeanHandler(this));
895                    }
896    
897                    return _escapedModel;
898            }
899    
900            @Override
901            public Object clone() {
902                    MBCategoryImpl mbCategoryImpl = new MBCategoryImpl();
903    
904                    mbCategoryImpl.setUuid(getUuid());
905                    mbCategoryImpl.setCategoryId(getCategoryId());
906                    mbCategoryImpl.setGroupId(getGroupId());
907                    mbCategoryImpl.setCompanyId(getCompanyId());
908                    mbCategoryImpl.setUserId(getUserId());
909                    mbCategoryImpl.setUserName(getUserName());
910                    mbCategoryImpl.setCreateDate(getCreateDate());
911                    mbCategoryImpl.setModifiedDate(getModifiedDate());
912                    mbCategoryImpl.setParentCategoryId(getParentCategoryId());
913                    mbCategoryImpl.setName(getName());
914                    mbCategoryImpl.setDescription(getDescription());
915                    mbCategoryImpl.setDisplayStyle(getDisplayStyle());
916                    mbCategoryImpl.setThreadCount(getThreadCount());
917                    mbCategoryImpl.setMessageCount(getMessageCount());
918                    mbCategoryImpl.setLastPostDate(getLastPostDate());
919                    mbCategoryImpl.setStatus(getStatus());
920                    mbCategoryImpl.setStatusByUserId(getStatusByUserId());
921                    mbCategoryImpl.setStatusByUserName(getStatusByUserName());
922                    mbCategoryImpl.setStatusDate(getStatusDate());
923    
924                    mbCategoryImpl.resetOriginalValues();
925    
926                    return mbCategoryImpl;
927            }
928    
929            @Override
930            public int compareTo(MBCategory mbCategory) {
931                    int value = 0;
932    
933                    if (getParentCategoryId() < mbCategory.getParentCategoryId()) {
934                            value = -1;
935                    }
936                    else if (getParentCategoryId() > mbCategory.getParentCategoryId()) {
937                            value = 1;
938                    }
939                    else {
940                            value = 0;
941                    }
942    
943                    if (value != 0) {
944                            return value;
945                    }
946    
947                    value = getName().compareToIgnoreCase(mbCategory.getName());
948    
949                    if (value != 0) {
950                            return value;
951                    }
952    
953                    return 0;
954            }
955    
956            @Override
957            public boolean equals(Object obj) {
958                    if (this == obj) {
959                            return true;
960                    }
961    
962                    if (!(obj instanceof MBCategory)) {
963                            return false;
964                    }
965    
966                    MBCategory mbCategory = (MBCategory)obj;
967    
968                    long primaryKey = mbCategory.getPrimaryKey();
969    
970                    if (getPrimaryKey() == primaryKey) {
971                            return true;
972                    }
973                    else {
974                            return false;
975                    }
976            }
977    
978            @Override
979            public int hashCode() {
980                    return (int)getPrimaryKey();
981            }
982    
983            @Override
984            public void resetOriginalValues() {
985                    MBCategoryModelImpl mbCategoryModelImpl = this;
986    
987                    mbCategoryModelImpl._originalUuid = mbCategoryModelImpl._uuid;
988    
989                    mbCategoryModelImpl._originalGroupId = mbCategoryModelImpl._groupId;
990    
991                    mbCategoryModelImpl._setOriginalGroupId = false;
992    
993                    mbCategoryModelImpl._originalCompanyId = mbCategoryModelImpl._companyId;
994    
995                    mbCategoryModelImpl._setOriginalCompanyId = false;
996    
997                    mbCategoryModelImpl._originalParentCategoryId = mbCategoryModelImpl._parentCategoryId;
998    
999                    mbCategoryModelImpl._setOriginalParentCategoryId = false;
1000    
1001                    mbCategoryModelImpl._originalStatus = mbCategoryModelImpl._status;
1002    
1003                    mbCategoryModelImpl._setOriginalStatus = false;
1004    
1005                    mbCategoryModelImpl._columnBitmask = 0;
1006            }
1007    
1008            @Override
1009            public CacheModel<MBCategory> toCacheModel() {
1010                    MBCategoryCacheModel mbCategoryCacheModel = new MBCategoryCacheModel();
1011    
1012                    mbCategoryCacheModel.uuid = getUuid();
1013    
1014                    String uuid = mbCategoryCacheModel.uuid;
1015    
1016                    if ((uuid != null) && (uuid.length() == 0)) {
1017                            mbCategoryCacheModel.uuid = null;
1018                    }
1019    
1020                    mbCategoryCacheModel.categoryId = getCategoryId();
1021    
1022                    mbCategoryCacheModel.groupId = getGroupId();
1023    
1024                    mbCategoryCacheModel.companyId = getCompanyId();
1025    
1026                    mbCategoryCacheModel.userId = getUserId();
1027    
1028                    mbCategoryCacheModel.userName = getUserName();
1029    
1030                    String userName = mbCategoryCacheModel.userName;
1031    
1032                    if ((userName != null) && (userName.length() == 0)) {
1033                            mbCategoryCacheModel.userName = null;
1034                    }
1035    
1036                    Date createDate = getCreateDate();
1037    
1038                    if (createDate != null) {
1039                            mbCategoryCacheModel.createDate = createDate.getTime();
1040                    }
1041                    else {
1042                            mbCategoryCacheModel.createDate = Long.MIN_VALUE;
1043                    }
1044    
1045                    Date modifiedDate = getModifiedDate();
1046    
1047                    if (modifiedDate != null) {
1048                            mbCategoryCacheModel.modifiedDate = modifiedDate.getTime();
1049                    }
1050                    else {
1051                            mbCategoryCacheModel.modifiedDate = Long.MIN_VALUE;
1052                    }
1053    
1054                    mbCategoryCacheModel.parentCategoryId = getParentCategoryId();
1055    
1056                    mbCategoryCacheModel.name = getName();
1057    
1058                    String name = mbCategoryCacheModel.name;
1059    
1060                    if ((name != null) && (name.length() == 0)) {
1061                            mbCategoryCacheModel.name = null;
1062                    }
1063    
1064                    mbCategoryCacheModel.description = getDescription();
1065    
1066                    String description = mbCategoryCacheModel.description;
1067    
1068                    if ((description != null) && (description.length() == 0)) {
1069                            mbCategoryCacheModel.description = null;
1070                    }
1071    
1072                    mbCategoryCacheModel.displayStyle = getDisplayStyle();
1073    
1074                    String displayStyle = mbCategoryCacheModel.displayStyle;
1075    
1076                    if ((displayStyle != null) && (displayStyle.length() == 0)) {
1077                            mbCategoryCacheModel.displayStyle = null;
1078                    }
1079    
1080                    mbCategoryCacheModel.threadCount = getThreadCount();
1081    
1082                    mbCategoryCacheModel.messageCount = getMessageCount();
1083    
1084                    Date lastPostDate = getLastPostDate();
1085    
1086                    if (lastPostDate != null) {
1087                            mbCategoryCacheModel.lastPostDate = lastPostDate.getTime();
1088                    }
1089                    else {
1090                            mbCategoryCacheModel.lastPostDate = Long.MIN_VALUE;
1091                    }
1092    
1093                    mbCategoryCacheModel.status = getStatus();
1094    
1095                    mbCategoryCacheModel.statusByUserId = getStatusByUserId();
1096    
1097                    mbCategoryCacheModel.statusByUserName = getStatusByUserName();
1098    
1099                    String statusByUserName = mbCategoryCacheModel.statusByUserName;
1100    
1101                    if ((statusByUserName != null) && (statusByUserName.length() == 0)) {
1102                            mbCategoryCacheModel.statusByUserName = null;
1103                    }
1104    
1105                    Date statusDate = getStatusDate();
1106    
1107                    if (statusDate != null) {
1108                            mbCategoryCacheModel.statusDate = statusDate.getTime();
1109                    }
1110                    else {
1111                            mbCategoryCacheModel.statusDate = Long.MIN_VALUE;
1112                    }
1113    
1114                    return mbCategoryCacheModel;
1115            }
1116    
1117            @Override
1118            public String toString() {
1119                    StringBundler sb = new StringBundler(39);
1120    
1121                    sb.append("{uuid=");
1122                    sb.append(getUuid());
1123                    sb.append(", categoryId=");
1124                    sb.append(getCategoryId());
1125                    sb.append(", groupId=");
1126                    sb.append(getGroupId());
1127                    sb.append(", companyId=");
1128                    sb.append(getCompanyId());
1129                    sb.append(", userId=");
1130                    sb.append(getUserId());
1131                    sb.append(", userName=");
1132                    sb.append(getUserName());
1133                    sb.append(", createDate=");
1134                    sb.append(getCreateDate());
1135                    sb.append(", modifiedDate=");
1136                    sb.append(getModifiedDate());
1137                    sb.append(", parentCategoryId=");
1138                    sb.append(getParentCategoryId());
1139                    sb.append(", name=");
1140                    sb.append(getName());
1141                    sb.append(", description=");
1142                    sb.append(getDescription());
1143                    sb.append(", displayStyle=");
1144                    sb.append(getDisplayStyle());
1145                    sb.append(", threadCount=");
1146                    sb.append(getThreadCount());
1147                    sb.append(", messageCount=");
1148                    sb.append(getMessageCount());
1149                    sb.append(", lastPostDate=");
1150                    sb.append(getLastPostDate());
1151                    sb.append(", status=");
1152                    sb.append(getStatus());
1153                    sb.append(", statusByUserId=");
1154                    sb.append(getStatusByUserId());
1155                    sb.append(", statusByUserName=");
1156                    sb.append(getStatusByUserName());
1157                    sb.append(", statusDate=");
1158                    sb.append(getStatusDate());
1159                    sb.append("}");
1160    
1161                    return sb.toString();
1162            }
1163    
1164            @Override
1165            public String toXmlString() {
1166                    StringBundler sb = new StringBundler(61);
1167    
1168                    sb.append("<model><model-name>");
1169                    sb.append("com.liferay.portlet.messageboards.model.MBCategory");
1170                    sb.append("</model-name>");
1171    
1172                    sb.append(
1173                            "<column><column-name>uuid</column-name><column-value><![CDATA[");
1174                    sb.append(getUuid());
1175                    sb.append("]]></column-value></column>");
1176                    sb.append(
1177                            "<column><column-name>categoryId</column-name><column-value><![CDATA[");
1178                    sb.append(getCategoryId());
1179                    sb.append("]]></column-value></column>");
1180                    sb.append(
1181                            "<column><column-name>groupId</column-name><column-value><![CDATA[");
1182                    sb.append(getGroupId());
1183                    sb.append("]]></column-value></column>");
1184                    sb.append(
1185                            "<column><column-name>companyId</column-name><column-value><![CDATA[");
1186                    sb.append(getCompanyId());
1187                    sb.append("]]></column-value></column>");
1188                    sb.append(
1189                            "<column><column-name>userId</column-name><column-value><![CDATA[");
1190                    sb.append(getUserId());
1191                    sb.append("]]></column-value></column>");
1192                    sb.append(
1193                            "<column><column-name>userName</column-name><column-value><![CDATA[");
1194                    sb.append(getUserName());
1195                    sb.append("]]></column-value></column>");
1196                    sb.append(
1197                            "<column><column-name>createDate</column-name><column-value><![CDATA[");
1198                    sb.append(getCreateDate());
1199                    sb.append("]]></column-value></column>");
1200                    sb.append(
1201                            "<column><column-name>modifiedDate</column-name><column-value><![CDATA[");
1202                    sb.append(getModifiedDate());
1203                    sb.append("]]></column-value></column>");
1204                    sb.append(
1205                            "<column><column-name>parentCategoryId</column-name><column-value><![CDATA[");
1206                    sb.append(getParentCategoryId());
1207                    sb.append("]]></column-value></column>");
1208                    sb.append(
1209                            "<column><column-name>name</column-name><column-value><![CDATA[");
1210                    sb.append(getName());
1211                    sb.append("]]></column-value></column>");
1212                    sb.append(
1213                            "<column><column-name>description</column-name><column-value><![CDATA[");
1214                    sb.append(getDescription());
1215                    sb.append("]]></column-value></column>");
1216                    sb.append(
1217                            "<column><column-name>displayStyle</column-name><column-value><![CDATA[");
1218                    sb.append(getDisplayStyle());
1219                    sb.append("]]></column-value></column>");
1220                    sb.append(
1221                            "<column><column-name>threadCount</column-name><column-value><![CDATA[");
1222                    sb.append(getThreadCount());
1223                    sb.append("]]></column-value></column>");
1224                    sb.append(
1225                            "<column><column-name>messageCount</column-name><column-value><![CDATA[");
1226                    sb.append(getMessageCount());
1227                    sb.append("]]></column-value></column>");
1228                    sb.append(
1229                            "<column><column-name>lastPostDate</column-name><column-value><![CDATA[");
1230                    sb.append(getLastPostDate());
1231                    sb.append("]]></column-value></column>");
1232                    sb.append(
1233                            "<column><column-name>status</column-name><column-value><![CDATA[");
1234                    sb.append(getStatus());
1235                    sb.append("]]></column-value></column>");
1236                    sb.append(
1237                            "<column><column-name>statusByUserId</column-name><column-value><![CDATA[");
1238                    sb.append(getStatusByUserId());
1239                    sb.append("]]></column-value></column>");
1240                    sb.append(
1241                            "<column><column-name>statusByUserName</column-name><column-value><![CDATA[");
1242                    sb.append(getStatusByUserName());
1243                    sb.append("]]></column-value></column>");
1244                    sb.append(
1245                            "<column><column-name>statusDate</column-name><column-value><![CDATA[");
1246                    sb.append(getStatusDate());
1247                    sb.append("]]></column-value></column>");
1248    
1249                    sb.append("</model>");
1250    
1251                    return sb.toString();
1252            }
1253    
1254            private static ClassLoader _classLoader = MBCategory.class.getClassLoader();
1255            private static Class<?>[] _escapedModelInterfaces = new Class[] {
1256                            MBCategory.class
1257                    };
1258            private String _uuid;
1259            private String _originalUuid;
1260            private long _categoryId;
1261            private long _groupId;
1262            private long _originalGroupId;
1263            private boolean _setOriginalGroupId;
1264            private long _companyId;
1265            private long _originalCompanyId;
1266            private boolean _setOriginalCompanyId;
1267            private long _userId;
1268            private String _userUuid;
1269            private String _userName;
1270            private Date _createDate;
1271            private Date _modifiedDate;
1272            private long _parentCategoryId;
1273            private long _originalParentCategoryId;
1274            private boolean _setOriginalParentCategoryId;
1275            private String _name;
1276            private String _description;
1277            private String _displayStyle;
1278            private int _threadCount;
1279            private int _messageCount;
1280            private Date _lastPostDate;
1281            private int _status;
1282            private int _originalStatus;
1283            private boolean _setOriginalStatus;
1284            private long _statusByUserId;
1285            private String _statusByUserUuid;
1286            private String _statusByUserName;
1287            private Date _statusDate;
1288            private long _columnBitmask;
1289            private MBCategory _escapedModel;
1290    }