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