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