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