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