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