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