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