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