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                            { "threadId", Types.BIGINT },
071                            { "groupId", Types.BIGINT },
072                            { "companyId", Types.BIGINT },
073                            { "categoryId", Types.BIGINT },
074                            { "rootMessageId", Types.BIGINT },
075                            { "rootMessageUserId", Types.BIGINT },
076                            { "messageCount", Types.INTEGER },
077                            { "viewCount", Types.INTEGER },
078                            { "lastPostByUserId", Types.BIGINT },
079                            { "lastPostDate", Types.TIMESTAMP },
080                            { "priority", Types.DOUBLE },
081                            { "question", Types.BOOLEAN },
082                            { "status", Types.INTEGER },
083                            { "statusByUserId", Types.BIGINT },
084                            { "statusByUserName", Types.VARCHAR },
085                            { "statusDate", Types.TIMESTAMP }
086                    };
087            public static final String TABLE_SQL_CREATE = "create table MBThread (threadId LONG not null primary key,groupId LONG,companyId LONG,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)";
088            public static final String TABLE_SQL_DROP = "drop table MBThread";
089            public static final String ORDER_BY_JPQL = " ORDER BY mbThread.priority DESC, mbThread.lastPostDate DESC";
090            public static final String ORDER_BY_SQL = " ORDER BY MBThread.priority DESC, MBThread.lastPostDate DESC";
091            public static final String DATA_SOURCE = "liferayDataSource";
092            public static final String SESSION_FACTORY = "liferaySessionFactory";
093            public static final String TX_MANAGER = "liferayTransactionManager";
094            public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
095                                    "value.object.entity.cache.enabled.com.liferay.portlet.messageboards.model.MBThread"),
096                            true);
097            public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
098                                    "value.object.finder.cache.enabled.com.liferay.portlet.messageboards.model.MBThread"),
099                            true);
100            public static final boolean COLUMN_BITMASK_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
101                                    "value.object.column.bitmask.enabled.com.liferay.portlet.messageboards.model.MBThread"),
102                            true);
103            public static long CATEGORYID_COLUMN_BITMASK = 1L;
104            public static long GROUPID_COLUMN_BITMASK = 2L;
105            public static long LASTPOSTDATE_COLUMN_BITMASK = 4L;
106            public static long PRIORITY_COLUMN_BITMASK = 8L;
107            public static long ROOTMESSAGEID_COLUMN_BITMASK = 16L;
108            public static long STATUS_COLUMN_BITMASK = 32L;
109    
110            /**
111             * Converts the soap model instance into a normal model instance.
112             *
113             * @param soapModel the soap model instance to convert
114             * @return the normal model instance
115             */
116            public static MBThread toModel(MBThreadSoap soapModel) {
117                    if (soapModel == null) {
118                            return null;
119                    }
120    
121                    MBThread model = new MBThreadImpl();
122    
123                    model.setThreadId(soapModel.getThreadId());
124                    model.setGroupId(soapModel.getGroupId());
125                    model.setCompanyId(soapModel.getCompanyId());
126                    model.setCategoryId(soapModel.getCategoryId());
127                    model.setRootMessageId(soapModel.getRootMessageId());
128                    model.setRootMessageUserId(soapModel.getRootMessageUserId());
129                    model.setMessageCount(soapModel.getMessageCount());
130                    model.setViewCount(soapModel.getViewCount());
131                    model.setLastPostByUserId(soapModel.getLastPostByUserId());
132                    model.setLastPostDate(soapModel.getLastPostDate());
133                    model.setPriority(soapModel.getPriority());
134                    model.setQuestion(soapModel.getQuestion());
135                    model.setStatus(soapModel.getStatus());
136                    model.setStatusByUserId(soapModel.getStatusByUserId());
137                    model.setStatusByUserName(soapModel.getStatusByUserName());
138                    model.setStatusDate(soapModel.getStatusDate());
139    
140                    return model;
141            }
142    
143            /**
144             * Converts the soap model instances into normal model instances.
145             *
146             * @param soapModels the soap model instances to convert
147             * @return the normal model instances
148             */
149            public static List<MBThread> toModels(MBThreadSoap[] soapModels) {
150                    if (soapModels == null) {
151                            return null;
152                    }
153    
154                    List<MBThread> models = new ArrayList<MBThread>(soapModels.length);
155    
156                    for (MBThreadSoap soapModel : soapModels) {
157                            models.add(toModel(soapModel));
158                    }
159    
160                    return models;
161            }
162    
163            public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
164                                    "lock.expiration.time.com.liferay.portlet.messageboards.model.MBThread"));
165    
166            public MBThreadModelImpl() {
167            }
168    
169            public long getPrimaryKey() {
170                    return _threadId;
171            }
172    
173            public void setPrimaryKey(long primaryKey) {
174                    setThreadId(primaryKey);
175            }
176    
177            public Serializable getPrimaryKeyObj() {
178                    return new Long(_threadId);
179            }
180    
181            public void setPrimaryKeyObj(Serializable primaryKeyObj) {
182                    setPrimaryKey(((Long)primaryKeyObj).longValue());
183            }
184    
185            public Class<?> getModelClass() {
186                    return MBThread.class;
187            }
188    
189            public String getModelClassName() {
190                    return MBThread.class.getName();
191            }
192    
193            @Override
194            public Map<String, Object> getModelAttributes() {
195                    Map<String, Object> attributes = new HashMap<String, Object>();
196    
197                    attributes.put("threadId", getThreadId());
198                    attributes.put("groupId", getGroupId());
199                    attributes.put("companyId", getCompanyId());
200                    attributes.put("categoryId", getCategoryId());
201                    attributes.put("rootMessageId", getRootMessageId());
202                    attributes.put("rootMessageUserId", getRootMessageUserId());
203                    attributes.put("messageCount", getMessageCount());
204                    attributes.put("viewCount", getViewCount());
205                    attributes.put("lastPostByUserId", getLastPostByUserId());
206                    attributes.put("lastPostDate", getLastPostDate());
207                    attributes.put("priority", getPriority());
208                    attributes.put("question", getQuestion());
209                    attributes.put("status", getStatus());
210                    attributes.put("statusByUserId", getStatusByUserId());
211                    attributes.put("statusByUserName", getStatusByUserName());
212                    attributes.put("statusDate", getStatusDate());
213    
214                    return attributes;
215            }
216    
217            @Override
218            public void setModelAttributes(Map<String, Object> attributes) {
219                    Long threadId = (Long)attributes.get("threadId");
220    
221                    if (threadId != null) {
222                            setThreadId(threadId);
223                    }
224    
225                    Long groupId = (Long)attributes.get("groupId");
226    
227                    if (groupId != null) {
228                            setGroupId(groupId);
229                    }
230    
231                    Long companyId = (Long)attributes.get("companyId");
232    
233                    if (companyId != null) {
234                            setCompanyId(companyId);
235                    }
236    
237                    Long categoryId = (Long)attributes.get("categoryId");
238    
239                    if (categoryId != null) {
240                            setCategoryId(categoryId);
241                    }
242    
243                    Long rootMessageId = (Long)attributes.get("rootMessageId");
244    
245                    if (rootMessageId != null) {
246                            setRootMessageId(rootMessageId);
247                    }
248    
249                    Long rootMessageUserId = (Long)attributes.get("rootMessageUserId");
250    
251                    if (rootMessageUserId != null) {
252                            setRootMessageUserId(rootMessageUserId);
253                    }
254    
255                    Integer messageCount = (Integer)attributes.get("messageCount");
256    
257                    if (messageCount != null) {
258                            setMessageCount(messageCount);
259                    }
260    
261                    Integer viewCount = (Integer)attributes.get("viewCount");
262    
263                    if (viewCount != null) {
264                            setViewCount(viewCount);
265                    }
266    
267                    Long lastPostByUserId = (Long)attributes.get("lastPostByUserId");
268    
269                    if (lastPostByUserId != null) {
270                            setLastPostByUserId(lastPostByUserId);
271                    }
272    
273                    Date lastPostDate = (Date)attributes.get("lastPostDate");
274    
275                    if (lastPostDate != null) {
276                            setLastPostDate(lastPostDate);
277                    }
278    
279                    Double priority = (Double)attributes.get("priority");
280    
281                    if (priority != null) {
282                            setPriority(priority);
283                    }
284    
285                    Boolean question = (Boolean)attributes.get("question");
286    
287                    if (question != null) {
288                            setQuestion(question);
289                    }
290    
291                    Integer status = (Integer)attributes.get("status");
292    
293                    if (status != null) {
294                            setStatus(status);
295                    }
296    
297                    Long statusByUserId = (Long)attributes.get("statusByUserId");
298    
299                    if (statusByUserId != null) {
300                            setStatusByUserId(statusByUserId);
301                    }
302    
303                    String statusByUserName = (String)attributes.get("statusByUserName");
304    
305                    if (statusByUserName != null) {
306                            setStatusByUserName(statusByUserName);
307                    }
308    
309                    Date statusDate = (Date)attributes.get("statusDate");
310    
311                    if (statusDate != null) {
312                            setStatusDate(statusDate);
313                    }
314            }
315    
316            @JSON
317            public long getThreadId() {
318                    return _threadId;
319            }
320    
321            public void setThreadId(long threadId) {
322                    _threadId = threadId;
323            }
324    
325            @JSON
326            public long getGroupId() {
327                    return _groupId;
328            }
329    
330            public void setGroupId(long groupId) {
331                    _columnBitmask |= GROUPID_COLUMN_BITMASK;
332    
333                    if (!_setOriginalGroupId) {
334                            _setOriginalGroupId = true;
335    
336                            _originalGroupId = _groupId;
337                    }
338    
339                    _groupId = groupId;
340            }
341    
342            public long getOriginalGroupId() {
343                    return _originalGroupId;
344            }
345    
346            @JSON
347            public long getCompanyId() {
348                    return _companyId;
349            }
350    
351            public void setCompanyId(long companyId) {
352                    _companyId = companyId;
353            }
354    
355            @JSON
356            public long getCategoryId() {
357                    return _categoryId;
358            }
359    
360            public void setCategoryId(long categoryId) {
361                    _columnBitmask |= CATEGORYID_COLUMN_BITMASK;
362    
363                    if (!_setOriginalCategoryId) {
364                            _setOriginalCategoryId = true;
365    
366                            _originalCategoryId = _categoryId;
367                    }
368    
369                    _categoryId = categoryId;
370            }
371    
372            public long getOriginalCategoryId() {
373                    return _originalCategoryId;
374            }
375    
376            @JSON
377            public long getRootMessageId() {
378                    return _rootMessageId;
379            }
380    
381            public void setRootMessageId(long rootMessageId) {
382                    _columnBitmask |= ROOTMESSAGEID_COLUMN_BITMASK;
383    
384                    if (!_setOriginalRootMessageId) {
385                            _setOriginalRootMessageId = true;
386    
387                            _originalRootMessageId = _rootMessageId;
388                    }
389    
390                    _rootMessageId = rootMessageId;
391            }
392    
393            public long getOriginalRootMessageId() {
394                    return _originalRootMessageId;
395            }
396    
397            @JSON
398            public long getRootMessageUserId() {
399                    return _rootMessageUserId;
400            }
401    
402            public void setRootMessageUserId(long rootMessageUserId) {
403                    _rootMessageUserId = rootMessageUserId;
404            }
405    
406            public String getRootMessageUserUuid() throws SystemException {
407                    return PortalUtil.getUserValue(getRootMessageUserId(), "uuid",
408                            _rootMessageUserUuid);
409            }
410    
411            public void setRootMessageUserUuid(String rootMessageUserUuid) {
412                    _rootMessageUserUuid = rootMessageUserUuid;
413            }
414    
415            @JSON
416            public int getMessageCount() {
417                    return _messageCount;
418            }
419    
420            public void setMessageCount(int messageCount) {
421                    _messageCount = messageCount;
422            }
423    
424            @JSON
425            public int getViewCount() {
426                    return _viewCount;
427            }
428    
429            public void setViewCount(int viewCount) {
430                    _viewCount = viewCount;
431            }
432    
433            @JSON
434            public long getLastPostByUserId() {
435                    return _lastPostByUserId;
436            }
437    
438            public void setLastPostByUserId(long lastPostByUserId) {
439                    _lastPostByUserId = lastPostByUserId;
440            }
441    
442            public String getLastPostByUserUuid() throws SystemException {
443                    return PortalUtil.getUserValue(getLastPostByUserId(), "uuid",
444                            _lastPostByUserUuid);
445            }
446    
447            public void setLastPostByUserUuid(String lastPostByUserUuid) {
448                    _lastPostByUserUuid = lastPostByUserUuid;
449            }
450    
451            @JSON
452            public Date getLastPostDate() {
453                    return _lastPostDate;
454            }
455    
456            public void setLastPostDate(Date lastPostDate) {
457                    _columnBitmask = -1L;
458    
459                    if (_originalLastPostDate == null) {
460                            _originalLastPostDate = _lastPostDate;
461                    }
462    
463                    _lastPostDate = lastPostDate;
464            }
465    
466            public Date getOriginalLastPostDate() {
467                    return _originalLastPostDate;
468            }
469    
470            @JSON
471            public double getPriority() {
472                    return _priority;
473            }
474    
475            public void setPriority(double priority) {
476                    _columnBitmask = -1L;
477    
478                    if (!_setOriginalPriority) {
479                            _setOriginalPriority = true;
480    
481                            _originalPriority = _priority;
482                    }
483    
484                    _priority = priority;
485            }
486    
487            public double getOriginalPriority() {
488                    return _originalPriority;
489            }
490    
491            @JSON
492            public boolean getQuestion() {
493                    return _question;
494            }
495    
496            public boolean isQuestion() {
497                    return _question;
498            }
499    
500            public void setQuestion(boolean question) {
501                    _question = question;
502            }
503    
504            @JSON
505            public int getStatus() {
506                    return _status;
507            }
508    
509            public void setStatus(int status) {
510                    _columnBitmask |= STATUS_COLUMN_BITMASK;
511    
512                    if (!_setOriginalStatus) {
513                            _setOriginalStatus = true;
514    
515                            _originalStatus = _status;
516                    }
517    
518                    _status = status;
519            }
520    
521            public int getOriginalStatus() {
522                    return _originalStatus;
523            }
524    
525            @JSON
526            public long getStatusByUserId() {
527                    return _statusByUserId;
528            }
529    
530            public void setStatusByUserId(long statusByUserId) {
531                    _statusByUserId = statusByUserId;
532            }
533    
534            public String getStatusByUserUuid() throws SystemException {
535                    return PortalUtil.getUserValue(getStatusByUserId(), "uuid",
536                            _statusByUserUuid);
537            }
538    
539            public void setStatusByUserUuid(String statusByUserUuid) {
540                    _statusByUserUuid = statusByUserUuid;
541            }
542    
543            @JSON
544            public String getStatusByUserName() {
545                    if (_statusByUserName == null) {
546                            return StringPool.BLANK;
547                    }
548                    else {
549                            return _statusByUserName;
550                    }
551            }
552    
553            public void setStatusByUserName(String statusByUserName) {
554                    _statusByUserName = statusByUserName;
555            }
556    
557            @JSON
558            public Date getStatusDate() {
559                    return _statusDate;
560            }
561    
562            public void setStatusDate(Date statusDate) {
563                    _statusDate = statusDate;
564            }
565    
566            /**
567             * @deprecated {@link #isApproved}
568             */
569            public boolean getApproved() {
570                    return isApproved();
571            }
572    
573            public boolean isApproved() {
574                    if (getStatus() == WorkflowConstants.STATUS_APPROVED) {
575                            return true;
576                    }
577                    else {
578                            return false;
579                    }
580            }
581    
582            public boolean isDenied() {
583                    if (getStatus() == WorkflowConstants.STATUS_DENIED) {
584                            return true;
585                    }
586                    else {
587                            return false;
588                    }
589            }
590    
591            public boolean isDraft() {
592                    if ((getStatus() == WorkflowConstants.STATUS_DRAFT) ||
593                                    (getStatus() == WorkflowConstants.STATUS_DRAFT_FROM_APPROVED)) {
594                            return true;
595                    }
596                    else {
597                            return false;
598                    }
599            }
600    
601            public boolean isExpired() {
602                    if (getStatus() == WorkflowConstants.STATUS_EXPIRED) {
603                            return true;
604                    }
605                    else {
606                            return false;
607                    }
608            }
609    
610            public boolean isInactive() {
611                    if (getStatus() == WorkflowConstants.STATUS_INACTIVE) {
612                            return true;
613                    }
614                    else {
615                            return false;
616                    }
617            }
618    
619            public boolean isIncomplete() {
620                    if (getStatus() == WorkflowConstants.STATUS_INCOMPLETE) {
621                            return true;
622                    }
623                    else {
624                            return false;
625                    }
626            }
627    
628            public boolean isPending() {
629                    if (getStatus() == WorkflowConstants.STATUS_PENDING) {
630                            return true;
631                    }
632                    else {
633                            return false;
634                    }
635            }
636    
637            public boolean isScheduled() {
638                    if (getStatus() == WorkflowConstants.STATUS_SCHEDULED) {
639                            return true;
640                    }
641                    else {
642                            return false;
643                    }
644            }
645    
646            public long getColumnBitmask() {
647                    return _columnBitmask;
648            }
649    
650            @Override
651            public ExpandoBridge getExpandoBridge() {
652                    return ExpandoBridgeFactoryUtil.getExpandoBridge(getCompanyId(),
653                            MBThread.class.getName(), getPrimaryKey());
654            }
655    
656            @Override
657            public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
658                    ExpandoBridge expandoBridge = getExpandoBridge();
659    
660                    expandoBridge.setAttributes(serviceContext);
661            }
662    
663            @Override
664            public MBThread toEscapedModel() {
665                    if (_escapedModel == null) {
666                            _escapedModel = (MBThread)ProxyUtil.newProxyInstance(_classLoader,
667                                            _escapedModelInterfaces, new AutoEscapeBeanHandler(this));
668                    }
669    
670                    return _escapedModel;
671            }
672    
673            public MBThread toUnescapedModel() {
674                    return (MBThread)this;
675            }
676    
677            @Override
678            public Object clone() {
679                    MBThreadImpl mbThreadImpl = new MBThreadImpl();
680    
681                    mbThreadImpl.setThreadId(getThreadId());
682                    mbThreadImpl.setGroupId(getGroupId());
683                    mbThreadImpl.setCompanyId(getCompanyId());
684                    mbThreadImpl.setCategoryId(getCategoryId());
685                    mbThreadImpl.setRootMessageId(getRootMessageId());
686                    mbThreadImpl.setRootMessageUserId(getRootMessageUserId());
687                    mbThreadImpl.setMessageCount(getMessageCount());
688                    mbThreadImpl.setViewCount(getViewCount());
689                    mbThreadImpl.setLastPostByUserId(getLastPostByUserId());
690                    mbThreadImpl.setLastPostDate(getLastPostDate());
691                    mbThreadImpl.setPriority(getPriority());
692                    mbThreadImpl.setQuestion(getQuestion());
693                    mbThreadImpl.setStatus(getStatus());
694                    mbThreadImpl.setStatusByUserId(getStatusByUserId());
695                    mbThreadImpl.setStatusByUserName(getStatusByUserName());
696                    mbThreadImpl.setStatusDate(getStatusDate());
697    
698                    mbThreadImpl.resetOriginalValues();
699    
700                    return mbThreadImpl;
701            }
702    
703            public int compareTo(MBThread mbThread) {
704                    int value = 0;
705    
706                    if (getPriority() < mbThread.getPriority()) {
707                            value = -1;
708                    }
709                    else if (getPriority() > mbThread.getPriority()) {
710                            value = 1;
711                    }
712                    else {
713                            value = 0;
714                    }
715    
716                    value = value * -1;
717    
718                    if (value != 0) {
719                            return value;
720                    }
721    
722                    value = DateUtil.compareTo(getLastPostDate(), mbThread.getLastPostDate());
723    
724                    value = value * -1;
725    
726                    if (value != 0) {
727                            return value;
728                    }
729    
730                    return 0;
731            }
732    
733            @Override
734            public boolean equals(Object obj) {
735                    if (this == obj) {
736                            return true;
737                    }
738    
739                    if (!(obj instanceof MBThread)) {
740                            return false;
741                    }
742    
743                    MBThread mbThread = (MBThread)obj;
744    
745                    long primaryKey = mbThread.getPrimaryKey();
746    
747                    if (getPrimaryKey() == primaryKey) {
748                            return true;
749                    }
750                    else {
751                            return false;
752                    }
753            }
754    
755            @Override
756            public int hashCode() {
757                    return (int)getPrimaryKey();
758            }
759    
760            @Override
761            public void resetOriginalValues() {
762                    MBThreadModelImpl mbThreadModelImpl = this;
763    
764                    mbThreadModelImpl._originalGroupId = mbThreadModelImpl._groupId;
765    
766                    mbThreadModelImpl._setOriginalGroupId = false;
767    
768                    mbThreadModelImpl._originalCategoryId = mbThreadModelImpl._categoryId;
769    
770                    mbThreadModelImpl._setOriginalCategoryId = false;
771    
772                    mbThreadModelImpl._originalRootMessageId = mbThreadModelImpl._rootMessageId;
773    
774                    mbThreadModelImpl._setOriginalRootMessageId = false;
775    
776                    mbThreadModelImpl._originalLastPostDate = mbThreadModelImpl._lastPostDate;
777    
778                    mbThreadModelImpl._originalPriority = mbThreadModelImpl._priority;
779    
780                    mbThreadModelImpl._setOriginalPriority = false;
781    
782                    mbThreadModelImpl._originalStatus = mbThreadModelImpl._status;
783    
784                    mbThreadModelImpl._setOriginalStatus = false;
785    
786                    mbThreadModelImpl._columnBitmask = 0;
787            }
788    
789            @Override
790            public CacheModel<MBThread> toCacheModel() {
791                    MBThreadCacheModel mbThreadCacheModel = new MBThreadCacheModel();
792    
793                    mbThreadCacheModel.threadId = getThreadId();
794    
795                    mbThreadCacheModel.groupId = getGroupId();
796    
797                    mbThreadCacheModel.companyId = getCompanyId();
798    
799                    mbThreadCacheModel.categoryId = getCategoryId();
800    
801                    mbThreadCacheModel.rootMessageId = getRootMessageId();
802    
803                    mbThreadCacheModel.rootMessageUserId = getRootMessageUserId();
804    
805                    mbThreadCacheModel.messageCount = getMessageCount();
806    
807                    mbThreadCacheModel.viewCount = getViewCount();
808    
809                    mbThreadCacheModel.lastPostByUserId = getLastPostByUserId();
810    
811                    Date lastPostDate = getLastPostDate();
812    
813                    if (lastPostDate != null) {
814                            mbThreadCacheModel.lastPostDate = lastPostDate.getTime();
815                    }
816                    else {
817                            mbThreadCacheModel.lastPostDate = Long.MIN_VALUE;
818                    }
819    
820                    mbThreadCacheModel.priority = getPriority();
821    
822                    mbThreadCacheModel.question = getQuestion();
823    
824                    mbThreadCacheModel.status = getStatus();
825    
826                    mbThreadCacheModel.statusByUserId = getStatusByUserId();
827    
828                    mbThreadCacheModel.statusByUserName = getStatusByUserName();
829    
830                    String statusByUserName = mbThreadCacheModel.statusByUserName;
831    
832                    if ((statusByUserName != null) && (statusByUserName.length() == 0)) {
833                            mbThreadCacheModel.statusByUserName = null;
834                    }
835    
836                    Date statusDate = getStatusDate();
837    
838                    if (statusDate != null) {
839                            mbThreadCacheModel.statusDate = statusDate.getTime();
840                    }
841                    else {
842                            mbThreadCacheModel.statusDate = Long.MIN_VALUE;
843                    }
844    
845                    return mbThreadCacheModel;
846            }
847    
848            @Override
849            public String toString() {
850                    StringBundler sb = new StringBundler(33);
851    
852                    sb.append("{threadId=");
853                    sb.append(getThreadId());
854                    sb.append(", groupId=");
855                    sb.append(getGroupId());
856                    sb.append(", companyId=");
857                    sb.append(getCompanyId());
858                    sb.append(", categoryId=");
859                    sb.append(getCategoryId());
860                    sb.append(", rootMessageId=");
861                    sb.append(getRootMessageId());
862                    sb.append(", rootMessageUserId=");
863                    sb.append(getRootMessageUserId());
864                    sb.append(", messageCount=");
865                    sb.append(getMessageCount());
866                    sb.append(", viewCount=");
867                    sb.append(getViewCount());
868                    sb.append(", lastPostByUserId=");
869                    sb.append(getLastPostByUserId());
870                    sb.append(", lastPostDate=");
871                    sb.append(getLastPostDate());
872                    sb.append(", priority=");
873                    sb.append(getPriority());
874                    sb.append(", question=");
875                    sb.append(getQuestion());
876                    sb.append(", status=");
877                    sb.append(getStatus());
878                    sb.append(", statusByUserId=");
879                    sb.append(getStatusByUserId());
880                    sb.append(", statusByUserName=");
881                    sb.append(getStatusByUserName());
882                    sb.append(", statusDate=");
883                    sb.append(getStatusDate());
884                    sb.append("}");
885    
886                    return sb.toString();
887            }
888    
889            public String toXmlString() {
890                    StringBundler sb = new StringBundler(52);
891    
892                    sb.append("<model><model-name>");
893                    sb.append("com.liferay.portlet.messageboards.model.MBThread");
894                    sb.append("</model-name>");
895    
896                    sb.append(
897                            "<column><column-name>threadId</column-name><column-value><![CDATA[");
898                    sb.append(getThreadId());
899                    sb.append("]]></column-value></column>");
900                    sb.append(
901                            "<column><column-name>groupId</column-name><column-value><![CDATA[");
902                    sb.append(getGroupId());
903                    sb.append("]]></column-value></column>");
904                    sb.append(
905                            "<column><column-name>companyId</column-name><column-value><![CDATA[");
906                    sb.append(getCompanyId());
907                    sb.append("]]></column-value></column>");
908                    sb.append(
909                            "<column><column-name>categoryId</column-name><column-value><![CDATA[");
910                    sb.append(getCategoryId());
911                    sb.append("]]></column-value></column>");
912                    sb.append(
913                            "<column><column-name>rootMessageId</column-name><column-value><![CDATA[");
914                    sb.append(getRootMessageId());
915                    sb.append("]]></column-value></column>");
916                    sb.append(
917                            "<column><column-name>rootMessageUserId</column-name><column-value><![CDATA[");
918                    sb.append(getRootMessageUserId());
919                    sb.append("]]></column-value></column>");
920                    sb.append(
921                            "<column><column-name>messageCount</column-name><column-value><![CDATA[");
922                    sb.append(getMessageCount());
923                    sb.append("]]></column-value></column>");
924                    sb.append(
925                            "<column><column-name>viewCount</column-name><column-value><![CDATA[");
926                    sb.append(getViewCount());
927                    sb.append("]]></column-value></column>");
928                    sb.append(
929                            "<column><column-name>lastPostByUserId</column-name><column-value><![CDATA[");
930                    sb.append(getLastPostByUserId());
931                    sb.append("]]></column-value></column>");
932                    sb.append(
933                            "<column><column-name>lastPostDate</column-name><column-value><![CDATA[");
934                    sb.append(getLastPostDate());
935                    sb.append("]]></column-value></column>");
936                    sb.append(
937                            "<column><column-name>priority</column-name><column-value><![CDATA[");
938                    sb.append(getPriority());
939                    sb.append("]]></column-value></column>");
940                    sb.append(
941                            "<column><column-name>question</column-name><column-value><![CDATA[");
942                    sb.append(getQuestion());
943                    sb.append("]]></column-value></column>");
944                    sb.append(
945                            "<column><column-name>status</column-name><column-value><![CDATA[");
946                    sb.append(getStatus());
947                    sb.append("]]></column-value></column>");
948                    sb.append(
949                            "<column><column-name>statusByUserId</column-name><column-value><![CDATA[");
950                    sb.append(getStatusByUserId());
951                    sb.append("]]></column-value></column>");
952                    sb.append(
953                            "<column><column-name>statusByUserName</column-name><column-value><![CDATA[");
954                    sb.append(getStatusByUserName());
955                    sb.append("]]></column-value></column>");
956                    sb.append(
957                            "<column><column-name>statusDate</column-name><column-value><![CDATA[");
958                    sb.append(getStatusDate());
959                    sb.append("]]></column-value></column>");
960    
961                    sb.append("</model>");
962    
963                    return sb.toString();
964            }
965    
966            private static ClassLoader _classLoader = MBThread.class.getClassLoader();
967            private static Class<?>[] _escapedModelInterfaces = new Class[] {
968                            MBThread.class
969                    };
970            private long _threadId;
971            private long _groupId;
972            private long _originalGroupId;
973            private boolean _setOriginalGroupId;
974            private long _companyId;
975            private long _categoryId;
976            private long _originalCategoryId;
977            private boolean _setOriginalCategoryId;
978            private long _rootMessageId;
979            private long _originalRootMessageId;
980            private boolean _setOriginalRootMessageId;
981            private long _rootMessageUserId;
982            private String _rootMessageUserUuid;
983            private int _messageCount;
984            private int _viewCount;
985            private long _lastPostByUserId;
986            private String _lastPostByUserUuid;
987            private Date _lastPostDate;
988            private Date _originalLastPostDate;
989            private double _priority;
990            private double _originalPriority;
991            private boolean _setOriginalPriority;
992            private boolean _question;
993            private int _status;
994            private int _originalStatus;
995            private boolean _setOriginalStatus;
996            private long _statusByUserId;
997            private String _statusByUserUuid;
998            private String _statusByUserName;
999            private Date _statusDate;
1000            private long _columnBitmask;
1001            private MBThread _escapedModel;
1002    }