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