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