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                                    getPrimaryKey());
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 TrashHandler getTrashHandler() {
833                    return TrashHandlerRegistryUtil.getTrashHandler(getModelClassName());
834            }
835    
836            @Override
837            public boolean isInTrash() {
838                    if (getStatus() == WorkflowConstants.STATUS_IN_TRASH) {
839                            return true;
840                    }
841                    else {
842                            return false;
843                    }
844            }
845    
846            @Override
847            public boolean isInTrashContainer() {
848                    TrashHandler trashHandler = getTrashHandler();
849    
850                    if ((trashHandler == null) ||
851                                    Validator.isNull(trashHandler.getContainerModelClassName())) {
852                            return false;
853                    }
854    
855                    try {
856                            ContainerModel containerModel = trashHandler.getParentContainerModel(this);
857    
858                            if (containerModel == null) {
859                                    return false;
860                            }
861    
862                            if (containerModel instanceof TrashedModel) {
863                                    return ((TrashedModel)containerModel).isInTrash();
864                            }
865                    }
866                    catch (Exception e) {
867                    }
868    
869                    return false;
870            }
871    
872            /**
873             * @deprecated As of 6.1.0, replaced by {@link #isApproved}
874             */
875            @Override
876            public boolean getApproved() {
877                    return isApproved();
878            }
879    
880            @Override
881            public boolean isApproved() {
882                    if (getStatus() == WorkflowConstants.STATUS_APPROVED) {
883                            return true;
884                    }
885                    else {
886                            return false;
887                    }
888            }
889    
890            @Override
891            public boolean isDenied() {
892                    if (getStatus() == WorkflowConstants.STATUS_DENIED) {
893                            return true;
894                    }
895                    else {
896                            return false;
897                    }
898            }
899    
900            @Override
901            public boolean isDraft() {
902                    if (getStatus() == WorkflowConstants.STATUS_DRAFT) {
903                            return true;
904                    }
905                    else {
906                            return false;
907                    }
908            }
909    
910            @Override
911            public boolean isExpired() {
912                    if (getStatus() == WorkflowConstants.STATUS_EXPIRED) {
913                            return true;
914                    }
915                    else {
916                            return false;
917                    }
918            }
919    
920            @Override
921            public boolean isInactive() {
922                    if (getStatus() == WorkflowConstants.STATUS_INACTIVE) {
923                            return true;
924                    }
925                    else {
926                            return false;
927                    }
928            }
929    
930            @Override
931            public boolean isIncomplete() {
932                    if (getStatus() == WorkflowConstants.STATUS_INCOMPLETE) {
933                            return true;
934                    }
935                    else {
936                            return false;
937                    }
938            }
939    
940            @Override
941            public boolean isPending() {
942                    if (getStatus() == WorkflowConstants.STATUS_PENDING) {
943                            return true;
944                    }
945                    else {
946                            return false;
947                    }
948            }
949    
950            @Override
951            public boolean isScheduled() {
952                    if (getStatus() == WorkflowConstants.STATUS_SCHEDULED) {
953                            return true;
954                    }
955                    else {
956                            return false;
957                    }
958            }
959    
960            public long getColumnBitmask() {
961                    return _columnBitmask;
962            }
963    
964            @Override
965            public ExpandoBridge getExpandoBridge() {
966                    return ExpandoBridgeFactoryUtil.getExpandoBridge(getCompanyId(),
967                            MBThread.class.getName(), getPrimaryKey());
968            }
969    
970            @Override
971            public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
972                    ExpandoBridge expandoBridge = getExpandoBridge();
973    
974                    expandoBridge.setAttributes(serviceContext);
975            }
976    
977            @Override
978            public MBThread toEscapedModel() {
979                    if (_escapedModel == null) {
980                            _escapedModel = (MBThread)ProxyUtil.newProxyInstance(_classLoader,
981                                            _escapedModelInterfaces, new AutoEscapeBeanHandler(this));
982                    }
983    
984                    return _escapedModel;
985            }
986    
987            @Override
988            public Object clone() {
989                    MBThreadImpl mbThreadImpl = new MBThreadImpl();
990    
991                    mbThreadImpl.setUuid(getUuid());
992                    mbThreadImpl.setThreadId(getThreadId());
993                    mbThreadImpl.setGroupId(getGroupId());
994                    mbThreadImpl.setCompanyId(getCompanyId());
995                    mbThreadImpl.setUserId(getUserId());
996                    mbThreadImpl.setUserName(getUserName());
997                    mbThreadImpl.setCreateDate(getCreateDate());
998                    mbThreadImpl.setModifiedDate(getModifiedDate());
999                    mbThreadImpl.setCategoryId(getCategoryId());
1000                    mbThreadImpl.setRootMessageId(getRootMessageId());
1001                    mbThreadImpl.setRootMessageUserId(getRootMessageUserId());
1002                    mbThreadImpl.setMessageCount(getMessageCount());
1003                    mbThreadImpl.setViewCount(getViewCount());
1004                    mbThreadImpl.setLastPostByUserId(getLastPostByUserId());
1005                    mbThreadImpl.setLastPostDate(getLastPostDate());
1006                    mbThreadImpl.setPriority(getPriority());
1007                    mbThreadImpl.setQuestion(getQuestion());
1008                    mbThreadImpl.setStatus(getStatus());
1009                    mbThreadImpl.setStatusByUserId(getStatusByUserId());
1010                    mbThreadImpl.setStatusByUserName(getStatusByUserName());
1011                    mbThreadImpl.setStatusDate(getStatusDate());
1012    
1013                    mbThreadImpl.resetOriginalValues();
1014    
1015                    return mbThreadImpl;
1016            }
1017    
1018            @Override
1019            public int compareTo(MBThread mbThread) {
1020                    int value = 0;
1021    
1022                    if (getPriority() < mbThread.getPriority()) {
1023                            value = -1;
1024                    }
1025                    else if (getPriority() > mbThread.getPriority()) {
1026                            value = 1;
1027                    }
1028                    else {
1029                            value = 0;
1030                    }
1031    
1032                    value = value * -1;
1033    
1034                    if (value != 0) {
1035                            return value;
1036                    }
1037    
1038                    value = DateUtil.compareTo(getLastPostDate(), mbThread.getLastPostDate());
1039    
1040                    value = value * -1;
1041    
1042                    if (value != 0) {
1043                            return value;
1044                    }
1045    
1046                    return 0;
1047            }
1048    
1049            @Override
1050            public boolean equals(Object obj) {
1051                    if (this == obj) {
1052                            return true;
1053                    }
1054    
1055                    if (!(obj instanceof MBThread)) {
1056                            return false;
1057                    }
1058    
1059                    MBThread mbThread = (MBThread)obj;
1060    
1061                    long primaryKey = mbThread.getPrimaryKey();
1062    
1063                    if (getPrimaryKey() == primaryKey) {
1064                            return true;
1065                    }
1066                    else {
1067                            return false;
1068                    }
1069            }
1070    
1071            @Override
1072            public int hashCode() {
1073                    return (int)getPrimaryKey();
1074            }
1075    
1076            @Override
1077            public void resetOriginalValues() {
1078                    MBThreadModelImpl mbThreadModelImpl = this;
1079    
1080                    mbThreadModelImpl._originalUuid = mbThreadModelImpl._uuid;
1081    
1082                    mbThreadModelImpl._originalGroupId = mbThreadModelImpl._groupId;
1083    
1084                    mbThreadModelImpl._setOriginalGroupId = false;
1085    
1086                    mbThreadModelImpl._originalCompanyId = mbThreadModelImpl._companyId;
1087    
1088                    mbThreadModelImpl._setOriginalCompanyId = false;
1089    
1090                    mbThreadModelImpl._originalCategoryId = mbThreadModelImpl._categoryId;
1091    
1092                    mbThreadModelImpl._setOriginalCategoryId = false;
1093    
1094                    mbThreadModelImpl._originalRootMessageId = mbThreadModelImpl._rootMessageId;
1095    
1096                    mbThreadModelImpl._setOriginalRootMessageId = false;
1097    
1098                    mbThreadModelImpl._originalLastPostDate = mbThreadModelImpl._lastPostDate;
1099    
1100                    mbThreadModelImpl._originalPriority = mbThreadModelImpl._priority;
1101    
1102                    mbThreadModelImpl._setOriginalPriority = false;
1103    
1104                    mbThreadModelImpl._originalStatus = mbThreadModelImpl._status;
1105    
1106                    mbThreadModelImpl._setOriginalStatus = false;
1107    
1108                    mbThreadModelImpl._columnBitmask = 0;
1109            }
1110    
1111            @Override
1112            public CacheModel<MBThread> toCacheModel() {
1113                    MBThreadCacheModel mbThreadCacheModel = new MBThreadCacheModel();
1114    
1115                    mbThreadCacheModel.uuid = getUuid();
1116    
1117                    String uuid = mbThreadCacheModel.uuid;
1118    
1119                    if ((uuid != null) && (uuid.length() == 0)) {
1120                            mbThreadCacheModel.uuid = null;
1121                    }
1122    
1123                    mbThreadCacheModel.threadId = getThreadId();
1124    
1125                    mbThreadCacheModel.groupId = getGroupId();
1126    
1127                    mbThreadCacheModel.companyId = getCompanyId();
1128    
1129                    mbThreadCacheModel.userId = getUserId();
1130    
1131                    mbThreadCacheModel.userName = getUserName();
1132    
1133                    String userName = mbThreadCacheModel.userName;
1134    
1135                    if ((userName != null) && (userName.length() == 0)) {
1136                            mbThreadCacheModel.userName = null;
1137                    }
1138    
1139                    Date createDate = getCreateDate();
1140    
1141                    if (createDate != null) {
1142                            mbThreadCacheModel.createDate = createDate.getTime();
1143                    }
1144                    else {
1145                            mbThreadCacheModel.createDate = Long.MIN_VALUE;
1146                    }
1147    
1148                    Date modifiedDate = getModifiedDate();
1149    
1150                    if (modifiedDate != null) {
1151                            mbThreadCacheModel.modifiedDate = modifiedDate.getTime();
1152                    }
1153                    else {
1154                            mbThreadCacheModel.modifiedDate = Long.MIN_VALUE;
1155                    }
1156    
1157                    mbThreadCacheModel.categoryId = getCategoryId();
1158    
1159                    mbThreadCacheModel.rootMessageId = getRootMessageId();
1160    
1161                    mbThreadCacheModel.rootMessageUserId = getRootMessageUserId();
1162    
1163                    mbThreadCacheModel.messageCount = getMessageCount();
1164    
1165                    mbThreadCacheModel.viewCount = getViewCount();
1166    
1167                    mbThreadCacheModel.lastPostByUserId = getLastPostByUserId();
1168    
1169                    Date lastPostDate = getLastPostDate();
1170    
1171                    if (lastPostDate != null) {
1172                            mbThreadCacheModel.lastPostDate = lastPostDate.getTime();
1173                    }
1174                    else {
1175                            mbThreadCacheModel.lastPostDate = Long.MIN_VALUE;
1176                    }
1177    
1178                    mbThreadCacheModel.priority = getPriority();
1179    
1180                    mbThreadCacheModel.question = getQuestion();
1181    
1182                    mbThreadCacheModel.status = getStatus();
1183    
1184                    mbThreadCacheModel.statusByUserId = getStatusByUserId();
1185    
1186                    mbThreadCacheModel.statusByUserName = getStatusByUserName();
1187    
1188                    String statusByUserName = mbThreadCacheModel.statusByUserName;
1189    
1190                    if ((statusByUserName != null) && (statusByUserName.length() == 0)) {
1191                            mbThreadCacheModel.statusByUserName = null;
1192                    }
1193    
1194                    Date statusDate = getStatusDate();
1195    
1196                    if (statusDate != null) {
1197                            mbThreadCacheModel.statusDate = statusDate.getTime();
1198                    }
1199                    else {
1200                            mbThreadCacheModel.statusDate = Long.MIN_VALUE;
1201                    }
1202    
1203                    return mbThreadCacheModel;
1204            }
1205    
1206            @Override
1207            public String toString() {
1208                    StringBundler sb = new StringBundler(43);
1209    
1210                    sb.append("{uuid=");
1211                    sb.append(getUuid());
1212                    sb.append(", threadId=");
1213                    sb.append(getThreadId());
1214                    sb.append(", groupId=");
1215                    sb.append(getGroupId());
1216                    sb.append(", companyId=");
1217                    sb.append(getCompanyId());
1218                    sb.append(", userId=");
1219                    sb.append(getUserId());
1220                    sb.append(", userName=");
1221                    sb.append(getUserName());
1222                    sb.append(", createDate=");
1223                    sb.append(getCreateDate());
1224                    sb.append(", modifiedDate=");
1225                    sb.append(getModifiedDate());
1226                    sb.append(", categoryId=");
1227                    sb.append(getCategoryId());
1228                    sb.append(", rootMessageId=");
1229                    sb.append(getRootMessageId());
1230                    sb.append(", rootMessageUserId=");
1231                    sb.append(getRootMessageUserId());
1232                    sb.append(", messageCount=");
1233                    sb.append(getMessageCount());
1234                    sb.append(", viewCount=");
1235                    sb.append(getViewCount());
1236                    sb.append(", lastPostByUserId=");
1237                    sb.append(getLastPostByUserId());
1238                    sb.append(", lastPostDate=");
1239                    sb.append(getLastPostDate());
1240                    sb.append(", priority=");
1241                    sb.append(getPriority());
1242                    sb.append(", question=");
1243                    sb.append(getQuestion());
1244                    sb.append(", status=");
1245                    sb.append(getStatus());
1246                    sb.append(", statusByUserId=");
1247                    sb.append(getStatusByUserId());
1248                    sb.append(", statusByUserName=");
1249                    sb.append(getStatusByUserName());
1250                    sb.append(", statusDate=");
1251                    sb.append(getStatusDate());
1252                    sb.append("}");
1253    
1254                    return sb.toString();
1255            }
1256    
1257            @Override
1258            public String toXmlString() {
1259                    StringBundler sb = new StringBundler(67);
1260    
1261                    sb.append("<model><model-name>");
1262                    sb.append("com.liferay.portlet.messageboards.model.MBThread");
1263                    sb.append("</model-name>");
1264    
1265                    sb.append(
1266                            "<column><column-name>uuid</column-name><column-value><![CDATA[");
1267                    sb.append(getUuid());
1268                    sb.append("]]></column-value></column>");
1269                    sb.append(
1270                            "<column><column-name>threadId</column-name><column-value><![CDATA[");
1271                    sb.append(getThreadId());
1272                    sb.append("]]></column-value></column>");
1273                    sb.append(
1274                            "<column><column-name>groupId</column-name><column-value><![CDATA[");
1275                    sb.append(getGroupId());
1276                    sb.append("]]></column-value></column>");
1277                    sb.append(
1278                            "<column><column-name>companyId</column-name><column-value><![CDATA[");
1279                    sb.append(getCompanyId());
1280                    sb.append("]]></column-value></column>");
1281                    sb.append(
1282                            "<column><column-name>userId</column-name><column-value><![CDATA[");
1283                    sb.append(getUserId());
1284                    sb.append("]]></column-value></column>");
1285                    sb.append(
1286                            "<column><column-name>userName</column-name><column-value><![CDATA[");
1287                    sb.append(getUserName());
1288                    sb.append("]]></column-value></column>");
1289                    sb.append(
1290                            "<column><column-name>createDate</column-name><column-value><![CDATA[");
1291                    sb.append(getCreateDate());
1292                    sb.append("]]></column-value></column>");
1293                    sb.append(
1294                            "<column><column-name>modifiedDate</column-name><column-value><![CDATA[");
1295                    sb.append(getModifiedDate());
1296                    sb.append("]]></column-value></column>");
1297                    sb.append(
1298                            "<column><column-name>categoryId</column-name><column-value><![CDATA[");
1299                    sb.append(getCategoryId());
1300                    sb.append("]]></column-value></column>");
1301                    sb.append(
1302                            "<column><column-name>rootMessageId</column-name><column-value><![CDATA[");
1303                    sb.append(getRootMessageId());
1304                    sb.append("]]></column-value></column>");
1305                    sb.append(
1306                            "<column><column-name>rootMessageUserId</column-name><column-value><![CDATA[");
1307                    sb.append(getRootMessageUserId());
1308                    sb.append("]]></column-value></column>");
1309                    sb.append(
1310                            "<column><column-name>messageCount</column-name><column-value><![CDATA[");
1311                    sb.append(getMessageCount());
1312                    sb.append("]]></column-value></column>");
1313                    sb.append(
1314                            "<column><column-name>viewCount</column-name><column-value><![CDATA[");
1315                    sb.append(getViewCount());
1316                    sb.append("]]></column-value></column>");
1317                    sb.append(
1318                            "<column><column-name>lastPostByUserId</column-name><column-value><![CDATA[");
1319                    sb.append(getLastPostByUserId());
1320                    sb.append("]]></column-value></column>");
1321                    sb.append(
1322                            "<column><column-name>lastPostDate</column-name><column-value><![CDATA[");
1323                    sb.append(getLastPostDate());
1324                    sb.append("]]></column-value></column>");
1325                    sb.append(
1326                            "<column><column-name>priority</column-name><column-value><![CDATA[");
1327                    sb.append(getPriority());
1328                    sb.append("]]></column-value></column>");
1329                    sb.append(
1330                            "<column><column-name>question</column-name><column-value><![CDATA[");
1331                    sb.append(getQuestion());
1332                    sb.append("]]></column-value></column>");
1333                    sb.append(
1334                            "<column><column-name>status</column-name><column-value><![CDATA[");
1335                    sb.append(getStatus());
1336                    sb.append("]]></column-value></column>");
1337                    sb.append(
1338                            "<column><column-name>statusByUserId</column-name><column-value><![CDATA[");
1339                    sb.append(getStatusByUserId());
1340                    sb.append("]]></column-value></column>");
1341                    sb.append(
1342                            "<column><column-name>statusByUserName</column-name><column-value><![CDATA[");
1343                    sb.append(getStatusByUserName());
1344                    sb.append("]]></column-value></column>");
1345                    sb.append(
1346                            "<column><column-name>statusDate</column-name><column-value><![CDATA[");
1347                    sb.append(getStatusDate());
1348                    sb.append("]]></column-value></column>");
1349    
1350                    sb.append("</model>");
1351    
1352                    return sb.toString();
1353            }
1354    
1355            private static ClassLoader _classLoader = MBThread.class.getClassLoader();
1356            private static Class<?>[] _escapedModelInterfaces = new Class[] {
1357                            MBThread.class
1358                    };
1359            private String _uuid;
1360            private String _originalUuid;
1361            private long _threadId;
1362            private long _groupId;
1363            private long _originalGroupId;
1364            private boolean _setOriginalGroupId;
1365            private long _companyId;
1366            private long _originalCompanyId;
1367            private boolean _setOriginalCompanyId;
1368            private long _userId;
1369            private String _userUuid;
1370            private String _userName;
1371            private Date _createDate;
1372            private Date _modifiedDate;
1373            private long _categoryId;
1374            private long _originalCategoryId;
1375            private boolean _setOriginalCategoryId;
1376            private long _rootMessageId;
1377            private long _originalRootMessageId;
1378            private boolean _setOriginalRootMessageId;
1379            private long _rootMessageUserId;
1380            private String _rootMessageUserUuid;
1381            private int _messageCount;
1382            private int _viewCount;
1383            private long _lastPostByUserId;
1384            private String _lastPostByUserUuid;
1385            private Date _lastPostDate;
1386            private Date _originalLastPostDate;
1387            private double _priority;
1388            private double _originalPriority;
1389            private boolean _setOriginalPriority;
1390            private boolean _question;
1391            private int _status;
1392            private int _originalStatus;
1393            private boolean _setOriginalStatus;
1394            private long _statusByUserId;
1395            private String _statusByUserUuid;
1396            private String _statusByUserName;
1397            private Date _statusDate;
1398            private long _columnBitmask;
1399            private MBThread _escapedModel;
1400    }