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.dao.orm.DynamicQuery;
28 import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
29 import com.liferay.portal.kernel.dao.orm.Query;
30 import com.liferay.portal.kernel.dao.orm.QueryPos;
31 import com.liferay.portal.kernel.dao.orm.QueryUtil;
32 import com.liferay.portal.kernel.dao.orm.Session;
33 import com.liferay.portal.kernel.log.Log;
34 import com.liferay.portal.kernel.log.LogFactoryUtil;
35 import com.liferay.portal.kernel.util.GetterUtil;
36 import com.liferay.portal.kernel.util.OrderByComparator;
37 import com.liferay.portal.kernel.util.StringPool;
38 import com.liferay.portal.kernel.util.StringUtil;
39 import com.liferay.portal.kernel.util.Validator;
40 import com.liferay.portal.kernel.uuid.PortalUUIDUtil;
41 import com.liferay.portal.model.ModelListener;
42 import com.liferay.portal.service.persistence.BatchSessionUtil;
43 import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
44
45 import com.liferay.portlet.calendar.NoSuchEventException;
46 import com.liferay.portlet.calendar.model.CalEvent;
47 import com.liferay.portlet.calendar.model.impl.CalEventImpl;
48 import com.liferay.portlet.calendar.model.impl.CalEventModelImpl;
49
50 import java.util.ArrayList;
51 import java.util.Collections;
52 import java.util.Iterator;
53 import java.util.List;
54
55
61 public class CalEventPersistenceImpl extends BasePersistenceImpl
62 implements CalEventPersistence {
63 public CalEvent create(long eventId) {
64 CalEvent calEvent = new CalEventImpl();
65
66 calEvent.setNew(true);
67 calEvent.setPrimaryKey(eventId);
68
69 String uuid = PortalUUIDUtil.generate();
70
71 calEvent.setUuid(uuid);
72
73 return calEvent;
74 }
75
76 public CalEvent remove(long eventId)
77 throws NoSuchEventException, SystemException {
78 Session session = null;
79
80 try {
81 session = openSession();
82
83 CalEvent calEvent = (CalEvent)session.get(CalEventImpl.class,
84 new Long(eventId));
85
86 if (calEvent == null) {
87 if (_log.isWarnEnabled()) {
88 _log.warn("No CalEvent exists with the primary key " +
89 eventId);
90 }
91
92 throw new NoSuchEventException(
93 "No CalEvent exists with the primary key " + eventId);
94 }
95
96 return remove(calEvent);
97 }
98 catch (NoSuchEventException nsee) {
99 throw nsee;
100 }
101 catch (Exception e) {
102 throw processException(e);
103 }
104 finally {
105 closeSession(session);
106 }
107 }
108
109 public CalEvent remove(CalEvent calEvent) throws SystemException {
110 for (ModelListener listener : listeners) {
111 listener.onBeforeRemove(calEvent);
112 }
113
114 calEvent = removeImpl(calEvent);
115
116 for (ModelListener listener : listeners) {
117 listener.onAfterRemove(calEvent);
118 }
119
120 return calEvent;
121 }
122
123 protected CalEvent removeImpl(CalEvent calEvent) throws SystemException {
124 Session session = null;
125
126 try {
127 session = openSession();
128
129 if (BatchSessionUtil.isEnabled()) {
130 Object staleObject = session.get(CalEventImpl.class,
131 calEvent.getPrimaryKeyObj());
132
133 if (staleObject != null) {
134 session.evict(staleObject);
135 }
136 }
137
138 session.delete(calEvent);
139
140 session.flush();
141
142 return calEvent;
143 }
144 catch (Exception e) {
145 throw processException(e);
146 }
147 finally {
148 closeSession(session);
149
150 FinderCacheUtil.clearCache(CalEvent.class.getName());
151 }
152 }
153
154
157 public CalEvent update(CalEvent calEvent) throws SystemException {
158 if (_log.isWarnEnabled()) {
159 _log.warn(
160 "Using the deprecated update(CalEvent calEvent) method. Use update(CalEvent calEvent, boolean merge) instead.");
161 }
162
163 return update(calEvent, false);
164 }
165
166
179 public CalEvent update(CalEvent calEvent, boolean merge)
180 throws SystemException {
181 boolean isNew = calEvent.isNew();
182
183 for (ModelListener listener : listeners) {
184 if (isNew) {
185 listener.onBeforeCreate(calEvent);
186 }
187 else {
188 listener.onBeforeUpdate(calEvent);
189 }
190 }
191
192 calEvent = updateImpl(calEvent, merge);
193
194 for (ModelListener listener : listeners) {
195 if (isNew) {
196 listener.onAfterCreate(calEvent);
197 }
198 else {
199 listener.onAfterUpdate(calEvent);
200 }
201 }
202
203 return calEvent;
204 }
205
206 public CalEvent updateImpl(
207 com.liferay.portlet.calendar.model.CalEvent calEvent, boolean merge)
208 throws SystemException {
209 if (Validator.isNull(calEvent.getUuid())) {
210 String uuid = PortalUUIDUtil.generate();
211
212 calEvent.setUuid(uuid);
213 }
214
215 Session session = null;
216
217 try {
218 session = openSession();
219
220 BatchSessionUtil.update(session, calEvent, merge);
221
222 calEvent.setNew(false);
223
224 return calEvent;
225 }
226 catch (Exception e) {
227 throw processException(e);
228 }
229 finally {
230 closeSession(session);
231
232 FinderCacheUtil.clearCache(CalEvent.class.getName());
233 }
234 }
235
236 public CalEvent findByPrimaryKey(long eventId)
237 throws NoSuchEventException, SystemException {
238 CalEvent calEvent = fetchByPrimaryKey(eventId);
239
240 if (calEvent == null) {
241 if (_log.isWarnEnabled()) {
242 _log.warn("No CalEvent exists with the primary key " + eventId);
243 }
244
245 throw new NoSuchEventException(
246 "No CalEvent exists with the primary key " + eventId);
247 }
248
249 return calEvent;
250 }
251
252 public CalEvent fetchByPrimaryKey(long eventId) throws SystemException {
253 Session session = null;
254
255 try {
256 session = openSession();
257
258 return (CalEvent)session.get(CalEventImpl.class, new Long(eventId));
259 }
260 catch (Exception e) {
261 throw processException(e);
262 }
263 finally {
264 closeSession(session);
265 }
266 }
267
268 public List<CalEvent> findByUuid(String uuid) throws SystemException {
269 boolean finderClassNameCacheEnabled = CalEventModelImpl.CACHE_ENABLED;
270 String finderClassName = CalEvent.class.getName();
271 String finderMethodName = "findByUuid";
272 String[] finderParams = new String[] { String.class.getName() };
273 Object[] finderArgs = new Object[] { uuid };
274
275 Object result = null;
276
277 if (finderClassNameCacheEnabled) {
278 result = FinderCacheUtil.getResult(finderClassName,
279 finderMethodName, finderParams, finderArgs, this);
280 }
281
282 if (result == null) {
283 Session session = null;
284
285 try {
286 session = openSession();
287
288 StringBuilder query = new StringBuilder();
289
290 query.append(
291 "FROM com.liferay.portlet.calendar.model.CalEvent WHERE ");
292
293 if (uuid == null) {
294 query.append("uuid_ IS NULL");
295 }
296 else {
297 query.append("uuid_ = ?");
298 }
299
300 query.append(" ");
301
302 query.append("ORDER BY ");
303
304 query.append("startDate ASC, ");
305 query.append("title ASC");
306
307 Query q = session.createQuery(query.toString());
308
309 QueryPos qPos = QueryPos.getInstance(q);
310
311 if (uuid != null) {
312 qPos.add(uuid);
313 }
314
315 List<CalEvent> list = q.list();
316
317 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
318 finderClassName, finderMethodName, finderParams,
319 finderArgs, list);
320
321 return list;
322 }
323 catch (Exception e) {
324 throw processException(e);
325 }
326 finally {
327 closeSession(session);
328 }
329 }
330 else {
331 return (List<CalEvent>)result;
332 }
333 }
334
335 public List<CalEvent> findByUuid(String uuid, int start, int end)
336 throws SystemException {
337 return findByUuid(uuid, start, end, null);
338 }
339
340 public List<CalEvent> findByUuid(String uuid, int start, int end,
341 OrderByComparator obc) throws SystemException {
342 boolean finderClassNameCacheEnabled = CalEventModelImpl.CACHE_ENABLED;
343 String finderClassName = CalEvent.class.getName();
344 String finderMethodName = "findByUuid";
345 String[] finderParams = new String[] {
346 String.class.getName(),
347
348 "java.lang.Integer", "java.lang.Integer",
349 "com.liferay.portal.kernel.util.OrderByComparator"
350 };
351 Object[] finderArgs = new Object[] {
352 uuid,
353
354 String.valueOf(start), String.valueOf(end), String.valueOf(obc)
355 };
356
357 Object result = null;
358
359 if (finderClassNameCacheEnabled) {
360 result = FinderCacheUtil.getResult(finderClassName,
361 finderMethodName, finderParams, finderArgs, this);
362 }
363
364 if (result == null) {
365 Session session = null;
366
367 try {
368 session = openSession();
369
370 StringBuilder query = new StringBuilder();
371
372 query.append(
373 "FROM com.liferay.portlet.calendar.model.CalEvent WHERE ");
374
375 if (uuid == null) {
376 query.append("uuid_ IS NULL");
377 }
378 else {
379 query.append("uuid_ = ?");
380 }
381
382 query.append(" ");
383
384 if (obc != null) {
385 query.append("ORDER BY ");
386 query.append(obc.getOrderBy());
387 }
388
389 else {
390 query.append("ORDER BY ");
391
392 query.append("startDate ASC, ");
393 query.append("title ASC");
394 }
395
396 Query q = session.createQuery(query.toString());
397
398 QueryPos qPos = QueryPos.getInstance(q);
399
400 if (uuid != null) {
401 qPos.add(uuid);
402 }
403
404 List<CalEvent> list = (List<CalEvent>)QueryUtil.list(q,
405 getDialect(), start, end);
406
407 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
408 finderClassName, finderMethodName, finderParams,
409 finderArgs, list);
410
411 return list;
412 }
413 catch (Exception e) {
414 throw processException(e);
415 }
416 finally {
417 closeSession(session);
418 }
419 }
420 else {
421 return (List<CalEvent>)result;
422 }
423 }
424
425 public CalEvent findByUuid_First(String uuid, OrderByComparator obc)
426 throws NoSuchEventException, SystemException {
427 List<CalEvent> list = findByUuid(uuid, 0, 1, obc);
428
429 if (list.size() == 0) {
430 StringBuilder msg = new StringBuilder();
431
432 msg.append("No CalEvent exists with the key {");
433
434 msg.append("uuid=" + uuid);
435
436 msg.append(StringPool.CLOSE_CURLY_BRACE);
437
438 throw new NoSuchEventException(msg.toString());
439 }
440 else {
441 return list.get(0);
442 }
443 }
444
445 public CalEvent findByUuid_Last(String uuid, OrderByComparator obc)
446 throws NoSuchEventException, SystemException {
447 int count = countByUuid(uuid);
448
449 List<CalEvent> list = findByUuid(uuid, count - 1, count, obc);
450
451 if (list.size() == 0) {
452 StringBuilder msg = new StringBuilder();
453
454 msg.append("No CalEvent exists with the key {");
455
456 msg.append("uuid=" + uuid);
457
458 msg.append(StringPool.CLOSE_CURLY_BRACE);
459
460 throw new NoSuchEventException(msg.toString());
461 }
462 else {
463 return list.get(0);
464 }
465 }
466
467 public CalEvent[] findByUuid_PrevAndNext(long eventId, String uuid,
468 OrderByComparator obc) throws NoSuchEventException, SystemException {
469 CalEvent calEvent = findByPrimaryKey(eventId);
470
471 int count = countByUuid(uuid);
472
473 Session session = null;
474
475 try {
476 session = openSession();
477
478 StringBuilder query = new StringBuilder();
479
480 query.append(
481 "FROM com.liferay.portlet.calendar.model.CalEvent WHERE ");
482
483 if (uuid == null) {
484 query.append("uuid_ IS NULL");
485 }
486 else {
487 query.append("uuid_ = ?");
488 }
489
490 query.append(" ");
491
492 if (obc != null) {
493 query.append("ORDER BY ");
494 query.append(obc.getOrderBy());
495 }
496
497 else {
498 query.append("ORDER BY ");
499
500 query.append("startDate ASC, ");
501 query.append("title ASC");
502 }
503
504 Query q = session.createQuery(query.toString());
505
506 QueryPos qPos = QueryPos.getInstance(q);
507
508 if (uuid != null) {
509 qPos.add(uuid);
510 }
511
512 Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc, calEvent);
513
514 CalEvent[] array = new CalEventImpl[3];
515
516 array[0] = (CalEvent)objArray[0];
517 array[1] = (CalEvent)objArray[1];
518 array[2] = (CalEvent)objArray[2];
519
520 return array;
521 }
522 catch (Exception e) {
523 throw processException(e);
524 }
525 finally {
526 closeSession(session);
527 }
528 }
529
530 public CalEvent findByUUID_G(String uuid, long groupId)
531 throws NoSuchEventException, SystemException {
532 CalEvent calEvent = fetchByUUID_G(uuid, groupId);
533
534 if (calEvent == null) {
535 StringBuilder msg = new StringBuilder();
536
537 msg.append("No CalEvent exists with the key {");
538
539 msg.append("uuid=" + uuid);
540
541 msg.append(", ");
542 msg.append("groupId=" + groupId);
543
544 msg.append(StringPool.CLOSE_CURLY_BRACE);
545
546 if (_log.isWarnEnabled()) {
547 _log.warn(msg.toString());
548 }
549
550 throw new NoSuchEventException(msg.toString());
551 }
552
553 return calEvent;
554 }
555
556 public CalEvent fetchByUUID_G(String uuid, long groupId)
557 throws SystemException {
558 boolean finderClassNameCacheEnabled = CalEventModelImpl.CACHE_ENABLED;
559 String finderClassName = CalEvent.class.getName();
560 String finderMethodName = "fetchByUUID_G";
561 String[] finderParams = new String[] {
562 String.class.getName(), Long.class.getName()
563 };
564 Object[] finderArgs = new Object[] { uuid, new Long(groupId) };
565
566 Object result = null;
567
568 if (finderClassNameCacheEnabled) {
569 result = FinderCacheUtil.getResult(finderClassName,
570 finderMethodName, finderParams, finderArgs, this);
571 }
572
573 if (result == null) {
574 Session session = null;
575
576 try {
577 session = openSession();
578
579 StringBuilder query = new StringBuilder();
580
581 query.append(
582 "FROM com.liferay.portlet.calendar.model.CalEvent WHERE ");
583
584 if (uuid == null) {
585 query.append("uuid_ IS NULL");
586 }
587 else {
588 query.append("uuid_ = ?");
589 }
590
591 query.append(" AND ");
592
593 query.append("groupId = ?");
594
595 query.append(" ");
596
597 query.append("ORDER BY ");
598
599 query.append("startDate ASC, ");
600 query.append("title ASC");
601
602 Query q = session.createQuery(query.toString());
603
604 QueryPos qPos = QueryPos.getInstance(q);
605
606 if (uuid != null) {
607 qPos.add(uuid);
608 }
609
610 qPos.add(groupId);
611
612 List<CalEvent> list = q.list();
613
614 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
615 finderClassName, finderMethodName, finderParams,
616 finderArgs, list);
617
618 if (list.size() == 0) {
619 return null;
620 }
621 else {
622 return list.get(0);
623 }
624 }
625 catch (Exception e) {
626 throw processException(e);
627 }
628 finally {
629 closeSession(session);
630 }
631 }
632 else {
633 List<CalEvent> list = (List<CalEvent>)result;
634
635 if (list.size() == 0) {
636 return null;
637 }
638 else {
639 return list.get(0);
640 }
641 }
642 }
643
644 public List<CalEvent> findByGroupId(long groupId) throws SystemException {
645 boolean finderClassNameCacheEnabled = CalEventModelImpl.CACHE_ENABLED;
646 String finderClassName = CalEvent.class.getName();
647 String finderMethodName = "findByGroupId";
648 String[] finderParams = new String[] { Long.class.getName() };
649 Object[] finderArgs = new Object[] { new Long(groupId) };
650
651 Object result = null;
652
653 if (finderClassNameCacheEnabled) {
654 result = FinderCacheUtil.getResult(finderClassName,
655 finderMethodName, finderParams, finderArgs, this);
656 }
657
658 if (result == null) {
659 Session session = null;
660
661 try {
662 session = openSession();
663
664 StringBuilder query = new StringBuilder();
665
666 query.append(
667 "FROM com.liferay.portlet.calendar.model.CalEvent WHERE ");
668
669 query.append("groupId = ?");
670
671 query.append(" ");
672
673 query.append("ORDER BY ");
674
675 query.append("startDate ASC, ");
676 query.append("title ASC");
677
678 Query q = session.createQuery(query.toString());
679
680 QueryPos qPos = QueryPos.getInstance(q);
681
682 qPos.add(groupId);
683
684 List<CalEvent> list = q.list();
685
686 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
687 finderClassName, finderMethodName, finderParams,
688 finderArgs, list);
689
690 return list;
691 }
692 catch (Exception e) {
693 throw processException(e);
694 }
695 finally {
696 closeSession(session);
697 }
698 }
699 else {
700 return (List<CalEvent>)result;
701 }
702 }
703
704 public List<CalEvent> findByGroupId(long groupId, int start, int end)
705 throws SystemException {
706 return findByGroupId(groupId, start, end, null);
707 }
708
709 public List<CalEvent> findByGroupId(long groupId, int start, int end,
710 OrderByComparator obc) throws SystemException {
711 boolean finderClassNameCacheEnabled = CalEventModelImpl.CACHE_ENABLED;
712 String finderClassName = CalEvent.class.getName();
713 String finderMethodName = "findByGroupId";
714 String[] finderParams = new String[] {
715 Long.class.getName(),
716
717 "java.lang.Integer", "java.lang.Integer",
718 "com.liferay.portal.kernel.util.OrderByComparator"
719 };
720 Object[] finderArgs = new Object[] {
721 new Long(groupId),
722
723 String.valueOf(start), String.valueOf(end), String.valueOf(obc)
724 };
725
726 Object result = null;
727
728 if (finderClassNameCacheEnabled) {
729 result = FinderCacheUtil.getResult(finderClassName,
730 finderMethodName, finderParams, finderArgs, this);
731 }
732
733 if (result == null) {
734 Session session = null;
735
736 try {
737 session = openSession();
738
739 StringBuilder query = new StringBuilder();
740
741 query.append(
742 "FROM com.liferay.portlet.calendar.model.CalEvent WHERE ");
743
744 query.append("groupId = ?");
745
746 query.append(" ");
747
748 if (obc != null) {
749 query.append("ORDER BY ");
750 query.append(obc.getOrderBy());
751 }
752
753 else {
754 query.append("ORDER BY ");
755
756 query.append("startDate ASC, ");
757 query.append("title ASC");
758 }
759
760 Query q = session.createQuery(query.toString());
761
762 QueryPos qPos = QueryPos.getInstance(q);
763
764 qPos.add(groupId);
765
766 List<CalEvent> list = (List<CalEvent>)QueryUtil.list(q,
767 getDialect(), start, end);
768
769 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
770 finderClassName, finderMethodName, finderParams,
771 finderArgs, list);
772
773 return list;
774 }
775 catch (Exception e) {
776 throw processException(e);
777 }
778 finally {
779 closeSession(session);
780 }
781 }
782 else {
783 return (List<CalEvent>)result;
784 }
785 }
786
787 public CalEvent findByGroupId_First(long groupId, OrderByComparator obc)
788 throws NoSuchEventException, SystemException {
789 List<CalEvent> list = findByGroupId(groupId, 0, 1, obc);
790
791 if (list.size() == 0) {
792 StringBuilder msg = new StringBuilder();
793
794 msg.append("No CalEvent exists with the key {");
795
796 msg.append("groupId=" + groupId);
797
798 msg.append(StringPool.CLOSE_CURLY_BRACE);
799
800 throw new NoSuchEventException(msg.toString());
801 }
802 else {
803 return list.get(0);
804 }
805 }
806
807 public CalEvent findByGroupId_Last(long groupId, OrderByComparator obc)
808 throws NoSuchEventException, SystemException {
809 int count = countByGroupId(groupId);
810
811 List<CalEvent> list = findByGroupId(groupId, count - 1, count, obc);
812
813 if (list.size() == 0) {
814 StringBuilder msg = new StringBuilder();
815
816 msg.append("No CalEvent exists with the key {");
817
818 msg.append("groupId=" + groupId);
819
820 msg.append(StringPool.CLOSE_CURLY_BRACE);
821
822 throw new NoSuchEventException(msg.toString());
823 }
824 else {
825 return list.get(0);
826 }
827 }
828
829 public CalEvent[] findByGroupId_PrevAndNext(long eventId, long groupId,
830 OrderByComparator obc) throws NoSuchEventException, SystemException {
831 CalEvent calEvent = findByPrimaryKey(eventId);
832
833 int count = countByGroupId(groupId);
834
835 Session session = null;
836
837 try {
838 session = openSession();
839
840 StringBuilder query = new StringBuilder();
841
842 query.append(
843 "FROM com.liferay.portlet.calendar.model.CalEvent WHERE ");
844
845 query.append("groupId = ?");
846
847 query.append(" ");
848
849 if (obc != null) {
850 query.append("ORDER BY ");
851 query.append(obc.getOrderBy());
852 }
853
854 else {
855 query.append("ORDER BY ");
856
857 query.append("startDate ASC, ");
858 query.append("title ASC");
859 }
860
861 Query q = session.createQuery(query.toString());
862
863 QueryPos qPos = QueryPos.getInstance(q);
864
865 qPos.add(groupId);
866
867 Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc, calEvent);
868
869 CalEvent[] array = new CalEventImpl[3];
870
871 array[0] = (CalEvent)objArray[0];
872 array[1] = (CalEvent)objArray[1];
873 array[2] = (CalEvent)objArray[2];
874
875 return array;
876 }
877 catch (Exception e) {
878 throw processException(e);
879 }
880 finally {
881 closeSession(session);
882 }
883 }
884
885 public List<CalEvent> findByG_T(long groupId, String type)
886 throws SystemException {
887 boolean finderClassNameCacheEnabled = CalEventModelImpl.CACHE_ENABLED;
888 String finderClassName = CalEvent.class.getName();
889 String finderMethodName = "findByG_T";
890 String[] finderParams = new String[] {
891 Long.class.getName(), String.class.getName()
892 };
893 Object[] finderArgs = new Object[] { new Long(groupId), type };
894
895 Object result = null;
896
897 if (finderClassNameCacheEnabled) {
898 result = FinderCacheUtil.getResult(finderClassName,
899 finderMethodName, finderParams, finderArgs, this);
900 }
901
902 if (result == 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("groupId = ?");
914
915 query.append(" AND ");
916
917 if (type == null) {
918 query.append("type_ IS NULL");
919 }
920 else {
921 query.append("type_ = ?");
922 }
923
924 query.append(" ");
925
926 query.append("ORDER BY ");
927
928 query.append("startDate ASC, ");
929 query.append("title ASC");
930
931 Query q = session.createQuery(query.toString());
932
933 QueryPos qPos = QueryPos.getInstance(q);
934
935 qPos.add(groupId);
936
937 if (type != null) {
938 qPos.add(type);
939 }
940
941 List<CalEvent> list = q.list();
942
943 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
944 finderClassName, finderMethodName, finderParams,
945 finderArgs, list);
946
947 return list;
948 }
949 catch (Exception e) {
950 throw processException(e);
951 }
952 finally {
953 closeSession(session);
954 }
955 }
956 else {
957 return (List<CalEvent>)result;
958 }
959 }
960
961 public List<CalEvent> findByG_T(long groupId, String type, int start,
962 int end) throws SystemException {
963 return findByG_T(groupId, type, start, end, null);
964 }
965
966 public List<CalEvent> findByG_T(long groupId, String type, int start,
967 int end, OrderByComparator obc) throws SystemException {
968 boolean finderClassNameCacheEnabled = CalEventModelImpl.CACHE_ENABLED;
969 String finderClassName = CalEvent.class.getName();
970 String finderMethodName = "findByG_T";
971 String[] finderParams = new String[] {
972 Long.class.getName(), String.class.getName(),
973
974 "java.lang.Integer", "java.lang.Integer",
975 "com.liferay.portal.kernel.util.OrderByComparator"
976 };
977 Object[] finderArgs = new Object[] {
978 new Long(groupId),
979
980 type,
981
982 String.valueOf(start), String.valueOf(end), String.valueOf(obc)
983 };
984
985 Object result = null;
986
987 if (finderClassNameCacheEnabled) {
988 result = FinderCacheUtil.getResult(finderClassName,
989 finderMethodName, finderParams, finderArgs, this);
990 }
991
992 if (result == null) {
993 Session session = null;
994
995 try {
996 session = openSession();
997
998 StringBuilder query = new StringBuilder();
999
1000 query.append(
1001 "FROM com.liferay.portlet.calendar.model.CalEvent WHERE ");
1002
1003 query.append("groupId = ?");
1004
1005 query.append(" AND ");
1006
1007 if (type == null) {
1008 query.append("type_ IS NULL");
1009 }
1010 else {
1011 query.append("type_ = ?");
1012 }
1013
1014 query.append(" ");
1015
1016 if (obc != null) {
1017 query.append("ORDER BY ");
1018 query.append(obc.getOrderBy());
1019 }
1020
1021 else {
1022 query.append("ORDER BY ");
1023
1024 query.append("startDate ASC, ");
1025 query.append("title ASC");
1026 }
1027
1028 Query q = session.createQuery(query.toString());
1029
1030 QueryPos qPos = QueryPos.getInstance(q);
1031
1032 qPos.add(groupId);
1033
1034 if (type != null) {
1035 qPos.add(type);
1036 }
1037
1038 List<CalEvent> list = (List<CalEvent>)QueryUtil.list(q,
1039 getDialect(), start, end);
1040
1041 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
1042 finderClassName, finderMethodName, finderParams,
1043 finderArgs, list);
1044
1045 return list;
1046 }
1047 catch (Exception e) {
1048 throw processException(e);
1049 }
1050 finally {
1051 closeSession(session);
1052 }
1053 }
1054 else {
1055 return (List<CalEvent>)result;
1056 }
1057 }
1058
1059 public CalEvent findByG_T_First(long groupId, String type,
1060 OrderByComparator obc) throws NoSuchEventException, SystemException {
1061 List<CalEvent> list = findByG_T(groupId, type, 0, 1, obc);
1062
1063 if (list.size() == 0) {
1064 StringBuilder msg = new StringBuilder();
1065
1066 msg.append("No CalEvent exists with the key {");
1067
1068 msg.append("groupId=" + groupId);
1069
1070 msg.append(", ");
1071 msg.append("type=" + type);
1072
1073 msg.append(StringPool.CLOSE_CURLY_BRACE);
1074
1075 throw new NoSuchEventException(msg.toString());
1076 }
1077 else {
1078 return list.get(0);
1079 }
1080 }
1081
1082 public CalEvent findByG_T_Last(long groupId, String type,
1083 OrderByComparator obc) throws NoSuchEventException, SystemException {
1084 int count = countByG_T(groupId, type);
1085
1086 List<CalEvent> list = findByG_T(groupId, type, count - 1, count, obc);
1087
1088 if (list.size() == 0) {
1089 StringBuilder msg = new StringBuilder();
1090
1091 msg.append("No CalEvent exists with the key {");
1092
1093 msg.append("groupId=" + groupId);
1094
1095 msg.append(", ");
1096 msg.append("type=" + type);
1097
1098 msg.append(StringPool.CLOSE_CURLY_BRACE);
1099
1100 throw new NoSuchEventException(msg.toString());
1101 }
1102 else {
1103 return list.get(0);
1104 }
1105 }
1106
1107 public CalEvent[] findByG_T_PrevAndNext(long eventId, long groupId,
1108 String type, OrderByComparator obc)
1109 throws NoSuchEventException, SystemException {
1110 CalEvent calEvent = findByPrimaryKey(eventId);
1111
1112 int count = countByG_T(groupId, type);
1113
1114 Session session = null;
1115
1116 try {
1117 session = openSession();
1118
1119 StringBuilder query = new StringBuilder();
1120
1121 query.append(
1122 "FROM com.liferay.portlet.calendar.model.CalEvent WHERE ");
1123
1124 query.append("groupId = ?");
1125
1126 query.append(" AND ");
1127
1128 if (type == null) {
1129 query.append("type_ IS NULL");
1130 }
1131 else {
1132 query.append("type_ = ?");
1133 }
1134
1135 query.append(" ");
1136
1137 if (obc != null) {
1138 query.append("ORDER BY ");
1139 query.append(obc.getOrderBy());
1140 }
1141
1142 else {
1143 query.append("ORDER BY ");
1144
1145 query.append("startDate ASC, ");
1146 query.append("title ASC");
1147 }
1148
1149 Query q = session.createQuery(query.toString());
1150
1151 QueryPos qPos = QueryPos.getInstance(q);
1152
1153 qPos.add(groupId);
1154
1155 if (type != null) {
1156 qPos.add(type);
1157 }
1158
1159 Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc, calEvent);
1160
1161 CalEvent[] array = new CalEventImpl[3];
1162
1163 array[0] = (CalEvent)objArray[0];
1164 array[1] = (CalEvent)objArray[1];
1165 array[2] = (CalEvent)objArray[2];
1166
1167 return array;
1168 }
1169 catch (Exception e) {
1170 throw processException(e);
1171 }
1172 finally {
1173 closeSession(session);
1174 }
1175 }
1176
1177 public List<CalEvent> findByG_R(long groupId, boolean repeating)
1178 throws SystemException {
1179 boolean finderClassNameCacheEnabled = CalEventModelImpl.CACHE_ENABLED;
1180 String finderClassName = CalEvent.class.getName();
1181 String finderMethodName = "findByG_R";
1182 String[] finderParams = new String[] {
1183 Long.class.getName(), Boolean.class.getName()
1184 };
1185 Object[] finderArgs = new Object[] {
1186 new Long(groupId), Boolean.valueOf(repeating)
1187 };
1188
1189 Object result = null;
1190
1191 if (finderClassNameCacheEnabled) {
1192 result = FinderCacheUtil.getResult(finderClassName,
1193 finderMethodName, finderParams, finderArgs, this);
1194 }
1195
1196 if (result == null) {
1197 Session session = null;
1198
1199 try {
1200 session = openSession();
1201
1202 StringBuilder query = new StringBuilder();
1203
1204 query.append(
1205 "FROM com.liferay.portlet.calendar.model.CalEvent WHERE ");
1206
1207 query.append("groupId = ?");
1208
1209 query.append(" AND ");
1210
1211 query.append("repeating = ?");
1212
1213 query.append(" ");
1214
1215 query.append("ORDER BY ");
1216
1217 query.append("startDate ASC, ");
1218 query.append("title ASC");
1219
1220 Query q = session.createQuery(query.toString());
1221
1222 QueryPos qPos = QueryPos.getInstance(q);
1223
1224 qPos.add(groupId);
1225
1226 qPos.add(repeating);
1227
1228 List<CalEvent> list = q.list();
1229
1230 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
1231 finderClassName, finderMethodName, finderParams,
1232 finderArgs, list);
1233
1234 return list;
1235 }
1236 catch (Exception e) {
1237 throw processException(e);
1238 }
1239 finally {
1240 closeSession(session);
1241 }
1242 }
1243 else {
1244 return (List<CalEvent>)result;
1245 }
1246 }
1247
1248 public List<CalEvent> findByG_R(long groupId, boolean repeating, int start,
1249 int end) throws SystemException {
1250 return findByG_R(groupId, repeating, start, end, null);
1251 }
1252
1253 public List<CalEvent> findByG_R(long groupId, boolean repeating, int start,
1254 int end, OrderByComparator obc) throws SystemException {
1255 boolean finderClassNameCacheEnabled = CalEventModelImpl.CACHE_ENABLED;
1256 String finderClassName = CalEvent.class.getName();
1257 String finderMethodName = "findByG_R";
1258 String[] finderParams = new String[] {
1259 Long.class.getName(), Boolean.class.getName(),
1260
1261 "java.lang.Integer", "java.lang.Integer",
1262 "com.liferay.portal.kernel.util.OrderByComparator"
1263 };
1264 Object[] finderArgs = new Object[] {
1265 new Long(groupId), Boolean.valueOf(repeating),
1266
1267 String.valueOf(start), String.valueOf(end), String.valueOf(obc)
1268 };
1269
1270 Object result = null;
1271
1272 if (finderClassNameCacheEnabled) {
1273 result = FinderCacheUtil.getResult(finderClassName,
1274 finderMethodName, finderParams, finderArgs, this);
1275 }
1276
1277 if (result == null) {
1278 Session session = null;
1279
1280 try {
1281 session = openSession();
1282
1283 StringBuilder query = new StringBuilder();
1284
1285 query.append(
1286 "FROM com.liferay.portlet.calendar.model.CalEvent WHERE ");
1287
1288 query.append("groupId = ?");
1289
1290 query.append(" AND ");
1291
1292 query.append("repeating = ?");
1293
1294 query.append(" ");
1295
1296 if (obc != null) {
1297 query.append("ORDER BY ");
1298 query.append(obc.getOrderBy());
1299 }
1300
1301 else {
1302 query.append("ORDER BY ");
1303
1304 query.append("startDate ASC, ");
1305 query.append("title ASC");
1306 }
1307
1308 Query q = session.createQuery(query.toString());
1309
1310 QueryPos qPos = QueryPos.getInstance(q);
1311
1312 qPos.add(groupId);
1313
1314 qPos.add(repeating);
1315
1316 List<CalEvent> list = (List<CalEvent>)QueryUtil.list(q,
1317 getDialect(), start, end);
1318
1319 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
1320 finderClassName, finderMethodName, finderParams,
1321 finderArgs, list);
1322
1323 return list;
1324 }
1325 catch (Exception e) {
1326 throw processException(e);
1327 }
1328 finally {
1329 closeSession(session);
1330 }
1331 }
1332 else {
1333 return (List<CalEvent>)result;
1334 }
1335 }
1336
1337 public CalEvent findByG_R_First(long groupId, boolean repeating,
1338 OrderByComparator obc) throws NoSuchEventException, SystemException {
1339 List<CalEvent> list = findByG_R(groupId, repeating, 0, 1, obc);
1340
1341 if (list.size() == 0) {
1342 StringBuilder msg = new StringBuilder();
1343
1344 msg.append("No CalEvent exists with the key {");
1345
1346 msg.append("groupId=" + groupId);
1347
1348 msg.append(", ");
1349 msg.append("repeating=" + repeating);
1350
1351 msg.append(StringPool.CLOSE_CURLY_BRACE);
1352
1353 throw new NoSuchEventException(msg.toString());
1354 }
1355 else {
1356 return list.get(0);
1357 }
1358 }
1359
1360 public CalEvent findByG_R_Last(long groupId, boolean repeating,
1361 OrderByComparator obc) throws NoSuchEventException, SystemException {
1362 int count = countByG_R(groupId, repeating);
1363
1364 List<CalEvent> list = findByG_R(groupId, repeating, count - 1, count,
1365 obc);
1366
1367 if (list.size() == 0) {
1368 StringBuilder msg = new StringBuilder();
1369
1370 msg.append("No CalEvent exists with the key {");
1371
1372 msg.append("groupId=" + groupId);
1373
1374 msg.append(", ");
1375 msg.append("repeating=" + repeating);
1376
1377 msg.append(StringPool.CLOSE_CURLY_BRACE);
1378
1379 throw new NoSuchEventException(msg.toString());
1380 }
1381 else {
1382 return list.get(0);
1383 }
1384 }
1385
1386 public CalEvent[] findByG_R_PrevAndNext(long eventId, long groupId,
1387 boolean repeating, OrderByComparator obc)
1388 throws NoSuchEventException, SystemException {
1389 CalEvent calEvent = findByPrimaryKey(eventId);
1390
1391 int count = countByG_R(groupId, repeating);
1392
1393 Session session = null;
1394
1395 try {
1396 session = openSession();
1397
1398 StringBuilder query = new StringBuilder();
1399
1400 query.append(
1401 "FROM com.liferay.portlet.calendar.model.CalEvent WHERE ");
1402
1403 query.append("groupId = ?");
1404
1405 query.append(" AND ");
1406
1407 query.append("repeating = ?");
1408
1409 query.append(" ");
1410
1411 if (obc != null) {
1412 query.append("ORDER BY ");
1413 query.append(obc.getOrderBy());
1414 }
1415
1416 else {
1417 query.append("ORDER BY ");
1418
1419 query.append("startDate ASC, ");
1420 query.append("title ASC");
1421 }
1422
1423 Query q = session.createQuery(query.toString());
1424
1425 QueryPos qPos = QueryPos.getInstance(q);
1426
1427 qPos.add(groupId);
1428
1429 qPos.add(repeating);
1430
1431 Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc, calEvent);
1432
1433 CalEvent[] array = new CalEventImpl[3];
1434
1435 array[0] = (CalEvent)objArray[0];
1436 array[1] = (CalEvent)objArray[1];
1437 array[2] = (CalEvent)objArray[2];
1438
1439 return array;
1440 }
1441 catch (Exception e) {
1442 throw processException(e);
1443 }
1444 finally {
1445 closeSession(session);
1446 }
1447 }
1448
1449 public List<Object> findWithDynamicQuery(DynamicQuery dynamicQuery)
1450 throws SystemException {
1451 Session session = null;
1452
1453 try {
1454 session = openSession();
1455
1456 dynamicQuery.compile(session);
1457
1458 return dynamicQuery.list();
1459 }
1460 catch (Exception e) {
1461 throw processException(e);
1462 }
1463 finally {
1464 closeSession(session);
1465 }
1466 }
1467
1468 public List<Object> findWithDynamicQuery(DynamicQuery dynamicQuery,
1469 int start, int end) throws SystemException {
1470 Session session = null;
1471
1472 try {
1473 session = openSession();
1474
1475 dynamicQuery.setLimit(start, end);
1476
1477 dynamicQuery.compile(session);
1478
1479 return dynamicQuery.list();
1480 }
1481 catch (Exception e) {
1482 throw processException(e);
1483 }
1484 finally {
1485 closeSession(session);
1486 }
1487 }
1488
1489 public List<CalEvent> findAll() throws SystemException {
1490 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1491 }
1492
1493 public List<CalEvent> findAll(int start, int end) throws SystemException {
1494 return findAll(start, end, null);
1495 }
1496
1497 public List<CalEvent> findAll(int start, int end, OrderByComparator obc)
1498 throws SystemException {
1499 boolean finderClassNameCacheEnabled = CalEventModelImpl.CACHE_ENABLED;
1500 String finderClassName = CalEvent.class.getName();
1501 String finderMethodName = "findAll";
1502 String[] finderParams = new String[] {
1503 "java.lang.Integer", "java.lang.Integer",
1504 "com.liferay.portal.kernel.util.OrderByComparator"
1505 };
1506 Object[] finderArgs = new Object[] {
1507 String.valueOf(start), String.valueOf(end), String.valueOf(obc)
1508 };
1509
1510 Object result = null;
1511
1512 if (finderClassNameCacheEnabled) {
1513 result = FinderCacheUtil.getResult(finderClassName,
1514 finderMethodName, finderParams, finderArgs, this);
1515 }
1516
1517 if (result == null) {
1518 Session session = null;
1519
1520 try {
1521 session = openSession();
1522
1523 StringBuilder query = new StringBuilder();
1524
1525 query.append(
1526 "FROM com.liferay.portlet.calendar.model.CalEvent ");
1527
1528 if (obc != null) {
1529 query.append("ORDER BY ");
1530 query.append(obc.getOrderBy());
1531 }
1532
1533 else {
1534 query.append("ORDER BY ");
1535
1536 query.append("startDate ASC, ");
1537 query.append("title ASC");
1538 }
1539
1540 Query q = session.createQuery(query.toString());
1541
1542 List<CalEvent> list = null;
1543
1544 if (obc == null) {
1545 list = (List<CalEvent>)QueryUtil.list(q, getDialect(),
1546 start, end, false);
1547
1548 Collections.sort(list);
1549 }
1550 else {
1551 list = (List<CalEvent>)QueryUtil.list(q, getDialect(),
1552 start, end);
1553 }
1554
1555 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
1556 finderClassName, finderMethodName, finderParams,
1557 finderArgs, list);
1558
1559 return list;
1560 }
1561 catch (Exception e) {
1562 throw processException(e);
1563 }
1564 finally {
1565 closeSession(session);
1566 }
1567 }
1568 else {
1569 return (List<CalEvent>)result;
1570 }
1571 }
1572
1573 public void removeByUuid(String uuid) throws SystemException {
1574 for (CalEvent calEvent : findByUuid(uuid)) {
1575 remove(calEvent);
1576 }
1577 }
1578
1579 public void removeByUUID_G(String uuid, long groupId)
1580 throws NoSuchEventException, SystemException {
1581 CalEvent calEvent = findByUUID_G(uuid, groupId);
1582
1583 remove(calEvent);
1584 }
1585
1586 public void removeByGroupId(long groupId) throws SystemException {
1587 for (CalEvent calEvent : findByGroupId(groupId)) {
1588 remove(calEvent);
1589 }
1590 }
1591
1592 public void removeByG_T(long groupId, String type)
1593 throws SystemException {
1594 for (CalEvent calEvent : findByG_T(groupId, type)) {
1595 remove(calEvent);
1596 }
1597 }
1598
1599 public void removeByG_R(long groupId, boolean repeating)
1600 throws SystemException {
1601 for (CalEvent calEvent : findByG_R(groupId, repeating)) {
1602 remove(calEvent);
1603 }
1604 }
1605
1606 public void removeAll() throws SystemException {
1607 for (CalEvent calEvent : findAll()) {
1608 remove(calEvent);
1609 }
1610 }
1611
1612 public int countByUuid(String uuid) throws SystemException {
1613 boolean finderClassNameCacheEnabled = CalEventModelImpl.CACHE_ENABLED;
1614 String finderClassName = CalEvent.class.getName();
1615 String finderMethodName = "countByUuid";
1616 String[] finderParams = new String[] { String.class.getName() };
1617 Object[] finderArgs = new Object[] { uuid };
1618
1619 Object result = null;
1620
1621 if (finderClassNameCacheEnabled) {
1622 result = FinderCacheUtil.getResult(finderClassName,
1623 finderMethodName, finderParams, finderArgs, this);
1624 }
1625
1626 if (result == null) {
1627 Session session = null;
1628
1629 try {
1630 session = openSession();
1631
1632 StringBuilder query = new StringBuilder();
1633
1634 query.append("SELECT COUNT(*) ");
1635 query.append(
1636 "FROM com.liferay.portlet.calendar.model.CalEvent WHERE ");
1637
1638 if (uuid == null) {
1639 query.append("uuid_ IS NULL");
1640 }
1641 else {
1642 query.append("uuid_ = ?");
1643 }
1644
1645 query.append(" ");
1646
1647 Query q = session.createQuery(query.toString());
1648
1649 QueryPos qPos = QueryPos.getInstance(q);
1650
1651 if (uuid != null) {
1652 qPos.add(uuid);
1653 }
1654
1655 Long count = null;
1656
1657 Iterator<Long> itr = q.list().iterator();
1658
1659 if (itr.hasNext()) {
1660 count = itr.next();
1661 }
1662
1663 if (count == null) {
1664 count = new Long(0);
1665 }
1666
1667 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
1668 finderClassName, finderMethodName, finderParams,
1669 finderArgs, count);
1670
1671 return count.intValue();
1672 }
1673 catch (Exception e) {
1674 throw processException(e);
1675 }
1676 finally {
1677 closeSession(session);
1678 }
1679 }
1680 else {
1681 return ((Long)result).intValue();
1682 }
1683 }
1684
1685 public int countByUUID_G(String uuid, long groupId)
1686 throws SystemException {
1687 boolean finderClassNameCacheEnabled = CalEventModelImpl.CACHE_ENABLED;
1688 String finderClassName = CalEvent.class.getName();
1689 String finderMethodName = "countByUUID_G";
1690 String[] finderParams = new String[] {
1691 String.class.getName(), Long.class.getName()
1692 };
1693 Object[] finderArgs = new Object[] { uuid, new Long(groupId) };
1694
1695 Object result = null;
1696
1697 if (finderClassNameCacheEnabled) {
1698 result = FinderCacheUtil.getResult(finderClassName,
1699 finderMethodName, finderParams, finderArgs, this);
1700 }
1701
1702 if (result == null) {
1703 Session session = null;
1704
1705 try {
1706 session = openSession();
1707
1708 StringBuilder query = new StringBuilder();
1709
1710 query.append("SELECT COUNT(*) ");
1711 query.append(
1712 "FROM com.liferay.portlet.calendar.model.CalEvent WHERE ");
1713
1714 if (uuid == null) {
1715 query.append("uuid_ IS NULL");
1716 }
1717 else {
1718 query.append("uuid_ = ?");
1719 }
1720
1721 query.append(" AND ");
1722
1723 query.append("groupId = ?");
1724
1725 query.append(" ");
1726
1727 Query q = session.createQuery(query.toString());
1728
1729 QueryPos qPos = QueryPos.getInstance(q);
1730
1731 if (uuid != null) {
1732 qPos.add(uuid);
1733 }
1734
1735 qPos.add(groupId);
1736
1737 Long count = null;
1738
1739 Iterator<Long> itr = q.list().iterator();
1740
1741 if (itr.hasNext()) {
1742 count = itr.next();
1743 }
1744
1745 if (count == null) {
1746 count = new Long(0);
1747 }
1748
1749 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
1750 finderClassName, finderMethodName, finderParams,
1751 finderArgs, count);
1752
1753 return count.intValue();
1754 }
1755 catch (Exception e) {
1756 throw processException(e);
1757 }
1758 finally {
1759 closeSession(session);
1760 }
1761 }
1762 else {
1763 return ((Long)result).intValue();
1764 }
1765 }
1766
1767 public int countByGroupId(long groupId) throws SystemException {
1768 boolean finderClassNameCacheEnabled = CalEventModelImpl.CACHE_ENABLED;
1769 String finderClassName = CalEvent.class.getName();
1770 String finderMethodName = "countByGroupId";
1771 String[] finderParams = new String[] { Long.class.getName() };
1772 Object[] finderArgs = new Object[] { new Long(groupId) };
1773
1774 Object result = null;
1775
1776 if (finderClassNameCacheEnabled) {
1777 result = FinderCacheUtil.getResult(finderClassName,
1778 finderMethodName, finderParams, finderArgs, this);
1779 }
1780
1781 if (result == null) {
1782 Session session = null;
1783
1784 try {
1785 session = openSession();
1786
1787 StringBuilder query = new StringBuilder();
1788
1789 query.append("SELECT COUNT(*) ");
1790 query.append(
1791 "FROM com.liferay.portlet.calendar.model.CalEvent WHERE ");
1792
1793 query.append("groupId = ?");
1794
1795 query.append(" ");
1796
1797 Query q = session.createQuery(query.toString());
1798
1799 QueryPos qPos = QueryPos.getInstance(q);
1800
1801 qPos.add(groupId);
1802
1803 Long count = null;
1804
1805 Iterator<Long> itr = q.list().iterator();
1806
1807 if (itr.hasNext()) {
1808 count = itr.next();
1809 }
1810
1811 if (count == null) {
1812 count = new Long(0);
1813 }
1814
1815 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
1816 finderClassName, finderMethodName, finderParams,
1817 finderArgs, count);
1818
1819 return count.intValue();
1820 }
1821 catch (Exception e) {
1822 throw processException(e);
1823 }
1824 finally {
1825 closeSession(session);
1826 }
1827 }
1828 else {
1829 return ((Long)result).intValue();
1830 }
1831 }
1832
1833 public int countByG_T(long groupId, String type) throws SystemException {
1834 boolean finderClassNameCacheEnabled = CalEventModelImpl.CACHE_ENABLED;
1835 String finderClassName = CalEvent.class.getName();
1836 String finderMethodName = "countByG_T";
1837 String[] finderParams = new String[] {
1838 Long.class.getName(), String.class.getName()
1839 };
1840 Object[] finderArgs = new Object[] { new Long(groupId), type };
1841
1842 Object result = null;
1843
1844 if (finderClassNameCacheEnabled) {
1845 result = FinderCacheUtil.getResult(finderClassName,
1846 finderMethodName, finderParams, finderArgs, this);
1847 }
1848
1849 if (result == null) {
1850 Session session = null;
1851
1852 try {
1853 session = openSession();
1854
1855 StringBuilder query = new StringBuilder();
1856
1857 query.append("SELECT COUNT(*) ");
1858 query.append(
1859 "FROM com.liferay.portlet.calendar.model.CalEvent WHERE ");
1860
1861 query.append("groupId = ?");
1862
1863 query.append(" AND ");
1864
1865 if (type == null) {
1866 query.append("type_ IS NULL");
1867 }
1868 else {
1869 query.append("type_ = ?");
1870 }
1871
1872 query.append(" ");
1873
1874 Query q = session.createQuery(query.toString());
1875
1876 QueryPos qPos = QueryPos.getInstance(q);
1877
1878 qPos.add(groupId);
1879
1880 if (type != null) {
1881 qPos.add(type);
1882 }
1883
1884 Long count = null;
1885
1886 Iterator<Long> itr = q.list().iterator();
1887
1888 if (itr.hasNext()) {
1889 count = itr.next();
1890 }
1891
1892 if (count == null) {
1893 count = new Long(0);
1894 }
1895
1896 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
1897 finderClassName, finderMethodName, finderParams,
1898 finderArgs, count);
1899
1900 return count.intValue();
1901 }
1902 catch (Exception e) {
1903 throw processException(e);
1904 }
1905 finally {
1906 closeSession(session);
1907 }
1908 }
1909 else {
1910 return ((Long)result).intValue();
1911 }
1912 }
1913
1914 public int countByG_R(long groupId, boolean repeating)
1915 throws SystemException {
1916 boolean finderClassNameCacheEnabled = CalEventModelImpl.CACHE_ENABLED;
1917 String finderClassName = CalEvent.class.getName();
1918 String finderMethodName = "countByG_R";
1919 String[] finderParams = new String[] {
1920 Long.class.getName(), Boolean.class.getName()
1921 };
1922 Object[] finderArgs = new Object[] {
1923 new Long(groupId), Boolean.valueOf(repeating)
1924 };
1925
1926 Object result = null;
1927
1928 if (finderClassNameCacheEnabled) {
1929 result = FinderCacheUtil.getResult(finderClassName,
1930 finderMethodName, finderParams, finderArgs, this);
1931 }
1932
1933 if (result == null) {
1934 Session session = null;
1935
1936 try {
1937 session = openSession();
1938
1939 StringBuilder query = new StringBuilder();
1940
1941 query.append("SELECT COUNT(*) ");
1942 query.append(
1943 "FROM com.liferay.portlet.calendar.model.CalEvent WHERE ");
1944
1945 query.append("groupId = ?");
1946
1947 query.append(" AND ");
1948
1949 query.append("repeating = ?");
1950
1951 query.append(" ");
1952
1953 Query q = session.createQuery(query.toString());
1954
1955 QueryPos qPos = QueryPos.getInstance(q);
1956
1957 qPos.add(groupId);
1958
1959 qPos.add(repeating);
1960
1961 Long count = null;
1962
1963 Iterator<Long> itr = q.list().iterator();
1964
1965 if (itr.hasNext()) {
1966 count = itr.next();
1967 }
1968
1969 if (count == null) {
1970 count = new Long(0);
1971 }
1972
1973 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
1974 finderClassName, finderMethodName, finderParams,
1975 finderArgs, count);
1976
1977 return count.intValue();
1978 }
1979 catch (Exception e) {
1980 throw processException(e);
1981 }
1982 finally {
1983 closeSession(session);
1984 }
1985 }
1986 else {
1987 return ((Long)result).intValue();
1988 }
1989 }
1990
1991 public int countAll() throws SystemException {
1992 boolean finderClassNameCacheEnabled = CalEventModelImpl.CACHE_ENABLED;
1993 String finderClassName = CalEvent.class.getName();
1994 String finderMethodName = "countAll";
1995 String[] finderParams = new String[] { };
1996 Object[] finderArgs = new Object[] { };
1997
1998 Object result = null;
1999
2000 if (finderClassNameCacheEnabled) {
2001 result = FinderCacheUtil.getResult(finderClassName,
2002 finderMethodName, finderParams, finderArgs, this);
2003 }
2004
2005 if (result == null) {
2006 Session session = null;
2007
2008 try {
2009 session = openSession();
2010
2011 Query q = session.createQuery(
2012 "SELECT COUNT(*) FROM com.liferay.portlet.calendar.model.CalEvent");
2013
2014 Long count = null;
2015
2016 Iterator<Long> itr = q.list().iterator();
2017
2018 if (itr.hasNext()) {
2019 count = itr.next();
2020 }
2021
2022 if (count == null) {
2023 count = new Long(0);
2024 }
2025
2026 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
2027 finderClassName, finderMethodName, finderParams,
2028 finderArgs, count);
2029
2030 return count.intValue();
2031 }
2032 catch (Exception e) {
2033 throw processException(e);
2034 }
2035 finally {
2036 closeSession(session);
2037 }
2038 }
2039 else {
2040 return ((Long)result).intValue();
2041 }
2042 }
2043
2044 public void afterPropertiesSet() {
2045 String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
2046 com.liferay.portal.util.PropsUtil.get(
2047 "value.object.listener.com.liferay.portlet.calendar.model.CalEvent")));
2048
2049 if (listenerClassNames.length > 0) {
2050 try {
2051 List<ModelListener> listenersList = new ArrayList<ModelListener>();
2052
2053 for (String listenerClassName : listenerClassNames) {
2054 listenersList.add((ModelListener)Class.forName(
2055 listenerClassName).newInstance());
2056 }
2057
2058 listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
2059 }
2060 catch (Exception e) {
2061 _log.error(e);
2062 }
2063 }
2064 }
2065
2066 @BeanReference(name = "com.liferay.portlet.calendar.service.persistence.CalEventPersistence.impl")
2067 protected com.liferay.portlet.calendar.service.persistence.CalEventPersistence calEventPersistence;
2068 @BeanReference(name = "com.liferay.portal.service.persistence.CompanyPersistence.impl")
2069 protected com.liferay.portal.service.persistence.CompanyPersistence companyPersistence;
2070 @BeanReference(name = "com.liferay.portal.service.persistence.PortletPreferencesPersistence.impl")
2071 protected com.liferay.portal.service.persistence.PortletPreferencesPersistence portletPreferencesPersistence;
2072 @BeanReference(name = "com.liferay.portal.service.persistence.ResourcePersistence.impl")
2073 protected com.liferay.portal.service.persistence.ResourcePersistence resourcePersistence;
2074 @BeanReference(name = "com.liferay.portlet.social.service.persistence.SocialActivityPersistence.impl")
2075 protected com.liferay.portlet.social.service.persistence.SocialActivityPersistence socialActivityPersistence;
2076 @BeanReference(name = "com.liferay.portal.service.persistence.UserPersistence.impl")
2077 protected com.liferay.portal.service.persistence.UserPersistence userPersistence;
2078 private static Log _log = LogFactoryUtil.getLog(CalEventPersistenceImpl.class);
2079}