001    /**
002     * Copyright (c) 2000-2013 Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
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    /**
031     * The cache model class for representing CalEvent in entity cache.
032     *
033     * @author Brian Wing Shun Chan
034     * @see CalEvent
035     * @generated
036     */
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            @Override
094            public CalEvent toEntityModel() {
095                    CalEventImpl calEventImpl = new CalEventImpl();
096    
097                    if (uuid == null) {
098                            calEventImpl.setUuid(StringPool.BLANK);
099                    }
100                    else {
101                            calEventImpl.setUuid(uuid);
102                    }
103    
104                    calEventImpl.setEventId(eventId);
105                    calEventImpl.setGroupId(groupId);
106                    calEventImpl.setCompanyId(companyId);
107                    calEventImpl.setUserId(userId);
108    
109                    if (userName == null) {
110                            calEventImpl.setUserName(StringPool.BLANK);
111                    }
112                    else {
113                            calEventImpl.setUserName(userName);
114                    }
115    
116                    if (createDate == Long.MIN_VALUE) {
117                            calEventImpl.setCreateDate(null);
118                    }
119                    else {
120                            calEventImpl.setCreateDate(new Date(createDate));
121                    }
122    
123                    if (modifiedDate == Long.MIN_VALUE) {
124                            calEventImpl.setModifiedDate(null);
125                    }
126                    else {
127                            calEventImpl.setModifiedDate(new Date(modifiedDate));
128                    }
129    
130                    if (title == null) {
131                            calEventImpl.setTitle(StringPool.BLANK);
132                    }
133                    else {
134                            calEventImpl.setTitle(title);
135                    }
136    
137                    if (description == null) {
138                            calEventImpl.setDescription(StringPool.BLANK);
139                    }
140                    else {
141                            calEventImpl.setDescription(description);
142                    }
143    
144                    if (location == null) {
145                            calEventImpl.setLocation(StringPool.BLANK);
146                    }
147                    else {
148                            calEventImpl.setLocation(location);
149                    }
150    
151                    if (startDate == Long.MIN_VALUE) {
152                            calEventImpl.setStartDate(null);
153                    }
154                    else {
155                            calEventImpl.setStartDate(new Date(startDate));
156                    }
157    
158                    if (endDate == Long.MIN_VALUE) {
159                            calEventImpl.setEndDate(null);
160                    }
161                    else {
162                            calEventImpl.setEndDate(new Date(endDate));
163                    }
164    
165                    calEventImpl.setDurationHour(durationHour);
166                    calEventImpl.setDurationMinute(durationMinute);
167                    calEventImpl.setAllDay(allDay);
168                    calEventImpl.setTimeZoneSensitive(timeZoneSensitive);
169    
170                    if (type == null) {
171                            calEventImpl.setType(StringPool.BLANK);
172                    }
173                    else {
174                            calEventImpl.setType(type);
175                    }
176    
177                    calEventImpl.setRepeating(repeating);
178    
179                    if (recurrence == null) {
180                            calEventImpl.setRecurrence(StringPool.BLANK);
181                    }
182                    else {
183                            calEventImpl.setRecurrence(recurrence);
184                    }
185    
186                    calEventImpl.setRemindBy(remindBy);
187                    calEventImpl.setFirstReminder(firstReminder);
188                    calEventImpl.setSecondReminder(secondReminder);
189    
190                    calEventImpl.resetOriginalValues();
191    
192                    return calEventImpl;
193            }
194    
195            @Override
196            public void readExternal(ObjectInput objectInput) throws IOException {
197                    uuid = objectInput.readUTF();
198                    eventId = objectInput.readLong();
199                    groupId = objectInput.readLong();
200                    companyId = objectInput.readLong();
201                    userId = objectInput.readLong();
202                    userName = objectInput.readUTF();
203                    createDate = objectInput.readLong();
204                    modifiedDate = objectInput.readLong();
205                    title = objectInput.readUTF();
206                    description = objectInput.readUTF();
207                    location = objectInput.readUTF();
208                    startDate = objectInput.readLong();
209                    endDate = objectInput.readLong();
210                    durationHour = objectInput.readInt();
211                    durationMinute = objectInput.readInt();
212                    allDay = objectInput.readBoolean();
213                    timeZoneSensitive = objectInput.readBoolean();
214                    type = objectInput.readUTF();
215                    repeating = objectInput.readBoolean();
216                    recurrence = objectInput.readUTF();
217                    remindBy = objectInput.readInt();
218                    firstReminder = objectInput.readInt();
219                    secondReminder = objectInput.readInt();
220            }
221    
222            @Override
223            public void writeExternal(ObjectOutput objectOutput)
224                    throws IOException {
225                    if (uuid == null) {
226                            objectOutput.writeUTF(StringPool.BLANK);
227                    }
228                    else {
229                            objectOutput.writeUTF(uuid);
230                    }
231    
232                    objectOutput.writeLong(eventId);
233                    objectOutput.writeLong(groupId);
234                    objectOutput.writeLong(companyId);
235                    objectOutput.writeLong(userId);
236    
237                    if (userName == null) {
238                            objectOutput.writeUTF(StringPool.BLANK);
239                    }
240                    else {
241                            objectOutput.writeUTF(userName);
242                    }
243    
244                    objectOutput.writeLong(createDate);
245                    objectOutput.writeLong(modifiedDate);
246    
247                    if (title == null) {
248                            objectOutput.writeUTF(StringPool.BLANK);
249                    }
250                    else {
251                            objectOutput.writeUTF(title);
252                    }
253    
254                    if (description == null) {
255                            objectOutput.writeUTF(StringPool.BLANK);
256                    }
257                    else {
258                            objectOutput.writeUTF(description);
259                    }
260    
261                    if (location == null) {
262                            objectOutput.writeUTF(StringPool.BLANK);
263                    }
264                    else {
265                            objectOutput.writeUTF(location);
266                    }
267    
268                    objectOutput.writeLong(startDate);
269                    objectOutput.writeLong(endDate);
270                    objectOutput.writeInt(durationHour);
271                    objectOutput.writeInt(durationMinute);
272                    objectOutput.writeBoolean(allDay);
273                    objectOutput.writeBoolean(timeZoneSensitive);
274    
275                    if (type == null) {
276                            objectOutput.writeUTF(StringPool.BLANK);
277                    }
278                    else {
279                            objectOutput.writeUTF(type);
280                    }
281    
282                    objectOutput.writeBoolean(repeating);
283    
284                    if (recurrence == null) {
285                            objectOutput.writeUTF(StringPool.BLANK);
286                    }
287                    else {
288                            objectOutput.writeUTF(recurrence);
289                    }
290    
291                    objectOutput.writeInt(remindBy);
292                    objectOutput.writeInt(firstReminder);
293                    objectOutput.writeInt(secondReminder);
294            }
295    
296            public String uuid;
297            public long eventId;
298            public long groupId;
299            public long companyId;
300            public long userId;
301            public String userName;
302            public long createDate;
303            public long modifiedDate;
304            public String title;
305            public String description;
306            public String location;
307            public long startDate;
308            public long endDate;
309            public int durationHour;
310            public int durationMinute;
311            public boolean allDay;
312            public boolean timeZoneSensitive;
313            public String type;
314            public boolean repeating;
315            public String recurrence;
316            public int remindBy;
317            public int firstReminder;
318            public int secondReminder;
319    }