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