001    /**
002     * Copyright (c) 2000-2010 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.util.DateUtil;
020    import com.liferay.portal.kernel.util.GetterUtil;
021    import com.liferay.portal.kernel.util.StringBundler;
022    import com.liferay.portal.kernel.util.StringPool;
023    import com.liferay.portal.model.impl.BaseModelImpl;
024    import com.liferay.portal.service.ServiceContext;
025    import com.liferay.portal.util.PortalUtil;
026    
027    import com.liferay.portlet.calendar.model.CalEvent;
028    import com.liferay.portlet.calendar.model.CalEventModel;
029    import com.liferay.portlet.calendar.model.CalEventSoap;
030    import com.liferay.portlet.expando.model.ExpandoBridge;
031    import com.liferay.portlet.expando.util.ExpandoBridgeFactoryUtil;
032    
033    import java.io.Serializable;
034    
035    import java.lang.reflect.Proxy;
036    
037    import java.sql.Types;
038    
039    import java.util.ArrayList;
040    import java.util.Date;
041    import java.util.List;
042    
043    /**
044     * <p>
045     * This interface is a model that represents the CalEvent table in the
046     * database.
047     * </p>
048     *
049     * @author    Brian Wing Shun Chan
050     * @see       CalEventImpl
051     * @see       com.liferay.portlet.calendar.model.CalEvent
052     * @see       com.liferay.portlet.calendar.model.CalEventModel
053     * @generated
054     */
055    public class CalEventModelImpl extends BaseModelImpl<CalEvent>
056            implements CalEventModel {
057            public static final String TABLE_NAME = "CalEvent";
058            public static final Object[][] TABLE_COLUMNS = {
059                            { "uuid_", new Integer(Types.VARCHAR) },
060                            { "eventId", new Integer(Types.BIGINT) },
061                            { "groupId", new Integer(Types.BIGINT) },
062                            { "companyId", new Integer(Types.BIGINT) },
063                            { "userId", new Integer(Types.BIGINT) },
064                            { "userName", new Integer(Types.VARCHAR) },
065                            { "createDate", new Integer(Types.TIMESTAMP) },
066                            { "modifiedDate", new Integer(Types.TIMESTAMP) },
067                            { "title", new Integer(Types.VARCHAR) },
068                            { "description", new Integer(Types.VARCHAR) },
069                            { "startDate", new Integer(Types.TIMESTAMP) },
070                            { "endDate", new Integer(Types.TIMESTAMP) },
071                            { "durationHour", new Integer(Types.INTEGER) },
072                            { "durationMinute", new Integer(Types.INTEGER) },
073                            { "allDay", new Integer(Types.BOOLEAN) },
074                            { "timeZoneSensitive", new Integer(Types.BOOLEAN) },
075                            { "type_", new Integer(Types.VARCHAR) },
076                            { "repeating", new Integer(Types.BOOLEAN) },
077                            { "recurrence", new Integer(Types.CLOB) },
078                            { "remindBy", new Integer(Types.INTEGER) },
079                            { "firstReminder", new Integer(Types.INTEGER) },
080                            { "secondReminder", new Integer(Types.INTEGER) }
081                    };
082            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,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)";
083            public static final String TABLE_SQL_DROP = "drop table CalEvent";
084            public static final String ORDER_BY_JPQL = " ORDER BY calEvent.startDate ASC, calEvent.title ASC";
085            public static final String ORDER_BY_SQL = " ORDER BY CalEvent.startDate ASC, CalEvent.title ASC";
086            public static final String DATA_SOURCE = "liferayDataSource";
087            public static final String SESSION_FACTORY = "liferaySessionFactory";
088            public static final String TX_MANAGER = "liferayTransactionManager";
089            public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
090                                    "value.object.entity.cache.enabled.com.liferay.portlet.calendar.model.CalEvent"),
091                            true);
092            public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
093                                    "value.object.finder.cache.enabled.com.liferay.portlet.calendar.model.CalEvent"),
094                            true);
095    
096            public static CalEvent toModel(CalEventSoap soapModel) {
097                    CalEvent model = new CalEventImpl();
098    
099                    model.setUuid(soapModel.getUuid());
100                    model.setEventId(soapModel.getEventId());
101                    model.setGroupId(soapModel.getGroupId());
102                    model.setCompanyId(soapModel.getCompanyId());
103                    model.setUserId(soapModel.getUserId());
104                    model.setUserName(soapModel.getUserName());
105                    model.setCreateDate(soapModel.getCreateDate());
106                    model.setModifiedDate(soapModel.getModifiedDate());
107                    model.setTitle(soapModel.getTitle());
108                    model.setDescription(soapModel.getDescription());
109                    model.setStartDate(soapModel.getStartDate());
110                    model.setEndDate(soapModel.getEndDate());
111                    model.setDurationHour(soapModel.getDurationHour());
112                    model.setDurationMinute(soapModel.getDurationMinute());
113                    model.setAllDay(soapModel.getAllDay());
114                    model.setTimeZoneSensitive(soapModel.getTimeZoneSensitive());
115                    model.setType(soapModel.getType());
116                    model.setRepeating(soapModel.getRepeating());
117                    model.setRecurrence(soapModel.getRecurrence());
118                    model.setRemindBy(soapModel.getRemindBy());
119                    model.setFirstReminder(soapModel.getFirstReminder());
120                    model.setSecondReminder(soapModel.getSecondReminder());
121    
122                    return model;
123            }
124    
125            public static List<CalEvent> toModels(CalEventSoap[] soapModels) {
126                    List<CalEvent> models = new ArrayList<CalEvent>(soapModels.length);
127    
128                    for (CalEventSoap soapModel : soapModels) {
129                            models.add(toModel(soapModel));
130                    }
131    
132                    return models;
133            }
134    
135            public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
136                                    "lock.expiration.time.com.liferay.portlet.calendar.model.CalEvent"));
137    
138            public CalEventModelImpl() {
139            }
140    
141            public long getPrimaryKey() {
142                    return _eventId;
143            }
144    
145            public void setPrimaryKey(long pk) {
146                    setEventId(pk);
147            }
148    
149            public Serializable getPrimaryKeyObj() {
150                    return new Long(_eventId);
151            }
152    
153            public String getUuid() {
154                    if (_uuid == null) {
155                            return StringPool.BLANK;
156                    }
157                    else {
158                            return _uuid;
159                    }
160            }
161    
162            public void setUuid(String uuid) {
163                    _uuid = uuid;
164    
165                    if (_originalUuid == null) {
166                            _originalUuid = uuid;
167                    }
168            }
169    
170            public String getOriginalUuid() {
171                    return GetterUtil.getString(_originalUuid);
172            }
173    
174            public long getEventId() {
175                    return _eventId;
176            }
177    
178            public void setEventId(long eventId) {
179                    _eventId = eventId;
180            }
181    
182            public long getGroupId() {
183                    return _groupId;
184            }
185    
186            public void setGroupId(long groupId) {
187                    _groupId = groupId;
188    
189                    if (!_setOriginalGroupId) {
190                            _setOriginalGroupId = true;
191    
192                            _originalGroupId = groupId;
193                    }
194            }
195    
196            public long getOriginalGroupId() {
197                    return _originalGroupId;
198            }
199    
200            public long getCompanyId() {
201                    return _companyId;
202            }
203    
204            public void setCompanyId(long companyId) {
205                    _companyId = companyId;
206            }
207    
208            public long getUserId() {
209                    return _userId;
210            }
211    
212            public void setUserId(long userId) {
213                    _userId = userId;
214            }
215    
216            public String getUserUuid() throws SystemException {
217                    return PortalUtil.getUserValue(getUserId(), "uuid", _userUuid);
218            }
219    
220            public void setUserUuid(String userUuid) {
221                    _userUuid = userUuid;
222            }
223    
224            public String getUserName() {
225                    if (_userName == null) {
226                            return StringPool.BLANK;
227                    }
228                    else {
229                            return _userName;
230                    }
231            }
232    
233            public void setUserName(String userName) {
234                    _userName = userName;
235            }
236    
237            public Date getCreateDate() {
238                    return _createDate;
239            }
240    
241            public void setCreateDate(Date createDate) {
242                    _createDate = createDate;
243            }
244    
245            public Date getModifiedDate() {
246                    return _modifiedDate;
247            }
248    
249            public void setModifiedDate(Date modifiedDate) {
250                    _modifiedDate = modifiedDate;
251            }
252    
253            public String getTitle() {
254                    if (_title == null) {
255                            return StringPool.BLANK;
256                    }
257                    else {
258                            return _title;
259                    }
260            }
261    
262            public void setTitle(String title) {
263                    _title = title;
264            }
265    
266            public String getDescription() {
267                    if (_description == null) {
268                            return StringPool.BLANK;
269                    }
270                    else {
271                            return _description;
272                    }
273            }
274    
275            public void setDescription(String description) {
276                    _description = description;
277            }
278    
279            public Date getStartDate() {
280                    return _startDate;
281            }
282    
283            public void setStartDate(Date startDate) {
284                    _startDate = startDate;
285            }
286    
287            public Date getEndDate() {
288                    return _endDate;
289            }
290    
291            public void setEndDate(Date endDate) {
292                    _endDate = endDate;
293            }
294    
295            public int getDurationHour() {
296                    return _durationHour;
297            }
298    
299            public void setDurationHour(int durationHour) {
300                    _durationHour = durationHour;
301            }
302    
303            public int getDurationMinute() {
304                    return _durationMinute;
305            }
306    
307            public void setDurationMinute(int durationMinute) {
308                    _durationMinute = durationMinute;
309            }
310    
311            public boolean getAllDay() {
312                    return _allDay;
313            }
314    
315            public boolean isAllDay() {
316                    return _allDay;
317            }
318    
319            public void setAllDay(boolean allDay) {
320                    _allDay = allDay;
321            }
322    
323            public boolean getTimeZoneSensitive() {
324                    return _timeZoneSensitive;
325            }
326    
327            public boolean isTimeZoneSensitive() {
328                    return _timeZoneSensitive;
329            }
330    
331            public void setTimeZoneSensitive(boolean timeZoneSensitive) {
332                    _timeZoneSensitive = timeZoneSensitive;
333            }
334    
335            public String getType() {
336                    if (_type == null) {
337                            return StringPool.BLANK;
338                    }
339                    else {
340                            return _type;
341                    }
342            }
343    
344            public void setType(String type) {
345                    _type = type;
346            }
347    
348            public boolean getRepeating() {
349                    return _repeating;
350            }
351    
352            public boolean isRepeating() {
353                    return _repeating;
354            }
355    
356            public void setRepeating(boolean repeating) {
357                    _repeating = repeating;
358            }
359    
360            public String getRecurrence() {
361                    if (_recurrence == null) {
362                            return StringPool.BLANK;
363                    }
364                    else {
365                            return _recurrence;
366                    }
367            }
368    
369            public void setRecurrence(String recurrence) {
370                    _recurrence = recurrence;
371            }
372    
373            public int getRemindBy() {
374                    return _remindBy;
375            }
376    
377            public void setRemindBy(int remindBy) {
378                    _remindBy = remindBy;
379            }
380    
381            public int getFirstReminder() {
382                    return _firstReminder;
383            }
384    
385            public void setFirstReminder(int firstReminder) {
386                    _firstReminder = firstReminder;
387            }
388    
389            public int getSecondReminder() {
390                    return _secondReminder;
391            }
392    
393            public void setSecondReminder(int secondReminder) {
394                    _secondReminder = secondReminder;
395            }
396    
397            public CalEvent toEscapedModel() {
398                    if (isEscapedModel()) {
399                            return (CalEvent)this;
400                    }
401                    else {
402                            return (CalEvent)Proxy.newProxyInstance(CalEvent.class.getClassLoader(),
403                                    new Class[] { CalEvent.class }, new AutoEscapeBeanHandler(this));
404                    }
405            }
406    
407            public ExpandoBridge getExpandoBridge() {
408                    if (_expandoBridge == null) {
409                            _expandoBridge = ExpandoBridgeFactoryUtil.getExpandoBridge(getCompanyId(),
410                                            CalEvent.class.getName(), getPrimaryKey());
411                    }
412    
413                    return _expandoBridge;
414            }
415    
416            public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
417                    getExpandoBridge().setAttributes(serviceContext);
418            }
419    
420            public Object clone() {
421                    CalEventImpl clone = new CalEventImpl();
422    
423                    clone.setUuid(getUuid());
424                    clone.setEventId(getEventId());
425                    clone.setGroupId(getGroupId());
426                    clone.setCompanyId(getCompanyId());
427                    clone.setUserId(getUserId());
428                    clone.setUserName(getUserName());
429                    clone.setCreateDate(getCreateDate());
430                    clone.setModifiedDate(getModifiedDate());
431                    clone.setTitle(getTitle());
432                    clone.setDescription(getDescription());
433                    clone.setStartDate(getStartDate());
434                    clone.setEndDate(getEndDate());
435                    clone.setDurationHour(getDurationHour());
436                    clone.setDurationMinute(getDurationMinute());
437                    clone.setAllDay(getAllDay());
438                    clone.setTimeZoneSensitive(getTimeZoneSensitive());
439                    clone.setType(getType());
440                    clone.setRepeating(getRepeating());
441                    clone.setRecurrence(getRecurrence());
442                    clone.setRemindBy(getRemindBy());
443                    clone.setFirstReminder(getFirstReminder());
444                    clone.setSecondReminder(getSecondReminder());
445    
446                    return clone;
447            }
448    
449            public int compareTo(CalEvent calEvent) {
450                    int value = 0;
451    
452                    value = DateUtil.compareTo(getStartDate(), calEvent.getStartDate());
453    
454                    if (value != 0) {
455                            return value;
456                    }
457    
458                    value = getTitle().toLowerCase()
459                                            .compareTo(calEvent.getTitle().toLowerCase());
460    
461                    if (value != 0) {
462                            return value;
463                    }
464    
465                    return 0;
466            }
467    
468            public boolean equals(Object obj) {
469                    if (obj == null) {
470                            return false;
471                    }
472    
473                    CalEvent calEvent = null;
474    
475                    try {
476                            calEvent = (CalEvent)obj;
477                    }
478                    catch (ClassCastException cce) {
479                            return false;
480                    }
481    
482                    long pk = calEvent.getPrimaryKey();
483    
484                    if (getPrimaryKey() == pk) {
485                            return true;
486                    }
487                    else {
488                            return false;
489                    }
490            }
491    
492            public int hashCode() {
493                    return (int)getPrimaryKey();
494            }
495    
496            public String toString() {
497                    StringBundler sb = new StringBundler(45);
498    
499                    sb.append("{uuid=");
500                    sb.append(getUuid());
501                    sb.append(", eventId=");
502                    sb.append(getEventId());
503                    sb.append(", groupId=");
504                    sb.append(getGroupId());
505                    sb.append(", companyId=");
506                    sb.append(getCompanyId());
507                    sb.append(", userId=");
508                    sb.append(getUserId());
509                    sb.append(", userName=");
510                    sb.append(getUserName());
511                    sb.append(", createDate=");
512                    sb.append(getCreateDate());
513                    sb.append(", modifiedDate=");
514                    sb.append(getModifiedDate());
515                    sb.append(", title=");
516                    sb.append(getTitle());
517                    sb.append(", description=");
518                    sb.append(getDescription());
519                    sb.append(", startDate=");
520                    sb.append(getStartDate());
521                    sb.append(", endDate=");
522                    sb.append(getEndDate());
523                    sb.append(", durationHour=");
524                    sb.append(getDurationHour());
525                    sb.append(", durationMinute=");
526                    sb.append(getDurationMinute());
527                    sb.append(", allDay=");
528                    sb.append(getAllDay());
529                    sb.append(", timeZoneSensitive=");
530                    sb.append(getTimeZoneSensitive());
531                    sb.append(", type=");
532                    sb.append(getType());
533                    sb.append(", repeating=");
534                    sb.append(getRepeating());
535                    sb.append(", recurrence=");
536                    sb.append(getRecurrence());
537                    sb.append(", remindBy=");
538                    sb.append(getRemindBy());
539                    sb.append(", firstReminder=");
540                    sb.append(getFirstReminder());
541                    sb.append(", secondReminder=");
542                    sb.append(getSecondReminder());
543                    sb.append("}");
544    
545                    return sb.toString();
546            }
547    
548            public String toXmlString() {
549                    StringBundler sb = new StringBundler(70);
550    
551                    sb.append("<model><model-name>");
552                    sb.append("com.liferay.portlet.calendar.model.CalEvent");
553                    sb.append("</model-name>");
554    
555                    sb.append(
556                            "<column><column-name>uuid</column-name><column-value><![CDATA[");
557                    sb.append(getUuid());
558                    sb.append("]]></column-value></column>");
559                    sb.append(
560                            "<column><column-name>eventId</column-name><column-value><![CDATA[");
561                    sb.append(getEventId());
562                    sb.append("]]></column-value></column>");
563                    sb.append(
564                            "<column><column-name>groupId</column-name><column-value><![CDATA[");
565                    sb.append(getGroupId());
566                    sb.append("]]></column-value></column>");
567                    sb.append(
568                            "<column><column-name>companyId</column-name><column-value><![CDATA[");
569                    sb.append(getCompanyId());
570                    sb.append("]]></column-value></column>");
571                    sb.append(
572                            "<column><column-name>userId</column-name><column-value><![CDATA[");
573                    sb.append(getUserId());
574                    sb.append("]]></column-value></column>");
575                    sb.append(
576                            "<column><column-name>userName</column-name><column-value><![CDATA[");
577                    sb.append(getUserName());
578                    sb.append("]]></column-value></column>");
579                    sb.append(
580                            "<column><column-name>createDate</column-name><column-value><![CDATA[");
581                    sb.append(getCreateDate());
582                    sb.append("]]></column-value></column>");
583                    sb.append(
584                            "<column><column-name>modifiedDate</column-name><column-value><![CDATA[");
585                    sb.append(getModifiedDate());
586                    sb.append("]]></column-value></column>");
587                    sb.append(
588                            "<column><column-name>title</column-name><column-value><![CDATA[");
589                    sb.append(getTitle());
590                    sb.append("]]></column-value></column>");
591                    sb.append(
592                            "<column><column-name>description</column-name><column-value><![CDATA[");
593                    sb.append(getDescription());
594                    sb.append("]]></column-value></column>");
595                    sb.append(
596                            "<column><column-name>startDate</column-name><column-value><![CDATA[");
597                    sb.append(getStartDate());
598                    sb.append("]]></column-value></column>");
599                    sb.append(
600                            "<column><column-name>endDate</column-name><column-value><![CDATA[");
601                    sb.append(getEndDate());
602                    sb.append("]]></column-value></column>");
603                    sb.append(
604                            "<column><column-name>durationHour</column-name><column-value><![CDATA[");
605                    sb.append(getDurationHour());
606                    sb.append("]]></column-value></column>");
607                    sb.append(
608                            "<column><column-name>durationMinute</column-name><column-value><![CDATA[");
609                    sb.append(getDurationMinute());
610                    sb.append("]]></column-value></column>");
611                    sb.append(
612                            "<column><column-name>allDay</column-name><column-value><![CDATA[");
613                    sb.append(getAllDay());
614                    sb.append("]]></column-value></column>");
615                    sb.append(
616                            "<column><column-name>timeZoneSensitive</column-name><column-value><![CDATA[");
617                    sb.append(getTimeZoneSensitive());
618                    sb.append("]]></column-value></column>");
619                    sb.append(
620                            "<column><column-name>type</column-name><column-value><![CDATA[");
621                    sb.append(getType());
622                    sb.append("]]></column-value></column>");
623                    sb.append(
624                            "<column><column-name>repeating</column-name><column-value><![CDATA[");
625                    sb.append(getRepeating());
626                    sb.append("]]></column-value></column>");
627                    sb.append(
628                            "<column><column-name>recurrence</column-name><column-value><![CDATA[");
629                    sb.append(getRecurrence());
630                    sb.append("]]></column-value></column>");
631                    sb.append(
632                            "<column><column-name>remindBy</column-name><column-value><![CDATA[");
633                    sb.append(getRemindBy());
634                    sb.append("]]></column-value></column>");
635                    sb.append(
636                            "<column><column-name>firstReminder</column-name><column-value><![CDATA[");
637                    sb.append(getFirstReminder());
638                    sb.append("]]></column-value></column>");
639                    sb.append(
640                            "<column><column-name>secondReminder</column-name><column-value><![CDATA[");
641                    sb.append(getSecondReminder());
642                    sb.append("]]></column-value></column>");
643    
644                    sb.append("</model>");
645    
646                    return sb.toString();
647            }
648    
649            private String _uuid;
650            private String _originalUuid;
651            private long _eventId;
652            private long _groupId;
653            private long _originalGroupId;
654            private boolean _setOriginalGroupId;
655            private long _companyId;
656            private long _userId;
657            private String _userUuid;
658            private String _userName;
659            private Date _createDate;
660            private Date _modifiedDate;
661            private String _title;
662            private String _description;
663            private Date _startDate;
664            private Date _endDate;
665            private int _durationHour;
666            private int _durationMinute;
667            private boolean _allDay;
668            private boolean _timeZoneSensitive;
669            private String _type;
670            private boolean _repeating;
671            private String _recurrence;
672            private int _remindBy;
673            private int _firstReminder;
674            private int _secondReminder;
675            private transient ExpandoBridge _expandoBridge;
676    }