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