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