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