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