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