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