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