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