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