001
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
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 @Override
090 public MBThread toEntityModel() {
091 MBThreadImpl mbThreadImpl = new MBThreadImpl();
092
093 if (uuid == null) {
094 mbThreadImpl.setUuid(StringPool.BLANK);
095 }
096 else {
097 mbThreadImpl.setUuid(uuid);
098 }
099
100 mbThreadImpl.setThreadId(threadId);
101 mbThreadImpl.setGroupId(groupId);
102 mbThreadImpl.setCompanyId(companyId);
103 mbThreadImpl.setUserId(userId);
104
105 if (userName == null) {
106 mbThreadImpl.setUserName(StringPool.BLANK);
107 }
108 else {
109 mbThreadImpl.setUserName(userName);
110 }
111
112 if (createDate == Long.MIN_VALUE) {
113 mbThreadImpl.setCreateDate(null);
114 }
115 else {
116 mbThreadImpl.setCreateDate(new Date(createDate));
117 }
118
119 if (modifiedDate == Long.MIN_VALUE) {
120 mbThreadImpl.setModifiedDate(null);
121 }
122 else {
123 mbThreadImpl.setModifiedDate(new Date(modifiedDate));
124 }
125
126 mbThreadImpl.setCategoryId(categoryId);
127 mbThreadImpl.setRootMessageId(rootMessageId);
128 mbThreadImpl.setRootMessageUserId(rootMessageUserId);
129 mbThreadImpl.setMessageCount(messageCount);
130 mbThreadImpl.setViewCount(viewCount);
131 mbThreadImpl.setLastPostByUserId(lastPostByUserId);
132
133 if (lastPostDate == Long.MIN_VALUE) {
134 mbThreadImpl.setLastPostDate(null);
135 }
136 else {
137 mbThreadImpl.setLastPostDate(new Date(lastPostDate));
138 }
139
140 mbThreadImpl.setPriority(priority);
141 mbThreadImpl.setQuestion(question);
142 mbThreadImpl.setStatus(status);
143 mbThreadImpl.setStatusByUserId(statusByUserId);
144
145 if (statusByUserName == null) {
146 mbThreadImpl.setStatusByUserName(StringPool.BLANK);
147 }
148 else {
149 mbThreadImpl.setStatusByUserName(statusByUserName);
150 }
151
152 if (statusDate == Long.MIN_VALUE) {
153 mbThreadImpl.setStatusDate(null);
154 }
155 else {
156 mbThreadImpl.setStatusDate(new Date(statusDate));
157 }
158
159 mbThreadImpl.resetOriginalValues();
160
161 return mbThreadImpl;
162 }
163
164 @Override
165 public void readExternal(ObjectInput objectInput) throws IOException {
166 uuid = objectInput.readUTF();
167 threadId = objectInput.readLong();
168 groupId = objectInput.readLong();
169 companyId = objectInput.readLong();
170 userId = objectInput.readLong();
171 userName = objectInput.readUTF();
172 createDate = objectInput.readLong();
173 modifiedDate = objectInput.readLong();
174 categoryId = objectInput.readLong();
175 rootMessageId = objectInput.readLong();
176 rootMessageUserId = objectInput.readLong();
177 messageCount = objectInput.readInt();
178 viewCount = objectInput.readInt();
179 lastPostByUserId = objectInput.readLong();
180 lastPostDate = objectInput.readLong();
181 priority = objectInput.readDouble();
182 question = objectInput.readBoolean();
183 status = objectInput.readInt();
184 statusByUserId = objectInput.readLong();
185 statusByUserName = objectInput.readUTF();
186 statusDate = objectInput.readLong();
187 }
188
189 @Override
190 public void writeExternal(ObjectOutput objectOutput)
191 throws IOException {
192 if (uuid == null) {
193 objectOutput.writeUTF(StringPool.BLANK);
194 }
195 else {
196 objectOutput.writeUTF(uuid);
197 }
198
199 objectOutput.writeLong(threadId);
200 objectOutput.writeLong(groupId);
201 objectOutput.writeLong(companyId);
202 objectOutput.writeLong(userId);
203
204 if (userName == null) {
205 objectOutput.writeUTF(StringPool.BLANK);
206 }
207 else {
208 objectOutput.writeUTF(userName);
209 }
210
211 objectOutput.writeLong(createDate);
212 objectOutput.writeLong(modifiedDate);
213 objectOutput.writeLong(categoryId);
214 objectOutput.writeLong(rootMessageId);
215 objectOutput.writeLong(rootMessageUserId);
216 objectOutput.writeInt(messageCount);
217 objectOutput.writeInt(viewCount);
218 objectOutput.writeLong(lastPostByUserId);
219 objectOutput.writeLong(lastPostDate);
220 objectOutput.writeDouble(priority);
221 objectOutput.writeBoolean(question);
222 objectOutput.writeInt(status);
223 objectOutput.writeLong(statusByUserId);
224
225 if (statusByUserName == null) {
226 objectOutput.writeUTF(StringPool.BLANK);
227 }
228 else {
229 objectOutput.writeUTF(statusByUserName);
230 }
231
232 objectOutput.writeLong(statusDate);
233 }
234
235 public String uuid;
236 public long threadId;
237 public long groupId;
238 public long companyId;
239 public long userId;
240 public String userName;
241 public long createDate;
242 public long modifiedDate;
243 public long categoryId;
244 public long rootMessageId;
245 public long rootMessageUserId;
246 public int messageCount;
247 public int viewCount;
248 public long lastPostByUserId;
249 public long lastPostDate;
250 public double priority;
251 public boolean question;
252 public int status;
253 public long statusByUserId;
254 public String statusByUserName;
255 public long statusDate;
256 }