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