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