1
14
15 package com.liferay.portlet.calendar.model.impl;
16
17 import com.liferay.portal.kernel.bean.ReadOnlyBeanHandler;
18 import com.liferay.portal.kernel.exception.SystemException;
19 import com.liferay.portal.kernel.util.DateUtil;
20 import com.liferay.portal.kernel.util.GetterUtil;
21 import com.liferay.portal.kernel.util.HtmlUtil;
22 import com.liferay.portal.kernel.util.StringBundler;
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 return GetterUtil.getString(_uuid);
160 }
161
162 public void setUuid(String uuid) {
163 _uuid = uuid;
164
165 if (_originalUuid == null) {
166 _originalUuid = uuid;
167 }
168 }
169
170 public String getOriginalUuid() {
171 return GetterUtil.getString(_originalUuid);
172 }
173
174 public long getEventId() {
175 return _eventId;
176 }
177
178 public void setEventId(long eventId) {
179 _eventId = eventId;
180 }
181
182 public long getGroupId() {
183 return _groupId;
184 }
185
186 public void setGroupId(long groupId) {
187 _groupId = groupId;
188
189 if (!_setOriginalGroupId) {
190 _setOriginalGroupId = true;
191
192 _originalGroupId = groupId;
193 }
194 }
195
196 public long getOriginalGroupId() {
197 return _originalGroupId;
198 }
199
200 public long getCompanyId() {
201 return _companyId;
202 }
203
204 public void setCompanyId(long companyId) {
205 _companyId = companyId;
206 }
207
208 public long getUserId() {
209 return _userId;
210 }
211
212 public void setUserId(long userId) {
213 _userId = userId;
214 }
215
216 public String getUserUuid() throws SystemException {
217 return PortalUtil.getUserValue(getUserId(), "uuid", _userUuid);
218 }
219
220 public void setUserUuid(String userUuid) {
221 _userUuid = userUuid;
222 }
223
224 public String getUserName() {
225 return GetterUtil.getString(_userName);
226 }
227
228 public void setUserName(String userName) {
229 _userName = userName;
230 }
231
232 public Date getCreateDate() {
233 return _createDate;
234 }
235
236 public void setCreateDate(Date createDate) {
237 _createDate = createDate;
238 }
239
240 public Date getModifiedDate() {
241 return _modifiedDate;
242 }
243
244 public void setModifiedDate(Date modifiedDate) {
245 _modifiedDate = modifiedDate;
246 }
247
248 public String getTitle() {
249 return GetterUtil.getString(_title);
250 }
251
252 public void setTitle(String title) {
253 _title = title;
254 }
255
256 public String getDescription() {
257 return GetterUtil.getString(_description);
258 }
259
260 public void setDescription(String description) {
261 _description = description;
262 }
263
264 public Date getStartDate() {
265 return _startDate;
266 }
267
268 public void setStartDate(Date startDate) {
269 _startDate = startDate;
270 }
271
272 public Date getEndDate() {
273 return _endDate;
274 }
275
276 public void setEndDate(Date endDate) {
277 _endDate = endDate;
278 }
279
280 public int getDurationHour() {
281 return _durationHour;
282 }
283
284 public void setDurationHour(int durationHour) {
285 _durationHour = durationHour;
286 }
287
288 public int getDurationMinute() {
289 return _durationMinute;
290 }
291
292 public void setDurationMinute(int durationMinute) {
293 _durationMinute = durationMinute;
294 }
295
296 public boolean getAllDay() {
297 return _allDay;
298 }
299
300 public boolean isAllDay() {
301 return _allDay;
302 }
303
304 public void setAllDay(boolean allDay) {
305 _allDay = allDay;
306 }
307
308 public boolean getTimeZoneSensitive() {
309 return _timeZoneSensitive;
310 }
311
312 public boolean isTimeZoneSensitive() {
313 return _timeZoneSensitive;
314 }
315
316 public void setTimeZoneSensitive(boolean timeZoneSensitive) {
317 _timeZoneSensitive = timeZoneSensitive;
318 }
319
320 public String getType() {
321 return GetterUtil.getString(_type);
322 }
323
324 public void setType(String type) {
325 _type = type;
326 }
327
328 public boolean getRepeating() {
329 return _repeating;
330 }
331
332 public boolean isRepeating() {
333 return _repeating;
334 }
335
336 public void setRepeating(boolean repeating) {
337 _repeating = repeating;
338 }
339
340 public String getRecurrence() {
341 return GetterUtil.getString(_recurrence);
342 }
343
344 public void setRecurrence(String recurrence) {
345 _recurrence = recurrence;
346 }
347
348 public int getRemindBy() {
349 return _remindBy;
350 }
351
352 public void setRemindBy(int remindBy) {
353 _remindBy = remindBy;
354 }
355
356 public int getFirstReminder() {
357 return _firstReminder;
358 }
359
360 public void setFirstReminder(int firstReminder) {
361 _firstReminder = firstReminder;
362 }
363
364 public int getSecondReminder() {
365 return _secondReminder;
366 }
367
368 public void setSecondReminder(int secondReminder) {
369 _secondReminder = secondReminder;
370 }
371
372 public CalEvent toEscapedModel() {
373 if (isEscapedModel()) {
374 return (CalEvent)this;
375 }
376 else {
377 CalEvent model = new CalEventImpl();
378
379 model.setNew(isNew());
380 model.setEscapedModel(true);
381
382 model.setUuid(HtmlUtil.escape(getUuid()));
383 model.setEventId(getEventId());
384 model.setGroupId(getGroupId());
385 model.setCompanyId(getCompanyId());
386 model.setUserId(getUserId());
387 model.setUserName(HtmlUtil.escape(getUserName()));
388 model.setCreateDate(getCreateDate());
389 model.setModifiedDate(getModifiedDate());
390 model.setTitle(HtmlUtil.escape(getTitle()));
391 model.setDescription(HtmlUtil.escape(getDescription()));
392 model.setStartDate(getStartDate());
393 model.setEndDate(getEndDate());
394 model.setDurationHour(getDurationHour());
395 model.setDurationMinute(getDurationMinute());
396 model.setAllDay(getAllDay());
397 model.setTimeZoneSensitive(getTimeZoneSensitive());
398 model.setType(HtmlUtil.escape(getType()));
399 model.setRepeating(getRepeating());
400 model.setRecurrence(getRecurrence());
401 model.setRemindBy(getRemindBy());
402 model.setFirstReminder(getFirstReminder());
403 model.setSecondReminder(getSecondReminder());
404
405 model = (CalEvent)Proxy.newProxyInstance(CalEvent.class.getClassLoader(),
406 new Class[] { CalEvent.class },
407 new ReadOnlyBeanHandler(model));
408
409 return model;
410 }
411 }
412
413 public ExpandoBridge getExpandoBridge() {
414 if (_expandoBridge == null) {
415 _expandoBridge = ExpandoBridgeFactoryUtil.getExpandoBridge(getCompanyId(),
416 CalEvent.class.getName(), getPrimaryKey());
417 }
418
419 return _expandoBridge;
420 }
421
422 public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
423 getExpandoBridge().setAttributes(serviceContext);
424 }
425
426 public Object clone() {
427 CalEventImpl clone = new CalEventImpl();
428
429 clone.setUuid(getUuid());
430 clone.setEventId(getEventId());
431 clone.setGroupId(getGroupId());
432 clone.setCompanyId(getCompanyId());
433 clone.setUserId(getUserId());
434 clone.setUserName(getUserName());
435 clone.setCreateDate(getCreateDate());
436 clone.setModifiedDate(getModifiedDate());
437 clone.setTitle(getTitle());
438 clone.setDescription(getDescription());
439 clone.setStartDate(getStartDate());
440 clone.setEndDate(getEndDate());
441 clone.setDurationHour(getDurationHour());
442 clone.setDurationMinute(getDurationMinute());
443 clone.setAllDay(getAllDay());
444 clone.setTimeZoneSensitive(getTimeZoneSensitive());
445 clone.setType(getType());
446 clone.setRepeating(getRepeating());
447 clone.setRecurrence(getRecurrence());
448 clone.setRemindBy(getRemindBy());
449 clone.setFirstReminder(getFirstReminder());
450 clone.setSecondReminder(getSecondReminder());
451
452 return clone;
453 }
454
455 public int compareTo(CalEvent calEvent) {
456 int value = 0;
457
458 value = DateUtil.compareTo(getStartDate(), calEvent.getStartDate());
459
460 if (value != 0) {
461 return value;
462 }
463
464 value = getTitle().toLowerCase()
465 .compareTo(calEvent.getTitle().toLowerCase());
466
467 if (value != 0) {
468 return value;
469 }
470
471 return 0;
472 }
473
474 public boolean equals(Object obj) {
475 if (obj == null) {
476 return false;
477 }
478
479 CalEvent calEvent = null;
480
481 try {
482 calEvent = (CalEvent)obj;
483 }
484 catch (ClassCastException cce) {
485 return false;
486 }
487
488 long pk = calEvent.getPrimaryKey();
489
490 if (getPrimaryKey() == pk) {
491 return true;
492 }
493 else {
494 return false;
495 }
496 }
497
498 public int hashCode() {
499 return (int)getPrimaryKey();
500 }
501
502 public String toString() {
503 StringBundler sb = new StringBundler(45);
504
505 sb.append("{uuid=");
506 sb.append(getUuid());
507 sb.append(", eventId=");
508 sb.append(getEventId());
509 sb.append(", groupId=");
510 sb.append(getGroupId());
511 sb.append(", companyId=");
512 sb.append(getCompanyId());
513 sb.append(", userId=");
514 sb.append(getUserId());
515 sb.append(", userName=");
516 sb.append(getUserName());
517 sb.append(", createDate=");
518 sb.append(getCreateDate());
519 sb.append(", modifiedDate=");
520 sb.append(getModifiedDate());
521 sb.append(", title=");
522 sb.append(getTitle());
523 sb.append(", description=");
524 sb.append(getDescription());
525 sb.append(", startDate=");
526 sb.append(getStartDate());
527 sb.append(", endDate=");
528 sb.append(getEndDate());
529 sb.append(", durationHour=");
530 sb.append(getDurationHour());
531 sb.append(", durationMinute=");
532 sb.append(getDurationMinute());
533 sb.append(", allDay=");
534 sb.append(getAllDay());
535 sb.append(", timeZoneSensitive=");
536 sb.append(getTimeZoneSensitive());
537 sb.append(", type=");
538 sb.append(getType());
539 sb.append(", repeating=");
540 sb.append(getRepeating());
541 sb.append(", recurrence=");
542 sb.append(getRecurrence());
543 sb.append(", remindBy=");
544 sb.append(getRemindBy());
545 sb.append(", firstReminder=");
546 sb.append(getFirstReminder());
547 sb.append(", secondReminder=");
548 sb.append(getSecondReminder());
549 sb.append("}");
550
551 return sb.toString();
552 }
553
554 public String toXmlString() {
555 StringBundler sb = new StringBundler(70);
556
557 sb.append("<model><model-name>");
558 sb.append("com.liferay.portlet.calendar.model.CalEvent");
559 sb.append("</model-name>");
560
561 sb.append(
562 "<column><column-name>uuid</column-name><column-value><![CDATA[");
563 sb.append(getUuid());
564 sb.append("]]></column-value></column>");
565 sb.append(
566 "<column><column-name>eventId</column-name><column-value><![CDATA[");
567 sb.append(getEventId());
568 sb.append("]]></column-value></column>");
569 sb.append(
570 "<column><column-name>groupId</column-name><column-value><![CDATA[");
571 sb.append(getGroupId());
572 sb.append("]]></column-value></column>");
573 sb.append(
574 "<column><column-name>companyId</column-name><column-value><![CDATA[");
575 sb.append(getCompanyId());
576 sb.append("]]></column-value></column>");
577 sb.append(
578 "<column><column-name>userId</column-name><column-value><![CDATA[");
579 sb.append(getUserId());
580 sb.append("]]></column-value></column>");
581 sb.append(
582 "<column><column-name>userName</column-name><column-value><![CDATA[");
583 sb.append(getUserName());
584 sb.append("]]></column-value></column>");
585 sb.append(
586 "<column><column-name>createDate</column-name><column-value><![CDATA[");
587 sb.append(getCreateDate());
588 sb.append("]]></column-value></column>");
589 sb.append(
590 "<column><column-name>modifiedDate</column-name><column-value><![CDATA[");
591 sb.append(getModifiedDate());
592 sb.append("]]></column-value></column>");
593 sb.append(
594 "<column><column-name>title</column-name><column-value><![CDATA[");
595 sb.append(getTitle());
596 sb.append("]]></column-value></column>");
597 sb.append(
598 "<column><column-name>description</column-name><column-value><![CDATA[");
599 sb.append(getDescription());
600 sb.append("]]></column-value></column>");
601 sb.append(
602 "<column><column-name>startDate</column-name><column-value><![CDATA[");
603 sb.append(getStartDate());
604 sb.append("]]></column-value></column>");
605 sb.append(
606 "<column><column-name>endDate</column-name><column-value><![CDATA[");
607 sb.append(getEndDate());
608 sb.append("]]></column-value></column>");
609 sb.append(
610 "<column><column-name>durationHour</column-name><column-value><![CDATA[");
611 sb.append(getDurationHour());
612 sb.append("]]></column-value></column>");
613 sb.append(
614 "<column><column-name>durationMinute</column-name><column-value><![CDATA[");
615 sb.append(getDurationMinute());
616 sb.append("]]></column-value></column>");
617 sb.append(
618 "<column><column-name>allDay</column-name><column-value><![CDATA[");
619 sb.append(getAllDay());
620 sb.append("]]></column-value></column>");
621 sb.append(
622 "<column><column-name>timeZoneSensitive</column-name><column-value><![CDATA[");
623 sb.append(getTimeZoneSensitive());
624 sb.append("]]></column-value></column>");
625 sb.append(
626 "<column><column-name>type</column-name><column-value><![CDATA[");
627 sb.append(getType());
628 sb.append("]]></column-value></column>");
629 sb.append(
630 "<column><column-name>repeating</column-name><column-value><![CDATA[");
631 sb.append(getRepeating());
632 sb.append("]]></column-value></column>");
633 sb.append(
634 "<column><column-name>recurrence</column-name><column-value><![CDATA[");
635 sb.append(getRecurrence());
636 sb.append("]]></column-value></column>");
637 sb.append(
638 "<column><column-name>remindBy</column-name><column-value><![CDATA[");
639 sb.append(getRemindBy());
640 sb.append("]]></column-value></column>");
641 sb.append(
642 "<column><column-name>firstReminder</column-name><column-value><![CDATA[");
643 sb.append(getFirstReminder());
644 sb.append("]]></column-value></column>");
645 sb.append(
646 "<column><column-name>secondReminder</column-name><column-value><![CDATA[");
647 sb.append(getSecondReminder());
648 sb.append("]]></column-value></column>");
649
650 sb.append("</model>");
651
652 return sb.toString();
653 }
654
655 private String _uuid;
656 private String _originalUuid;
657 private long _eventId;
658 private long _groupId;
659 private long _originalGroupId;
660 private boolean _setOriginalGroupId;
661 private long _companyId;
662 private long _userId;
663 private String _userUuid;
664 private String _userName;
665 private Date _createDate;
666 private Date _modifiedDate;
667 private String _title;
668 private String _description;
669 private Date _startDate;
670 private Date _endDate;
671 private int _durationHour;
672 private int _durationMinute;
673 private boolean _allDay;
674 private boolean _timeZoneSensitive;
675 private String _type;
676 private boolean _repeating;
677 private String _recurrence;
678 private int _remindBy;
679 private int _firstReminder;
680 private int _secondReminder;
681 private transient ExpandoBridge _expandoBridge;
682 }