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