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.util.StringBundler;
018    import com.liferay.portal.kernel.util.StringPool;
019    import com.liferay.portal.model.CacheModel;
020    
021    import com.liferay.portlet.messageboards.model.MBThread;
022    
023    import java.io.Externalizable;
024    import java.io.IOException;
025    import java.io.ObjectInput;
026    import java.io.ObjectOutput;
027    
028    import java.util.Date;
029    
030    /**
031     * The cache model class for representing MBThread in entity cache.
032     *
033     * @author Brian Wing Shun Chan
034     * @see MBThread
035     * @generated
036     */
037    public class MBThreadCacheModel implements CacheModel<MBThread>, Externalizable {
038            @Override
039            public String toString() {
040                    StringBundler sb = new StringBundler(43);
041    
042                    sb.append("{uuid=");
043                    sb.append(uuid);
044                    sb.append(", threadId=");
045                    sb.append(threadId);
046                    sb.append(", groupId=");
047                    sb.append(groupId);
048                    sb.append(", companyId=");
049                    sb.append(companyId);
050                    sb.append(", userId=");
051                    sb.append(userId);
052                    sb.append(", userName=");
053                    sb.append(userName);
054                    sb.append(", createDate=");
055                    sb.append(createDate);
056                    sb.append(", modifiedDate=");
057                    sb.append(modifiedDate);
058                    sb.append(", categoryId=");
059                    sb.append(categoryId);
060                    sb.append(", rootMessageId=");
061                    sb.append(rootMessageId);
062                    sb.append(", rootMessageUserId=");
063                    sb.append(rootMessageUserId);
064                    sb.append(", messageCount=");
065                    sb.append(messageCount);
066                    sb.append(", viewCount=");
067                    sb.append(viewCount);
068                    sb.append(", lastPostByUserId=");
069                    sb.append(lastPostByUserId);
070                    sb.append(", lastPostDate=");
071                    sb.append(lastPostDate);
072                    sb.append(", priority=");
073                    sb.append(priority);
074                    sb.append(", question=");
075                    sb.append(question);
076                    sb.append(", status=");
077                    sb.append(status);
078                    sb.append(", statusByUserId=");
079                    sb.append(statusByUserId);
080                    sb.append(", statusByUserName=");
081                    sb.append(statusByUserName);
082                    sb.append(", statusDate=");
083                    sb.append(statusDate);
084                    sb.append("}");
085    
086                    return sb.toString();
087            }
088    
089            public MBThread toEntityModel() {
090                    MBThreadImpl mbThreadImpl = new MBThreadImpl();
091    
092                    if (uuid == null) {
093                            mbThreadImpl.setUuid(StringPool.BLANK);
094                    }
095                    else {
096                            mbThreadImpl.setUuid(uuid);
097                    }
098    
099                    mbThreadImpl.setThreadId(threadId);
100                    mbThreadImpl.setGroupId(groupId);
101                    mbThreadImpl.setCompanyId(companyId);
102                    mbThreadImpl.setUserId(userId);
103    
104                    if (userName == null) {
105                            mbThreadImpl.setUserName(StringPool.BLANK);
106                    }
107                    else {
108                            mbThreadImpl.setUserName(userName);
109                    }
110    
111                    if (createDate == Long.MIN_VALUE) {
112                            mbThreadImpl.setCreateDate(null);
113                    }
114                    else {
115                            mbThreadImpl.setCreateDate(new Date(createDate));
116                    }
117    
118                    if (modifiedDate == Long.MIN_VALUE) {
119                            mbThreadImpl.setModifiedDate(null);
120                    }
121                    else {
122                            mbThreadImpl.setModifiedDate(new Date(modifiedDate));
123                    }
124    
125                    mbThreadImpl.setCategoryId(categoryId);
126                    mbThreadImpl.setRootMessageId(rootMessageId);
127                    mbThreadImpl.setRootMessageUserId(rootMessageUserId);
128                    mbThreadImpl.setMessageCount(messageCount);
129                    mbThreadImpl.setViewCount(viewCount);
130                    mbThreadImpl.setLastPostByUserId(lastPostByUserId);
131    
132                    if (lastPostDate == Long.MIN_VALUE) {
133                            mbThreadImpl.setLastPostDate(null);
134                    }
135                    else {
136                            mbThreadImpl.setLastPostDate(new Date(lastPostDate));
137                    }
138    
139                    mbThreadImpl.setPriority(priority);
140                    mbThreadImpl.setQuestion(question);
141                    mbThreadImpl.setStatus(status);
142                    mbThreadImpl.setStatusByUserId(statusByUserId);
143    
144                    if (statusByUserName == null) {
145                            mbThreadImpl.setStatusByUserName(StringPool.BLANK);
146                    }
147                    else {
148                            mbThreadImpl.setStatusByUserName(statusByUserName);
149                    }
150    
151                    if (statusDate == Long.MIN_VALUE) {
152                            mbThreadImpl.setStatusDate(null);
153                    }
154                    else {
155                            mbThreadImpl.setStatusDate(new Date(statusDate));
156                    }
157    
158                    mbThreadImpl.resetOriginalValues();
159    
160                    return mbThreadImpl;
161            }
162    
163            public void readExternal(ObjectInput objectInput) throws IOException {
164                    uuid = objectInput.readUTF();
165                    threadId = objectInput.readLong();
166                    groupId = objectInput.readLong();
167                    companyId = objectInput.readLong();
168                    userId = objectInput.readLong();
169                    userName = objectInput.readUTF();
170                    createDate = objectInput.readLong();
171                    modifiedDate = objectInput.readLong();
172                    categoryId = objectInput.readLong();
173                    rootMessageId = objectInput.readLong();
174                    rootMessageUserId = objectInput.readLong();
175                    messageCount = objectInput.readInt();
176                    viewCount = objectInput.readInt();
177                    lastPostByUserId = objectInput.readLong();
178                    lastPostDate = objectInput.readLong();
179                    priority = objectInput.readDouble();
180                    question = objectInput.readBoolean();
181                    status = objectInput.readInt();
182                    statusByUserId = objectInput.readLong();
183                    statusByUserName = objectInput.readUTF();
184                    statusDate = objectInput.readLong();
185            }
186    
187            public void writeExternal(ObjectOutput objectOutput)
188                    throws IOException {
189                    if (uuid == null) {
190                            objectOutput.writeUTF(StringPool.BLANK);
191                    }
192                    else {
193                            objectOutput.writeUTF(uuid);
194                    }
195    
196                    objectOutput.writeLong(threadId);
197                    objectOutput.writeLong(groupId);
198                    objectOutput.writeLong(companyId);
199                    objectOutput.writeLong(userId);
200    
201                    if (userName == null) {
202                            objectOutput.writeUTF(StringPool.BLANK);
203                    }
204                    else {
205                            objectOutput.writeUTF(userName);
206                    }
207    
208                    objectOutput.writeLong(createDate);
209                    objectOutput.writeLong(modifiedDate);
210                    objectOutput.writeLong(categoryId);
211                    objectOutput.writeLong(rootMessageId);
212                    objectOutput.writeLong(rootMessageUserId);
213                    objectOutput.writeInt(messageCount);
214                    objectOutput.writeInt(viewCount);
215                    objectOutput.writeLong(lastPostByUserId);
216                    objectOutput.writeLong(lastPostDate);
217                    objectOutput.writeDouble(priority);
218                    objectOutput.writeBoolean(question);
219                    objectOutput.writeInt(status);
220                    objectOutput.writeLong(statusByUserId);
221    
222                    if (statusByUserName == null) {
223                            objectOutput.writeUTF(StringPool.BLANK);
224                    }
225                    else {
226                            objectOutput.writeUTF(statusByUserName);
227                    }
228    
229                    objectOutput.writeLong(statusDate);
230            }
231    
232            public String uuid;
233            public long threadId;
234            public long groupId;
235            public long companyId;
236            public long userId;
237            public String userName;
238            public long createDate;
239            public long modifiedDate;
240            public long categoryId;
241            public long rootMessageId;
242            public long rootMessageUserId;
243            public int messageCount;
244            public int viewCount;
245            public long lastPostByUserId;
246            public long lastPostDate;
247            public double priority;
248            public boolean question;
249            public int status;
250            public long statusByUserId;
251            public String statusByUserName;
252            public long statusDate;
253    }