1
22
23 package com.liferay.portlet.calendar.service.persistence;
24
25 import com.liferay.portal.SystemException;
26 import com.liferay.portal.kernel.annotation.BeanReference;
27 import com.liferay.portal.kernel.cache.CacheRegistry;
28 import com.liferay.portal.kernel.dao.orm.DynamicQuery;
29 import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
30 import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
31 import com.liferay.portal.kernel.dao.orm.FinderPath;
32 import com.liferay.portal.kernel.dao.orm.Query;
33 import com.liferay.portal.kernel.dao.orm.QueryPos;
34 import com.liferay.portal.kernel.dao.orm.QueryUtil;
35 import com.liferay.portal.kernel.dao.orm.Session;
36 import com.liferay.portal.kernel.log.Log;
37 import com.liferay.portal.kernel.log.LogFactoryUtil;
38 import com.liferay.portal.kernel.util.GetterUtil;
39 import com.liferay.portal.kernel.util.OrderByComparator;
40 import com.liferay.portal.kernel.util.StringPool;
41 import com.liferay.portal.kernel.util.StringUtil;
42 import com.liferay.portal.kernel.util.Validator;
43 import com.liferay.portal.kernel.uuid.PortalUUIDUtil;
44 import com.liferay.portal.model.ModelListener;
45 import com.liferay.portal.service.persistence.BatchSessionUtil;
46 import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
47
48 import com.liferay.portlet.calendar.NoSuchEventException;
49 import com.liferay.portlet.calendar.model.CalEvent;
50 import com.liferay.portlet.calendar.model.impl.CalEventImpl;
51 import com.liferay.portlet.calendar.model.impl.CalEventModelImpl;
52
53 import java.util.ArrayList;
54 import java.util.Collections;
55 import java.util.List;
56
57
70 public class CalEventPersistenceImpl extends BasePersistenceImpl
71 implements CalEventPersistence {
72 public static final String FINDER_CLASS_NAME_ENTITY = CalEventImpl.class.getName();
73 public static final String FINDER_CLASS_NAME_LIST = FINDER_CLASS_NAME_ENTITY +
74 ".List";
75 public static final FinderPath FINDER_PATH_FIND_BY_UUID = new FinderPath(CalEventModelImpl.ENTITY_CACHE_ENABLED,
76 CalEventModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
77 "findByUuid", new String[] { String.class.getName() });
78 public static final FinderPath FINDER_PATH_FIND_BY_OBC_UUID = new FinderPath(CalEventModelImpl.ENTITY_CACHE_ENABLED,
79 CalEventModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
80 "findByUuid",
81 new String[] {
82 String.class.getName(),
83
84 "java.lang.Integer", "java.lang.Integer",
85 "com.liferay.portal.kernel.util.OrderByComparator"
86 });
87 public static final FinderPath FINDER_PATH_COUNT_BY_UUID = new FinderPath(CalEventModelImpl.ENTITY_CACHE_ENABLED,
88 CalEventModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
89 "countByUuid", new String[] { String.class.getName() });
90 public static final FinderPath FINDER_PATH_FETCH_BY_UUID_G = new FinderPath(CalEventModelImpl.ENTITY_CACHE_ENABLED,
91 CalEventModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_ENTITY,
92 "fetchByUUID_G",
93 new String[] { String.class.getName(), Long.class.getName() });
94 public static final FinderPath FINDER_PATH_COUNT_BY_UUID_G = new FinderPath(CalEventModelImpl.ENTITY_CACHE_ENABLED,
95 CalEventModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
96 "countByUUID_G",
97 new String[] { String.class.getName(), Long.class.getName() });
98 public static final FinderPath FINDER_PATH_FIND_BY_COMPANYID = new FinderPath(CalEventModelImpl.ENTITY_CACHE_ENABLED,
99 CalEventModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
100 "findByCompanyId", new String[] { Long.class.getName() });
101 public static final FinderPath FINDER_PATH_FIND_BY_OBC_COMPANYID = new FinderPath(CalEventModelImpl.ENTITY_CACHE_ENABLED,
102 CalEventModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
103 "findByCompanyId",
104 new String[] {
105 Long.class.getName(),
106
107 "java.lang.Integer", "java.lang.Integer",
108 "com.liferay.portal.kernel.util.OrderByComparator"
109 });
110 public static final FinderPath FINDER_PATH_COUNT_BY_COMPANYID = new FinderPath(CalEventModelImpl.ENTITY_CACHE_ENABLED,
111 CalEventModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
112 "countByCompanyId", new String[] { Long.class.getName() });
113 public static final FinderPath FINDER_PATH_FIND_BY_GROUPID = new FinderPath(CalEventModelImpl.ENTITY_CACHE_ENABLED,
114 CalEventModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
115 "findByGroupId", new String[] { Long.class.getName() });
116 public static final FinderPath FINDER_PATH_FIND_BY_OBC_GROUPID = new FinderPath(CalEventModelImpl.ENTITY_CACHE_ENABLED,
117 CalEventModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
118 "findByGroupId",
119 new String[] {
120 Long.class.getName(),
121
122 "java.lang.Integer", "java.lang.Integer",
123 "com.liferay.portal.kernel.util.OrderByComparator"
124 });
125 public static final FinderPath FINDER_PATH_COUNT_BY_GROUPID = new FinderPath(CalEventModelImpl.ENTITY_CACHE_ENABLED,
126 CalEventModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
127 "countByGroupId", new String[] { Long.class.getName() });
128 public static final FinderPath FINDER_PATH_FIND_BY_REMINDBY = new FinderPath(CalEventModelImpl.ENTITY_CACHE_ENABLED,
129 CalEventModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
130 "findByRemindBy", new String[] { Integer.class.getName() });
131 public static final FinderPath FINDER_PATH_FIND_BY_OBC_REMINDBY = new FinderPath(CalEventModelImpl.ENTITY_CACHE_ENABLED,
132 CalEventModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
133 "findByRemindBy",
134 new String[] {
135 Integer.class.getName(),
136
137 "java.lang.Integer", "java.lang.Integer",
138 "com.liferay.portal.kernel.util.OrderByComparator"
139 });
140 public static final FinderPath FINDER_PATH_COUNT_BY_REMINDBY = new FinderPath(CalEventModelImpl.ENTITY_CACHE_ENABLED,
141 CalEventModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
142 "countByRemindBy", new String[] { Integer.class.getName() });
143 public static final FinderPath FINDER_PATH_FIND_BY_G_T = new FinderPath(CalEventModelImpl.ENTITY_CACHE_ENABLED,
144 CalEventModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
145 "findByG_T",
146 new String[] { Long.class.getName(), String.class.getName() });
147 public static final FinderPath FINDER_PATH_FIND_BY_OBC_G_T = new FinderPath(CalEventModelImpl.ENTITY_CACHE_ENABLED,
148 CalEventModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
149 "findByG_T",
150 new String[] {
151 Long.class.getName(), String.class.getName(),
152
153 "java.lang.Integer", "java.lang.Integer",
154 "com.liferay.portal.kernel.util.OrderByComparator"
155 });
156 public static final FinderPath FINDER_PATH_COUNT_BY_G_T = new FinderPath(CalEventModelImpl.ENTITY_CACHE_ENABLED,
157 CalEventModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
158 "countByG_T",
159 new String[] { Long.class.getName(), String.class.getName() });
160 public static final FinderPath FINDER_PATH_FIND_BY_G_R = new FinderPath(CalEventModelImpl.ENTITY_CACHE_ENABLED,
161 CalEventModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
162 "findByG_R",
163 new String[] { Long.class.getName(), Boolean.class.getName() });
164 public static final FinderPath FINDER_PATH_FIND_BY_OBC_G_R = new FinderPath(CalEventModelImpl.ENTITY_CACHE_ENABLED,
165 CalEventModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
166 "findByG_R",
167 new String[] {
168 Long.class.getName(), Boolean.class.getName(),
169
170 "java.lang.Integer", "java.lang.Integer",
171 "com.liferay.portal.kernel.util.OrderByComparator"
172 });
173 public static final FinderPath FINDER_PATH_COUNT_BY_G_R = new FinderPath(CalEventModelImpl.ENTITY_CACHE_ENABLED,
174 CalEventModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
175 "countByG_R",
176 new String[] { Long.class.getName(), Boolean.class.getName() });
177 public static final FinderPath FINDER_PATH_FIND_ALL = new FinderPath(CalEventModelImpl.ENTITY_CACHE_ENABLED,
178 CalEventModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
179 "findAll", new String[0]);
180 public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(CalEventModelImpl.ENTITY_CACHE_ENABLED,
181 CalEventModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
182 "countAll", new String[0]);
183
184 public void cacheResult(CalEvent calEvent) {
185 EntityCacheUtil.putResult(CalEventModelImpl.ENTITY_CACHE_ENABLED,
186 CalEventImpl.class, calEvent.getPrimaryKey(), calEvent);
187
188 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
189 new Object[] { calEvent.getUuid(), new Long(calEvent.getGroupId()) },
190 calEvent);
191 }
192
193 public void cacheResult(List<CalEvent> calEvents) {
194 for (CalEvent calEvent : calEvents) {
195 if (EntityCacheUtil.getResult(
196 CalEventModelImpl.ENTITY_CACHE_ENABLED,
197 CalEventImpl.class, calEvent.getPrimaryKey(), this) == null) {
198 cacheResult(calEvent);
199 }
200 }
201 }
202
203 public void clearCache() {
204 CacheRegistry.clear(CalEventImpl.class.getName());
205 EntityCacheUtil.clearCache(CalEventImpl.class.getName());
206 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
207 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
208 }
209
210 public CalEvent create(long eventId) {
211 CalEvent calEvent = new CalEventImpl();
212
213 calEvent.setNew(true);
214 calEvent.setPrimaryKey(eventId);
215
216 String uuid = PortalUUIDUtil.generate();
217
218 calEvent.setUuid(uuid);
219
220 return calEvent;
221 }
222
223 public CalEvent remove(long eventId)
224 throws NoSuchEventException, SystemException {
225 Session session = null;
226
227 try {
228 session = openSession();
229
230 CalEvent calEvent = (CalEvent)session.get(CalEventImpl.class,
231 new Long(eventId));
232
233 if (calEvent == null) {
234 if (_log.isWarnEnabled()) {
235 _log.warn("No CalEvent exists with the primary key " +
236 eventId);
237 }
238
239 throw new NoSuchEventException(
240 "No CalEvent exists with the primary key " + eventId);
241 }
242
243 return remove(calEvent);
244 }
245 catch (NoSuchEventException nsee) {
246 throw nsee;
247 }
248 catch (Exception e) {
249 throw processException(e);
250 }
251 finally {
252 closeSession(session);
253 }
254 }
255
256 public CalEvent remove(CalEvent calEvent) throws SystemException {
257 for (ModelListener<CalEvent> listener : listeners) {
258 listener.onBeforeRemove(calEvent);
259 }
260
261 calEvent = removeImpl(calEvent);
262
263 for (ModelListener<CalEvent> listener : listeners) {
264 listener.onAfterRemove(calEvent);
265 }
266
267 return calEvent;
268 }
269
270 protected CalEvent removeImpl(CalEvent calEvent) throws SystemException {
271 calEvent = toUnwrappedModel(calEvent);
272
273 Session session = null;
274
275 try {
276 session = openSession();
277
278 if (calEvent.isCachedModel() || BatchSessionUtil.isEnabled()) {
279 Object staleObject = session.get(CalEventImpl.class,
280 calEvent.getPrimaryKeyObj());
281
282 if (staleObject != null) {
283 session.evict(staleObject);
284 }
285 }
286
287 session.delete(calEvent);
288
289 session.flush();
290 }
291 catch (Exception e) {
292 throw processException(e);
293 }
294 finally {
295 closeSession(session);
296 }
297
298 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
299
300 CalEventModelImpl calEventModelImpl = (CalEventModelImpl)calEvent;
301
302 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G,
303 new Object[] {
304 calEventModelImpl.getOriginalUuid(),
305 new Long(calEventModelImpl.getOriginalGroupId())
306 });
307
308 EntityCacheUtil.removeResult(CalEventModelImpl.ENTITY_CACHE_ENABLED,
309 CalEventImpl.class, calEvent.getPrimaryKey());
310
311 return calEvent;
312 }
313
314
317 public CalEvent update(CalEvent calEvent) throws SystemException {
318 if (_log.isWarnEnabled()) {
319 _log.warn(
320 "Using the deprecated update(CalEvent calEvent) method. Use update(CalEvent calEvent, boolean merge) instead.");
321 }
322
323 return update(calEvent, false);
324 }
325
326
338 public CalEvent update(CalEvent calEvent, boolean merge)
339 throws SystemException {
340 boolean isNew = calEvent.isNew();
341
342 for (ModelListener<CalEvent> listener : listeners) {
343 if (isNew) {
344 listener.onBeforeCreate(calEvent);
345 }
346 else {
347 listener.onBeforeUpdate(calEvent);
348 }
349 }
350
351 calEvent = updateImpl(calEvent, merge);
352
353 for (ModelListener<CalEvent> listener : listeners) {
354 if (isNew) {
355 listener.onAfterCreate(calEvent);
356 }
357 else {
358 listener.onAfterUpdate(calEvent);
359 }
360 }
361
362 return calEvent;
363 }
364
365 public CalEvent updateImpl(
366 com.liferay.portlet.calendar.model.CalEvent calEvent, boolean merge)
367 throws SystemException {
368 calEvent = toUnwrappedModel(calEvent);
369
370 boolean isNew = calEvent.isNew();
371
372 CalEventModelImpl calEventModelImpl = (CalEventModelImpl)calEvent;
373
374 if (Validator.isNull(calEvent.getUuid())) {
375 String uuid = PortalUUIDUtil.generate();
376
377 calEvent.setUuid(uuid);
378 }
379
380 Session session = null;
381
382 try {
383 session = openSession();
384
385 BatchSessionUtil.update(session, calEvent, merge);
386
387 calEvent.setNew(false);
388 }
389 catch (Exception e) {
390 throw processException(e);
391 }
392 finally {
393 closeSession(session);
394 }
395
396 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
397
398 EntityCacheUtil.putResult(CalEventModelImpl.ENTITY_CACHE_ENABLED,
399 CalEventImpl.class, calEvent.getPrimaryKey(), calEvent);
400
401 if (!isNew &&
402 (!Validator.equals(calEvent.getUuid(),
403 calEventModelImpl.getOriginalUuid()) ||
404 (calEvent.getGroupId() != calEventModelImpl.getOriginalGroupId()))) {
405 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G,
406 new Object[] {
407 calEventModelImpl.getOriginalUuid(),
408 new Long(calEventModelImpl.getOriginalGroupId())
409 });
410 }
411
412 if (isNew ||
413 (!Validator.equals(calEvent.getUuid(),
414 calEventModelImpl.getOriginalUuid()) ||
415 (calEvent.getGroupId() != calEventModelImpl.getOriginalGroupId()))) {
416 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
417 new Object[] { calEvent.getUuid(), new Long(
418 calEvent.getGroupId()) }, calEvent);
419 }
420
421 return calEvent;
422 }
423
424 protected CalEvent toUnwrappedModel(CalEvent calEvent) {
425 if (calEvent instanceof CalEventImpl) {
426 return calEvent;
427 }
428
429 CalEventImpl calEventImpl = new CalEventImpl();
430
431 calEventImpl.setNew(calEvent.isNew());
432 calEventImpl.setPrimaryKey(calEvent.getPrimaryKey());
433
434 calEventImpl.setUuid(calEvent.getUuid());
435 calEventImpl.setEventId(calEvent.getEventId());
436 calEventImpl.setGroupId(calEvent.getGroupId());
437 calEventImpl.setCompanyId(calEvent.getCompanyId());
438 calEventImpl.setUserId(calEvent.getUserId());
439 calEventImpl.setUserName(calEvent.getUserName());
440 calEventImpl.setCreateDate(calEvent.getCreateDate());
441 calEventImpl.setModifiedDate(calEvent.getModifiedDate());
442 calEventImpl.setTitle(calEvent.getTitle());
443 calEventImpl.setDescription(calEvent.getDescription());
444 calEventImpl.setStartDate(calEvent.getStartDate());
445 calEventImpl.setEndDate(calEvent.getEndDate());
446 calEventImpl.setDurationHour(calEvent.getDurationHour());
447 calEventImpl.setDurationMinute(calEvent.getDurationMinute());
448 calEventImpl.setAllDay(calEvent.isAllDay());
449 calEventImpl.setTimeZoneSensitive(calEvent.isTimeZoneSensitive());
450 calEventImpl.setType(calEvent.getType());
451 calEventImpl.setRepeating(calEvent.isRepeating());
452 calEventImpl.setRecurrence(calEvent.getRecurrence());
453 calEventImpl.setRemindBy(calEvent.getRemindBy());
454 calEventImpl.setFirstReminder(calEvent.getFirstReminder());
455 calEventImpl.setSecondReminder(calEvent.getSecondReminder());
456
457 return calEventImpl;
458 }
459
460 public CalEvent findByPrimaryKey(long eventId)
461 throws NoSuchEventException, SystemException {
462 CalEvent calEvent = fetchByPrimaryKey(eventId);
463
464 if (calEvent == null) {
465 if (_log.isWarnEnabled()) {
466 _log.warn("No CalEvent exists with the primary key " + eventId);
467 }
468
469 throw new NoSuchEventException(
470 "No CalEvent exists with the primary key " + eventId);
471 }
472
473 return calEvent;
474 }
475
476 public CalEvent fetchByPrimaryKey(long eventId) throws SystemException {
477 CalEvent calEvent = (CalEvent)EntityCacheUtil.getResult(CalEventModelImpl.ENTITY_CACHE_ENABLED,
478 CalEventImpl.class, eventId, this);
479
480 if (calEvent == null) {
481 Session session = null;
482
483 try {
484 session = openSession();
485
486 calEvent = (CalEvent)session.get(CalEventImpl.class,
487 new Long(eventId));
488 }
489 catch (Exception e) {
490 throw processException(e);
491 }
492 finally {
493 if (calEvent != null) {
494 cacheResult(calEvent);
495 }
496
497 closeSession(session);
498 }
499 }
500
501 return calEvent;
502 }
503
504 public List<CalEvent> findByUuid(String uuid) throws SystemException {
505 Object[] finderArgs = new Object[] { uuid };
506
507 List<CalEvent> list = (List<CalEvent>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_UUID,
508 finderArgs, this);
509
510 if (list == null) {
511 Session session = null;
512
513 try {
514 session = openSession();
515
516 StringBuilder query = new StringBuilder();
517
518 query.append("SELECT calEvent FROM CalEvent calEvent WHERE ");
519
520 if (uuid == null) {
521 query.append("calEvent.uuid IS NULL");
522 }
523 else {
524 query.append("calEvent.uuid = ?");
525 }
526
527 query.append(" ");
528
529 query.append("ORDER BY ");
530
531 query.append("calEvent.startDate ASC, ");
532 query.append("calEvent.title ASC");
533
534 Query q = session.createQuery(query.toString());
535
536 QueryPos qPos = QueryPos.getInstance(q);
537
538 if (uuid != null) {
539 qPos.add(uuid);
540 }
541
542 list = q.list();
543 }
544 catch (Exception e) {
545 throw processException(e);
546 }
547 finally {
548 if (list == null) {
549 list = new ArrayList<CalEvent>();
550 }
551
552 cacheResult(list);
553
554 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_UUID, finderArgs,
555 list);
556
557 closeSession(session);
558 }
559 }
560
561 return list;
562 }
563
564 public List<CalEvent> findByUuid(String uuid, int start, int end)
565 throws SystemException {
566 return findByUuid(uuid, start, end, null);
567 }
568
569 public List<CalEvent> findByUuid(String uuid, int start, int end,
570 OrderByComparator obc) throws SystemException {
571 Object[] finderArgs = new Object[] {
572 uuid,
573
574 String.valueOf(start), String.valueOf(end), String.valueOf(obc)
575 };
576
577 List<CalEvent> list = (List<CalEvent>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_OBC_UUID,
578 finderArgs, this);
579
580 if (list == null) {
581 Session session = null;
582
583 try {
584 session = openSession();
585
586 StringBuilder query = new StringBuilder();
587
588 query.append("SELECT calEvent FROM CalEvent calEvent WHERE ");
589
590 if (uuid == null) {
591 query.append("calEvent.uuid IS NULL");
592 }
593 else {
594 query.append("calEvent.uuid = ?");
595 }
596
597 query.append(" ");
598
599 if (obc != null) {
600 query.append("ORDER BY ");
601
602 String[] orderByFields = obc.getOrderByFields();
603
604 for (int i = 0; i < orderByFields.length; i++) {
605 query.append("calEvent.");
606 query.append(orderByFields[i]);
607
608 if (obc.isAscending()) {
609 query.append(" ASC");
610 }
611 else {
612 query.append(" DESC");
613 }
614
615 if ((i + 1) < orderByFields.length) {
616 query.append(", ");
617 }
618 }
619 }
620
621 else {
622 query.append("ORDER BY ");
623
624 query.append("calEvent.startDate ASC, ");
625 query.append("calEvent.title ASC");
626 }
627
628 Query q = session.createQuery(query.toString());
629
630 QueryPos qPos = QueryPos.getInstance(q);
631
632 if (uuid != null) {
633 qPos.add(uuid);
634 }
635
636 list = (List<CalEvent>)QueryUtil.list(q, getDialect(), start,
637 end);
638 }
639 catch (Exception e) {
640 throw processException(e);
641 }
642 finally {
643 if (list == null) {
644 list = new ArrayList<CalEvent>();
645 }
646
647 cacheResult(list);
648
649 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_OBC_UUID,
650 finderArgs, list);
651
652 closeSession(session);
653 }
654 }
655
656 return list;
657 }
658
659 public CalEvent findByUuid_First(String uuid, OrderByComparator obc)
660 throws NoSuchEventException, SystemException {
661 List<CalEvent> list = findByUuid(uuid, 0, 1, obc);
662
663 if (list.isEmpty()) {
664 StringBuilder msg = new StringBuilder();
665
666 msg.append("No CalEvent exists with the key {");
667
668 msg.append("uuid=" + uuid);
669
670 msg.append(StringPool.CLOSE_CURLY_BRACE);
671
672 throw new NoSuchEventException(msg.toString());
673 }
674 else {
675 return list.get(0);
676 }
677 }
678
679 public CalEvent findByUuid_Last(String uuid, OrderByComparator obc)
680 throws NoSuchEventException, SystemException {
681 int count = countByUuid(uuid);
682
683 List<CalEvent> list = findByUuid(uuid, count - 1, count, obc);
684
685 if (list.isEmpty()) {
686 StringBuilder msg = new StringBuilder();
687
688 msg.append("No CalEvent exists with the key {");
689
690 msg.append("uuid=" + uuid);
691
692 msg.append(StringPool.CLOSE_CURLY_BRACE);
693
694 throw new NoSuchEventException(msg.toString());
695 }
696 else {
697 return list.get(0);
698 }
699 }
700
701 public CalEvent[] findByUuid_PrevAndNext(long eventId, String uuid,
702 OrderByComparator obc) throws NoSuchEventException, SystemException {
703 CalEvent calEvent = findByPrimaryKey(eventId);
704
705 int count = countByUuid(uuid);
706
707 Session session = null;
708
709 try {
710 session = openSession();
711
712 StringBuilder query = new StringBuilder();
713
714 query.append("SELECT calEvent FROM CalEvent calEvent WHERE ");
715
716 if (uuid == null) {
717 query.append("calEvent.uuid IS NULL");
718 }
719 else {
720 query.append("calEvent.uuid = ?");
721 }
722
723 query.append(" ");
724
725 if (obc != null) {
726 query.append("ORDER BY ");
727
728 String[] orderByFields = obc.getOrderByFields();
729
730 for (int i = 0; i < orderByFields.length; i++) {
731 query.append("calEvent.");
732 query.append(orderByFields[i]);
733
734 if (obc.isAscending()) {
735 query.append(" ASC");
736 }
737 else {
738 query.append(" DESC");
739 }
740
741 if ((i + 1) < orderByFields.length) {
742 query.append(", ");
743 }
744 }
745 }
746
747 else {
748 query.append("ORDER BY ");
749
750 query.append("calEvent.startDate ASC, ");
751 query.append("calEvent.title ASC");
752 }
753
754 Query q = session.createQuery(query.toString());
755
756 QueryPos qPos = QueryPos.getInstance(q);
757
758 if (uuid != null) {
759 qPos.add(uuid);
760 }
761
762 Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc, calEvent);
763
764 CalEvent[] array = new CalEventImpl[3];
765
766 array[0] = (CalEvent)objArray[0];
767 array[1] = (CalEvent)objArray[1];
768 array[2] = (CalEvent)objArray[2];
769
770 return array;
771 }
772 catch (Exception e) {
773 throw processException(e);
774 }
775 finally {
776 closeSession(session);
777 }
778 }
779
780 public CalEvent findByUUID_G(String uuid, long groupId)
781 throws NoSuchEventException, SystemException {
782 CalEvent calEvent = fetchByUUID_G(uuid, groupId);
783
784 if (calEvent == null) {
785 StringBuilder msg = new StringBuilder();
786
787 msg.append("No CalEvent exists with the key {");
788
789 msg.append("uuid=" + uuid);
790
791 msg.append(", ");
792 msg.append("groupId=" + groupId);
793
794 msg.append(StringPool.CLOSE_CURLY_BRACE);
795
796 if (_log.isWarnEnabled()) {
797 _log.warn(msg.toString());
798 }
799
800 throw new NoSuchEventException(msg.toString());
801 }
802
803 return calEvent;
804 }
805
806 public CalEvent fetchByUUID_G(String uuid, long groupId)
807 throws SystemException {
808 return fetchByUUID_G(uuid, groupId, true);
809 }
810
811 public CalEvent fetchByUUID_G(String uuid, long groupId,
812 boolean retrieveFromCache) throws SystemException {
813 Object[] finderArgs = new Object[] { uuid, new Long(groupId) };
814
815 Object result = null;
816
817 if (retrieveFromCache) {
818 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_UUID_G,
819 finderArgs, this);
820 }
821
822 if (result == null) {
823 Session session = null;
824
825 try {
826 session = openSession();
827
828 StringBuilder query = new StringBuilder();
829
830 query.append("SELECT calEvent FROM CalEvent calEvent WHERE ");
831
832 if (uuid == null) {
833 query.append("calEvent.uuid IS NULL");
834 }
835 else {
836 query.append("calEvent.uuid = ?");
837 }
838
839 query.append(" AND ");
840
841 query.append("calEvent.groupId = ?");
842
843 query.append(" ");
844
845 query.append("ORDER BY ");
846
847 query.append("calEvent.startDate ASC, ");
848 query.append("calEvent.title ASC");
849
850 Query q = session.createQuery(query.toString());
851
852 QueryPos qPos = QueryPos.getInstance(q);
853
854 if (uuid != null) {
855 qPos.add(uuid);
856 }
857
858 qPos.add(groupId);
859
860 List<CalEvent> list = q.list();
861
862 result = list;
863
864 CalEvent calEvent = null;
865
866 if (list.isEmpty()) {
867 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
868 finderArgs, list);
869 }
870 else {
871 calEvent = list.get(0);
872
873 cacheResult(calEvent);
874
875 if ((calEvent.getUuid() == null) ||
876 !calEvent.getUuid().equals(uuid) ||
877 (calEvent.getGroupId() != groupId)) {
878 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
879 finderArgs, calEvent);
880 }
881 }
882
883 return calEvent;
884 }
885 catch (Exception e) {
886 throw processException(e);
887 }
888 finally {
889 if (result == null) {
890 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
891 finderArgs, new ArrayList<CalEvent>());
892 }
893
894 closeSession(session);
895 }
896 }
897 else {
898 if (result instanceof List<?>) {
899 return null;
900 }
901 else {
902 return (CalEvent)result;
903 }
904 }
905 }
906
907 public List<CalEvent> findByCompanyId(long companyId)
908 throws SystemException {
909 Object[] finderArgs = new Object[] { new Long(companyId) };
910
911 List<CalEvent> list = (List<CalEvent>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_COMPANYID,
912 finderArgs, this);
913
914 if (list == null) {
915 Session session = null;
916
917 try {
918 session = openSession();
919
920 StringBuilder query = new StringBuilder();
921
922 query.append("SELECT calEvent FROM CalEvent calEvent WHERE ");
923
924 query.append("calEvent.companyId = ?");
925
926 query.append(" ");
927
928 query.append("ORDER BY ");
929
930 query.append("calEvent.startDate ASC, ");
931 query.append("calEvent.title ASC");
932
933 Query q = session.createQuery(query.toString());
934
935 QueryPos qPos = QueryPos.getInstance(q);
936
937 qPos.add(companyId);
938
939 list = q.list();
940 }
941 catch (Exception e) {
942 throw processException(e);
943 }
944 finally {
945 if (list == null) {
946 list = new ArrayList<CalEvent>();
947 }
948
949 cacheResult(list);
950
951 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_COMPANYID,
952 finderArgs, list);
953
954 closeSession(session);
955 }
956 }
957
958 return list;
959 }
960
961 public List<CalEvent> findByCompanyId(long companyId, int start, int end)
962 throws SystemException {
963 return findByCompanyId(companyId, start, end, null);
964 }
965
966 public List<CalEvent> findByCompanyId(long companyId, int start, int end,
967 OrderByComparator obc) throws SystemException {
968 Object[] finderArgs = new Object[] {
969 new Long(companyId),
970
971 String.valueOf(start), String.valueOf(end), String.valueOf(obc)
972 };
973
974 List<CalEvent> list = (List<CalEvent>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_OBC_COMPANYID,
975 finderArgs, this);
976
977 if (list == null) {
978 Session session = null;
979
980 try {
981 session = openSession();
982
983 StringBuilder query = new StringBuilder();
984
985 query.append("SELECT calEvent FROM CalEvent calEvent WHERE ");
986
987 query.append("calEvent.companyId = ?");
988
989 query.append(" ");
990
991 if (obc != null) {
992 query.append("ORDER BY ");
993
994 String[] orderByFields = obc.getOrderByFields();
995
996 for (int i = 0; i < orderByFields.length; i++) {
997 query.append("calEvent.");
998 query.append(orderByFields[i]);
999
1000 if (obc.isAscending()) {
1001 query.append(" ASC");
1002 }
1003 else {
1004 query.append(" DESC");
1005 }
1006
1007 if ((i + 1) < orderByFields.length) {
1008 query.append(", ");
1009 }
1010 }
1011 }
1012
1013 else {
1014 query.append("ORDER BY ");
1015
1016 query.append("calEvent.startDate ASC, ");
1017 query.append("calEvent.title ASC");
1018 }
1019
1020 Query q = session.createQuery(query.toString());
1021
1022 QueryPos qPos = QueryPos.getInstance(q);
1023
1024 qPos.add(companyId);
1025
1026 list = (List<CalEvent>)QueryUtil.list(q, getDialect(), start,
1027 end);
1028 }
1029 catch (Exception e) {
1030 throw processException(e);
1031 }
1032 finally {
1033 if (list == null) {
1034 list = new ArrayList<CalEvent>();
1035 }
1036
1037 cacheResult(list);
1038
1039 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_OBC_COMPANYID,
1040 finderArgs, list);
1041
1042 closeSession(session);
1043 }
1044 }
1045
1046 return list;
1047 }
1048
1049 public CalEvent findByCompanyId_First(long companyId, OrderByComparator obc)
1050 throws NoSuchEventException, SystemException {
1051 List<CalEvent> list = findByCompanyId(companyId, 0, 1, obc);
1052
1053 if (list.isEmpty()) {
1054 StringBuilder msg = new StringBuilder();
1055
1056 msg.append("No CalEvent exists with the key {");
1057
1058 msg.append("companyId=" + companyId);
1059
1060 msg.append(StringPool.CLOSE_CURLY_BRACE);
1061
1062 throw new NoSuchEventException(msg.toString());
1063 }
1064 else {
1065 return list.get(0);
1066 }
1067 }
1068
1069 public CalEvent findByCompanyId_Last(long companyId, OrderByComparator obc)
1070 throws NoSuchEventException, SystemException {
1071 int count = countByCompanyId(companyId);
1072
1073 List<CalEvent> list = findByCompanyId(companyId, count - 1, count, obc);
1074
1075 if (list.isEmpty()) {
1076 StringBuilder msg = new StringBuilder();
1077
1078 msg.append("No CalEvent exists with the key {");
1079
1080 msg.append("companyId=" + companyId);
1081
1082 msg.append(StringPool.CLOSE_CURLY_BRACE);
1083
1084 throw new NoSuchEventException(msg.toString());
1085 }
1086 else {
1087 return list.get(0);
1088 }
1089 }
1090
1091 public CalEvent[] findByCompanyId_PrevAndNext(long eventId, long companyId,
1092 OrderByComparator obc) throws NoSuchEventException, SystemException {
1093 CalEvent calEvent = findByPrimaryKey(eventId);
1094
1095 int count = countByCompanyId(companyId);
1096
1097 Session session = null;
1098
1099 try {
1100 session = openSession();
1101
1102 StringBuilder query = new StringBuilder();
1103
1104 query.append("SELECT calEvent FROM CalEvent calEvent WHERE ");
1105
1106 query.append("calEvent.companyId = ?");
1107
1108 query.append(" ");
1109
1110 if (obc != null) {
1111 query.append("ORDER BY ");
1112
1113 String[] orderByFields = obc.getOrderByFields();
1114
1115 for (int i = 0; i < orderByFields.length; i++) {
1116 query.append("calEvent.");
1117 query.append(orderByFields[i]);
1118
1119 if (obc.isAscending()) {
1120 query.append(" ASC");
1121 }
1122 else {
1123 query.append(" DESC");
1124 }
1125
1126 if ((i + 1) < orderByFields.length) {
1127 query.append(", ");
1128 }
1129 }
1130 }
1131
1132 else {
1133 query.append("ORDER BY ");
1134
1135 query.append("calEvent.startDate ASC, ");
1136 query.append("calEvent.title ASC");
1137 }
1138
1139 Query q = session.createQuery(query.toString());
1140
1141 QueryPos qPos = QueryPos.getInstance(q);
1142
1143 qPos.add(companyId);
1144
1145 Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc, calEvent);
1146
1147 CalEvent[] array = new CalEventImpl[3];
1148
1149 array[0] = (CalEvent)objArray[0];
1150 array[1] = (CalEvent)objArray[1];
1151 array[2] = (CalEvent)objArray[2];
1152
1153 return array;
1154 }
1155 catch (Exception e) {
1156 throw processException(e);
1157 }
1158 finally {
1159 closeSession(session);
1160 }
1161 }
1162
1163 public List<CalEvent> findByGroupId(long groupId) throws SystemException {
1164 Object[] finderArgs = new Object[] { new Long(groupId) };
1165
1166 List<CalEvent> list = (List<CalEvent>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_GROUPID,
1167 finderArgs, this);
1168
1169 if (list == null) {
1170 Session session = null;
1171
1172 try {
1173 session = openSession();
1174
1175 StringBuilder query = new StringBuilder();
1176
1177 query.append("SELECT calEvent FROM CalEvent calEvent WHERE ");
1178
1179 query.append("calEvent.groupId = ?");
1180
1181 query.append(" ");
1182
1183 query.append("ORDER BY ");
1184
1185 query.append("calEvent.startDate ASC, ");
1186 query.append("calEvent.title ASC");
1187
1188 Query q = session.createQuery(query.toString());
1189
1190 QueryPos qPos = QueryPos.getInstance(q);
1191
1192 qPos.add(groupId);
1193
1194 list = q.list();
1195 }
1196 catch (Exception e) {
1197 throw processException(e);
1198 }
1199 finally {
1200 if (list == null) {
1201 list = new ArrayList<CalEvent>();
1202 }
1203
1204 cacheResult(list);
1205
1206 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_GROUPID,
1207 finderArgs, list);
1208
1209 closeSession(session);
1210 }
1211 }
1212
1213 return list;
1214 }
1215
1216 public List<CalEvent> findByGroupId(long groupId, int start, int end)
1217 throws SystemException {
1218 return findByGroupId(groupId, start, end, null);
1219 }
1220
1221 public List<CalEvent> findByGroupId(long groupId, int start, int end,
1222 OrderByComparator obc) throws SystemException {
1223 Object[] finderArgs = new Object[] {
1224 new Long(groupId),
1225
1226 String.valueOf(start), String.valueOf(end), String.valueOf(obc)
1227 };
1228
1229 List<CalEvent> list = (List<CalEvent>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_OBC_GROUPID,
1230 finderArgs, this);
1231
1232 if (list == null) {
1233 Session session = null;
1234
1235 try {
1236 session = openSession();
1237
1238 StringBuilder query = new StringBuilder();
1239
1240 query.append("SELECT calEvent FROM CalEvent calEvent WHERE ");
1241
1242 query.append("calEvent.groupId = ?");
1243
1244 query.append(" ");
1245
1246 if (obc != null) {
1247 query.append("ORDER BY ");
1248
1249 String[] orderByFields = obc.getOrderByFields();
1250
1251 for (int i = 0; i < orderByFields.length; i++) {
1252 query.append("calEvent.");
1253 query.append(orderByFields[i]);
1254
1255 if (obc.isAscending()) {
1256 query.append(" ASC");
1257 }
1258 else {
1259 query.append(" DESC");
1260 }
1261
1262 if ((i + 1) < orderByFields.length) {
1263 query.append(", ");
1264 }
1265 }
1266 }
1267
1268 else {
1269 query.append("ORDER BY ");
1270
1271 query.append("calEvent.startDate ASC, ");
1272 query.append("calEvent.title ASC");
1273 }
1274
1275 Query q = session.createQuery(query.toString());
1276
1277 QueryPos qPos = QueryPos.getInstance(q);
1278
1279 qPos.add(groupId);
1280
1281 list = (List<CalEvent>)QueryUtil.list(q, getDialect(), start,
1282 end);
1283 }
1284 catch (Exception e) {
1285 throw processException(e);
1286 }
1287 finally {
1288 if (list == null) {
1289 list = new ArrayList<CalEvent>();
1290 }
1291
1292 cacheResult(list);
1293
1294 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_OBC_GROUPID,
1295 finderArgs, list);
1296
1297 closeSession(session);
1298 }
1299 }
1300
1301 return list;
1302 }
1303
1304 public CalEvent findByGroupId_First(long groupId, OrderByComparator obc)
1305 throws NoSuchEventException, SystemException {
1306 List<CalEvent> list = findByGroupId(groupId, 0, 1, obc);
1307
1308 if (list.isEmpty()) {
1309 StringBuilder msg = new StringBuilder();
1310
1311 msg.append("No CalEvent exists with the key {");
1312
1313 msg.append("groupId=" + groupId);
1314
1315 msg.append(StringPool.CLOSE_CURLY_BRACE);
1316
1317 throw new NoSuchEventException(msg.toString());
1318 }
1319 else {
1320 return list.get(0);
1321 }
1322 }
1323
1324 public CalEvent findByGroupId_Last(long groupId, OrderByComparator obc)
1325 throws NoSuchEventException, SystemException {
1326 int count = countByGroupId(groupId);
1327
1328 List<CalEvent> list = findByGroupId(groupId, count - 1, count, obc);
1329
1330 if (list.isEmpty()) {
1331 StringBuilder msg = new StringBuilder();
1332
1333 msg.append("No CalEvent exists with the key {");
1334
1335 msg.append("groupId=" + groupId);
1336
1337 msg.append(StringPool.CLOSE_CURLY_BRACE);
1338
1339 throw new NoSuchEventException(msg.toString());
1340 }
1341 else {
1342 return list.get(0);
1343 }
1344 }
1345
1346 public CalEvent[] findByGroupId_PrevAndNext(long eventId, long groupId,
1347 OrderByComparator obc) throws NoSuchEventException, SystemException {
1348 CalEvent calEvent = findByPrimaryKey(eventId);
1349
1350 int count = countByGroupId(groupId);
1351
1352 Session session = null;
1353
1354 try {
1355 session = openSession();
1356
1357 StringBuilder query = new StringBuilder();
1358
1359 query.append("SELECT calEvent FROM CalEvent calEvent WHERE ");
1360
1361 query.append("calEvent.groupId = ?");
1362
1363 query.append(" ");
1364
1365 if (obc != null) {
1366 query.append("ORDER BY ");
1367
1368 String[] orderByFields = obc.getOrderByFields();
1369
1370 for (int i = 0; i < orderByFields.length; i++) {
1371 query.append("calEvent.");
1372 query.append(orderByFields[i]);
1373
1374 if (obc.isAscending()) {
1375 query.append(" ASC");
1376 }
1377 else {
1378 query.append(" DESC");
1379 }
1380
1381 if ((i + 1) < orderByFields.length) {
1382 query.append(", ");
1383 }
1384 }
1385 }
1386
1387 else {
1388 query.append("ORDER BY ");
1389
1390 query.append("calEvent.startDate ASC, ");
1391 query.append("calEvent.title ASC");
1392 }
1393
1394 Query q = session.createQuery(query.toString());
1395
1396 QueryPos qPos = QueryPos.getInstance(q);
1397
1398 qPos.add(groupId);
1399
1400 Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc, calEvent);
1401
1402 CalEvent[] array = new CalEventImpl[3];
1403
1404 array[0] = (CalEvent)objArray[0];
1405 array[1] = (CalEvent)objArray[1];
1406 array[2] = (CalEvent)objArray[2];
1407
1408 return array;
1409 }
1410 catch (Exception e) {
1411 throw processException(e);
1412 }
1413 finally {
1414 closeSession(session);
1415 }
1416 }
1417
1418 public List<CalEvent> findByRemindBy(int remindBy)
1419 throws SystemException {
1420 Object[] finderArgs = new Object[] { new Integer(remindBy) };
1421
1422 List<CalEvent> list = (List<CalEvent>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_REMINDBY,
1423 finderArgs, this);
1424
1425 if (list == null) {
1426 Session session = null;
1427
1428 try {
1429 session = openSession();
1430
1431 StringBuilder query = new StringBuilder();
1432
1433 query.append("SELECT calEvent FROM CalEvent calEvent WHERE ");
1434
1435 query.append("calEvent.remindBy != ?");
1436
1437 query.append(" ");
1438
1439 query.append("ORDER BY ");
1440
1441 query.append("calEvent.startDate ASC, ");
1442 query.append("calEvent.title ASC");
1443
1444 Query q = session.createQuery(query.toString());
1445
1446 QueryPos qPos = QueryPos.getInstance(q);
1447
1448 qPos.add(remindBy);
1449
1450 list = q.list();
1451 }
1452 catch (Exception e) {
1453 throw processException(e);
1454 }
1455 finally {
1456 if (list == null) {
1457 list = new ArrayList<CalEvent>();
1458 }
1459
1460 cacheResult(list);
1461
1462 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_REMINDBY,
1463 finderArgs, list);
1464
1465 closeSession(session);
1466 }
1467 }
1468
1469 return list;
1470 }
1471
1472 public List<CalEvent> findByRemindBy(int remindBy, int start, int end)
1473 throws SystemException {
1474 return findByRemindBy(remindBy, start, end, null);
1475 }
1476
1477 public List<CalEvent> findByRemindBy(int remindBy, int start, int end,
1478 OrderByComparator obc) throws SystemException {
1479 Object[] finderArgs = new Object[] {
1480 new Integer(remindBy),
1481
1482 String.valueOf(start), String.valueOf(end), String.valueOf(obc)
1483 };
1484
1485 List<CalEvent> list = (List<CalEvent>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_OBC_REMINDBY,
1486 finderArgs, this);
1487
1488 if (list == null) {
1489 Session session = null;
1490
1491 try {
1492 session = openSession();
1493
1494 StringBuilder query = new StringBuilder();
1495
1496 query.append("SELECT calEvent FROM CalEvent calEvent WHERE ");
1497
1498 query.append("calEvent.remindBy != ?");
1499
1500 query.append(" ");
1501
1502 if (obc != null) {
1503 query.append("ORDER BY ");
1504
1505 String[] orderByFields = obc.getOrderByFields();
1506
1507 for (int i = 0; i < orderByFields.length; i++) {
1508 query.append("calEvent.");
1509 query.append(orderByFields[i]);
1510
1511 if (obc.isAscending()) {
1512 query.append(" ASC");
1513 }
1514 else {
1515 query.append(" DESC");
1516 }
1517
1518 if ((i + 1) < orderByFields.length) {
1519 query.append(", ");
1520 }
1521 }
1522 }
1523
1524 else {
1525 query.append("ORDER BY ");
1526
1527 query.append("calEvent.startDate ASC, ");
1528 query.append("calEvent.title ASC");
1529 }
1530
1531 Query q = session.createQuery(query.toString());
1532
1533 QueryPos qPos = QueryPos.getInstance(q);
1534
1535 qPos.add(remindBy);
1536
1537 list = (List<CalEvent>)QueryUtil.list(q, getDialect(), start,
1538 end);
1539 }
1540 catch (Exception e) {
1541 throw processException(e);
1542 }
1543 finally {
1544 if (list == null) {
1545 list = new ArrayList<CalEvent>();
1546 }
1547
1548 cacheResult(list);
1549
1550 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_OBC_REMINDBY,
1551 finderArgs, list);
1552
1553 closeSession(session);
1554 }
1555 }
1556
1557 return list;
1558 }
1559
1560 public CalEvent findByRemindBy_First(int remindBy, OrderByComparator obc)
1561 throws NoSuchEventException, SystemException {
1562 List<CalEvent> list = findByRemindBy(remindBy, 0, 1, obc);
1563
1564 if (list.isEmpty()) {
1565 StringBuilder msg = new StringBuilder();
1566
1567 msg.append("No CalEvent exists with the key {");
1568
1569 msg.append("remindBy=" + remindBy);
1570
1571 msg.append(StringPool.CLOSE_CURLY_BRACE);
1572
1573 throw new NoSuchEventException(msg.toString());
1574 }
1575 else {
1576 return list.get(0);
1577 }
1578 }
1579
1580 public CalEvent findByRemindBy_Last(int remindBy, OrderByComparator obc)
1581 throws NoSuchEventException, SystemException {
1582 int count = countByRemindBy(remindBy);
1583
1584 List<CalEvent> list = findByRemindBy(remindBy, count - 1, count, obc);
1585
1586 if (list.isEmpty()) {
1587 StringBuilder msg = new StringBuilder();
1588
1589 msg.append("No CalEvent exists with the key {");
1590
1591 msg.append("remindBy=" + remindBy);
1592
1593 msg.append(StringPool.CLOSE_CURLY_BRACE);
1594
1595 throw new NoSuchEventException(msg.toString());
1596 }
1597 else {
1598 return list.get(0);
1599 }
1600 }
1601
1602 public CalEvent[] findByRemindBy_PrevAndNext(long eventId, int remindBy,
1603 OrderByComparator obc) throws NoSuchEventException, SystemException {
1604 CalEvent calEvent = findByPrimaryKey(eventId);
1605
1606 int count = countByRemindBy(remindBy);
1607
1608 Session session = null;
1609
1610 try {
1611 session = openSession();
1612
1613 StringBuilder query = new StringBuilder();
1614
1615 query.append("SELECT calEvent FROM CalEvent calEvent WHERE ");
1616
1617 query.append("calEvent.remindBy != ?");
1618
1619 query.append(" ");
1620
1621 if (obc != null) {
1622 query.append("ORDER BY ");
1623
1624 String[] orderByFields = obc.getOrderByFields();
1625
1626 for (int i = 0; i < orderByFields.length; i++) {
1627 query.append("calEvent.");
1628 query.append(orderByFields[i]);
1629
1630 if (obc.isAscending()) {
1631 query.append(" ASC");
1632 }
1633 else {
1634 query.append(" DESC");
1635 }
1636
1637 if ((i + 1) < orderByFields.length) {
1638 query.append(", ");
1639 }
1640 }
1641 }
1642
1643 else {
1644 query.append("ORDER BY ");
1645
1646 query.append("calEvent.startDate ASC, ");
1647 query.append("calEvent.title ASC");
1648 }
1649
1650 Query q = session.createQuery(query.toString());
1651
1652 QueryPos qPos = QueryPos.getInstance(q);
1653
1654 qPos.add(remindBy);
1655
1656 Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc, calEvent);
1657
1658 CalEvent[] array = new CalEventImpl[3];
1659
1660 array[0] = (CalEvent)objArray[0];
1661 array[1] = (CalEvent)objArray[1];
1662 array[2] = (CalEvent)objArray[2];
1663
1664 return array;
1665 }
1666 catch (Exception e) {
1667 throw processException(e);
1668 }
1669 finally {
1670 closeSession(session);
1671 }
1672 }
1673
1674 public List<CalEvent> findByG_T(long groupId, String type)
1675 throws SystemException {
1676 Object[] finderArgs = new Object[] { new Long(groupId), type };
1677
1678 List<CalEvent> list = (List<CalEvent>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_G_T,
1679 finderArgs, this);
1680
1681 if (list == null) {
1682 Session session = null;
1683
1684 try {
1685 session = openSession();
1686
1687 StringBuilder query = new StringBuilder();
1688
1689 query.append("SELECT calEvent FROM CalEvent calEvent WHERE ");
1690
1691 query.append("calEvent.groupId = ?");
1692
1693 query.append(" AND ");
1694
1695 if (type == null) {
1696 query.append("calEvent.type IS NULL");
1697 }
1698 else {
1699 query.append("calEvent.type = ?");
1700 }
1701
1702 query.append(" ");
1703
1704 query.append("ORDER BY ");
1705
1706 query.append("calEvent.startDate ASC, ");
1707 query.append("calEvent.title ASC");
1708
1709 Query q = session.createQuery(query.toString());
1710
1711 QueryPos qPos = QueryPos.getInstance(q);
1712
1713 qPos.add(groupId);
1714
1715 if (type != null) {
1716 qPos.add(type);
1717 }
1718
1719 list = q.list();
1720 }
1721 catch (Exception e) {
1722 throw processException(e);
1723 }
1724 finally {
1725 if (list == null) {
1726 list = new ArrayList<CalEvent>();
1727 }
1728
1729 cacheResult(list);
1730
1731 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_G_T, finderArgs,
1732 list);
1733
1734 closeSession(session);
1735 }
1736 }
1737
1738 return list;
1739 }
1740
1741 public List<CalEvent> findByG_T(long groupId, String type, int start,
1742 int end) throws SystemException {
1743 return findByG_T(groupId, type, start, end, null);
1744 }
1745
1746 public List<CalEvent> findByG_T(long groupId, String type, int start,
1747 int end, OrderByComparator obc) throws SystemException {
1748 Object[] finderArgs = new Object[] {
1749 new Long(groupId),
1750
1751 type,
1752
1753 String.valueOf(start), String.valueOf(end), String.valueOf(obc)
1754 };
1755
1756 List<CalEvent> list = (List<CalEvent>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_OBC_G_T,
1757 finderArgs, this);
1758
1759 if (list == null) {
1760 Session session = null;
1761
1762 try {
1763 session = openSession();
1764
1765 StringBuilder query = new StringBuilder();
1766
1767 query.append("SELECT calEvent FROM CalEvent calEvent WHERE ");
1768
1769 query.append("calEvent.groupId = ?");
1770
1771 query.append(" AND ");
1772
1773 if (type == null) {
1774 query.append("calEvent.type IS NULL");
1775 }
1776 else {
1777 query.append("calEvent.type = ?");
1778 }
1779
1780 query.append(" ");
1781
1782 if (obc != null) {
1783 query.append("ORDER BY ");
1784
1785 String[] orderByFields = obc.getOrderByFields();
1786
1787 for (int i = 0; i < orderByFields.length; i++) {
1788 query.append("calEvent.");
1789 query.append(orderByFields[i]);
1790
1791 if (obc.isAscending()) {
1792 query.append(" ASC");
1793 }
1794 else {
1795 query.append(" DESC");
1796 }
1797
1798 if ((i + 1) < orderByFields.length) {
1799 query.append(", ");
1800 }
1801 }
1802 }
1803
1804 else {
1805 query.append("ORDER BY ");
1806
1807 query.append("calEvent.startDate ASC, ");
1808 query.append("calEvent.title ASC");
1809 }
1810
1811 Query q = session.createQuery(query.toString());
1812
1813 QueryPos qPos = QueryPos.getInstance(q);
1814
1815 qPos.add(groupId);
1816
1817 if (type != null) {
1818 qPos.add(type);
1819 }
1820
1821 list = (List<CalEvent>)QueryUtil.list(q, getDialect(), start,
1822 end);
1823 }
1824 catch (Exception e) {
1825 throw processException(e);
1826 }
1827 finally {
1828 if (list == null) {
1829 list = new ArrayList<CalEvent>();
1830 }
1831
1832 cacheResult(list);
1833
1834 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_OBC_G_T,
1835 finderArgs, list);
1836
1837 closeSession(session);
1838 }
1839 }
1840
1841 return list;
1842 }
1843
1844 public CalEvent findByG_T_First(long groupId, String type,
1845 OrderByComparator obc) throws NoSuchEventException, SystemException {
1846 List<CalEvent> list = findByG_T(groupId, type, 0, 1, obc);
1847
1848 if (list.isEmpty()) {
1849 StringBuilder msg = new StringBuilder();
1850
1851 msg.append("No CalEvent exists with the key {");
1852
1853 msg.append("groupId=" + groupId);
1854
1855 msg.append(", ");
1856 msg.append("type=" + type);
1857
1858 msg.append(StringPool.CLOSE_CURLY_BRACE);
1859
1860 throw new NoSuchEventException(msg.toString());
1861 }
1862 else {
1863 return list.get(0);
1864 }
1865 }
1866
1867 public CalEvent findByG_T_Last(long groupId, String type,
1868 OrderByComparator obc) throws NoSuchEventException, SystemException {
1869 int count = countByG_T(groupId, type);
1870
1871 List<CalEvent> list = findByG_T(groupId, type, count - 1, count, obc);
1872
1873 if (list.isEmpty()) {
1874 StringBuilder msg = new StringBuilder();
1875
1876 msg.append("No CalEvent exists with the key {");
1877
1878 msg.append("groupId=" + groupId);
1879
1880 msg.append(", ");
1881 msg.append("type=" + type);
1882
1883 msg.append(StringPool.CLOSE_CURLY_BRACE);
1884
1885 throw new NoSuchEventException(msg.toString());
1886 }
1887 else {
1888 return list.get(0);
1889 }
1890 }
1891
1892 public CalEvent[] findByG_T_PrevAndNext(long eventId, long groupId,
1893 String type, OrderByComparator obc)
1894 throws NoSuchEventException, SystemException {
1895 CalEvent calEvent = findByPrimaryKey(eventId);
1896
1897 int count = countByG_T(groupId, type);
1898
1899 Session session = null;
1900
1901 try {
1902 session = openSession();
1903
1904 StringBuilder query = new StringBuilder();
1905
1906 query.append("SELECT calEvent FROM CalEvent calEvent WHERE ");
1907
1908 query.append("calEvent.groupId = ?");
1909
1910 query.append(" AND ");
1911
1912 if (type == null) {
1913 query.append("calEvent.type IS NULL");
1914 }
1915 else {
1916 query.append("calEvent.type = ?");
1917 }
1918
1919 query.append(" ");
1920
1921 if (obc != null) {
1922 query.append("ORDER BY ");
1923
1924 String[] orderByFields = obc.getOrderByFields();
1925
1926 for (int i = 0; i < orderByFields.length; i++) {
1927 query.append("calEvent.");
1928 query.append(orderByFields[i]);
1929
1930 if (obc.isAscending()) {
1931 query.append(" ASC");
1932 }
1933 else {
1934 query.append(" DESC");
1935 }
1936
1937 if ((i + 1) < orderByFields.length) {
1938 query.append(", ");
1939 }
1940 }
1941 }
1942
1943 else {
1944 query.append("ORDER BY ");
1945
1946 query.append("calEvent.startDate ASC, ");
1947 query.append("calEvent.title ASC");
1948 }
1949
1950 Query q = session.createQuery(query.toString());
1951
1952 QueryPos qPos = QueryPos.getInstance(q);
1953
1954 qPos.add(groupId);
1955
1956 if (type != null) {
1957 qPos.add(type);
1958 }
1959
1960 Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc, calEvent);
1961
1962 CalEvent[] array = new CalEventImpl[3];
1963
1964 array[0] = (CalEvent)objArray[0];
1965 array[1] = (CalEvent)objArray[1];
1966 array[2] = (CalEvent)objArray[2];
1967
1968 return array;
1969 }
1970 catch (Exception e) {
1971 throw processException(e);
1972 }
1973 finally {
1974 closeSession(session);
1975 }
1976 }
1977
1978 public List<CalEvent> findByG_R(long groupId, boolean repeating)
1979 throws SystemException {
1980 Object[] finderArgs = new Object[] {
1981 new Long(groupId), Boolean.valueOf(repeating)
1982 };
1983
1984 List<CalEvent> list = (List<CalEvent>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_G_R,
1985 finderArgs, this);
1986
1987 if (list == null) {
1988 Session session = null;
1989
1990 try {
1991 session = openSession();
1992
1993 StringBuilder query = new StringBuilder();
1994
1995 query.append("SELECT calEvent FROM CalEvent calEvent WHERE ");
1996
1997 query.append("calEvent.groupId = ?");
1998
1999 query.append(" AND ");
2000
2001 query.append("calEvent.repeating = ?");
2002
2003 query.append(" ");
2004
2005 query.append("ORDER BY ");
2006
2007 query.append("calEvent.startDate ASC, ");
2008 query.append("calEvent.title ASC");
2009
2010 Query q = session.createQuery(query.toString());
2011
2012 QueryPos qPos = QueryPos.getInstance(q);
2013
2014 qPos.add(groupId);
2015
2016 qPos.add(repeating);
2017
2018 list = q.list();
2019 }
2020 catch (Exception e) {
2021 throw processException(e);
2022 }
2023 finally {
2024 if (list == null) {
2025 list = new ArrayList<CalEvent>();
2026 }
2027
2028 cacheResult(list);
2029
2030 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_G_R, finderArgs,
2031 list);
2032
2033 closeSession(session);
2034 }
2035 }
2036
2037 return list;
2038 }
2039
2040 public List<CalEvent> findByG_R(long groupId, boolean repeating, int start,
2041 int end) throws SystemException {
2042 return findByG_R(groupId, repeating, start, end, null);
2043 }
2044
2045 public List<CalEvent> findByG_R(long groupId, boolean repeating, int start,
2046 int end, OrderByComparator obc) throws SystemException {
2047 Object[] finderArgs = new Object[] {
2048 new Long(groupId), Boolean.valueOf(repeating),
2049
2050 String.valueOf(start), String.valueOf(end), String.valueOf(obc)
2051 };
2052
2053 List<CalEvent> list = (List<CalEvent>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_OBC_G_R,
2054 finderArgs, this);
2055
2056 if (list == null) {
2057 Session session = null;
2058
2059 try {
2060 session = openSession();
2061
2062 StringBuilder query = new StringBuilder();
2063
2064 query.append("SELECT calEvent FROM CalEvent calEvent WHERE ");
2065
2066 query.append("calEvent.groupId = ?");
2067
2068 query.append(" AND ");
2069
2070 query.append("calEvent.repeating = ?");
2071
2072 query.append(" ");
2073
2074 if (obc != null) {
2075 query.append("ORDER BY ");
2076
2077 String[] orderByFields = obc.getOrderByFields();
2078
2079 for (int i = 0; i < orderByFields.length; i++) {
2080 query.append("calEvent.");
2081 query.append(orderByFields[i]);
2082
2083 if (obc.isAscending()) {
2084 query.append(" ASC");
2085 }
2086 else {
2087 query.append(" DESC");
2088 }
2089
2090 if ((i + 1) < orderByFields.length) {
2091 query.append(", ");
2092 }
2093 }
2094 }
2095
2096 else {
2097 query.append("ORDER BY ");
2098
2099 query.append("calEvent.startDate ASC, ");
2100 query.append("calEvent.title ASC");
2101 }
2102
2103 Query q = session.createQuery(query.toString());
2104
2105 QueryPos qPos = QueryPos.getInstance(q);
2106
2107 qPos.add(groupId);
2108
2109 qPos.add(repeating);
2110
2111 list = (List<CalEvent>)QueryUtil.list(q, getDialect(), start,
2112 end);
2113 }
2114 catch (Exception e) {
2115 throw processException(e);
2116 }
2117 finally {
2118 if (list == null) {
2119 list = new ArrayList<CalEvent>();
2120 }
2121
2122 cacheResult(list);
2123
2124 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_OBC_G_R,
2125 finderArgs, list);
2126
2127 closeSession(session);
2128 }
2129 }
2130
2131 return list;
2132 }
2133
2134 public CalEvent findByG_R_First(long groupId, boolean repeating,
2135 OrderByComparator obc) throws NoSuchEventException, SystemException {
2136 List<CalEvent> list = findByG_R(groupId, repeating, 0, 1, obc);
2137
2138 if (list.isEmpty()) {
2139 StringBuilder msg = new StringBuilder();
2140
2141 msg.append("No CalEvent exists with the key {");
2142
2143 msg.append("groupId=" + groupId);
2144
2145 msg.append(", ");
2146 msg.append("repeating=" + repeating);
2147
2148 msg.append(StringPool.CLOSE_CURLY_BRACE);
2149
2150 throw new NoSuchEventException(msg.toString());
2151 }
2152 else {
2153 return list.get(0);
2154 }
2155 }
2156
2157 public CalEvent findByG_R_Last(long groupId, boolean repeating,
2158 OrderByComparator obc) throws NoSuchEventException, SystemException {
2159 int count = countByG_R(groupId, repeating);
2160
2161 List<CalEvent> list = findByG_R(groupId, repeating, count - 1, count,
2162 obc);
2163
2164 if (list.isEmpty()) {
2165 StringBuilder msg = new StringBuilder();
2166
2167 msg.append("No CalEvent exists with the key {");
2168
2169 msg.append("groupId=" + groupId);
2170
2171 msg.append(", ");
2172 msg.append("repeating=" + repeating);
2173
2174 msg.append(StringPool.CLOSE_CURLY_BRACE);
2175
2176 throw new NoSuchEventException(msg.toString());
2177 }
2178 else {
2179 return list.get(0);
2180 }
2181 }
2182
2183 public CalEvent[] findByG_R_PrevAndNext(long eventId, long groupId,
2184 boolean repeating, OrderByComparator obc)
2185 throws NoSuchEventException, SystemException {
2186 CalEvent calEvent = findByPrimaryKey(eventId);
2187
2188 int count = countByG_R(groupId, repeating);
2189
2190 Session session = null;
2191
2192 try {
2193 session = openSession();
2194
2195 StringBuilder query = new StringBuilder();
2196
2197 query.append("SELECT calEvent FROM CalEvent calEvent WHERE ");
2198
2199 query.append("calEvent.groupId = ?");
2200
2201 query.append(" AND ");
2202
2203 query.append("calEvent.repeating = ?");
2204
2205 query.append(" ");
2206
2207 if (obc != null) {
2208 query.append("ORDER BY ");
2209
2210 String[] orderByFields = obc.getOrderByFields();
2211
2212 for (int i = 0; i < orderByFields.length; i++) {
2213 query.append("calEvent.");
2214 query.append(orderByFields[i]);
2215
2216 if (obc.isAscending()) {
2217 query.append(" ASC");
2218 }
2219 else {
2220 query.append(" DESC");
2221 }
2222
2223 if ((i + 1) < orderByFields.length) {
2224 query.append(", ");
2225 }
2226 }
2227 }
2228
2229 else {
2230 query.append("ORDER BY ");
2231
2232 query.append("calEvent.startDate ASC, ");
2233 query.append("calEvent.title ASC");
2234 }
2235
2236 Query q = session.createQuery(query.toString());
2237
2238 QueryPos qPos = QueryPos.getInstance(q);
2239
2240 qPos.add(groupId);
2241
2242 qPos.add(repeating);
2243
2244 Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc, calEvent);
2245
2246 CalEvent[] array = new CalEventImpl[3];
2247
2248 array[0] = (CalEvent)objArray[0];
2249 array[1] = (CalEvent)objArray[1];
2250 array[2] = (CalEvent)objArray[2];
2251
2252 return array;
2253 }
2254 catch (Exception e) {
2255 throw processException(e);
2256 }
2257 finally {
2258 closeSession(session);
2259 }
2260 }
2261
2262 public List<Object> findWithDynamicQuery(DynamicQuery dynamicQuery)
2263 throws SystemException {
2264 Session session = null;
2265
2266 try {
2267 session = openSession();
2268
2269 dynamicQuery.compile(session);
2270
2271 return dynamicQuery.list();
2272 }
2273 catch (Exception e) {
2274 throw processException(e);
2275 }
2276 finally {
2277 closeSession(session);
2278 }
2279 }
2280
2281 public List<Object> findWithDynamicQuery(DynamicQuery dynamicQuery,
2282 int start, int end) throws SystemException {
2283 Session session = null;
2284
2285 try {
2286 session = openSession();
2287
2288 dynamicQuery.setLimit(start, end);
2289
2290 dynamicQuery.compile(session);
2291
2292 return dynamicQuery.list();
2293 }
2294 catch (Exception e) {
2295 throw processException(e);
2296 }
2297 finally {
2298 closeSession(session);
2299 }
2300 }
2301
2302 public List<CalEvent> findAll() throws SystemException {
2303 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
2304 }
2305
2306 public List<CalEvent> findAll(int start, int end) throws SystemException {
2307 return findAll(start, end, null);
2308 }
2309
2310 public List<CalEvent> findAll(int start, int end, OrderByComparator obc)
2311 throws SystemException {
2312 Object[] finderArgs = new Object[] {
2313 String.valueOf(start), String.valueOf(end), String.valueOf(obc)
2314 };
2315
2316 List<CalEvent> list = (List<CalEvent>)FinderCacheUtil.getResult(FINDER_PATH_FIND_ALL,
2317 finderArgs, this);
2318
2319 if (list == null) {
2320 Session session = null;
2321
2322 try {
2323 session = openSession();
2324
2325 StringBuilder query = new StringBuilder();
2326
2327 query.append("SELECT calEvent FROM CalEvent calEvent ");
2328
2329 if (obc != null) {
2330 query.append("ORDER BY ");
2331
2332 String[] orderByFields = obc.getOrderByFields();
2333
2334 for (int i = 0; i < orderByFields.length; i++) {
2335 query.append("calEvent.");
2336 query.append(orderByFields[i]);
2337
2338 if (obc.isAscending()) {
2339 query.append(" ASC");
2340 }
2341 else {
2342 query.append(" DESC");
2343 }
2344
2345 if ((i + 1) < orderByFields.length) {
2346 query.append(", ");
2347 }
2348 }
2349 }
2350
2351 else {
2352 query.append("ORDER BY ");
2353
2354 query.append("calEvent.startDate ASC, ");
2355 query.append("calEvent.title ASC");
2356 }
2357
2358 Query q = session.createQuery(query.toString());
2359
2360 if (obc == null) {
2361 list = (List<CalEvent>)QueryUtil.list(q, getDialect(),
2362 start, end, false);
2363
2364 Collections.sort(list);
2365 }
2366 else {
2367 list = (List<CalEvent>)QueryUtil.list(q, getDialect(),
2368 start, end);
2369 }
2370 }
2371 catch (Exception e) {
2372 throw processException(e);
2373 }
2374 finally {
2375 if (list == null) {
2376 list = new ArrayList<CalEvent>();
2377 }
2378
2379 cacheResult(list);
2380
2381 FinderCacheUtil.putResult(FINDER_PATH_FIND_ALL, finderArgs, list);
2382
2383 closeSession(session);
2384 }
2385 }
2386
2387 return list;
2388 }
2389
2390 public void removeByUuid(String uuid) throws SystemException {
2391 for (CalEvent calEvent : findByUuid(uuid)) {
2392 remove(calEvent);
2393 }
2394 }
2395
2396 public void removeByUUID_G(String uuid, long groupId)
2397 throws NoSuchEventException, SystemException {
2398 CalEvent calEvent = findByUUID_G(uuid, groupId);
2399
2400 remove(calEvent);
2401 }
2402
2403 public void removeByCompanyId(long companyId) throws SystemException {
2404 for (CalEvent calEvent : findByCompanyId(companyId)) {
2405 remove(calEvent);
2406 }
2407 }
2408
2409 public void removeByGroupId(long groupId) throws SystemException {
2410 for (CalEvent calEvent : findByGroupId(groupId)) {
2411 remove(calEvent);
2412 }
2413 }
2414
2415 public void removeByRemindBy(int remindBy) throws SystemException {
2416 for (CalEvent calEvent : findByRemindBy(remindBy)) {
2417 remove(calEvent);
2418 }
2419 }
2420
2421 public void removeByG_T(long groupId, String type)
2422 throws SystemException {
2423 for (CalEvent calEvent : findByG_T(groupId, type)) {
2424 remove(calEvent);
2425 }
2426 }
2427
2428 public void removeByG_R(long groupId, boolean repeating)
2429 throws SystemException {
2430 for (CalEvent calEvent : findByG_R(groupId, repeating)) {
2431 remove(calEvent);
2432 }
2433 }
2434
2435 public void removeAll() throws SystemException {
2436 for (CalEvent calEvent : findAll()) {
2437 remove(calEvent);
2438 }
2439 }
2440
2441 public int countByUuid(String uuid) throws SystemException {
2442 Object[] finderArgs = new Object[] { uuid };
2443
2444 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_UUID,
2445 finderArgs, this);
2446
2447 if (count == null) {
2448 Session session = null;
2449
2450 try {
2451 session = openSession();
2452
2453 StringBuilder query = new StringBuilder();
2454
2455 query.append("SELECT COUNT(calEvent) ");
2456 query.append("FROM CalEvent calEvent WHERE ");
2457
2458 if (uuid == null) {
2459 query.append("calEvent.uuid IS NULL");
2460 }
2461 else {
2462 query.append("calEvent.uuid = ?");
2463 }
2464
2465 query.append(" ");
2466
2467 Query q = session.createQuery(query.toString());
2468
2469 QueryPos qPos = QueryPos.getInstance(q);
2470
2471 if (uuid != null) {
2472 qPos.add(uuid);
2473 }
2474
2475 count = (Long)q.uniqueResult();
2476 }
2477 catch (Exception e) {
2478 throw processException(e);
2479 }
2480 finally {
2481 if (count == null) {
2482 count = Long.valueOf(0);
2483 }
2484
2485 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID,
2486 finderArgs, count);
2487
2488 closeSession(session);
2489 }
2490 }
2491
2492 return count.intValue();
2493 }
2494
2495 public int countByUUID_G(String uuid, long groupId)
2496 throws SystemException {
2497 Object[] finderArgs = new Object[] { uuid, new Long(groupId) };
2498
2499 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_UUID_G,
2500 finderArgs, this);
2501
2502 if (count == null) {
2503 Session session = null;
2504
2505 try {
2506 session = openSession();
2507
2508 StringBuilder query = new StringBuilder();
2509
2510 query.append("SELECT COUNT(calEvent) ");
2511 query.append("FROM CalEvent calEvent WHERE ");
2512
2513 if (uuid == null) {
2514 query.append("calEvent.uuid IS NULL");
2515 }
2516 else {
2517 query.append("calEvent.uuid = ?");
2518 }
2519
2520 query.append(" AND ");
2521
2522 query.append("calEvent.groupId = ?");
2523
2524 query.append(" ");
2525
2526 Query q = session.createQuery(query.toString());
2527
2528 QueryPos qPos = QueryPos.getInstance(q);
2529
2530 if (uuid != null) {
2531 qPos.add(uuid);
2532 }
2533
2534 qPos.add(groupId);
2535
2536 count = (Long)q.uniqueResult();
2537 }
2538 catch (Exception e) {
2539 throw processException(e);
2540 }
2541 finally {
2542 if (count == null) {
2543 count = Long.valueOf(0);
2544 }
2545
2546 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID_G,
2547 finderArgs, count);
2548
2549 closeSession(session);
2550 }
2551 }
2552
2553 return count.intValue();
2554 }
2555
2556 public int countByCompanyId(long companyId) throws SystemException {
2557 Object[] finderArgs = new Object[] { new Long(companyId) };
2558
2559 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_COMPANYID,
2560 finderArgs, this);
2561
2562 if (count == null) {
2563 Session session = null;
2564
2565 try {
2566 session = openSession();
2567
2568 StringBuilder query = new StringBuilder();
2569
2570 query.append("SELECT COUNT(calEvent) ");
2571 query.append("FROM CalEvent calEvent WHERE ");
2572
2573 query.append("calEvent.companyId = ?");
2574
2575 query.append(" ");
2576
2577 Query q = session.createQuery(query.toString());
2578
2579 QueryPos qPos = QueryPos.getInstance(q);
2580
2581 qPos.add(companyId);
2582
2583 count = (Long)q.uniqueResult();
2584 }
2585 catch (Exception e) {
2586 throw processException(e);
2587 }
2588 finally {
2589 if (count == null) {
2590 count = Long.valueOf(0);
2591 }
2592
2593 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_COMPANYID,
2594 finderArgs, count);
2595
2596 closeSession(session);
2597 }
2598 }
2599
2600 return count.intValue();
2601 }
2602
2603 public int countByGroupId(long groupId) throws SystemException {
2604 Object[] finderArgs = new Object[] { new Long(groupId) };
2605
2606 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_GROUPID,
2607 finderArgs, this);
2608
2609 if (count == null) {
2610 Session session = null;
2611
2612 try {
2613 session = openSession();
2614
2615 StringBuilder query = new StringBuilder();
2616
2617 query.append("SELECT COUNT(calEvent) ");
2618 query.append("FROM CalEvent calEvent WHERE ");
2619
2620 query.append("calEvent.groupId = ?");
2621
2622 query.append(" ");
2623
2624 Query q = session.createQuery(query.toString());
2625
2626 QueryPos qPos = QueryPos.getInstance(q);
2627
2628 qPos.add(groupId);
2629
2630 count = (Long)q.uniqueResult();
2631 }
2632 catch (Exception e) {
2633 throw processException(e);
2634 }
2635 finally {
2636 if (count == null) {
2637 count = Long.valueOf(0);
2638 }
2639
2640 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_GROUPID,
2641 finderArgs, count);
2642
2643 closeSession(session);
2644 }
2645 }
2646
2647 return count.intValue();
2648 }
2649
2650 public int countByRemindBy(int remindBy) throws SystemException {
2651 Object[] finderArgs = new Object[] { new Integer(remindBy) };
2652
2653 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_REMINDBY,
2654 finderArgs, this);
2655
2656 if (count == null) {
2657 Session session = null;
2658
2659 try {
2660 session = openSession();
2661
2662 StringBuilder query = new StringBuilder();
2663
2664 query.append("SELECT COUNT(calEvent) ");
2665 query.append("FROM CalEvent calEvent WHERE ");
2666
2667 query.append("calEvent.remindBy != ?");
2668
2669 query.append(" ");
2670
2671 Query q = session.createQuery(query.toString());
2672
2673 QueryPos qPos = QueryPos.getInstance(q);
2674
2675 qPos.add(remindBy);
2676
2677 count = (Long)q.uniqueResult();
2678 }
2679 catch (Exception e) {
2680 throw processException(e);
2681 }
2682 finally {
2683 if (count == null) {
2684 count = Long.valueOf(0);
2685 }
2686
2687 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_REMINDBY,
2688 finderArgs, count);
2689
2690 closeSession(session);
2691 }
2692 }
2693
2694 return count.intValue();
2695 }
2696
2697 public int countByG_T(long groupId, String type) throws SystemException {
2698 Object[] finderArgs = new Object[] { new Long(groupId), type };
2699
2700 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_T,
2701 finderArgs, this);
2702
2703 if (count == null) {
2704 Session session = null;
2705
2706 try {
2707 session = openSession();
2708
2709 StringBuilder query = new StringBuilder();
2710
2711 query.append("SELECT COUNT(calEvent) ");
2712 query.append("FROM CalEvent calEvent WHERE ");
2713
2714 query.append("calEvent.groupId = ?");
2715
2716 query.append(" AND ");
2717
2718 if (type == null) {
2719 query.append("calEvent.type IS NULL");
2720 }
2721 else {
2722 query.append("calEvent.type = ?");
2723 }
2724
2725 query.append(" ");
2726
2727 Query q = session.createQuery(query.toString());
2728
2729 QueryPos qPos = QueryPos.getInstance(q);
2730
2731 qPos.add(groupId);
2732
2733 if (type != null) {
2734 qPos.add(type);
2735 }
2736
2737 count = (Long)q.uniqueResult();
2738 }
2739 catch (Exception e) {
2740 throw processException(e);
2741 }
2742 finally {
2743 if (count == null) {
2744 count = Long.valueOf(0);
2745 }
2746
2747 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_T, finderArgs,
2748 count);
2749
2750 closeSession(session);
2751 }
2752 }
2753
2754 return count.intValue();
2755 }
2756
2757 public int countByG_R(long groupId, boolean repeating)
2758 throws SystemException {
2759 Object[] finderArgs = new Object[] {
2760 new Long(groupId), Boolean.valueOf(repeating)
2761 };
2762
2763 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_R,
2764 finderArgs, this);
2765
2766 if (count == null) {
2767 Session session = null;
2768
2769 try {
2770 session = openSession();
2771
2772 StringBuilder query = new StringBuilder();
2773
2774 query.append("SELECT COUNT(calEvent) ");
2775 query.append("FROM CalEvent calEvent WHERE ");
2776
2777 query.append("calEvent.groupId = ?");
2778
2779 query.append(" AND ");
2780
2781 query.append("calEvent.repeating = ?");
2782
2783 query.append(" ");
2784
2785 Query q = session.createQuery(query.toString());
2786
2787 QueryPos qPos = QueryPos.getInstance(q);
2788
2789 qPos.add(groupId);
2790
2791 qPos.add(repeating);
2792
2793 count = (Long)q.uniqueResult();
2794 }
2795 catch (Exception e) {
2796 throw processException(e);
2797 }
2798 finally {
2799 if (count == null) {
2800 count = Long.valueOf(0);
2801 }
2802
2803 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_R, finderArgs,
2804 count);
2805
2806 closeSession(session);
2807 }
2808 }
2809
2810 return count.intValue();
2811 }
2812
2813 public int countAll() throws SystemException {
2814 Object[] finderArgs = new Object[0];
2815
2816 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
2817 finderArgs, this);
2818
2819 if (count == null) {
2820 Session session = null;
2821
2822 try {
2823 session = openSession();
2824
2825 Query q = session.createQuery(
2826 "SELECT COUNT(calEvent) FROM CalEvent calEvent");
2827
2828 count = (Long)q.uniqueResult();
2829 }
2830 catch (Exception e) {
2831 throw processException(e);
2832 }
2833 finally {
2834 if (count == null) {
2835 count = Long.valueOf(0);
2836 }
2837
2838 FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL, finderArgs,
2839 count);
2840
2841 closeSession(session);
2842 }
2843 }
2844
2845 return count.intValue();
2846 }
2847
2848 public void afterPropertiesSet() {
2849 String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
2850 com.liferay.portal.util.PropsUtil.get(
2851 "value.object.listener.com.liferay.portlet.calendar.model.CalEvent")));
2852
2853 if (listenerClassNames.length > 0) {
2854 try {
2855 List<ModelListener<CalEvent>> listenersList = new ArrayList<ModelListener<CalEvent>>();
2856
2857 for (String listenerClassName : listenerClassNames) {
2858 listenersList.add((ModelListener<CalEvent>)Class.forName(
2859 listenerClassName).newInstance());
2860 }
2861
2862 listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
2863 }
2864 catch (Exception e) {
2865 _log.error(e);
2866 }
2867 }
2868 }
2869
2870 @BeanReference(name = "com.liferay.portlet.calendar.service.persistence.CalEventPersistence.impl")
2871 protected com.liferay.portlet.calendar.service.persistence.CalEventPersistence calEventPersistence;
2872 @BeanReference(name = "com.liferay.portal.service.persistence.CompanyPersistence.impl")
2873 protected com.liferay.portal.service.persistence.CompanyPersistence companyPersistence;
2874 @BeanReference(name = "com.liferay.portal.service.persistence.GroupPersistence.impl")
2875 protected com.liferay.portal.service.persistence.GroupPersistence groupPersistence;
2876 @BeanReference(name = "com.liferay.portal.service.persistence.PortletPreferencesPersistence.impl")
2877 protected com.liferay.portal.service.persistence.PortletPreferencesPersistence portletPreferencesPersistence;
2878 @BeanReference(name = "com.liferay.portal.service.persistence.ResourcePersistence.impl")
2879 protected com.liferay.portal.service.persistence.ResourcePersistence resourcePersistence;
2880 @BeanReference(name = "com.liferay.portal.service.persistence.UserPersistence.impl")
2881 protected com.liferay.portal.service.persistence.UserPersistence userPersistence;
2882 @BeanReference(name = "com.liferay.portlet.expando.service.persistence.ExpandoValuePersistence.impl")
2883 protected com.liferay.portlet.expando.service.persistence.ExpandoValuePersistence expandoValuePersistence;
2884 @BeanReference(name = "com.liferay.portlet.social.service.persistence.SocialActivityPersistence.impl")
2885 protected com.liferay.portlet.social.service.persistence.SocialActivityPersistence socialActivityPersistence;
2886 @BeanReference(name = "com.liferay.portlet.tags.service.persistence.TagsAssetPersistence.impl")
2887 protected com.liferay.portlet.tags.service.persistence.TagsAssetPersistence tagsAssetPersistence;
2888 @BeanReference(name = "com.liferay.portlet.tags.service.persistence.TagsEntryPersistence.impl")
2889 protected com.liferay.portlet.tags.service.persistence.TagsEntryPersistence tagsEntryPersistence;
2890 private static Log _log = LogFactoryUtil.getLog(CalEventPersistenceImpl.class);
2891}