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