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.HashUtil;
020 import com.liferay.portal.kernel.util.StringBundler;
021 import com.liferay.portal.kernel.util.StringPool;
022 import com.liferay.portal.model.CacheModel;
023
024 import com.liferay.portlet.asset.model.AssetEntry;
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 groupId = objectInput.readLong();
258 companyId = objectInput.readLong();
259 userId = objectInput.readLong();
260 userName = objectInput.readUTF();
261 createDate = objectInput.readLong();
262 modifiedDate = objectInput.readLong();
263 classNameId = objectInput.readLong();
264 classPK = objectInput.readLong();
265 classUuid = objectInput.readUTF();
266 classTypeId = objectInput.readLong();
267 listable = objectInput.readBoolean();
268 visible = objectInput.readBoolean();
269 startDate = objectInput.readLong();
270 endDate = objectInput.readLong();
271 publishDate = objectInput.readLong();
272 expirationDate = objectInput.readLong();
273 mimeType = objectInput.readUTF();
274 title = objectInput.readUTF();
275 description = objectInput.readUTF();
276 summary = objectInput.readUTF();
277 url = objectInput.readUTF();
278 layoutUuid = objectInput.readUTF();
279 height = objectInput.readInt();
280 width = objectInput.readInt();
281 priority = objectInput.readDouble();
282 viewCount = objectInput.readInt();
283 }
284
285 @Override
286 public void writeExternal(ObjectOutput objectOutput)
287 throws IOException {
288 objectOutput.writeLong(entryId);
289 objectOutput.writeLong(groupId);
290 objectOutput.writeLong(companyId);
291 objectOutput.writeLong(userId);
292
293 if (userName == null) {
294 objectOutput.writeUTF(StringPool.BLANK);
295 }
296 else {
297 objectOutput.writeUTF(userName);
298 }
299
300 objectOutput.writeLong(createDate);
301 objectOutput.writeLong(modifiedDate);
302 objectOutput.writeLong(classNameId);
303 objectOutput.writeLong(classPK);
304
305 if (classUuid == null) {
306 objectOutput.writeUTF(StringPool.BLANK);
307 }
308 else {
309 objectOutput.writeUTF(classUuid);
310 }
311
312 objectOutput.writeLong(classTypeId);
313 objectOutput.writeBoolean(listable);
314 objectOutput.writeBoolean(visible);
315 objectOutput.writeLong(startDate);
316 objectOutput.writeLong(endDate);
317 objectOutput.writeLong(publishDate);
318 objectOutput.writeLong(expirationDate);
319
320 if (mimeType == null) {
321 objectOutput.writeUTF(StringPool.BLANK);
322 }
323 else {
324 objectOutput.writeUTF(mimeType);
325 }
326
327 if (title == null) {
328 objectOutput.writeUTF(StringPool.BLANK);
329 }
330 else {
331 objectOutput.writeUTF(title);
332 }
333
334 if (description == null) {
335 objectOutput.writeUTF(StringPool.BLANK);
336 }
337 else {
338 objectOutput.writeUTF(description);
339 }
340
341 if (summary == null) {
342 objectOutput.writeUTF(StringPool.BLANK);
343 }
344 else {
345 objectOutput.writeUTF(summary);
346 }
347
348 if (url == null) {
349 objectOutput.writeUTF(StringPool.BLANK);
350 }
351 else {
352 objectOutput.writeUTF(url);
353 }
354
355 if (layoutUuid == null) {
356 objectOutput.writeUTF(StringPool.BLANK);
357 }
358 else {
359 objectOutput.writeUTF(layoutUuid);
360 }
361
362 objectOutput.writeInt(height);
363 objectOutput.writeInt(width);
364 objectOutput.writeDouble(priority);
365 objectOutput.writeInt(viewCount);
366 }
367
368 public long entryId;
369 public long groupId;
370 public long companyId;
371 public long userId;
372 public String userName;
373 public long createDate;
374 public long modifiedDate;
375 public long classNameId;
376 public long classPK;
377 public String classUuid;
378 public long classTypeId;
379 public boolean listable;
380 public boolean visible;
381 public long startDate;
382 public long endDate;
383 public long publishDate;
384 public long expirationDate;
385 public String mimeType;
386 public String title;
387 public String description;
388 public String summary;
389 public String url;
390 public String layoutUuid;
391 public int height;
392 public int width;
393 public double priority;
394 public int viewCount;
395 }