001
014
015 package com.liferay.portlet.calendar.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.calendar.model.CalEvent;
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 CalEventCacheModel implements CacheModel<CalEvent>, Externalizable {
042 @Override
043 public boolean equals(Object obj) {
044 if (this == obj) {
045 return true;
046 }
047
048 if (!(obj instanceof CalEventCacheModel)) {
049 return false;
050 }
051
052 CalEventCacheModel calEventCacheModel = (CalEventCacheModel)obj;
053
054 if (eventId == calEventCacheModel.eventId) {
055 return true;
056 }
057
058 return false;
059 }
060
061 @Override
062 public int hashCode() {
063 return HashUtil.hash(0, eventId);
064 }
065
066 @Override
067 public String toString() {
068 StringBundler sb = new StringBundler(47);
069
070 sb.append("{uuid=");
071 sb.append(uuid);
072 sb.append(", eventId=");
073 sb.append(eventId);
074 sb.append(", groupId=");
075 sb.append(groupId);
076 sb.append(", companyId=");
077 sb.append(companyId);
078 sb.append(", userId=");
079 sb.append(userId);
080 sb.append(", userName=");
081 sb.append(userName);
082 sb.append(", createDate=");
083 sb.append(createDate);
084 sb.append(", modifiedDate=");
085 sb.append(modifiedDate);
086 sb.append(", title=");
087 sb.append(title);
088 sb.append(", description=");
089 sb.append(description);
090 sb.append(", location=");
091 sb.append(location);
092 sb.append(", startDate=");
093 sb.append(startDate);
094 sb.append(", endDate=");
095 sb.append(endDate);
096 sb.append(", durationHour=");
097 sb.append(durationHour);
098 sb.append(", durationMinute=");
099 sb.append(durationMinute);
100 sb.append(", allDay=");
101 sb.append(allDay);
102 sb.append(", timeZoneSensitive=");
103 sb.append(timeZoneSensitive);
104 sb.append(", type=");
105 sb.append(type);
106 sb.append(", repeating=");
107 sb.append(repeating);
108 sb.append(", recurrence=");
109 sb.append(recurrence);
110 sb.append(", remindBy=");
111 sb.append(remindBy);
112 sb.append(", firstReminder=");
113 sb.append(firstReminder);
114 sb.append(", secondReminder=");
115 sb.append(secondReminder);
116 sb.append("}");
117
118 return sb.toString();
119 }
120
121 @Override
122 public CalEvent toEntityModel() {
123 CalEventImpl calEventImpl = new CalEventImpl();
124
125 if (uuid == null) {
126 calEventImpl.setUuid(StringPool.BLANK);
127 }
128 else {
129 calEventImpl.setUuid(uuid);
130 }
131
132 calEventImpl.setEventId(eventId);
133 calEventImpl.setGroupId(groupId);
134 calEventImpl.setCompanyId(companyId);
135 calEventImpl.setUserId(userId);
136
137 if (userName == null) {
138 calEventImpl.setUserName(StringPool.BLANK);
139 }
140 else {
141 calEventImpl.setUserName(userName);
142 }
143
144 if (createDate == Long.MIN_VALUE) {
145 calEventImpl.setCreateDate(null);
146 }
147 else {
148 calEventImpl.setCreateDate(new Date(createDate));
149 }
150
151 if (modifiedDate == Long.MIN_VALUE) {
152 calEventImpl.setModifiedDate(null);
153 }
154 else {
155 calEventImpl.setModifiedDate(new Date(modifiedDate));
156 }
157
158 if (title == null) {
159 calEventImpl.setTitle(StringPool.BLANK);
160 }
161 else {
162 calEventImpl.setTitle(title);
163 }
164
165 if (description == null) {
166 calEventImpl.setDescription(StringPool.BLANK);
167 }
168 else {
169 calEventImpl.setDescription(description);
170 }
171
172 if (location == null) {
173 calEventImpl.setLocation(StringPool.BLANK);
174 }
175 else {
176 calEventImpl.setLocation(location);
177 }
178
179 if (startDate == Long.MIN_VALUE) {
180 calEventImpl.setStartDate(null);
181 }
182 else {
183 calEventImpl.setStartDate(new Date(startDate));
184 }
185
186 if (endDate == Long.MIN_VALUE) {
187 calEventImpl.setEndDate(null);
188 }
189 else {
190 calEventImpl.setEndDate(new Date(endDate));
191 }
192
193 calEventImpl.setDurationHour(durationHour);
194 calEventImpl.setDurationMinute(durationMinute);
195 calEventImpl.setAllDay(allDay);
196 calEventImpl.setTimeZoneSensitive(timeZoneSensitive);
197
198 if (type == null) {
199 calEventImpl.setType(StringPool.BLANK);
200 }
201 else {
202 calEventImpl.setType(type);
203 }
204
205 calEventImpl.setRepeating(repeating);
206
207 if (recurrence == null) {
208 calEventImpl.setRecurrence(StringPool.BLANK);
209 }
210 else {
211 calEventImpl.setRecurrence(recurrence);
212 }
213
214 calEventImpl.setRemindBy(remindBy);
215 calEventImpl.setFirstReminder(firstReminder);
216 calEventImpl.setSecondReminder(secondReminder);
217
218 calEventImpl.resetOriginalValues();
219
220 return calEventImpl;
221 }
222
223 @Override
224 public void readExternal(ObjectInput objectInput) throws IOException {
225 uuid = objectInput.readUTF();
226 eventId = objectInput.readLong();
227 groupId = objectInput.readLong();
228 companyId = objectInput.readLong();
229 userId = objectInput.readLong();
230 userName = objectInput.readUTF();
231 createDate = objectInput.readLong();
232 modifiedDate = objectInput.readLong();
233 title = objectInput.readUTF();
234 description = objectInput.readUTF();
235 location = objectInput.readUTF();
236 startDate = objectInput.readLong();
237 endDate = objectInput.readLong();
238 durationHour = objectInput.readInt();
239 durationMinute = objectInput.readInt();
240 allDay = objectInput.readBoolean();
241 timeZoneSensitive = objectInput.readBoolean();
242 type = objectInput.readUTF();
243 repeating = objectInput.readBoolean();
244 recurrence = objectInput.readUTF();
245 remindBy = objectInput.readInt();
246 firstReminder = objectInput.readInt();
247 secondReminder = objectInput.readInt();
248 }
249
250 @Override
251 public void writeExternal(ObjectOutput objectOutput)
252 throws IOException {
253 if (uuid == null) {
254 objectOutput.writeUTF(StringPool.BLANK);
255 }
256 else {
257 objectOutput.writeUTF(uuid);
258 }
259
260 objectOutput.writeLong(eventId);
261 objectOutput.writeLong(groupId);
262 objectOutput.writeLong(companyId);
263 objectOutput.writeLong(userId);
264
265 if (userName == null) {
266 objectOutput.writeUTF(StringPool.BLANK);
267 }
268 else {
269 objectOutput.writeUTF(userName);
270 }
271
272 objectOutput.writeLong(createDate);
273 objectOutput.writeLong(modifiedDate);
274
275 if (title == null) {
276 objectOutput.writeUTF(StringPool.BLANK);
277 }
278 else {
279 objectOutput.writeUTF(title);
280 }
281
282 if (description == null) {
283 objectOutput.writeUTF(StringPool.BLANK);
284 }
285 else {
286 objectOutput.writeUTF(description);
287 }
288
289 if (location == null) {
290 objectOutput.writeUTF(StringPool.BLANK);
291 }
292 else {
293 objectOutput.writeUTF(location);
294 }
295
296 objectOutput.writeLong(startDate);
297 objectOutput.writeLong(endDate);
298 objectOutput.writeInt(durationHour);
299 objectOutput.writeInt(durationMinute);
300 objectOutput.writeBoolean(allDay);
301 objectOutput.writeBoolean(timeZoneSensitive);
302
303 if (type == null) {
304 objectOutput.writeUTF(StringPool.BLANK);
305 }
306 else {
307 objectOutput.writeUTF(type);
308 }
309
310 objectOutput.writeBoolean(repeating);
311
312 if (recurrence == null) {
313 objectOutput.writeUTF(StringPool.BLANK);
314 }
315 else {
316 objectOutput.writeUTF(recurrence);
317 }
318
319 objectOutput.writeInt(remindBy);
320 objectOutput.writeInt(firstReminder);
321 objectOutput.writeInt(secondReminder);
322 }
323
324 public String uuid;
325 public long eventId;
326 public long groupId;
327 public long companyId;
328 public long userId;
329 public String userName;
330 public long createDate;
331 public long modifiedDate;
332 public String title;
333 public String description;
334 public String location;
335 public long startDate;
336 public long endDate;
337 public int durationHour;
338 public int durationMinute;
339 public boolean allDay;
340 public boolean timeZoneSensitive;
341 public String type;
342 public boolean repeating;
343 public String recurrence;
344 public int remindBy;
345 public int firstReminder;
346 public int secondReminder;
347 }