001
014
015 package com.liferay.portlet.messageboards.model.impl;
016
017 import aQute.bnd.annotation.ProviderType;
018
019 import com.liferay.portal.kernel.util.HashUtil;
020 import com.liferay.portal.kernel.util.StringBundler;
021 import com.liferay.portal.kernel.util.StringPool;
022 import com.liferay.portal.model.CacheModel;
023
024 import com.liferay.portlet.messageboards.model.MBThread;
025
026 import java.io.Externalizable;
027 import java.io.IOException;
028 import java.io.ObjectInput;
029 import java.io.ObjectOutput;
030
031 import java.util.Date;
032
033
040 @ProviderType
041 public class MBThreadCacheModel implements CacheModel<MBThread>, Externalizable {
042 @Override
043 public boolean equals(Object obj) {
044 if (this == obj) {
045 return true;
046 }
047
048 if (!(obj instanceof MBThreadCacheModel)) {
049 return false;
050 }
051
052 MBThreadCacheModel mbThreadCacheModel = (MBThreadCacheModel)obj;
053
054 if (threadId == mbThreadCacheModel.threadId) {
055 return true;
056 }
057
058 return false;
059 }
060
061 @Override
062 public int hashCode() {
063 return HashUtil.hash(0, threadId);
064 }
065
066 @Override
067 public String toString() {
068 StringBundler sb = new StringBundler(45);
069
070 sb.append("{uuid=");
071 sb.append(uuid);
072 sb.append(", threadId=");
073 sb.append(threadId);
074 sb.append(", groupId=");
075 sb.append(groupId);
076 sb.append(", companyId=");
077 sb.append(companyId);
078 sb.append(", userId=");
079 sb.append(userId);
080 sb.append(", userName=");
081 sb.append(userName);
082 sb.append(", createDate=");
083 sb.append(createDate);
084 sb.append(", modifiedDate=");
085 sb.append(modifiedDate);
086 sb.append(", categoryId=");
087 sb.append(categoryId);
088 sb.append(", rootMessageId=");
089 sb.append(rootMessageId);
090 sb.append(", rootMessageUserId=");
091 sb.append(rootMessageUserId);
092 sb.append(", messageCount=");
093 sb.append(messageCount);
094 sb.append(", viewCount=");
095 sb.append(viewCount);
096 sb.append(", lastPostByUserId=");
097 sb.append(lastPostByUserId);
098 sb.append(", lastPostDate=");
099 sb.append(lastPostDate);
100 sb.append(", priority=");
101 sb.append(priority);
102 sb.append(", question=");
103 sb.append(question);
104 sb.append(", lastPublishDate=");
105 sb.append(lastPublishDate);
106 sb.append(", status=");
107 sb.append(status);
108 sb.append(", statusByUserId=");
109 sb.append(statusByUserId);
110 sb.append(", statusByUserName=");
111 sb.append(statusByUserName);
112 sb.append(", statusDate=");
113 sb.append(statusDate);
114 sb.append("}");
115
116 return sb.toString();
117 }
118
119 @Override
120 public MBThread toEntityModel() {
121 MBThreadImpl mbThreadImpl = new MBThreadImpl();
122
123 if (uuid == null) {
124 mbThreadImpl.setUuid(StringPool.BLANK);
125 }
126 else {
127 mbThreadImpl.setUuid(uuid);
128 }
129
130 mbThreadImpl.setThreadId(threadId);
131 mbThreadImpl.setGroupId(groupId);
132 mbThreadImpl.setCompanyId(companyId);
133 mbThreadImpl.setUserId(userId);
134
135 if (userName == null) {
136 mbThreadImpl.setUserName(StringPool.BLANK);
137 }
138 else {
139 mbThreadImpl.setUserName(userName);
140 }
141
142 if (createDate == Long.MIN_VALUE) {
143 mbThreadImpl.setCreateDate(null);
144 }
145 else {
146 mbThreadImpl.setCreateDate(new Date(createDate));
147 }
148
149 if (modifiedDate == Long.MIN_VALUE) {
150 mbThreadImpl.setModifiedDate(null);
151 }
152 else {
153 mbThreadImpl.setModifiedDate(new Date(modifiedDate));
154 }
155
156 mbThreadImpl.setCategoryId(categoryId);
157 mbThreadImpl.setRootMessageId(rootMessageId);
158 mbThreadImpl.setRootMessageUserId(rootMessageUserId);
159 mbThreadImpl.setMessageCount(messageCount);
160 mbThreadImpl.setViewCount(viewCount);
161 mbThreadImpl.setLastPostByUserId(lastPostByUserId);
162
163 if (lastPostDate == Long.MIN_VALUE) {
164 mbThreadImpl.setLastPostDate(null);
165 }
166 else {
167 mbThreadImpl.setLastPostDate(new Date(lastPostDate));
168 }
169
170 mbThreadImpl.setPriority(priority);
171 mbThreadImpl.setQuestion(question);
172
173 if (lastPublishDate == Long.MIN_VALUE) {
174 mbThreadImpl.setLastPublishDate(null);
175 }
176 else {
177 mbThreadImpl.setLastPublishDate(new Date(lastPublishDate));
178 }
179
180 mbThreadImpl.setStatus(status);
181 mbThreadImpl.setStatusByUserId(statusByUserId);
182
183 if (statusByUserName == null) {
184 mbThreadImpl.setStatusByUserName(StringPool.BLANK);
185 }
186 else {
187 mbThreadImpl.setStatusByUserName(statusByUserName);
188 }
189
190 if (statusDate == Long.MIN_VALUE) {
191 mbThreadImpl.setStatusDate(null);
192 }
193 else {
194 mbThreadImpl.setStatusDate(new Date(statusDate));
195 }
196
197 mbThreadImpl.resetOriginalValues();
198
199 return mbThreadImpl;
200 }
201
202 @Override
203 public void readExternal(ObjectInput objectInput) throws IOException {
204 uuid = objectInput.readUTF();
205 threadId = objectInput.readLong();
206 groupId = objectInput.readLong();
207 companyId = objectInput.readLong();
208 userId = objectInput.readLong();
209 userName = objectInput.readUTF();
210 createDate = objectInput.readLong();
211 modifiedDate = objectInput.readLong();
212 categoryId = objectInput.readLong();
213 rootMessageId = objectInput.readLong();
214 rootMessageUserId = objectInput.readLong();
215 messageCount = objectInput.readInt();
216 viewCount = objectInput.readInt();
217 lastPostByUserId = objectInput.readLong();
218 lastPostDate = objectInput.readLong();
219 priority = objectInput.readDouble();
220 question = objectInput.readBoolean();
221 lastPublishDate = objectInput.readLong();
222 status = objectInput.readInt();
223 statusByUserId = objectInput.readLong();
224 statusByUserName = objectInput.readUTF();
225 statusDate = objectInput.readLong();
226 }
227
228 @Override
229 public void writeExternal(ObjectOutput objectOutput)
230 throws IOException {
231 if (uuid == null) {
232 objectOutput.writeUTF(StringPool.BLANK);
233 }
234 else {
235 objectOutput.writeUTF(uuid);
236 }
237
238 objectOutput.writeLong(threadId);
239 objectOutput.writeLong(groupId);
240 objectOutput.writeLong(companyId);
241 objectOutput.writeLong(userId);
242
243 if (userName == null) {
244 objectOutput.writeUTF(StringPool.BLANK);
245 }
246 else {
247 objectOutput.writeUTF(userName);
248 }
249
250 objectOutput.writeLong(createDate);
251 objectOutput.writeLong(modifiedDate);
252 objectOutput.writeLong(categoryId);
253 objectOutput.writeLong(rootMessageId);
254 objectOutput.writeLong(rootMessageUserId);
255 objectOutput.writeInt(messageCount);
256 objectOutput.writeInt(viewCount);
257 objectOutput.writeLong(lastPostByUserId);
258 objectOutput.writeLong(lastPostDate);
259 objectOutput.writeDouble(priority);
260 objectOutput.writeBoolean(question);
261 objectOutput.writeLong(lastPublishDate);
262 objectOutput.writeInt(status);
263 objectOutput.writeLong(statusByUserId);
264
265 if (statusByUserName == null) {
266 objectOutput.writeUTF(StringPool.BLANK);
267 }
268 else {
269 objectOutput.writeUTF(statusByUserName);
270 }
271
272 objectOutput.writeLong(statusDate);
273 }
274
275 public String uuid;
276 public long threadId;
277 public long groupId;
278 public long companyId;
279 public long userId;
280 public String userName;
281 public long createDate;
282 public long modifiedDate;
283 public long categoryId;
284 public long rootMessageId;
285 public long rootMessageUserId;
286 public int messageCount;
287 public int viewCount;
288 public long lastPostByUserId;
289 public long lastPostDate;
290 public double priority;
291 public boolean question;
292 public long lastPublishDate;
293 public int status;
294 public long statusByUserId;
295 public String statusByUserName;
296 public long statusDate;
297 }