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  import com.liferay.portlet.expando.model.ExpandoBridge;
31  import com.liferay.portlet.expando.model.impl.ExpandoBridgeImpl;
32  
33  import java.io.Serializable;
34  
35  import java.lang.reflect.Proxy;
36  
37  import java.sql.Types;
38  
39  import java.util.ArrayList;
40  import java.util.Date;
41  import java.util.List;
42  
43  /**
44   * <a href="CalEventModelImpl.java.html"><b><i>View Source</i></b></a>
45   *
46   * <p>
47   * ServiceBuilder generated this class. Modifications in this class will be
48   * overwritten the next time is generated.
49   * </p>
50   *
51   * <p>
52   * This class is a model that represents the <code>CalEvent</code> table
53   * in the database.
54   * </p>
55   *
56   * @author Brian Wing Shun Chan
57   *
58   * @see com.liferay.portlet.calendar.model.CalEvent
59   * @see com.liferay.portlet.calendar.model.CalEventModel
60   * @see com.liferay.portlet.calendar.model.impl.CalEventImpl
61   *
62   */
63  public class CalEventModelImpl extends BaseModelImpl<CalEvent> {
64      public static final String TABLE_NAME = "CalEvent";
65      public static final Object[][] TABLE_COLUMNS = {
66              { "uuid_", new Integer(Types.VARCHAR) },
67              
68  
69              { "eventId", new Integer(Types.BIGINT) },
70              
71  
72              { "groupId", new Integer(Types.BIGINT) },
73              
74  
75              { "companyId", new Integer(Types.BIGINT) },
76              
77  
78              { "userId", new Integer(Types.BIGINT) },
79              
80  
81              { "userName", new Integer(Types.VARCHAR) },
82              
83  
84              { "createDate", new Integer(Types.TIMESTAMP) },
85              
86  
87              { "modifiedDate", new Integer(Types.TIMESTAMP) },
88              
89  
90              { "title", new Integer(Types.VARCHAR) },
91              
92  
93              { "description", new Integer(Types.VARCHAR) },
94              
95  
96              { "startDate", new Integer(Types.TIMESTAMP) },
97              
98  
99              { "endDate", new Integer(Types.TIMESTAMP) },
100             
101 
102             { "durationHour", new Integer(Types.INTEGER) },
103             
104 
105             { "durationMinute", new Integer(Types.INTEGER) },
106             
107 
108             { "allDay", new Integer(Types.BOOLEAN) },
109             
110 
111             { "timeZoneSensitive", new Integer(Types.BOOLEAN) },
112             
113 
114             { "type_", new Integer(Types.VARCHAR) },
115             
116 
117             { "repeating", new Integer(Types.BOOLEAN) },
118             
119 
120             { "recurrence", new Integer(Types.CLOB) },
121             
122 
123             { "remindBy", new Integer(Types.INTEGER) },
124             
125 
126             { "firstReminder", new Integer(Types.INTEGER) },
127             
128 
129             { "secondReminder", new Integer(Types.INTEGER) }
130         };
131     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 INTEGER,firstReminder INTEGER,secondReminder INTEGER)";
132     public static final String TABLE_SQL_DROP = "drop table CalEvent";
133     public static final String DATA_SOURCE = "liferayDataSource";
134     public static final String SESSION_FACTORY = "liferaySessionFactory";
135     public static final String TX_MANAGER = "liferayTransactionManager";
136     public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
137                 "value.object.entity.cache.enabled.com.liferay.portlet.calendar.model.CalEvent"),
138             true);
139     public static final boolean FINDER_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         _uuid = uuid;
206 
207         if (_originalUuid == null) {
208             _originalUuid = uuid;
209         }
210     }
211 
212     public String getOriginalUuid() {
213         return GetterUtil.getString(_originalUuid);
214     }
215 
216     public long getEventId() {
217         return _eventId;
218     }
219 
220     public void setEventId(long eventId) {
221         _eventId = eventId;
222     }
223 
224     public long getGroupId() {
225         return _groupId;
226     }
227 
228     public void setGroupId(long groupId) {
229         _groupId = groupId;
230 
231         if (!_setOriginalGroupId) {
232             _setOriginalGroupId = true;
233 
234             _originalGroupId = groupId;
235         }
236     }
237 
238     public long getOriginalGroupId() {
239         return _originalGroupId;
240     }
241 
242     public long getCompanyId() {
243         return _companyId;
244     }
245 
246     public void setCompanyId(long companyId) {
247         _companyId = companyId;
248     }
249 
250     public long getUserId() {
251         return _userId;
252     }
253 
254     public void setUserId(long userId) {
255         _userId = userId;
256     }
257 
258     public String getUserName() {
259         return GetterUtil.getString(_userName);
260     }
261 
262     public void setUserName(String userName) {
263         _userName = userName;
264     }
265 
266     public Date getCreateDate() {
267         return _createDate;
268     }
269 
270     public void setCreateDate(Date createDate) {
271         _createDate = createDate;
272     }
273 
274     public Date getModifiedDate() {
275         return _modifiedDate;
276     }
277 
278     public void setModifiedDate(Date modifiedDate) {
279         _modifiedDate = modifiedDate;
280     }
281 
282     public String getTitle() {
283         return GetterUtil.getString(_title);
284     }
285 
286     public void setTitle(String title) {
287         _title = title;
288     }
289 
290     public String getDescription() {
291         return GetterUtil.getString(_description);
292     }
293 
294     public void setDescription(String description) {
295         _description = description;
296     }
297 
298     public Date getStartDate() {
299         return _startDate;
300     }
301 
302     public void setStartDate(Date startDate) {
303         _startDate = startDate;
304     }
305 
306     public Date getEndDate() {
307         return _endDate;
308     }
309 
310     public void setEndDate(Date endDate) {
311         _endDate = endDate;
312     }
313 
314     public int getDurationHour() {
315         return _durationHour;
316     }
317 
318     public void setDurationHour(int durationHour) {
319         _durationHour = durationHour;
320     }
321 
322     public int getDurationMinute() {
323         return _durationMinute;
324     }
325 
326     public void setDurationMinute(int durationMinute) {
327         _durationMinute = durationMinute;
328     }
329 
330     public boolean getAllDay() {
331         return _allDay;
332     }
333 
334     public boolean isAllDay() {
335         return _allDay;
336     }
337 
338     public void setAllDay(boolean allDay) {
339         _allDay = allDay;
340     }
341 
342     public boolean getTimeZoneSensitive() {
343         return _timeZoneSensitive;
344     }
345 
346     public boolean isTimeZoneSensitive() {
347         return _timeZoneSensitive;
348     }
349 
350     public void setTimeZoneSensitive(boolean timeZoneSensitive) {
351         _timeZoneSensitive = timeZoneSensitive;
352     }
353 
354     public String getType() {
355         return GetterUtil.getString(_type);
356     }
357 
358     public void setType(String type) {
359         _type = type;
360     }
361 
362     public boolean getRepeating() {
363         return _repeating;
364     }
365 
366     public boolean isRepeating() {
367         return _repeating;
368     }
369 
370     public void setRepeating(boolean repeating) {
371         _repeating = repeating;
372     }
373 
374     public String getRecurrence() {
375         return GetterUtil.getString(_recurrence);
376     }
377 
378     public void setRecurrence(String recurrence) {
379         _recurrence = recurrence;
380     }
381 
382     public int getRemindBy() {
383         return _remindBy;
384     }
385 
386     public void setRemindBy(int remindBy) {
387         _remindBy = remindBy;
388     }
389 
390     public int getFirstReminder() {
391         return _firstReminder;
392     }
393 
394     public void setFirstReminder(int firstReminder) {
395         _firstReminder = firstReminder;
396     }
397 
398     public int getSecondReminder() {
399         return _secondReminder;
400     }
401 
402     public void setSecondReminder(int secondReminder) {
403         _secondReminder = secondReminder;
404     }
405 
406     public CalEvent toEscapedModel() {
407         if (isEscapedModel()) {
408             return (CalEvent)this;
409         }
410         else {
411             CalEvent model = new CalEventImpl();
412 
413             model.setNew(isNew());
414             model.setEscapedModel(true);
415 
416             model.setUuid(HtmlUtil.escape(getUuid()));
417             model.setEventId(getEventId());
418             model.setGroupId(getGroupId());
419             model.setCompanyId(getCompanyId());
420             model.setUserId(getUserId());
421             model.setUserName(HtmlUtil.escape(getUserName()));
422             model.setCreateDate(getCreateDate());
423             model.setModifiedDate(getModifiedDate());
424             model.setTitle(HtmlUtil.escape(getTitle()));
425             model.setDescription(HtmlUtil.escape(getDescription()));
426             model.setStartDate(getStartDate());
427             model.setEndDate(getEndDate());
428             model.setDurationHour(getDurationHour());
429             model.setDurationMinute(getDurationMinute());
430             model.setAllDay(getAllDay());
431             model.setTimeZoneSensitive(getTimeZoneSensitive());
432             model.setType(HtmlUtil.escape(getType()));
433             model.setRepeating(getRepeating());
434             model.setRecurrence(getRecurrence());
435             model.setRemindBy(getRemindBy());
436             model.setFirstReminder(getFirstReminder());
437             model.setSecondReminder(getSecondReminder());
438 
439             model = (CalEvent)Proxy.newProxyInstance(CalEvent.class.getClassLoader(),
440                     new Class[] { CalEvent.class },
441                     new ReadOnlyBeanHandler(model));
442 
443             return model;
444         }
445     }
446 
447     public ExpandoBridge getExpandoBridge() {
448         if (_expandoBridge == null) {
449             _expandoBridge = new ExpandoBridgeImpl(CalEvent.class.getName(),
450                     getPrimaryKey());
451         }
452 
453         return _expandoBridge;
454     }
455 
456     public Object clone() {
457         CalEventImpl clone = new CalEventImpl();
458 
459         clone.setUuid(getUuid());
460         clone.setEventId(getEventId());
461         clone.setGroupId(getGroupId());
462         clone.setCompanyId(getCompanyId());
463         clone.setUserId(getUserId());
464         clone.setUserName(getUserName());
465         clone.setCreateDate(getCreateDate());
466         clone.setModifiedDate(getModifiedDate());
467         clone.setTitle(getTitle());
468         clone.setDescription(getDescription());
469         clone.setStartDate(getStartDate());
470         clone.setEndDate(getEndDate());
471         clone.setDurationHour(getDurationHour());
472         clone.setDurationMinute(getDurationMinute());
473         clone.setAllDay(getAllDay());
474         clone.setTimeZoneSensitive(getTimeZoneSensitive());
475         clone.setType(getType());
476         clone.setRepeating(getRepeating());
477         clone.setRecurrence(getRecurrence());
478         clone.setRemindBy(getRemindBy());
479         clone.setFirstReminder(getFirstReminder());
480         clone.setSecondReminder(getSecondReminder());
481 
482         return clone;
483     }
484 
485     public int compareTo(CalEvent calEvent) {
486         int value = 0;
487 
488         value = DateUtil.compareTo(getStartDate(), calEvent.getStartDate());
489 
490         if (value != 0) {
491             return value;
492         }
493 
494         value = getTitle().toLowerCase()
495                     .compareTo(calEvent.getTitle().toLowerCase());
496 
497         if (value != 0) {
498             return value;
499         }
500 
501         return 0;
502     }
503 
504     public boolean equals(Object obj) {
505         if (obj == null) {
506             return false;
507         }
508 
509         CalEvent calEvent = null;
510 
511         try {
512             calEvent = (CalEvent)obj;
513         }
514         catch (ClassCastException cce) {
515             return false;
516         }
517 
518         long pk = calEvent.getPrimaryKey();
519 
520         if (getPrimaryKey() == pk) {
521             return true;
522         }
523         else {
524             return false;
525         }
526     }
527 
528     public int hashCode() {
529         return (int)getPrimaryKey();
530     }
531 
532     public String toString() {
533         StringBuilder sb = new StringBuilder();
534 
535         sb.append("{uuid=");
536         sb.append(getUuid());
537         sb.append(", eventId=");
538         sb.append(getEventId());
539         sb.append(", groupId=");
540         sb.append(getGroupId());
541         sb.append(", companyId=");
542         sb.append(getCompanyId());
543         sb.append(", userId=");
544         sb.append(getUserId());
545         sb.append(", userName=");
546         sb.append(getUserName());
547         sb.append(", createDate=");
548         sb.append(getCreateDate());
549         sb.append(", modifiedDate=");
550         sb.append(getModifiedDate());
551         sb.append(", title=");
552         sb.append(getTitle());
553         sb.append(", description=");
554         sb.append(getDescription());
555         sb.append(", startDate=");
556         sb.append(getStartDate());
557         sb.append(", endDate=");
558         sb.append(getEndDate());
559         sb.append(", durationHour=");
560         sb.append(getDurationHour());
561         sb.append(", durationMinute=");
562         sb.append(getDurationMinute());
563         sb.append(", allDay=");
564         sb.append(getAllDay());
565         sb.append(", timeZoneSensitive=");
566         sb.append(getTimeZoneSensitive());
567         sb.append(", type=");
568         sb.append(getType());
569         sb.append(", repeating=");
570         sb.append(getRepeating());
571         sb.append(", recurrence=");
572         sb.append(getRecurrence());
573         sb.append(", remindBy=");
574         sb.append(getRemindBy());
575         sb.append(", firstReminder=");
576         sb.append(getFirstReminder());
577         sb.append(", secondReminder=");
578         sb.append(getSecondReminder());
579         sb.append("}");
580 
581         return sb.toString();
582     }
583 
584     public String toXmlString() {
585         StringBuilder sb = new StringBuilder();
586 
587         sb.append("<model><model-name>");
588         sb.append("com.liferay.portlet.calendar.model.CalEvent");
589         sb.append("</model-name>");
590 
591         sb.append(
592             "<column><column-name>uuid</column-name><column-value><![CDATA[");
593         sb.append(getUuid());
594         sb.append("]]></column-value></column>");
595         sb.append(
596             "<column><column-name>eventId</column-name><column-value><![CDATA[");
597         sb.append(getEventId());
598         sb.append("]]></column-value></column>");
599         sb.append(
600             "<column><column-name>groupId</column-name><column-value><![CDATA[");
601         sb.append(getGroupId());
602         sb.append("]]></column-value></column>");
603         sb.append(
604             "<column><column-name>companyId</column-name><column-value><![CDATA[");
605         sb.append(getCompanyId());
606         sb.append("]]></column-value></column>");
607         sb.append(
608             "<column><column-name>userId</column-name><column-value><![CDATA[");
609         sb.append(getUserId());
610         sb.append("]]></column-value></column>");
611         sb.append(
612             "<column><column-name>userName</column-name><column-value><![CDATA[");
613         sb.append(getUserName());
614         sb.append("]]></column-value></column>");
615         sb.append(
616             "<column><column-name>createDate</column-name><column-value><![CDATA[");
617         sb.append(getCreateDate());
618         sb.append("]]></column-value></column>");
619         sb.append(
620             "<column><column-name>modifiedDate</column-name><column-value><![CDATA[");
621         sb.append(getModifiedDate());
622         sb.append("]]></column-value></column>");
623         sb.append(
624             "<column><column-name>title</column-name><column-value><![CDATA[");
625         sb.append(getTitle());
626         sb.append("]]></column-value></column>");
627         sb.append(
628             "<column><column-name>description</column-name><column-value><![CDATA[");
629         sb.append(getDescription());
630         sb.append("]]></column-value></column>");
631         sb.append(
632             "<column><column-name>startDate</column-name><column-value><![CDATA[");
633         sb.append(getStartDate());
634         sb.append("]]></column-value></column>");
635         sb.append(
636             "<column><column-name>endDate</column-name><column-value><![CDATA[");
637         sb.append(getEndDate());
638         sb.append("]]></column-value></column>");
639         sb.append(
640             "<column><column-name>durationHour</column-name><column-value><![CDATA[");
641         sb.append(getDurationHour());
642         sb.append("]]></column-value></column>");
643         sb.append(
644             "<column><column-name>durationMinute</column-name><column-value><![CDATA[");
645         sb.append(getDurationMinute());
646         sb.append("]]></column-value></column>");
647         sb.append(
648             "<column><column-name>allDay</column-name><column-value><![CDATA[");
649         sb.append(getAllDay());
650         sb.append("]]></column-value></column>");
651         sb.append(
652             "<column><column-name>timeZoneSensitive</column-name><column-value><![CDATA[");
653         sb.append(getTimeZoneSensitive());
654         sb.append("]]></column-value></column>");
655         sb.append(
656             "<column><column-name>type</column-name><column-value><![CDATA[");
657         sb.append(getType());
658         sb.append("]]></column-value></column>");
659         sb.append(
660             "<column><column-name>repeating</column-name><column-value><![CDATA[");
661         sb.append(getRepeating());
662         sb.append("]]></column-value></column>");
663         sb.append(
664             "<column><column-name>recurrence</column-name><column-value><![CDATA[");
665         sb.append(getRecurrence());
666         sb.append("]]></column-value></column>");
667         sb.append(
668             "<column><column-name>remindBy</column-name><column-value><![CDATA[");
669         sb.append(getRemindBy());
670         sb.append("]]></column-value></column>");
671         sb.append(
672             "<column><column-name>firstReminder</column-name><column-value><![CDATA[");
673         sb.append(getFirstReminder());
674         sb.append("]]></column-value></column>");
675         sb.append(
676             "<column><column-name>secondReminder</column-name><column-value><![CDATA[");
677         sb.append(getSecondReminder());
678         sb.append("]]></column-value></column>");
679 
680         sb.append("</model>");
681 
682         return sb.toString();
683     }
684 
685     private String _uuid;
686     private String _originalUuid;
687     private long _eventId;
688     private long _groupId;
689     private long _originalGroupId;
690     private boolean _setOriginalGroupId;
691     private long _companyId;
692     private long _userId;
693     private String _userName;
694     private Date _createDate;
695     private Date _modifiedDate;
696     private String _title;
697     private String _description;
698     private Date _startDate;
699     private Date _endDate;
700     private int _durationHour;
701     private int _durationMinute;
702     private boolean _allDay;
703     private boolean _timeZoneSensitive;
704     private String _type;
705     private boolean _repeating;
706     private String _recurrence;
707     private int _remindBy;
708     private int _firstReminder;
709     private int _secondReminder;
710     private transient ExpandoBridge _expandoBridge;
711 }