001
014
015 package com.liferay.portlet.blogs.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.blogs.model.BlogsEntry;
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 BlogsEntryCacheModel implements CacheModel<BlogsEntry>,
038 Externalizable {
039 @Override
040 public String toString() {
041 StringBundler sb = new StringBundler(47);
042
043 sb.append("{uuid=");
044 sb.append(uuid);
045 sb.append(", entryId=");
046 sb.append(entryId);
047 sb.append(", groupId=");
048 sb.append(groupId);
049 sb.append(", companyId=");
050 sb.append(companyId);
051 sb.append(", userId=");
052 sb.append(userId);
053 sb.append(", userName=");
054 sb.append(userName);
055 sb.append(", createDate=");
056 sb.append(createDate);
057 sb.append(", modifiedDate=");
058 sb.append(modifiedDate);
059 sb.append(", title=");
060 sb.append(title);
061 sb.append(", urlTitle=");
062 sb.append(urlTitle);
063 sb.append(", description=");
064 sb.append(description);
065 sb.append(", content=");
066 sb.append(content);
067 sb.append(", displayDate=");
068 sb.append(displayDate);
069 sb.append(", allowPingbacks=");
070 sb.append(allowPingbacks);
071 sb.append(", allowTrackbacks=");
072 sb.append(allowTrackbacks);
073 sb.append(", trackbacks=");
074 sb.append(trackbacks);
075 sb.append(", smallImage=");
076 sb.append(smallImage);
077 sb.append(", smallImageId=");
078 sb.append(smallImageId);
079 sb.append(", smallImageURL=");
080 sb.append(smallImageURL);
081 sb.append(", status=");
082 sb.append(status);
083 sb.append(", statusByUserId=");
084 sb.append(statusByUserId);
085 sb.append(", statusByUserName=");
086 sb.append(statusByUserName);
087 sb.append(", statusDate=");
088 sb.append(statusDate);
089 sb.append("}");
090
091 return sb.toString();
092 }
093
094 public BlogsEntry toEntityModel() {
095 BlogsEntryImpl blogsEntryImpl = new BlogsEntryImpl();
096
097 if (uuid == null) {
098 blogsEntryImpl.setUuid(StringPool.BLANK);
099 }
100 else {
101 blogsEntryImpl.setUuid(uuid);
102 }
103
104 blogsEntryImpl.setEntryId(entryId);
105 blogsEntryImpl.setGroupId(groupId);
106 blogsEntryImpl.setCompanyId(companyId);
107 blogsEntryImpl.setUserId(userId);
108
109 if (userName == null) {
110 blogsEntryImpl.setUserName(StringPool.BLANK);
111 }
112 else {
113 blogsEntryImpl.setUserName(userName);
114 }
115
116 if (createDate == Long.MIN_VALUE) {
117 blogsEntryImpl.setCreateDate(null);
118 }
119 else {
120 blogsEntryImpl.setCreateDate(new Date(createDate));
121 }
122
123 if (modifiedDate == Long.MIN_VALUE) {
124 blogsEntryImpl.setModifiedDate(null);
125 }
126 else {
127 blogsEntryImpl.setModifiedDate(new Date(modifiedDate));
128 }
129
130 if (title == null) {
131 blogsEntryImpl.setTitle(StringPool.BLANK);
132 }
133 else {
134 blogsEntryImpl.setTitle(title);
135 }
136
137 if (urlTitle == null) {
138 blogsEntryImpl.setUrlTitle(StringPool.BLANK);
139 }
140 else {
141 blogsEntryImpl.setUrlTitle(urlTitle);
142 }
143
144 if (description == null) {
145 blogsEntryImpl.setDescription(StringPool.BLANK);
146 }
147 else {
148 blogsEntryImpl.setDescription(description);
149 }
150
151 if (content == null) {
152 blogsEntryImpl.setContent(StringPool.BLANK);
153 }
154 else {
155 blogsEntryImpl.setContent(content);
156 }
157
158 if (displayDate == Long.MIN_VALUE) {
159 blogsEntryImpl.setDisplayDate(null);
160 }
161 else {
162 blogsEntryImpl.setDisplayDate(new Date(displayDate));
163 }
164
165 blogsEntryImpl.setAllowPingbacks(allowPingbacks);
166 blogsEntryImpl.setAllowTrackbacks(allowTrackbacks);
167
168 if (trackbacks == null) {
169 blogsEntryImpl.setTrackbacks(StringPool.BLANK);
170 }
171 else {
172 blogsEntryImpl.setTrackbacks(trackbacks);
173 }
174
175 blogsEntryImpl.setSmallImage(smallImage);
176 blogsEntryImpl.setSmallImageId(smallImageId);
177
178 if (smallImageURL == null) {
179 blogsEntryImpl.setSmallImageURL(StringPool.BLANK);
180 }
181 else {
182 blogsEntryImpl.setSmallImageURL(smallImageURL);
183 }
184
185 blogsEntryImpl.setStatus(status);
186 blogsEntryImpl.setStatusByUserId(statusByUserId);
187
188 if (statusByUserName == null) {
189 blogsEntryImpl.setStatusByUserName(StringPool.BLANK);
190 }
191 else {
192 blogsEntryImpl.setStatusByUserName(statusByUserName);
193 }
194
195 if (statusDate == Long.MIN_VALUE) {
196 blogsEntryImpl.setStatusDate(null);
197 }
198 else {
199 blogsEntryImpl.setStatusDate(new Date(statusDate));
200 }
201
202 blogsEntryImpl.resetOriginalValues();
203
204 return blogsEntryImpl;
205 }
206
207 public void readExternal(ObjectInput objectInput) throws IOException {
208 uuid = objectInput.readUTF();
209 entryId = objectInput.readLong();
210 groupId = objectInput.readLong();
211 companyId = objectInput.readLong();
212 userId = objectInput.readLong();
213 userName = objectInput.readUTF();
214 createDate = objectInput.readLong();
215 modifiedDate = objectInput.readLong();
216 title = objectInput.readUTF();
217 urlTitle = objectInput.readUTF();
218 description = objectInput.readUTF();
219 content = objectInput.readUTF();
220 displayDate = objectInput.readLong();
221 allowPingbacks = objectInput.readBoolean();
222 allowTrackbacks = objectInput.readBoolean();
223 trackbacks = objectInput.readUTF();
224 smallImage = objectInput.readBoolean();
225 smallImageId = objectInput.readLong();
226 smallImageURL = objectInput.readUTF();
227 status = objectInput.readInt();
228 statusByUserId = objectInput.readLong();
229 statusByUserName = objectInput.readUTF();
230 statusDate = objectInput.readLong();
231 }
232
233 public void writeExternal(ObjectOutput objectOutput)
234 throws IOException {
235 if (uuid == null) {
236 objectOutput.writeUTF(StringPool.BLANK);
237 }
238 else {
239 objectOutput.writeUTF(uuid);
240 }
241
242 objectOutput.writeLong(entryId);
243 objectOutput.writeLong(groupId);
244 objectOutput.writeLong(companyId);
245 objectOutput.writeLong(userId);
246
247 if (userName == null) {
248 objectOutput.writeUTF(StringPool.BLANK);
249 }
250 else {
251 objectOutput.writeUTF(userName);
252 }
253
254 objectOutput.writeLong(createDate);
255 objectOutput.writeLong(modifiedDate);
256
257 if (title == null) {
258 objectOutput.writeUTF(StringPool.BLANK);
259 }
260 else {
261 objectOutput.writeUTF(title);
262 }
263
264 if (urlTitle == null) {
265 objectOutput.writeUTF(StringPool.BLANK);
266 }
267 else {
268 objectOutput.writeUTF(urlTitle);
269 }
270
271 if (description == null) {
272 objectOutput.writeUTF(StringPool.BLANK);
273 }
274 else {
275 objectOutput.writeUTF(description);
276 }
277
278 if (content == null) {
279 objectOutput.writeUTF(StringPool.BLANK);
280 }
281 else {
282 objectOutput.writeUTF(content);
283 }
284
285 objectOutput.writeLong(displayDate);
286 objectOutput.writeBoolean(allowPingbacks);
287 objectOutput.writeBoolean(allowTrackbacks);
288
289 if (trackbacks == null) {
290 objectOutput.writeUTF(StringPool.BLANK);
291 }
292 else {
293 objectOutput.writeUTF(trackbacks);
294 }
295
296 objectOutput.writeBoolean(smallImage);
297 objectOutput.writeLong(smallImageId);
298
299 if (smallImageURL == null) {
300 objectOutput.writeUTF(StringPool.BLANK);
301 }
302 else {
303 objectOutput.writeUTF(smallImageURL);
304 }
305
306 objectOutput.writeInt(status);
307 objectOutput.writeLong(statusByUserId);
308
309 if (statusByUserName == null) {
310 objectOutput.writeUTF(StringPool.BLANK);
311 }
312 else {
313 objectOutput.writeUTF(statusByUserName);
314 }
315
316 objectOutput.writeLong(statusDate);
317 }
318
319 public String uuid;
320 public long entryId;
321 public long groupId;
322 public long companyId;
323 public long userId;
324 public String userName;
325 public long createDate;
326 public long modifiedDate;
327 public String title;
328 public String urlTitle;
329 public String description;
330 public String content;
331 public long displayDate;
332 public boolean allowPingbacks;
333 public boolean allowTrackbacks;
334 public String trackbacks;
335 public boolean smallImage;
336 public long smallImageId;
337 public String smallImageURL;
338 public int status;
339 public long statusByUserId;
340 public String statusByUserName;
341 public long statusDate;
342 }