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.bean.AutoEscapeBeanHandler;
018    import com.liferay.portal.kernel.exception.SystemException;
019    import com.liferay.portal.kernel.json.JSON;
020    import com.liferay.portal.kernel.util.DateUtil;
021    import com.liferay.portal.kernel.util.GetterUtil;
022    import com.liferay.portal.kernel.util.ProxyUtil;
023    import com.liferay.portal.kernel.util.StringBundler;
024    import com.liferay.portal.kernel.util.StringPool;
025    import com.liferay.portal.model.CacheModel;
026    import com.liferay.portal.model.impl.BaseModelImpl;
027    import com.liferay.portal.service.ServiceContext;
028    import com.liferay.portal.util.PortalUtil;
029    
030    import com.liferay.portlet.calendar.model.CalEvent;
031    import com.liferay.portlet.calendar.model.CalEventModel;
032    import com.liferay.portlet.calendar.model.CalEventSoap;
033    import com.liferay.portlet.expando.model.ExpandoBridge;
034    import com.liferay.portlet.expando.util.ExpandoBridgeFactoryUtil;
035    
036    import java.io.Serializable;
037    
038    import java.sql.Types;
039    
040    import java.util.ArrayList;
041    import java.util.Date;
042    import java.util.HashMap;
043    import java.util.List;
044    import java.util.Map;
045    
046    /**
047     * The base model implementation for the CalEvent service. Represents a row in the "CalEvent" database table, with each column mapped to a property of this class.
048     *
049     * <p>
050     * This implementation and its corresponding interface {@link com.liferay.portlet.calendar.model.CalEventModel} exist only as a container for the default property accessors generated by ServiceBuilder. Helper methods and all application logic should be put in {@link CalEventImpl}.
051     * </p>
052     *
053     * @author Brian Wing Shun Chan
054     * @see CalEventImpl
055     * @see com.liferay.portlet.calendar.model.CalEvent
056     * @see com.liferay.portlet.calendar.model.CalEventModel
057     * @generated
058     */
059    @JSON(strict = true)
060    public class CalEventModelImpl extends BaseModelImpl<CalEvent>
061            implements CalEventModel {
062            /*
063             * NOTE FOR DEVELOPERS:
064             *
065             * Never modify or reference this class directly. All methods that expect a cal event model instance should use the {@link com.liferay.portlet.calendar.model.CalEvent} interface instead.
066             */
067            public static final String TABLE_NAME = "CalEvent";
068            public static final Object[][] TABLE_COLUMNS = {
069                            { "uuid_", Types.VARCHAR },
070                            { "eventId", Types.BIGINT },
071                            { "groupId", Types.BIGINT },
072                            { "companyId", Types.BIGINT },
073                            { "userId", Types.BIGINT },
074                            { "userName", Types.VARCHAR },
075                            { "createDate", Types.TIMESTAMP },
076                            { "modifiedDate", Types.TIMESTAMP },
077                            { "title", Types.VARCHAR },
078                            { "description", Types.VARCHAR },
079                            { "location", Types.VARCHAR },
080                            { "startDate", Types.TIMESTAMP },
081                            { "endDate", Types.TIMESTAMP },
082                            { "durationHour", Types.INTEGER },
083                            { "durationMinute", Types.INTEGER },
084                            { "allDay", Types.BOOLEAN },
085                            { "timeZoneSensitive", Types.BOOLEAN },
086                            { "type_", Types.VARCHAR },
087                            { "repeating", Types.BOOLEAN },
088                            { "recurrence", Types.CLOB },
089                            { "remindBy", Types.INTEGER },
090                            { "firstReminder", Types.INTEGER },
091                            { "secondReminder", Types.INTEGER }
092                    };
093            public static final String TABLE_SQL_CREATE = "create table CalEvent (uuid_ VARCHAR(75) null,eventId LONG not null primary key,groupId LONG,companyId LONG,userId LONG,userName VARCHAR(75) null,createDate DATE null,modifiedDate DATE null,title VARCHAR(75) null,description STRING null,location STRING null,startDate DATE null,endDate DATE null,durationHour INTEGER,durationMinute INTEGER,allDay BOOLEAN,timeZoneSensitive BOOLEAN,type_ VARCHAR(75) null,repeating BOOLEAN,recurrence TEXT null,remindBy INTEGER,firstReminder INTEGER,secondReminder INTEGER)";
094            public static final String TABLE_SQL_DROP = "drop table CalEvent";
095            public static final String ORDER_BY_JPQL = " ORDER BY calEvent.startDate ASC, calEvent.title ASC";
096            public static final String ORDER_BY_SQL = " ORDER BY CalEvent.startDate ASC, CalEvent.title ASC";
097            public static final String DATA_SOURCE = "liferayDataSource";
098            public static final String SESSION_FACTORY = "liferaySessionFactory";
099            public static final String TX_MANAGER = "liferayTransactionManager";
100            public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
101                                    "value.object.entity.cache.enabled.com.liferay.portlet.calendar.model.CalEvent"),
102                            true);
103            public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
104                                    "value.object.finder.cache.enabled.com.liferay.portlet.calendar.model.CalEvent"),
105                            true);
106            public static final boolean COLUMN_BITMASK_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
107                                    "value.object.column.bitmask.enabled.com.liferay.portlet.calendar.model.CalEvent"),
108                            true);
109            public static long COMPANYID_COLUMN_BITMASK = 1L;
110            public static long GROUPID_COLUMN_BITMASK = 2L;
111            public static long REMINDBY_COLUMN_BITMASK = 4L;
112            public static long REPEATING_COLUMN_BITMASK = 8L;
113            public static long TYPE_COLUMN_BITMASK = 16L;
114            public static long UUID_COLUMN_BITMASK = 32L;
115    
116            /**
117             * Converts the soap model instance into a normal model instance.
118             *
119             * @param soapModel the soap model instance to convert
120             * @return the normal model instance
121             */
122            public static CalEvent toModel(CalEventSoap soapModel) {
123                    if (soapModel == null) {
124                            return null;
125                    }
126    
127                    CalEvent model = new CalEventImpl();
128    
129                    model.setUuid(soapModel.getUuid());
130                    model.setEventId(soapModel.getEventId());
131                    model.setGroupId(soapModel.getGroupId());
132                    model.setCompanyId(soapModel.getCompanyId());
133                    model.setUserId(soapModel.getUserId());
134                    model.setUserName(soapModel.getUserName());
135                    model.setCreateDate(soapModel.getCreateDate());
136                    model.setModifiedDate(soapModel.getModifiedDate());
137                    model.setTitle(soapModel.getTitle());
138                    model.setDescription(soapModel.getDescription());
139                    model.setLocation(soapModel.getLocation());
140                    model.setStartDate(soapModel.getStartDate());
141                    model.setEndDate(soapModel.getEndDate());
142                    model.setDurationHour(soapModel.getDurationHour());
143                    model.setDurationMinute(soapModel.getDurationMinute());
144                    model.setAllDay(soapModel.getAllDay());
145                    model.setTimeZoneSensitive(soapModel.getTimeZoneSensitive());
146                    model.setType(soapModel.getType());
147                    model.setRepeating(soapModel.getRepeating());
148                    model.setRecurrence(soapModel.getRecurrence());
149                    model.setRemindBy(soapModel.getRemindBy());
150                    model.setFirstReminder(soapModel.getFirstReminder());
151                    model.setSecondReminder(soapModel.getSecondReminder());
152    
153                    return model;
154            }
155    
156            /**
157             * Converts the soap model instances into normal model instances.
158             *
159             * @param soapModels the soap model instances to convert
160             * @return the normal model instances
161             */
162            public static List<CalEvent> toModels(CalEventSoap[] soapModels) {
163                    if (soapModels == null) {
164                            return null;
165                    }
166    
167                    List<CalEvent> models = new ArrayList<CalEvent>(soapModels.length);
168    
169                    for (CalEventSoap soapModel : soapModels) {
170                            models.add(toModel(soapModel));
171                    }
172    
173                    return models;
174            }
175    
176            public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
177                                    "lock.expiration.time.com.liferay.portlet.calendar.model.CalEvent"));
178    
179            public CalEventModelImpl() {
180            }
181    
182            public long getPrimaryKey() {
183                    return _eventId;
184            }
185    
186            public void setPrimaryKey(long primaryKey) {
187                    setEventId(primaryKey);
188            }
189    
190            public Serializable getPrimaryKeyObj() {
191                    return new Long(_eventId);
192            }
193    
194            public void setPrimaryKeyObj(Serializable primaryKeyObj) {
195                    setPrimaryKey(((Long)primaryKeyObj).longValue());
196            }
197    
198            public Class<?> getModelClass() {
199                    return CalEvent.class;
200            }
201    
202            public String getModelClassName() {
203                    return CalEvent.class.getName();
204            }
205    
206            @Override
207            public Map<String, Object> getModelAttributes() {
208                    Map<String, Object> attributes = new HashMap<String, Object>();
209    
210                    attributes.put("uuid", getUuid());
211                    attributes.put("eventId", getEventId());
212                    attributes.put("groupId", getGroupId());
213                    attributes.put("companyId", getCompanyId());
214                    attributes.put("userId", getUserId());
215                    attributes.put("userName", getUserName());
216                    attributes.put("createDate", getCreateDate());
217                    attributes.put("modifiedDate", getModifiedDate());
218                    attributes.put("title", getTitle());
219                    attributes.put("description", getDescription());
220                    attributes.put("location", getLocation());
221                    attributes.put("startDate", getStartDate());
222                    attributes.put("endDate", getEndDate());
223                    attributes.put("durationHour", getDurationHour());
224                    attributes.put("durationMinute", getDurationMinute());
225                    attributes.put("allDay", getAllDay());
226                    attributes.put("timeZoneSensitive", getTimeZoneSensitive());
227                    attributes.put("type", getType());
228                    attributes.put("repeating", getRepeating());
229                    attributes.put("recurrence", getRecurrence());
230                    attributes.put("remindBy", getRemindBy());
231                    attributes.put("firstReminder", getFirstReminder());
232                    attributes.put("secondReminder", getSecondReminder());
233    
234                    return attributes;
235            }
236    
237            @Override
238            public void setModelAttributes(Map<String, Object> attributes) {
239                    String uuid = (String)attributes.get("uuid");
240    
241                    if (uuid != null) {
242                            setUuid(uuid);
243                    }
244    
245                    Long eventId = (Long)attributes.get("eventId");
246    
247                    if (eventId != null) {
248                            setEventId(eventId);
249                    }
250    
251                    Long groupId = (Long)attributes.get("groupId");
252    
253                    if (groupId != null) {
254                            setGroupId(groupId);
255                    }
256    
257                    Long companyId = (Long)attributes.get("companyId");
258    
259                    if (companyId != null) {
260                            setCompanyId(companyId);
261                    }
262    
263                    Long userId = (Long)attributes.get("userId");
264    
265                    if (userId != null) {
266                            setUserId(userId);
267                    }
268    
269                    String userName = (String)attributes.get("userName");
270    
271                    if (userName != null) {
272                            setUserName(userName);
273                    }
274    
275                    Date createDate = (Date)attributes.get("createDate");
276    
277                    if (createDate != null) {
278                            setCreateDate(createDate);
279                    }
280    
281                    Date modifiedDate = (Date)attributes.get("modifiedDate");
282    
283                    if (modifiedDate != null) {
284                            setModifiedDate(modifiedDate);
285                    }
286    
287                    String title = (String)attributes.get("title");
288    
289                    if (title != null) {
290                            setTitle(title);
291                    }
292    
293                    String description = (String)attributes.get("description");
294    
295                    if (description != null) {
296                            setDescription(description);
297                    }
298    
299                    String location = (String)attributes.get("location");
300    
301                    if (location != null) {
302                            setLocation(location);
303                    }
304    
305                    Date startDate = (Date)attributes.get("startDate");
306    
307                    if (startDate != null) {
308                            setStartDate(startDate);
309                    }
310    
311                    Date endDate = (Date)attributes.get("endDate");
312    
313                    if (endDate != null) {
314                            setEndDate(endDate);
315                    }
316    
317                    Integer durationHour = (Integer)attributes.get("durationHour");
318    
319                    if (durationHour != null) {
320                            setDurationHour(durationHour);
321                    }
322    
323                    Integer durationMinute = (Integer)attributes.get("durationMinute");
324    
325                    if (durationMinute != null) {
326                            setDurationMinute(durationMinute);
327                    }
328    
329                    Boolean allDay = (Boolean)attributes.get("allDay");
330    
331                    if (allDay != null) {
332                            setAllDay(allDay);
333                    }
334    
335                    Boolean timeZoneSensitive = (Boolean)attributes.get("timeZoneSensitive");
336    
337                    if (timeZoneSensitive != null) {
338                            setTimeZoneSensitive(timeZoneSensitive);
339                    }
340    
341                    String type = (String)attributes.get("type");
342    
343                    if (type != null) {
344                            setType(type);
345                    }
346    
347                    Boolean repeating = (Boolean)attributes.get("repeating");
348    
349                    if (repeating != null) {
350                            setRepeating(repeating);
351                    }
352    
353                    String recurrence = (String)attributes.get("recurrence");
354    
355                    if (recurrence != null) {
356                            setRecurrence(recurrence);
357                    }
358    
359                    Integer remindBy = (Integer)attributes.get("remindBy");
360    
361                    if (remindBy != null) {
362                            setRemindBy(remindBy);
363                    }
364    
365                    Integer firstReminder = (Integer)attributes.get("firstReminder");
366    
367                    if (firstReminder != null) {
368                            setFirstReminder(firstReminder);
369                    }
370    
371                    Integer secondReminder = (Integer)attributes.get("secondReminder");
372    
373                    if (secondReminder != null) {
374                            setSecondReminder(secondReminder);
375                    }
376            }
377    
378            @JSON
379            public String getUuid() {
380                    if (_uuid == null) {
381                            return StringPool.BLANK;
382                    }
383                    else {
384                            return _uuid;
385                    }
386            }
387    
388            public void setUuid(String uuid) {
389                    if (_originalUuid == null) {
390                            _originalUuid = _uuid;
391                    }
392    
393                    _uuid = uuid;
394            }
395    
396            public String getOriginalUuid() {
397                    return GetterUtil.getString(_originalUuid);
398            }
399    
400            @JSON
401            public long getEventId() {
402                    return _eventId;
403            }
404    
405            public void setEventId(long eventId) {
406                    _eventId = eventId;
407            }
408    
409            @JSON
410            public long getGroupId() {
411                    return _groupId;
412            }
413    
414            public void setGroupId(long groupId) {
415                    _columnBitmask |= GROUPID_COLUMN_BITMASK;
416    
417                    if (!_setOriginalGroupId) {
418                            _setOriginalGroupId = true;
419    
420                            _originalGroupId = _groupId;
421                    }
422    
423                    _groupId = groupId;
424            }
425    
426            public long getOriginalGroupId() {
427                    return _originalGroupId;
428            }
429    
430            @JSON
431            public long getCompanyId() {
432                    return _companyId;
433            }
434    
435            public void setCompanyId(long companyId) {
436                    _columnBitmask |= COMPANYID_COLUMN_BITMASK;
437    
438                    if (!_setOriginalCompanyId) {
439                            _setOriginalCompanyId = true;
440    
441                            _originalCompanyId = _companyId;
442                    }
443    
444                    _companyId = companyId;
445            }
446    
447            public long getOriginalCompanyId() {
448                    return _originalCompanyId;
449            }
450    
451            @JSON
452            public long getUserId() {
453                    return _userId;
454            }
455    
456            public void setUserId(long userId) {
457                    _userId = userId;
458            }
459    
460            public String getUserUuid() throws SystemException {
461                    return PortalUtil.getUserValue(getUserId(), "uuid", _userUuid);
462            }
463    
464            public void setUserUuid(String userUuid) {
465                    _userUuid = userUuid;
466            }
467    
468            @JSON
469            public String getUserName() {
470                    if (_userName == null) {
471                            return StringPool.BLANK;
472                    }
473                    else {
474                            return _userName;
475                    }
476            }
477    
478            public void setUserName(String userName) {
479                    _userName = userName;
480            }
481    
482            @JSON
483            public Date getCreateDate() {
484                    return _createDate;
485            }
486    
487            public void setCreateDate(Date createDate) {
488                    _createDate = createDate;
489            }
490    
491            @JSON
492            public Date getModifiedDate() {
493                    return _modifiedDate;
494            }
495    
496            public void setModifiedDate(Date modifiedDate) {
497                    _modifiedDate = modifiedDate;
498            }
499    
500            @JSON
501            public String getTitle() {
502                    if (_title == null) {
503                            return StringPool.BLANK;
504                    }
505                    else {
506                            return _title;
507                    }
508            }
509    
510            public void setTitle(String title) {
511                    _columnBitmask = -1L;
512    
513                    _title = title;
514            }
515    
516            @JSON
517            public String getDescription() {
518                    if (_description == null) {
519                            return StringPool.BLANK;
520                    }
521                    else {
522                            return _description;
523                    }
524            }
525    
526            public void setDescription(String description) {
527                    _description = description;
528            }
529    
530            @JSON
531            public String getLocation() {
532                    if (_location == null) {
533                            return StringPool.BLANK;
534                    }
535                    else {
536                            return _location;
537                    }
538            }
539    
540            public void setLocation(String location) {
541                    _location = location;
542            }
543    
544            @JSON
545            public Date getStartDate() {
546                    return _startDate;
547            }
548    
549            public void setStartDate(Date startDate) {
550                    _columnBitmask = -1L;
551    
552                    _startDate = startDate;
553            }
554    
555            @JSON
556            public Date getEndDate() {
557                    return _endDate;
558            }
559    
560            public void setEndDate(Date endDate) {
561                    _endDate = endDate;
562            }
563    
564            @JSON
565            public int getDurationHour() {
566                    return _durationHour;
567            }
568    
569            public void setDurationHour(int durationHour) {
570                    _durationHour = durationHour;
571            }
572    
573            @JSON
574            public int getDurationMinute() {
575                    return _durationMinute;
576            }
577    
578            public void setDurationMinute(int durationMinute) {
579                    _durationMinute = durationMinute;
580            }
581    
582            @JSON
583            public boolean getAllDay() {
584                    return _allDay;
585            }
586    
587            public boolean isAllDay() {
588                    return _allDay;
589            }
590    
591            public void setAllDay(boolean allDay) {
592                    _allDay = allDay;
593            }
594    
595            @JSON
596            public boolean getTimeZoneSensitive() {
597                    return _timeZoneSensitive;
598            }
599    
600            public boolean isTimeZoneSensitive() {
601                    return _timeZoneSensitive;
602            }
603    
604            public void setTimeZoneSensitive(boolean timeZoneSensitive) {
605                    _timeZoneSensitive = timeZoneSensitive;
606            }
607    
608            @JSON
609            public String getType() {
610                    if (_type == null) {
611                            return StringPool.BLANK;
612                    }
613                    else {
614                            return _type;
615                    }
616            }
617    
618            public void setType(String type) {
619                    _columnBitmask |= TYPE_COLUMN_BITMASK;
620    
621                    if (_originalType == null) {
622                            _originalType = _type;
623                    }
624    
625                    _type = type;
626            }
627    
628            public String getOriginalType() {
629                    return GetterUtil.getString(_originalType);
630            }
631    
632            @JSON
633            public boolean getRepeating() {
634                    return _repeating;
635            }
636    
637            public boolean isRepeating() {
638                    return _repeating;
639            }
640    
641            public void setRepeating(boolean repeating) {
642                    _columnBitmask |= REPEATING_COLUMN_BITMASK;
643    
644                    if (!_setOriginalRepeating) {
645                            _setOriginalRepeating = true;
646    
647                            _originalRepeating = _repeating;
648                    }
649    
650                    _repeating = repeating;
651            }
652    
653            public boolean getOriginalRepeating() {
654                    return _originalRepeating;
655            }
656    
657            @JSON
658            public String getRecurrence() {
659                    if (_recurrence == null) {
660                            return StringPool.BLANK;
661                    }
662                    else {
663                            return _recurrence;
664                    }
665            }
666    
667            public void setRecurrence(String recurrence) {
668                    _recurrence = recurrence;
669            }
670    
671            @JSON
672            public int getRemindBy() {
673                    return _remindBy;
674            }
675    
676            public void setRemindBy(int remindBy) {
677                    _columnBitmask |= REMINDBY_COLUMN_BITMASK;
678    
679                    if (!_setOriginalRemindBy) {
680                            _setOriginalRemindBy = true;
681    
682                            _originalRemindBy = _remindBy;
683                    }
684    
685                    _remindBy = remindBy;
686            }
687    
688            public int getOriginalRemindBy() {
689                    return _originalRemindBy;
690            }
691    
692            @JSON
693            public int getFirstReminder() {
694                    return _firstReminder;
695            }
696    
697            public void setFirstReminder(int firstReminder) {
698                    _firstReminder = firstReminder;
699            }
700    
701            @JSON
702            public int getSecondReminder() {
703                    return _secondReminder;
704            }
705    
706            public void setSecondReminder(int secondReminder) {
707                    _secondReminder = secondReminder;
708            }
709    
710            public long getColumnBitmask() {
711                    return _columnBitmask;
712            }
713    
714            @Override
715            public ExpandoBridge getExpandoBridge() {
716                    return ExpandoBridgeFactoryUtil.getExpandoBridge(getCompanyId(),
717                            CalEvent.class.getName(), getPrimaryKey());
718            }
719    
720            @Override
721            public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
722                    ExpandoBridge expandoBridge = getExpandoBridge();
723    
724                    expandoBridge.setAttributes(serviceContext);
725            }
726    
727            @Override
728            public CalEvent toEscapedModel() {
729                    if (_escapedModel == null) {
730                            _escapedModel = (CalEvent)ProxyUtil.newProxyInstance(_classLoader,
731                                            _escapedModelInterfaces, new AutoEscapeBeanHandler(this));
732                    }
733    
734                    return _escapedModel;
735            }
736    
737            public CalEvent toUnescapedModel() {
738                    return (CalEvent)this;
739            }
740    
741            @Override
742            public Object clone() {
743                    CalEventImpl calEventImpl = new CalEventImpl();
744    
745                    calEventImpl.setUuid(getUuid());
746                    calEventImpl.setEventId(getEventId());
747                    calEventImpl.setGroupId(getGroupId());
748                    calEventImpl.setCompanyId(getCompanyId());
749                    calEventImpl.setUserId(getUserId());
750                    calEventImpl.setUserName(getUserName());
751                    calEventImpl.setCreateDate(getCreateDate());
752                    calEventImpl.setModifiedDate(getModifiedDate());
753                    calEventImpl.setTitle(getTitle());
754                    calEventImpl.setDescription(getDescription());
755                    calEventImpl.setLocation(getLocation());
756                    calEventImpl.setStartDate(getStartDate());
757                    calEventImpl.setEndDate(getEndDate());
758                    calEventImpl.setDurationHour(getDurationHour());
759                    calEventImpl.setDurationMinute(getDurationMinute());
760                    calEventImpl.setAllDay(getAllDay());
761                    calEventImpl.setTimeZoneSensitive(getTimeZoneSensitive());
762                    calEventImpl.setType(getType());
763                    calEventImpl.setRepeating(getRepeating());
764                    calEventImpl.setRecurrence(getRecurrence());
765                    calEventImpl.setRemindBy(getRemindBy());
766                    calEventImpl.setFirstReminder(getFirstReminder());
767                    calEventImpl.setSecondReminder(getSecondReminder());
768    
769                    calEventImpl.resetOriginalValues();
770    
771                    return calEventImpl;
772            }
773    
774            public int compareTo(CalEvent calEvent) {
775                    int value = 0;
776    
777                    value = DateUtil.compareTo(getStartDate(), calEvent.getStartDate());
778    
779                    if (value != 0) {
780                            return value;
781                    }
782    
783                    value = getTitle().toLowerCase()
784                                            .compareTo(calEvent.getTitle().toLowerCase());
785    
786                    if (value != 0) {
787                            return value;
788                    }
789    
790                    return 0;
791            }
792    
793            @Override
794            public boolean equals(Object obj) {
795                    if (this == obj) {
796                            return true;
797                    }
798    
799                    if (!(obj instanceof CalEvent)) {
800                            return false;
801                    }
802    
803                    CalEvent calEvent = (CalEvent)obj;
804    
805                    long primaryKey = calEvent.getPrimaryKey();
806    
807                    if (getPrimaryKey() == primaryKey) {
808                            return true;
809                    }
810                    else {
811                            return false;
812                    }
813            }
814    
815            @Override
816            public int hashCode() {
817                    return (int)getPrimaryKey();
818            }
819    
820            @Override
821            public void resetOriginalValues() {
822                    CalEventModelImpl calEventModelImpl = this;
823    
824                    calEventModelImpl._originalUuid = calEventModelImpl._uuid;
825    
826                    calEventModelImpl._originalGroupId = calEventModelImpl._groupId;
827    
828                    calEventModelImpl._setOriginalGroupId = false;
829    
830                    calEventModelImpl._originalCompanyId = calEventModelImpl._companyId;
831    
832                    calEventModelImpl._setOriginalCompanyId = false;
833    
834                    calEventModelImpl._originalType = calEventModelImpl._type;
835    
836                    calEventModelImpl._originalRepeating = calEventModelImpl._repeating;
837    
838                    calEventModelImpl._setOriginalRepeating = false;
839    
840                    calEventModelImpl._originalRemindBy = calEventModelImpl._remindBy;
841    
842                    calEventModelImpl._setOriginalRemindBy = false;
843    
844                    calEventModelImpl._columnBitmask = 0;
845            }
846    
847            @Override
848            public CacheModel<CalEvent> toCacheModel() {
849                    CalEventCacheModel calEventCacheModel = new CalEventCacheModel();
850    
851                    calEventCacheModel.uuid = getUuid();
852    
853                    String uuid = calEventCacheModel.uuid;
854    
855                    if ((uuid != null) && (uuid.length() == 0)) {
856                            calEventCacheModel.uuid = null;
857                    }
858    
859                    calEventCacheModel.eventId = getEventId();
860    
861                    calEventCacheModel.groupId = getGroupId();
862    
863                    calEventCacheModel.companyId = getCompanyId();
864    
865                    calEventCacheModel.userId = getUserId();
866    
867                    calEventCacheModel.userName = getUserName();
868    
869                    String userName = calEventCacheModel.userName;
870    
871                    if ((userName != null) && (userName.length() == 0)) {
872                            calEventCacheModel.userName = null;
873                    }
874    
875                    Date createDate = getCreateDate();
876    
877                    if (createDate != null) {
878                            calEventCacheModel.createDate = createDate.getTime();
879                    }
880                    else {
881                            calEventCacheModel.createDate = Long.MIN_VALUE;
882                    }
883    
884                    Date modifiedDate = getModifiedDate();
885    
886                    if (modifiedDate != null) {
887                            calEventCacheModel.modifiedDate = modifiedDate.getTime();
888                    }
889                    else {
890                            calEventCacheModel.modifiedDate = Long.MIN_VALUE;
891                    }
892    
893                    calEventCacheModel.title = getTitle();
894    
895                    String title = calEventCacheModel.title;
896    
897                    if ((title != null) && (title.length() == 0)) {
898                            calEventCacheModel.title = null;
899                    }
900    
901                    calEventCacheModel.description = getDescription();
902    
903                    String description = calEventCacheModel.description;
904    
905                    if ((description != null) && (description.length() == 0)) {
906                            calEventCacheModel.description = null;
907                    }
908    
909                    calEventCacheModel.location = getLocation();
910    
911                    String location = calEventCacheModel.location;
912    
913                    if ((location != null) && (location.length() == 0)) {
914                            calEventCacheModel.location = null;
915                    }
916    
917                    Date startDate = getStartDate();
918    
919                    if (startDate != null) {
920                            calEventCacheModel.startDate = startDate.getTime();
921                    }
922                    else {
923                            calEventCacheModel.startDate = Long.MIN_VALUE;
924                    }
925    
926                    Date endDate = getEndDate();
927    
928                    if (endDate != null) {
929                            calEventCacheModel.endDate = endDate.getTime();
930                    }
931                    else {
932                            calEventCacheModel.endDate = Long.MIN_VALUE;
933                    }
934    
935                    calEventCacheModel.durationHour = getDurationHour();
936    
937                    calEventCacheModel.durationMinute = getDurationMinute();
938    
939                    calEventCacheModel.allDay = getAllDay();
940    
941                    calEventCacheModel.timeZoneSensitive = getTimeZoneSensitive();
942    
943                    calEventCacheModel.type = getType();
944    
945                    String type = calEventCacheModel.type;
946    
947                    if ((type != null) && (type.length() == 0)) {
948                            calEventCacheModel.type = null;
949                    }
950    
951                    calEventCacheModel.repeating = getRepeating();
952    
953                    calEventCacheModel.recurrence = getRecurrence();
954    
955                    String recurrence = calEventCacheModel.recurrence;
956    
957                    if ((recurrence != null) && (recurrence.length() == 0)) {
958                            calEventCacheModel.recurrence = null;
959                    }
960    
961                    calEventCacheModel.remindBy = getRemindBy();
962    
963                    calEventCacheModel.firstReminder = getFirstReminder();
964    
965                    calEventCacheModel.secondReminder = getSecondReminder();
966    
967                    return calEventCacheModel;
968            }
969    
970            @Override
971            public String toString() {
972                    StringBundler sb = new StringBundler(47);
973    
974                    sb.append("{uuid=");
975                    sb.append(getUuid());
976                    sb.append(", eventId=");
977                    sb.append(getEventId());
978                    sb.append(", groupId=");
979                    sb.append(getGroupId());
980                    sb.append(", companyId=");
981                    sb.append(getCompanyId());
982                    sb.append(", userId=");
983                    sb.append(getUserId());
984                    sb.append(", userName=");
985                    sb.append(getUserName());
986                    sb.append(", createDate=");
987                    sb.append(getCreateDate());
988                    sb.append(", modifiedDate=");
989                    sb.append(getModifiedDate());
990                    sb.append(", title=");
991                    sb.append(getTitle());
992                    sb.append(", description=");
993                    sb.append(getDescription());
994                    sb.append(", location=");
995                    sb.append(getLocation());
996                    sb.append(", startDate=");
997                    sb.append(getStartDate());
998                    sb.append(", endDate=");
999                    sb.append(getEndDate());
1000                    sb.append(", durationHour=");
1001                    sb.append(getDurationHour());
1002                    sb.append(", durationMinute=");
1003                    sb.append(getDurationMinute());
1004                    sb.append(", allDay=");
1005                    sb.append(getAllDay());
1006                    sb.append(", timeZoneSensitive=");
1007                    sb.append(getTimeZoneSensitive());
1008                    sb.append(", type=");
1009                    sb.append(getType());
1010                    sb.append(", repeating=");
1011                    sb.append(getRepeating());
1012                    sb.append(", recurrence=");
1013                    sb.append(getRecurrence());
1014                    sb.append(", remindBy=");
1015                    sb.append(getRemindBy());
1016                    sb.append(", firstReminder=");
1017                    sb.append(getFirstReminder());
1018                    sb.append(", secondReminder=");
1019                    sb.append(getSecondReminder());
1020                    sb.append("}");
1021    
1022                    return sb.toString();
1023            }
1024    
1025            public String toXmlString() {
1026                    StringBundler sb = new StringBundler(73);
1027    
1028                    sb.append("<model><model-name>");
1029                    sb.append("com.liferay.portlet.calendar.model.CalEvent");
1030                    sb.append("</model-name>");
1031    
1032                    sb.append(
1033                            "<column><column-name>uuid</column-name><column-value><![CDATA[");
1034                    sb.append(getUuid());
1035                    sb.append("]]></column-value></column>");
1036                    sb.append(
1037                            "<column><column-name>eventId</column-name><column-value><![CDATA[");
1038                    sb.append(getEventId());
1039                    sb.append("]]></column-value></column>");
1040                    sb.append(
1041                            "<column><column-name>groupId</column-name><column-value><![CDATA[");
1042                    sb.append(getGroupId());
1043                    sb.append("]]></column-value></column>");
1044                    sb.append(
1045                            "<column><column-name>companyId</column-name><column-value><![CDATA[");
1046                    sb.append(getCompanyId());
1047                    sb.append("]]></column-value></column>");
1048                    sb.append(
1049                            "<column><column-name>userId</column-name><column-value><![CDATA[");
1050                    sb.append(getUserId());
1051                    sb.append("]]></column-value></column>");
1052                    sb.append(
1053                            "<column><column-name>userName</column-name><column-value><![CDATA[");
1054                    sb.append(getUserName());
1055                    sb.append("]]></column-value></column>");
1056                    sb.append(
1057                            "<column><column-name>createDate</column-name><column-value><![CDATA[");
1058                    sb.append(getCreateDate());
1059                    sb.append("]]></column-value></column>");
1060                    sb.append(
1061                            "<column><column-name>modifiedDate</column-name><column-value><![CDATA[");
1062                    sb.append(getModifiedDate());
1063                    sb.append("]]></column-value></column>");
1064                    sb.append(
1065                            "<column><column-name>title</column-name><column-value><![CDATA[");
1066                    sb.append(getTitle());
1067                    sb.append("]]></column-value></column>");
1068                    sb.append(
1069                            "<column><column-name>description</column-name><column-value><![CDATA[");
1070                    sb.append(getDescription());
1071                    sb.append("]]></column-value></column>");
1072                    sb.append(
1073                            "<column><column-name>location</column-name><column-value><![CDATA[");
1074                    sb.append(getLocation());
1075                    sb.append("]]></column-value></column>");
1076                    sb.append(
1077                            "<column><column-name>startDate</column-name><column-value><![CDATA[");
1078                    sb.append(getStartDate());
1079                    sb.append("]]></column-value></column>");
1080                    sb.append(
1081                            "<column><column-name>endDate</column-name><column-value><![CDATA[");
1082                    sb.append(getEndDate());
1083                    sb.append("]]></column-value></column>");
1084                    sb.append(
1085                            "<column><column-name>durationHour</column-name><column-value><![CDATA[");
1086                    sb.append(getDurationHour());
1087                    sb.append("]]></column-value></column>");
1088                    sb.append(
1089                            "<column><column-name>durationMinute</column-name><column-value><![CDATA[");
1090                    sb.append(getDurationMinute());
1091                    sb.append("]]></column-value></column>");
1092                    sb.append(
1093                            "<column><column-name>allDay</column-name><column-value><![CDATA[");
1094                    sb.append(getAllDay());
1095                    sb.append("]]></column-value></column>");
1096                    sb.append(
1097                            "<column><column-name>timeZoneSensitive</column-name><column-value><![CDATA[");
1098                    sb.append(getTimeZoneSensitive());
1099                    sb.append("]]></column-value></column>");
1100                    sb.append(
1101                            "<column><column-name>type</column-name><column-value><![CDATA[");
1102                    sb.append(getType());
1103                    sb.append("]]></column-value></column>");
1104                    sb.append(
1105                            "<column><column-name>repeating</column-name><column-value><![CDATA[");
1106                    sb.append(getRepeating());
1107                    sb.append("]]></column-value></column>");
1108                    sb.append(
1109                            "<column><column-name>recurrence</column-name><column-value><![CDATA[");
1110                    sb.append(getRecurrence());
1111                    sb.append("]]></column-value></column>");
1112                    sb.append(
1113                            "<column><column-name>remindBy</column-name><column-value><![CDATA[");
1114                    sb.append(getRemindBy());
1115                    sb.append("]]></column-value></column>");
1116                    sb.append(
1117                            "<column><column-name>firstReminder</column-name><column-value><![CDATA[");
1118                    sb.append(getFirstReminder());
1119                    sb.append("]]></column-value></column>");
1120                    sb.append(
1121                            "<column><column-name>secondReminder</column-name><column-value><![CDATA[");
1122                    sb.append(getSecondReminder());
1123                    sb.append("]]></column-value></column>");
1124    
1125                    sb.append("</model>");
1126    
1127                    return sb.toString();
1128            }
1129    
1130            private static ClassLoader _classLoader = CalEvent.class.getClassLoader();
1131            private static Class<?>[] _escapedModelInterfaces = new Class[] {
1132                            CalEvent.class
1133                    };
1134            private String _uuid;
1135            private String _originalUuid;
1136            private long _eventId;
1137            private long _groupId;
1138            private long _originalGroupId;
1139            private boolean _setOriginalGroupId;
1140            private long _companyId;
1141            private long _originalCompanyId;
1142            private boolean _setOriginalCompanyId;
1143            private long _userId;
1144            private String _userUuid;
1145            private String _userName;
1146            private Date _createDate;
1147            private Date _modifiedDate;
1148            private String _title;
1149            private String _description;
1150            private String _location;
1151            private Date _startDate;
1152            private Date _endDate;
1153            private int _durationHour;
1154            private int _durationMinute;
1155            private boolean _allDay;
1156            private boolean _timeZoneSensitive;
1157            private String _type;
1158            private String _originalType;
1159            private boolean _repeating;
1160            private boolean _originalRepeating;
1161            private boolean _setOriginalRepeating;
1162            private String _recurrence;
1163            private int _remindBy;
1164            private int _originalRemindBy;
1165            private boolean _setOriginalRemindBy;
1166            private int _firstReminder;
1167            private int _secondReminder;
1168            private long _columnBitmask;
1169            private CalEvent _escapedModel;
1170    }