1   /**
2    * Copyright (c) 2000-2009 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   * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
12   * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
13   * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
14   * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
15   * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
16   * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
17   * SOFTWARE.
18   */
19  
20  package com.liferay.portlet.calendar.model.impl;
21  
22  import com.liferay.portal.kernel.bean.ReadOnlyBeanHandler;
23  import com.liferay.portal.kernel.util.DateUtil;
24  import com.liferay.portal.kernel.util.GetterUtil;
25  import com.liferay.portal.kernel.util.HtmlUtil;
26  import com.liferay.portal.model.impl.BaseModelImpl;
27  
28  import com.liferay.portlet.calendar.model.CalEvent;
29  import com.liferay.portlet.calendar.model.CalEventSoap;
30  
31  import java.io.Serializable;
32  
33  import java.lang.reflect.Proxy;
34  
35  import java.sql.Types;
36  
37  import java.util.ArrayList;
38  import java.util.Date;
39  import java.util.List;
40  
41  /**
42   * <a href="CalEventModelImpl.java.html"><b><i>View Source</i></b></a>
43   *
44   * <p>
45   * ServiceBuilder generated this class. Modifications in this class will be
46   * overwritten the next time is generated.
47   * </p>
48   *
49   * <p>
50   * This class is a model that represents the <code>CalEvent</code> table
51   * in the database.
52   * </p>
53   *
54   * @author Brian Wing Shun Chan
55   *
56   * @see com.liferay.portlet.calendar.model.CalEvent
57   * @see com.liferay.portlet.calendar.model.CalEventModel
58   * @see com.liferay.portlet.calendar.model.impl.CalEventImpl
59   *
60   */
61  public class CalEventModelImpl extends BaseModelImpl {
62      public static final String TABLE_NAME = "CalEvent";
63      public static final Object[][] TABLE_COLUMNS = {
64              { "uuid_", new Integer(Types.VARCHAR) },
65              
66  
67              { "eventId", new Integer(Types.BIGINT) },
68              
69  
70              { "groupId", new Integer(Types.BIGINT) },
71              
72  
73              { "companyId", new Integer(Types.BIGINT) },
74              
75  
76              { "userId", new Integer(Types.BIGINT) },
77              
78  
79              { "userName", new Integer(Types.VARCHAR) },
80              
81  
82              { "createDate", new Integer(Types.TIMESTAMP) },
83              
84  
85              { "modifiedDate", new Integer(Types.TIMESTAMP) },
86              
87  
88              { "title", new Integer(Types.VARCHAR) },
89              
90  
91              { "description", new Integer(Types.VARCHAR) },
92              
93  
94              { "startDate", new Integer(Types.TIMESTAMP) },
95              
96  
97              { "endDate", new Integer(Types.TIMESTAMP) },
98              
99  
100             { "durationHour", new Integer(Types.INTEGER) },
101             
102 
103             { "durationMinute", new Integer(Types.INTEGER) },
104             
105 
106             { "allDay", new Integer(Types.BOOLEAN) },
107             
108 
109             { "timeZoneSensitive", new Integer(Types.BOOLEAN) },
110             
111 
112             { "type_", new Integer(Types.VARCHAR) },
113             
114 
115             { "repeating", new Integer(Types.BOOLEAN) },
116             
117 
118             { "recurrence", new Integer(Types.CLOB) },
119             
120 
121             { "remindBy", new Integer(Types.VARCHAR) },
122             
123 
124             { "firstReminder", new Integer(Types.INTEGER) },
125             
126 
127             { "secondReminder", new Integer(Types.INTEGER) }
128         };
129     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)";
130     public static final String TABLE_SQL_DROP = "drop table CalEvent";
131     public static final String DATA_SOURCE = "liferayDataSource";
132     public static final String SESSION_FACTORY = "liferaySessionFactory";
133     public static final String TX_MANAGER = "liferayTransactionManager";
134     public static final boolean CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
135                 "value.object.finder.cache.enabled.com.liferay.portlet.calendar.model.CalEvent"),
136             true);
137 
138     public static CalEvent toModel(CalEventSoap soapModel) {
139         CalEvent model = new CalEventImpl();
140 
141         model.setUuid(soapModel.getUuid());
142         model.setEventId(soapModel.getEventId());
143         model.setGroupId(soapModel.getGroupId());
144         model.setCompanyId(soapModel.getCompanyId());
145         model.setUserId(soapModel.getUserId());
146         model.setUserName(soapModel.getUserName());
147         model.setCreateDate(soapModel.getCreateDate());
148         model.setModifiedDate(soapModel.getModifiedDate());
149         model.setTitle(soapModel.getTitle());
150         model.setDescription(soapModel.getDescription());
151         model.setStartDate(soapModel.getStartDate());
152         model.setEndDate(soapModel.getEndDate());
153         model.setDurationHour(soapModel.getDurationHour());
154         model.setDurationMinute(soapModel.getDurationMinute());
155         model.setAllDay(soapModel.getAllDay());
156         model.setTimeZoneSensitive(soapModel.getTimeZoneSensitive());
157         model.setType(soapModel.getType());
158         model.setRepeating(soapModel.getRepeating());
159         model.setRecurrence(soapModel.getRecurrence());
160         model.setRemindBy(soapModel.getRemindBy());
161         model.setFirstReminder(soapModel.getFirstReminder());
162         model.setSecondReminder(soapModel.getSecondReminder());
163 
164         return model;
165     }
166 
167     public static List<CalEvent> toModels(CalEventSoap[] soapModels) {
168         List<CalEvent> models = new ArrayList<CalEvent>(soapModels.length);
169 
170         for (CalEventSoap soapModel : soapModels) {
171             models.add(toModel(soapModel));
172         }
173 
174         return models;
175     }
176 
177     public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
178                 "lock.expiration.time.com.liferay.portlet.calendar.model.CalEvent"));
179 
180     public CalEventModelImpl() {
181     }
182 
183     public long getPrimaryKey() {
184         return _eventId;
185     }
186 
187     public void setPrimaryKey(long pk) {
188         setEventId(pk);
189     }
190 
191     public Serializable getPrimaryKeyObj() {
192         return new Long(_eventId);
193     }
194 
195     public String getUuid() {
196         return GetterUtil.getString(_uuid);
197     }
198 
199     public void setUuid(String uuid) {
200         if ((uuid != null) && (uuid != _uuid)) {
201             _uuid = uuid;
202         }
203     }
204 
205     public long getEventId() {
206         return _eventId;
207     }
208 
209     public void setEventId(long eventId) {
210         if (eventId != _eventId) {
211             _eventId = eventId;
212         }
213     }
214 
215     public long getGroupId() {
216         return _groupId;
217     }
218 
219     public void setGroupId(long groupId) {
220         if (groupId != _groupId) {
221             _groupId = groupId;
222         }
223     }
224 
225     public long getCompanyId() {
226         return _companyId;
227     }
228 
229     public void setCompanyId(long companyId) {
230         if (companyId != _companyId) {
231             _companyId = companyId;
232         }
233     }
234 
235     public long getUserId() {
236         return _userId;
237     }
238 
239     public void setUserId(long userId) {
240         if (userId != _userId) {
241             _userId = userId;
242         }
243     }
244 
245     public String getUserName() {
246         return GetterUtil.getString(_userName);
247     }
248 
249     public void setUserName(String userName) {
250         if (((userName == null) && (_userName != null)) ||
251                 ((userName != null) && (_userName == null)) ||
252                 ((userName != null) && (_userName != null) &&
253                 !userName.equals(_userName))) {
254             _userName = userName;
255         }
256     }
257 
258     public Date getCreateDate() {
259         return _createDate;
260     }
261 
262     public void setCreateDate(Date createDate) {
263         if (((createDate == null) && (_createDate != null)) ||
264                 ((createDate != null) && (_createDate == null)) ||
265                 ((createDate != null) && (_createDate != null) &&
266                 !createDate.equals(_createDate))) {
267             _createDate = createDate;
268         }
269     }
270 
271     public Date getModifiedDate() {
272         return _modifiedDate;
273     }
274 
275     public void setModifiedDate(Date modifiedDate) {
276         if (((modifiedDate == null) && (_modifiedDate != null)) ||
277                 ((modifiedDate != null) && (_modifiedDate == null)) ||
278                 ((modifiedDate != null) && (_modifiedDate != null) &&
279                 !modifiedDate.equals(_modifiedDate))) {
280             _modifiedDate = modifiedDate;
281         }
282     }
283 
284     public String getTitle() {
285         return GetterUtil.getString(_title);
286     }
287 
288     public void setTitle(String title) {
289         if (((title == null) && (_title != null)) ||
290                 ((title != null) && (_title == null)) ||
291                 ((title != null) && (_title != null) && !title.equals(_title))) {
292             _title = title;
293         }
294     }
295 
296     public String getDescription() {
297         return GetterUtil.getString(_description);
298     }
299 
300     public void setDescription(String description) {
301         if (((description == null) && (_description != null)) ||
302                 ((description != null) && (_description == null)) ||
303                 ((description != null) && (_description != null) &&
304                 !description.equals(_description))) {
305             _description = description;
306         }
307     }
308 
309     public Date getStartDate() {
310         return _startDate;
311     }
312 
313     public void setStartDate(Date startDate) {
314         if (((startDate == null) && (_startDate != null)) ||
315                 ((startDate != null) && (_startDate == null)) ||
316                 ((startDate != null) && (_startDate != null) &&
317                 !startDate.equals(_startDate))) {
318             _startDate = startDate;
319         }
320     }
321 
322     public Date getEndDate() {
323         return _endDate;
324     }
325 
326     public void setEndDate(Date endDate) {
327         if (((endDate == null) && (_endDate != null)) ||
328                 ((endDate != null) && (_endDate == null)) ||
329                 ((endDate != null) && (_endDate != null) &&
330                 !endDate.equals(_endDate))) {
331             _endDate = endDate;
332         }
333     }
334 
335     public int getDurationHour() {
336         return _durationHour;
337     }
338 
339     public void setDurationHour(int durationHour) {
340         if (durationHour != _durationHour) {
341             _durationHour = durationHour;
342         }
343     }
344 
345     public int getDurationMinute() {
346         return _durationMinute;
347     }
348 
349     public void setDurationMinute(int durationMinute) {
350         if (durationMinute != _durationMinute) {
351             _durationMinute = durationMinute;
352         }
353     }
354 
355     public boolean getAllDay() {
356         return _allDay;
357     }
358 
359     public boolean isAllDay() {
360         return _allDay;
361     }
362 
363     public void setAllDay(boolean allDay) {
364         if (allDay != _allDay) {
365             _allDay = allDay;
366         }
367     }
368 
369     public boolean getTimeZoneSensitive() {
370         return _timeZoneSensitive;
371     }
372 
373     public boolean isTimeZoneSensitive() {
374         return _timeZoneSensitive;
375     }
376 
377     public void setTimeZoneSensitive(boolean timeZoneSensitive) {
378         if (timeZoneSensitive != _timeZoneSensitive) {
379             _timeZoneSensitive = timeZoneSensitive;
380         }
381     }
382 
383     public String getType() {
384         return GetterUtil.getString(_type);
385     }
386 
387     public void setType(String type) {
388         if (((type == null) && (_type != null)) ||
389                 ((type != null) && (_type == null)) ||
390                 ((type != null) && (_type != null) && !type.equals(_type))) {
391             _type = type;
392         }
393     }
394 
395     public boolean getRepeating() {
396         return _repeating;
397     }
398 
399     public boolean isRepeating() {
400         return _repeating;
401     }
402 
403     public void setRepeating(boolean repeating) {
404         if (repeating != _repeating) {
405             _repeating = repeating;
406         }
407     }
408 
409     public String getRecurrence() {
410         return GetterUtil.getString(_recurrence);
411     }
412 
413     public void setRecurrence(String recurrence) {
414         if (((recurrence == null) && (_recurrence != null)) ||
415                 ((recurrence != null) && (_recurrence == null)) ||
416                 ((recurrence != null) && (_recurrence != null) &&
417                 !recurrence.equals(_recurrence))) {
418             _recurrence = recurrence;
419         }
420     }
421 
422     public String getRemindBy() {
423         return GetterUtil.getString(_remindBy);
424     }
425 
426     public void setRemindBy(String remindBy) {
427         if (((remindBy == null) && (_remindBy != null)) ||
428                 ((remindBy != null) && (_remindBy == null)) ||
429                 ((remindBy != null) && (_remindBy != null) &&
430                 !remindBy.equals(_remindBy))) {
431             _remindBy = remindBy;
432         }
433     }
434 
435     public int getFirstReminder() {
436         return _firstReminder;
437     }
438 
439     public void setFirstReminder(int firstReminder) {
440         if (firstReminder != _firstReminder) {
441             _firstReminder = firstReminder;
442         }
443     }
444 
445     public int getSecondReminder() {
446         return _secondReminder;
447     }
448 
449     public void setSecondReminder(int secondReminder) {
450         if (secondReminder != _secondReminder) {
451             _secondReminder = secondReminder;
452         }
453     }
454 
455     public CalEvent toEscapedModel() {
456         if (isEscapedModel()) {
457             return (CalEvent)this;
458         }
459         else {
460             CalEvent model = new CalEventImpl();
461 
462             model.setNew(isNew());
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 }