1   /**
2    * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3    *
4    * The contents of this file are subject to the terms of the Liferay Enterprise
5    * Subscription License ("License"). You may not use this file except in
6    * compliance with the License. You can obtain a copy of the License by
7    * contacting Liferay, Inc. See the License for the specific language governing
8    * permissions and limitations under the License, including but not limited to
9    * distribution rights of the Software.
10   *
11   *
12   * 
13   */
14  
15  package com.liferay.portlet.calendar.model.impl;
16  
17  import com.liferay.portal.SystemException;
18  import com.liferay.portal.kernel.bean.ReadOnlyBeanHandler;
19  import com.liferay.portal.kernel.util.DateUtil;
20  import com.liferay.portal.kernel.util.GetterUtil;
21  import com.liferay.portal.kernel.util.HtmlUtil;
22  import com.liferay.portal.kernel.util.StringBundler;
23  import com.liferay.portal.model.impl.BaseModelImpl;
24  import com.liferay.portal.util.PortalUtil;
25  
26  import com.liferay.portlet.calendar.model.CalEvent;
27  import com.liferay.portlet.calendar.model.CalEventSoap;
28  
29  import java.io.Serializable;
30  
31  import java.lang.reflect.Proxy;
32  
33  import java.sql.Types;
34  
35  import java.util.ArrayList;
36  import java.util.Date;
37  import java.util.List;
38  
39  /**
40   * <a href="CalEventModelImpl.java.html"><b><i>View Source</i></b></a>
41   *
42   * <p>
43   * ServiceBuilder generated this class. Modifications in this class will be
44   * overwritten the next time is generated.
45   * </p>
46   *
47   * <p>
48   * This interface is a model that represents the CalEvent table in the
49   * database.
50   * </p>
51   *
52   * @author    Brian Wing Shun Chan
53   * @see       CalEventImpl
54   * @see       com.liferay.portlet.calendar.model.CalEvent
55   * @see       com.liferay.portlet.calendar.model.CalEventModel
56   * @generated
57   */
58  public class CalEventModelImpl extends BaseModelImpl<CalEvent> {
59      public static final String TABLE_NAME = "CalEvent";
60      public static final Object[][] TABLE_COLUMNS = {
61              { "uuid_", new Integer(Types.VARCHAR) },
62              { "eventId", new Integer(Types.BIGINT) },
63              { "groupId", new Integer(Types.BIGINT) },
64              { "companyId", new Integer(Types.BIGINT) },
65              { "userId", new Integer(Types.BIGINT) },
66              { "userName", new Integer(Types.VARCHAR) },
67              { "createDate", new Integer(Types.TIMESTAMP) },
68              { "modifiedDate", new Integer(Types.TIMESTAMP) },
69              { "title", new Integer(Types.VARCHAR) },
70              { "description", new Integer(Types.VARCHAR) },
71              { "startDate", new Integer(Types.TIMESTAMP) },
72              { "endDate", new Integer(Types.TIMESTAMP) },
73              { "durationHour", new Integer(Types.INTEGER) },
74              { "durationMinute", new Integer(Types.INTEGER) },
75              { "allDay", new Integer(Types.BOOLEAN) },
76              { "timeZoneSensitive", new Integer(Types.BOOLEAN) },
77              { "type_", new Integer(Types.VARCHAR) },
78              { "repeating", new Integer(Types.BOOLEAN) },
79              { "recurrence", new Integer(Types.CLOB) },
80              { "remindBy", new Integer(Types.INTEGER) },
81              { "firstReminder", new Integer(Types.INTEGER) },
82              { "secondReminder", new Integer(Types.INTEGER) }
83          };
84      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)";
85      public static final String TABLE_SQL_DROP = "drop table CalEvent";
86      public static final String ORDER_BY_JPQL = " ORDER BY calEvent.startDate ASC, calEvent.title ASC";
87      public static final String ORDER_BY_SQL = " ORDER BY CalEvent.startDate ASC, CalEvent.title ASC";
88      public static final String DATA_SOURCE = "liferayDataSource";
89      public static final String SESSION_FACTORY = "liferaySessionFactory";
90      public static final String TX_MANAGER = "liferayTransactionManager";
91      public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
92                  "value.object.entity.cache.enabled.com.liferay.portlet.calendar.model.CalEvent"),
93              true);
94      public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
95                  "value.object.finder.cache.enabled.com.liferay.portlet.calendar.model.CalEvent"),
96              true);
97  
98      public static CalEvent toModel(CalEventSoap soapModel) {
99          CalEvent model = new CalEventImpl();
100 
101         model.setUuid(soapModel.getUuid());
102         model.setEventId(soapModel.getEventId());
103         model.setGroupId(soapModel.getGroupId());
104         model.setCompanyId(soapModel.getCompanyId());
105         model.setUserId(soapModel.getUserId());
106         model.setUserName(soapModel.getUserName());
107         model.setCreateDate(soapModel.getCreateDate());
108         model.setModifiedDate(soapModel.getModifiedDate());
109         model.setTitle(soapModel.getTitle());
110         model.setDescription(soapModel.getDescription());
111         model.setStartDate(soapModel.getStartDate());
112         model.setEndDate(soapModel.getEndDate());
113         model.setDurationHour(soapModel.getDurationHour());
114         model.setDurationMinute(soapModel.getDurationMinute());
115         model.setAllDay(soapModel.getAllDay());
116         model.setTimeZoneSensitive(soapModel.getTimeZoneSensitive());
117         model.setType(soapModel.getType());
118         model.setRepeating(soapModel.getRepeating());
119         model.setRecurrence(soapModel.getRecurrence());
120         model.setRemindBy(soapModel.getRemindBy());
121         model.setFirstReminder(soapModel.getFirstReminder());
122         model.setSecondReminder(soapModel.getSecondReminder());
123 
124         return model;
125     }
126 
127     public static List<CalEvent> toModels(CalEventSoap[] soapModels) {
128         List<CalEvent> models = new ArrayList<CalEvent>(soapModels.length);
129 
130         for (CalEventSoap soapModel : soapModels) {
131             models.add(toModel(soapModel));
132         }
133 
134         return models;
135     }
136 
137     public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
138                 "lock.expiration.time.com.liferay.portlet.calendar.model.CalEvent"));
139 
140     public CalEventModelImpl() {
141     }
142 
143     public long getPrimaryKey() {
144         return _eventId;
145     }
146 
147     public void setPrimaryKey(long pk) {
148         setEventId(pk);
149     }
150 
151     public Serializable getPrimaryKeyObj() {
152         return new Long(_eventId);
153     }
154 
155     public String getUuid() {
156         return GetterUtil.getString(_uuid);
157     }
158 
159     public void setUuid(String uuid) {
160         _uuid = uuid;
161 
162         if (_originalUuid == null) {
163             _originalUuid = uuid;
164         }
165     }
166 
167     public String getOriginalUuid() {
168         return GetterUtil.getString(_originalUuid);
169     }
170 
171     public long getEventId() {
172         return _eventId;
173     }
174 
175     public void setEventId(long eventId) {
176         _eventId = eventId;
177     }
178 
179     public long getGroupId() {
180         return _groupId;
181     }
182 
183     public void setGroupId(long groupId) {
184         _groupId = groupId;
185 
186         if (!_setOriginalGroupId) {
187             _setOriginalGroupId = true;
188 
189             _originalGroupId = groupId;
190         }
191     }
192 
193     public long getOriginalGroupId() {
194         return _originalGroupId;
195     }
196 
197     public long getCompanyId() {
198         return _companyId;
199     }
200 
201     public void setCompanyId(long companyId) {
202         _companyId = companyId;
203     }
204 
205     public long getUserId() {
206         return _userId;
207     }
208 
209     public void setUserId(long userId) {
210         _userId = userId;
211     }
212 
213     public String getUserUuid() throws SystemException {
214         return PortalUtil.getUserValue(getUserId(), "uuid", _userUuid);
215     }
216 
217     public void setUserUuid(String userUuid) {
218         _userUuid = userUuid;
219     }
220 
221     public String getUserName() {
222         return GetterUtil.getString(_userName);
223     }
224 
225     public void setUserName(String userName) {
226         _userName = userName;
227     }
228 
229     public Date getCreateDate() {
230         return _createDate;
231     }
232 
233     public void setCreateDate(Date createDate) {
234         _createDate = createDate;
235     }
236 
237     public Date getModifiedDate() {
238         return _modifiedDate;
239     }
240 
241     public void setModifiedDate(Date modifiedDate) {
242         _modifiedDate = modifiedDate;
243     }
244 
245     public String getTitle() {
246         return GetterUtil.getString(_title);
247     }
248 
249     public void setTitle(String title) {
250         _title = title;
251     }
252 
253     public String getDescription() {
254         return GetterUtil.getString(_description);
255     }
256 
257     public void setDescription(String description) {
258         _description = description;
259     }
260 
261     public Date getStartDate() {
262         return _startDate;
263     }
264 
265     public void setStartDate(Date startDate) {
266         _startDate = startDate;
267     }
268 
269     public Date getEndDate() {
270         return _endDate;
271     }
272 
273     public void setEndDate(Date endDate) {
274         _endDate = endDate;
275     }
276 
277     public int getDurationHour() {
278         return _durationHour;
279     }
280 
281     public void setDurationHour(int durationHour) {
282         _durationHour = durationHour;
283     }
284 
285     public int getDurationMinute() {
286         return _durationMinute;
287     }
288 
289     public void setDurationMinute(int durationMinute) {
290         _durationMinute = durationMinute;
291     }
292 
293     public boolean getAllDay() {
294         return _allDay;
295     }
296 
297     public boolean isAllDay() {
298         return _allDay;
299     }
300 
301     public void setAllDay(boolean allDay) {
302         _allDay = allDay;
303     }
304 
305     public boolean getTimeZoneSensitive() {
306         return _timeZoneSensitive;
307     }
308 
309     public boolean isTimeZoneSensitive() {
310         return _timeZoneSensitive;
311     }
312 
313     public void setTimeZoneSensitive(boolean timeZoneSensitive) {
314         _timeZoneSensitive = timeZoneSensitive;
315     }
316 
317     public String getType() {
318         return GetterUtil.getString(_type);
319     }
320 
321     public void setType(String type) {
322         _type = type;
323     }
324 
325     public boolean getRepeating() {
326         return _repeating;
327     }
328 
329     public boolean isRepeating() {
330         return _repeating;
331     }
332 
333     public void setRepeating(boolean repeating) {
334         _repeating = repeating;
335     }
336 
337     public String getRecurrence() {
338         return GetterUtil.getString(_recurrence);
339     }
340 
341     public void setRecurrence(String recurrence) {
342         _recurrence = recurrence;
343     }
344 
345     public int getRemindBy() {
346         return _remindBy;
347     }
348 
349     public void setRemindBy(int remindBy) {
350         _remindBy = remindBy;
351     }
352 
353     public int getFirstReminder() {
354         return _firstReminder;
355     }
356 
357     public void setFirstReminder(int firstReminder) {
358         _firstReminder = firstReminder;
359     }
360 
361     public int getSecondReminder() {
362         return _secondReminder;
363     }
364 
365     public void setSecondReminder(int secondReminder) {
366         _secondReminder = secondReminder;
367     }
368 
369     public CalEvent toEscapedModel() {
370         if (isEscapedModel()) {
371             return (CalEvent)this;
372         }
373         else {
374             CalEvent model = new CalEventImpl();
375 
376             model.setNew(isNew());
377             model.setEscapedModel(true);
378 
379             model.setUuid(HtmlUtil.escape(getUuid()));
380             model.setEventId(getEventId());
381             model.setGroupId(getGroupId());
382             model.setCompanyId(getCompanyId());
383             model.setUserId(getUserId());
384             model.setUserName(HtmlUtil.escape(getUserName()));
385             model.setCreateDate(getCreateDate());
386             model.setModifiedDate(getModifiedDate());
387             model.setTitle(HtmlUtil.escape(getTitle()));
388             model.setDescription(HtmlUtil.escape(getDescription()));
389             model.setStartDate(getStartDate());
390             model.setEndDate(getEndDate());
391             model.setDurationHour(getDurationHour());
392             model.setDurationMinute(getDurationMinute());
393             model.setAllDay(getAllDay());
394             model.setTimeZoneSensitive(getTimeZoneSensitive());
395             model.setType(HtmlUtil.escape(getType()));
396             model.setRepeating(getRepeating());
397             model.setRecurrence(getRecurrence());
398             model.setRemindBy(getRemindBy());
399             model.setFirstReminder(getFirstReminder());
400             model.setSecondReminder(getSecondReminder());
401 
402             model = (CalEvent)Proxy.newProxyInstance(CalEvent.class.getClassLoader(),
403                     new Class[] { CalEvent.class },
404                     new ReadOnlyBeanHandler(model));
405 
406             return model;
407         }
408     }
409 
410     public Object clone() {
411         CalEventImpl clone = new CalEventImpl();
412 
413         clone.setUuid(getUuid());
414         clone.setEventId(getEventId());
415         clone.setGroupId(getGroupId());
416         clone.setCompanyId(getCompanyId());
417         clone.setUserId(getUserId());
418         clone.setUserName(getUserName());
419         clone.setCreateDate(getCreateDate());
420         clone.setModifiedDate(getModifiedDate());
421         clone.setTitle(getTitle());
422         clone.setDescription(getDescription());
423         clone.setStartDate(getStartDate());
424         clone.setEndDate(getEndDate());
425         clone.setDurationHour(getDurationHour());
426         clone.setDurationMinute(getDurationMinute());
427         clone.setAllDay(getAllDay());
428         clone.setTimeZoneSensitive(getTimeZoneSensitive());
429         clone.setType(getType());
430         clone.setRepeating(getRepeating());
431         clone.setRecurrence(getRecurrence());
432         clone.setRemindBy(getRemindBy());
433         clone.setFirstReminder(getFirstReminder());
434         clone.setSecondReminder(getSecondReminder());
435 
436         return clone;
437     }
438 
439     public int compareTo(CalEvent calEvent) {
440         int value = 0;
441 
442         value = DateUtil.compareTo(getStartDate(), calEvent.getStartDate());
443 
444         if (value != 0) {
445             return value;
446         }
447 
448         value = getTitle().toLowerCase()
449                     .compareTo(calEvent.getTitle().toLowerCase());
450 
451         if (value != 0) {
452             return value;
453         }
454 
455         return 0;
456     }
457 
458     public boolean equals(Object obj) {
459         if (obj == null) {
460             return false;
461         }
462 
463         CalEvent calEvent = null;
464 
465         try {
466             calEvent = (CalEvent)obj;
467         }
468         catch (ClassCastException cce) {
469             return false;
470         }
471 
472         long pk = calEvent.getPrimaryKey();
473 
474         if (getPrimaryKey() == pk) {
475             return true;
476         }
477         else {
478             return false;
479         }
480     }
481 
482     public int hashCode() {
483         return (int)getPrimaryKey();
484     }
485 
486     public String toString() {
487         StringBundler sb = new StringBundler(45);
488 
489         sb.append("{uuid=");
490         sb.append(getUuid());
491         sb.append(", eventId=");
492         sb.append(getEventId());
493         sb.append(", groupId=");
494         sb.append(getGroupId());
495         sb.append(", companyId=");
496         sb.append(getCompanyId());
497         sb.append(", userId=");
498         sb.append(getUserId());
499         sb.append(", userName=");
500         sb.append(getUserName());
501         sb.append(", createDate=");
502         sb.append(getCreateDate());
503         sb.append(", modifiedDate=");
504         sb.append(getModifiedDate());
505         sb.append(", title=");
506         sb.append(getTitle());
507         sb.append(", description=");
508         sb.append(getDescription());
509         sb.append(", startDate=");
510         sb.append(getStartDate());
511         sb.append(", endDate=");
512         sb.append(getEndDate());
513         sb.append(", durationHour=");
514         sb.append(getDurationHour());
515         sb.append(", durationMinute=");
516         sb.append(getDurationMinute());
517         sb.append(", allDay=");
518         sb.append(getAllDay());
519         sb.append(", timeZoneSensitive=");
520         sb.append(getTimeZoneSensitive());
521         sb.append(", type=");
522         sb.append(getType());
523         sb.append(", repeating=");
524         sb.append(getRepeating());
525         sb.append(", recurrence=");
526         sb.append(getRecurrence());
527         sb.append(", remindBy=");
528         sb.append(getRemindBy());
529         sb.append(", firstReminder=");
530         sb.append(getFirstReminder());
531         sb.append(", secondReminder=");
532         sb.append(getSecondReminder());
533         sb.append("}");
534 
535         return sb.toString();
536     }
537 
538     public String toXmlString() {
539         StringBundler sb = new StringBundler(70);
540 
541         sb.append("<model><model-name>");
542         sb.append("com.liferay.portlet.calendar.model.CalEvent");
543         sb.append("</model-name>");
544 
545         sb.append(
546             "<column><column-name>uuid</column-name><column-value><![CDATA[");
547         sb.append(getUuid());
548         sb.append("]]></column-value></column>");
549         sb.append(
550             "<column><column-name>eventId</column-name><column-value><![CDATA[");
551         sb.append(getEventId());
552         sb.append("]]></column-value></column>");
553         sb.append(
554             "<column><column-name>groupId</column-name><column-value><![CDATA[");
555         sb.append(getGroupId());
556         sb.append("]]></column-value></column>");
557         sb.append(
558             "<column><column-name>companyId</column-name><column-value><![CDATA[");
559         sb.append(getCompanyId());
560         sb.append("]]></column-value></column>");
561         sb.append(
562             "<column><column-name>userId</column-name><column-value><![CDATA[");
563         sb.append(getUserId());
564         sb.append("]]></column-value></column>");
565         sb.append(
566             "<column><column-name>userName</column-name><column-value><![CDATA[");
567         sb.append(getUserName());
568         sb.append("]]></column-value></column>");
569         sb.append(
570             "<column><column-name>createDate</column-name><column-value><![CDATA[");
571         sb.append(getCreateDate());
572         sb.append("]]></column-value></column>");
573         sb.append(
574             "<column><column-name>modifiedDate</column-name><column-value><![CDATA[");
575         sb.append(getModifiedDate());
576         sb.append("]]></column-value></column>");
577         sb.append(
578             "<column><column-name>title</column-name><column-value><![CDATA[");
579         sb.append(getTitle());
580         sb.append("]]></column-value></column>");
581         sb.append(
582             "<column><column-name>description</column-name><column-value><![CDATA[");
583         sb.append(getDescription());
584         sb.append("]]></column-value></column>");
585         sb.append(
586             "<column><column-name>startDate</column-name><column-value><![CDATA[");
587         sb.append(getStartDate());
588         sb.append("]]></column-value></column>");
589         sb.append(
590             "<column><column-name>endDate</column-name><column-value><![CDATA[");
591         sb.append(getEndDate());
592         sb.append("]]></column-value></column>");
593         sb.append(
594             "<column><column-name>durationHour</column-name><column-value><![CDATA[");
595         sb.append(getDurationHour());
596         sb.append("]]></column-value></column>");
597         sb.append(
598             "<column><column-name>durationMinute</column-name><column-value><![CDATA[");
599         sb.append(getDurationMinute());
600         sb.append("]]></column-value></column>");
601         sb.append(
602             "<column><column-name>allDay</column-name><column-value><![CDATA[");
603         sb.append(getAllDay());
604         sb.append("]]></column-value></column>");
605         sb.append(
606             "<column><column-name>timeZoneSensitive</column-name><column-value><![CDATA[");
607         sb.append(getTimeZoneSensitive());
608         sb.append("]]></column-value></column>");
609         sb.append(
610             "<column><column-name>type</column-name><column-value><![CDATA[");
611         sb.append(getType());
612         sb.append("]]></column-value></column>");
613         sb.append(
614             "<column><column-name>repeating</column-name><column-value><![CDATA[");
615         sb.append(getRepeating());
616         sb.append("]]></column-value></column>");
617         sb.append(
618             "<column><column-name>recurrence</column-name><column-value><![CDATA[");
619         sb.append(getRecurrence());
620         sb.append("]]></column-value></column>");
621         sb.append(
622             "<column><column-name>remindBy</column-name><column-value><![CDATA[");
623         sb.append(getRemindBy());
624         sb.append("]]></column-value></column>");
625         sb.append(
626             "<column><column-name>firstReminder</column-name><column-value><![CDATA[");
627         sb.append(getFirstReminder());
628         sb.append("]]></column-value></column>");
629         sb.append(
630             "<column><column-name>secondReminder</column-name><column-value><![CDATA[");
631         sb.append(getSecondReminder());
632         sb.append("]]></column-value></column>");
633 
634         sb.append("</model>");
635 
636         return sb.toString();
637     }
638 
639     private String _uuid;
640     private String _originalUuid;
641     private long _eventId;
642     private long _groupId;
643     private long _originalGroupId;
644     private boolean _setOriginalGroupId;
645     private long _companyId;
646     private long _userId;
647     private String _userUuid;
648     private String _userName;
649     private Date _createDate;
650     private Date _modifiedDate;
651     private String _title;
652     private String _description;
653     private Date _startDate;
654     private Date _endDate;
655     private int _durationHour;
656     private int _durationMinute;
657     private boolean _allDay;
658     private boolean _timeZoneSensitive;
659     private String _type;
660     private boolean _repeating;
661     private String _recurrence;
662     private int _remindBy;
663     private int _firstReminder;
664     private int _secondReminder;
665 }