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