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