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