2 * Copyright (c) 2000-2012 Liferay, Inc. All rights reserved.
\r
4 * This library is free software; you can redistribute it and/or modify it under
\r
5 * the terms of the GNU Lesser General Public License as published by the Free
\r
6 * Software Foundation; either version 2.1 of the License, or (at your option)
\r
9 * This library is distributed in the hope that it will be useful, but WITHOUT
\r
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
\r
11 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
\r
15 package com.liferay.portlet.social.service.impl;
\r
17 import com.liferay.portal.kernel.dao.orm.QueryUtil;
\r
18 import com.liferay.portal.kernel.exception.PortalException;
\r
19 import com.liferay.portal.kernel.exception.SystemException;
\r
20 import com.liferay.portal.kernel.lar.ImportExportThreadLocal;
\r
21 import com.liferay.portal.kernel.messaging.async.Async;
\r
22 import com.liferay.portal.model.Group;
\r
23 import com.liferay.portal.model.Layout;
\r
24 import com.liferay.portal.model.User;
\r
25 import com.liferay.portal.util.PortalUtil;
\r
26 import com.liferay.portlet.asset.model.AssetEntry;
\r
27 import com.liferay.portlet.social.NoSuchActivityException;
\r
28 import com.liferay.portlet.social.model.SocialActivity;
\r
29 import com.liferay.portlet.social.model.SocialActivityDefinition;
\r
30 import com.liferay.portlet.social.service.base.SocialActivityLocalServiceBaseImpl;
\r
31 import com.pentila.entSavoie.utils.ENTMainUtilsLocalServiceUtil;
\r
33 import java.util.ArrayList;
\r
34 import java.util.Date;
\r
35 import java.util.List;
\r
38 * The social activity local service. This service provides the means to record
\r
39 * and list social activities in groups and organizations.
\r
42 * Social activities are identified by their type and the type of asset they are
\r
43 * done on. Each activity records the exact time of the action as well as human
\r
44 * readable information needed for activity feeds.
\r
48 * Most of the <i>get-</i> methods in this service order activities in
\r
49 * descending order by their execution times, so the most recent activities are
\r
53 * @author Brian Wing Shun Chan
\r
55 public class SocialActivityLocalServiceImpl
\r
56 extends SocialActivityLocalServiceBaseImpl {
\r
59 * Records an activity with the given time in the database.
\r
62 * This method records a social activity done on an asset, identified by its
\r
63 * class name and class primary key, in the database. Additional information
\r
64 * (such as the original message ID for a reply to a forum post) is passed
\r
65 * in via the <code>extraData</code> in JSON format. For activities
\r
66 * affecting another user, a mirror activity is generated that describes the
\r
67 * action from the user's point of view. The target user's ID is passed in
\r
68 * via the <code>receiverUserId</code>.
\r
72 * Example for a mirrored activity:<br> When a user replies to a message
\r
73 * boards post, the reply action is stored in the database with the
\r
74 * <code>receiverUserId</code> being the ID of the author of the original
\r
75 * message. The <code>extraData</code> contains the ID of the original
\r
76 * message in JSON format. A mirror activity is generated with the values of
\r
77 * the <code>userId</code> and the <code>receiverUserId</code> swapped. This
\r
78 * mirror activity basically describes a "replied to" event.
\r
82 * Mirror activities are most often used in relation to friend requests and
\r
86 * @param userId the primary key of the acting user
\r
87 * @param groupId the primary key of the group
\r
88 * @param createDate the activity's date
\r
89 * @param className the target asset's class name
\r
90 * @param classPK the primary key of the target asset
\r
91 * @param type the activity's type
\r
92 * @param extraData any extra data regarding the activity
\r
93 * @param receiverUserId the primary key of the receiving user
\r
94 * @throws PortalException if the user or group could not be found
\r
95 * @throws SystemException if a system exception occurred
\r
97 public void addActivity(
\r
98 long userId, long groupId, Date createDate, String className,
\r
99 long classPK, int type, String extraData, long receiverUserId)
\r
100 throws PortalException, SystemException {
\r
102 if(!ENTMainUtilsLocalServiceUtil.getEntSocialActivityEnabled()){
\r
106 if (ImportExportThreadLocal.isImportInProcess()) {
\r
110 User user = userPersistence.findByPrimaryKey(userId);
\r
111 long classNameId = PortalUtil.getClassNameId(className);
\r
114 Group group = groupLocalService.getGroup(groupId);
\r
116 if (group.isLayout()) {
\r
117 Layout layout = layoutLocalService.getLayout(
\r
118 group.getClassPK());
\r
120 groupId = layout.getGroupId();
\r
124 SocialActivity activity = socialActivityPersistence.create(0);
\r
126 activity.setGroupId(groupId);
\r
127 activity.setCompanyId(user.getCompanyId());
\r
128 activity.setUserId(user.getUserId());
\r
129 activity.setCreateDate(createDate.getTime());
\r
130 activity.setMirrorActivityId(0);
\r
131 activity.setClassNameId(classNameId);
\r
132 activity.setClassPK(classPK);
\r
133 activity.setType(type);
\r
134 activity.setExtraData(extraData);
\r
135 activity.setReceiverUserId(receiverUserId);
\r
137 AssetEntry assetEntry = assetEntryPersistence.fetchByC_C(
\r
138 classNameId, classPK);
\r
140 activity.setAssetEntry(assetEntry);
\r
142 SocialActivity mirrorActivity = null;
\r
144 if ((receiverUserId > 0) && (userId != receiverUserId)) {
\r
145 mirrorActivity = socialActivityPersistence.create(0);
\r
147 mirrorActivity.setGroupId(groupId);
\r
148 mirrorActivity.setCompanyId(user.getCompanyId());
\r
149 mirrorActivity.setUserId(receiverUserId);
\r
150 mirrorActivity.setCreateDate(createDate.getTime());
\r
151 mirrorActivity.setClassNameId(classNameId);
\r
152 mirrorActivity.setClassPK(classPK);
\r
153 mirrorActivity.setType(type);
\r
154 mirrorActivity.setExtraData(extraData);
\r
155 mirrorActivity.setReceiverUserId(user.getUserId());
\r
156 mirrorActivity.setAssetEntry(assetEntry);
\r
159 socialActivityLocalService.addActivity(activity, mirrorActivity);
\r
163 * Records an activity in the database, using a time based on the current
\r
164 * time in an attempt to make the activity's time unique.
\r
166 * @param userId the primary key of the acting user
\r
167 * @param groupId the primary key of the group
\r
168 * @param className the target asset's class name
\r
169 * @param classPK the primary key of the target asset
\r
170 * @param type the activity's type
\r
171 * @param extraData any extra data regarding the activity
\r
172 * @param receiverUserId the primary key of the receiving user
\r
173 * @throws PortalException if the user or group could not be found
\r
174 * @throws SystemException if a system exception occurred
\r
176 public void addActivity(
\r
177 long userId, long groupId, String className, long classPK, int type,
\r
178 String extraData, long receiverUserId)
\r
179 throws PortalException, SystemException {
\r
181 if(!ENTMainUtilsLocalServiceUtil.getEntSocialActivityEnabled()){
\r
185 if (ImportExportThreadLocal.isImportInProcess()) {
\r
189 Date createDate = new Date();
\r
191 long classNameId = PortalUtil.getClassNameId(className);
\r
194 SocialActivity socialActivity =
\r
195 socialActivityPersistence.fetchByG_U_CD_C_C_T_R(
\r
196 groupId, userId, createDate.getTime(), classNameId, classPK,
\r
197 type, receiverUserId);
\r
199 if (socialActivity != null) {
\r
200 createDate = new Date(createDate.getTime() + 1);
\r
208 userId, groupId, createDate, className, classPK, type, extraData,
\r
213 public void addActivity(
\r
214 SocialActivity activity, SocialActivity mirrorActivity)
\r
215 throws PortalException, SystemException {
\r
217 if(!ENTMainUtilsLocalServiceUtil.getEntSocialActivityEnabled()){
\r
221 if (ImportExportThreadLocal.isImportInProcess()) {
\r
225 if ((activity.getActivityId() > 0) ||
\r
226 ((mirrorActivity != null) &&
\r
227 (mirrorActivity.getActivityId() > 0))) {
\r
229 throw new PortalException(
\r
230 "Activity and mirror activity must not have primary keys set");
\r
233 SocialActivityDefinition activityDefinition =
\r
234 socialActivitySettingLocalService.getActivityDefinition(
\r
235 activity.getGroupId(), activity.getClassName(),
\r
236 activity.getType());
\r
238 if (((activityDefinition == null) && (activity.getType() < 10000)) ||
\r
239 ((activityDefinition != null) &&
\r
240 activityDefinition.isLogActivity())) {
\r
242 long activityId = counterLocalService.increment(
\r
243 SocialActivity.class.getName());
\r
245 activity.setActivityId(activityId);
\r
247 socialActivityPersistence.update(activity, false);
\r
249 if (mirrorActivity != null) {
\r
250 long mirrorActivityId = counterLocalService.increment(
\r
251 SocialActivity.class.getName());
\r
253 mirrorActivity.setActivityId(mirrorActivityId);
\r
254 mirrorActivity.setMirrorActivityId(activity.getPrimaryKey());
\r
256 socialActivityPersistence.update(mirrorActivity, false);
\r
260 socialActivityCounterLocalService.addActivityCounters(activity);
\r
264 * Records an activity in the database, but only if there isn't already an
\r
265 * activity with the same parameters.
\r
268 * For the main functionality see {@link #addActivity(long, long, Date,
\r
269 * String, long, int, String, long)}
\r
272 * @param userId the primary key of the acting user
\r
273 * @param groupId the primary key of the group
\r
274 * @param createDate the activity's date
\r
275 * @param className the target asset's class name
\r
276 * @param classPK the primary key of the target asset
\r
277 * @param type the activity's type
\r
278 * @param extraData any extra data regarding the activity
\r
279 * @param receiverUserId the primary key of the receiving user
\r
280 * @throws PortalException if the user or group could not be found
\r
281 * @throws SystemException if a system exception occurred
\r
283 public void addUniqueActivity(
\r
284 long userId, long groupId, Date createDate, String className,
\r
285 long classPK, int type, String extraData, long receiverUserId)
\r
286 throws PortalException, SystemException {
\r
288 if(!ENTMainUtilsLocalServiceUtil.getEntSocialActivityEnabled()){
\r
292 long classNameId = PortalUtil.getClassNameId(className);
\r
294 SocialActivity socialActivity =
\r
295 socialActivityPersistence.fetchByG_U_CD_C_C_T_R(
\r
296 groupId, userId, createDate.getTime(), classNameId, classPK,
\r
297 type, receiverUserId);
\r
299 if (socialActivity != null) {
\r
304 userId, groupId, createDate, className, classPK, type, extraData,
\r
309 * Records an activity with the current time in the database, but only if
\r
310 * there isn't one with the same parameters.
\r
313 * For the main functionality see {@link #addActivity(long, long, Date,
\r
314 * String, long, int, String, long)}
\r
317 * @param userId the primary key of the acting user
\r
318 * @param groupId the primary key of the group
\r
319 * @param className the target asset's class name
\r
320 * @param classPK the primary key of the target asset
\r
321 * @param type the activity's type
\r
322 * @param extraData any extra data regarding the activity
\r
323 * @param receiverUserId the primary key of the receiving user
\r
324 * @throws PortalException if the user or group could not be found
\r
325 * @throws SystemException if a system exception occurred
\r
327 public void addUniqueActivity(
\r
328 long userId, long groupId, String className, long classPK, int type,
\r
329 String extraData, long receiverUserId)
\r
330 throws PortalException, SystemException {
\r
332 if(!ENTMainUtilsLocalServiceUtil.getEntSocialActivityEnabled()){
\r
336 long classNameId = PortalUtil.getClassNameId(className);
\r
338 int count = socialActivityPersistence.countByG_U_C_C_T_R(
\r
339 groupId, userId, classNameId, classPK, type, receiverUserId);
\r
346 userId, groupId, new Date(), className, classPK, type, extraData,
\r
351 * Removes stored activities for the asset identified by the class name ID
\r
352 * and class primary key.
\r
354 * @throws SystemException if a system exception occurred
\r
356 public void deleteActivities(AssetEntry assetEntry)
\r
357 throws PortalException, SystemException {
\r
359 if(!ENTMainUtilsLocalServiceUtil.getEntSocialActivityEnabled()){
\r
363 socialActivityPersistence.removeByC_C(
\r
364 assetEntry.getClassNameId(), assetEntry.getClassPK());
\r
366 socialActivityCounterLocalService.deleteActivityCounters(assetEntry);
\r
370 * Removes stored activities for the asset identified by the class name and
\r
371 * class primary key.
\r
373 * @param className the target asset's class name
\r
374 * @param classPK the primary key of the target asset
\r
375 * @throws SystemException if a system exception occurred
\r
377 public void deleteActivities(String className, long classPK)
\r
378 throws SystemException {
\r
380 if(!ENTMainUtilsLocalServiceUtil.getEntSocialActivityEnabled()){
\r
384 long classNameId = PortalUtil.getClassNameId(className);
\r
386 socialActivityPersistence.removeByC_C(classNameId, classPK);
\r
390 * Removes the stored activity from the database.
\r
392 * @param activityId the primary key of the stored activity
\r
393 * @throws PortalException if the activity could not be found
\r
394 * @throws SystemException if a system exception occurred
\r
396 public void deleteActivity(long activityId)
\r
397 throws PortalException, SystemException {
\r
399 if(!ENTMainUtilsLocalServiceUtil.getEntSocialActivityEnabled()){
\r
403 SocialActivity activity = socialActivityPersistence.findByPrimaryKey(
\r
406 deleteActivity(activity);
\r
410 * Removes the stored activity and its mirror activity from the database.
\r
412 * @param activity the activity to be removed
\r
413 * @throws SystemException if a system exception occurred
\r
415 public void deleteActivity(SocialActivity activity) throws SystemException {
\r
417 if(!ENTMainUtilsLocalServiceUtil.getEntSocialActivityEnabled()){
\r
421 socialActivityPersistence.remove(activity);
\r
424 socialActivityPersistence.removeByMirrorActivityId(
\r
425 activity.getActivityId());
\r
427 catch (NoSuchActivityException nsae) {
\r
432 * Removes the user's stored activities from the database.
\r
435 * This method removes all activities where the user is either the actor or
\r
439 * @param userId the primary key of the user
\r
440 * @throws SystemException if a system exception occurred
\r
442 public void deleteUserActivities(long userId) throws SystemException {
\r
444 if(!ENTMainUtilsLocalServiceUtil.getEntSocialActivityEnabled()){
\r
448 List<SocialActivity> activities =
\r
449 socialActivityPersistence.findByUserId(
\r
450 userId, QueryUtil.ALL_POS, QueryUtil.ALL_POS);
\r
452 for (SocialActivity activity : activities) {
\r
453 socialActivityPersistence.remove(activity);
\r
456 activities = socialActivityPersistence.findByReceiverUserId(
\r
457 userId, QueryUtil.ALL_POS, QueryUtil.ALL_POS);
\r
459 for (SocialActivity activity : activities) {
\r
460 socialActivityPersistence.remove(activity);
\r
463 socialActivityCounterLocalService.deleteActivityCounters(
\r
464 PortalUtil.getClassNameId(User.class.getName()), userId);
\r
468 * Returns a range of all the activities done on assets identified by the
\r
472 * Useful when paginating results. Returns a maximum of <code>end -
\r
473 * start</code> instances. <code>start</code> and <code>end</code> are not
\r
474 * primary keys, they are indexes in the result set. Thus, <code>0</code>
\r
475 * refers to the first result in the set. Setting both <code>start</code>
\r
476 * and <code>end</code> to {@link
\r
477 * com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full
\r
481 * @param classNameId the target asset's class name ID
\r
482 * @param start the lower bound of the range of results
\r
483 * @param end the upper bound of the range of results (not inclusive)
\r
484 * @return the range of matching activities
\r
485 * @throws SystemException if a system exception occurred
\r
487 public List<SocialActivity> getActivities(
\r
488 long classNameId, int start, int end)
\r
489 throws SystemException {
\r
491 if(!ENTMainUtilsLocalServiceUtil.getEntSocialActivityEnabled()){
\r
492 return new ArrayList<SocialActivity>();
\r
495 return socialActivityPersistence.findByClassNameId(
\r
496 classNameId, start, end);
\r
500 * Returns a range of all the activities done on the asset identified by the
\r
501 * class name ID and class primary key that are mirrors of the activity
\r
502 * identified by the mirror activity ID.
\r
505 * Useful when paginating results. Returns a maximum of <code>end -
\r
506 * start</code> instances. <code>start</code> and <code>end</code> are not
\r
507 * primary keys, they are indexes in the result set. Thus, <code>0</code>
\r
508 * refers to the first result in the set. Setting both <code>start</code>
\r
509 * and <code>end</code> to {@link
\r
510 * com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full
\r
514 * @param mirrorActivityId the primary key of the mirror activity
\r
515 * @param classNameId the target asset's class name ID
\r
516 * @param classPK the primary key of the target asset
\r
517 * @param start the lower bound of the range of results
\r
518 * @param end the upper bound of the range of results (not inclusive)
\r
519 * @return the range of matching activities
\r
520 * @throws SystemException if a system exception occurred
\r
522 public List<SocialActivity> getActivities(
\r
523 long mirrorActivityId, long classNameId, long classPK, int start,
\r
525 throws SystemException {
\r
527 if(!ENTMainUtilsLocalServiceUtil.getEntSocialActivityEnabled()){
\r
528 return new ArrayList<SocialActivity>();
\r
531 return socialActivityPersistence.findByM_C_C(
\r
532 mirrorActivityId, classNameId, classPK, start, end);
\r
536 * Returns a range of all the activities done on the asset identified by the
\r
537 * class name and the class primary key that are mirrors of the activity
\r
538 * identified by the mirror activity ID.
\r
541 * Useful when paginating results. Returns a maximum of <code>end -
\r
542 * start</code> instances. <code>start</code> and <code>end</code> are not
\r
543 * primary keys, they are indexes in the result set. Thus, <code>0</code>
\r
544 * refers to the first result in the set. Setting both <code>start</code>
\r
545 * and <code>end</code> to {@link
\r
546 * com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full
\r
550 * @param mirrorActivityId the primary key of the mirror activity
\r
551 * @param className the target asset's class name
\r
552 * @param classPK the primary key of the target asset
\r
553 * @param start the lower bound of the range of results
\r
554 * @param end the upper bound of the range of results (not inclusive)
\r
555 * @return the range of matching activities
\r
556 * @throws SystemException if a system exception occurred
\r
558 public List<SocialActivity> getActivities(
\r
559 long mirrorActivityId, String className, long classPK, int start,
\r
561 throws SystemException {
\r
563 if(!ENTMainUtilsLocalServiceUtil.getEntSocialActivityEnabled()){
\r
564 return new ArrayList<SocialActivity>();
\r
567 long classNameId = PortalUtil.getClassNameId(className);
\r
569 return getActivities(
\r
570 mirrorActivityId, classNameId, classPK, start, end);
\r
574 * Returns a range of all the activities done on assets identified by the
\r
578 * Useful when paginating results. Returns a maximum of <code>end -
\r
579 * start</code> instances. <code>start</code> and <code>end</code> are not
\r
580 * primary keys, they are indexes in the result set. Thus, <code>0</code>
\r
581 * refers to the first result in the set. Setting both <code>start</code>
\r
582 * and <code>end</code> to {@link
\r
583 * com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full
\r
587 * @param className the target asset's class name
\r
588 * @param start the lower bound of the range of results
\r
589 * @param end the upper bound of the range of results (not inclusive)
\r
590 * @return the range of matching activities
\r
591 * @throws SystemException if a system exception occurred
\r
593 public List<SocialActivity> getActivities(
\r
594 String className, int start, int end)
\r
595 throws SystemException {
\r
597 if(!ENTMainUtilsLocalServiceUtil.getEntSocialActivityEnabled()){
\r
598 return new ArrayList<SocialActivity>();
\r
601 long classNameId = PortalUtil.getClassNameId(className);
\r
603 return getActivities(classNameId, start, end);
\r
607 * Returns the number of activities done on assets identified by the class
\r
610 * @param classNameId the target asset's class name ID
\r
611 * @return the number of matching activities
\r
612 * @throws SystemException if a system exception occurred
\r
614 public int getActivitiesCount(long classNameId) throws SystemException {
\r
615 if(!ENTMainUtilsLocalServiceUtil.getEntSocialActivityEnabled()){
\r
619 return socialActivityPersistence.countByClassNameId(classNameId);
\r
623 * Returns the number of activities done on the asset identified by the
\r
624 * class name ID and class primary key that are mirrors of the activity
\r
625 * identified by the mirror activity ID.
\r
627 * @param mirrorActivityId the primary key of the mirror activity
\r
628 * @param classNameId the target asset's class name ID
\r
629 * @param classPK the primary key of the target asset
\r
630 * @return the number of matching activities
\r
631 * @throws SystemException if a system exception occurred
\r
633 public int getActivitiesCount(
\r
634 long mirrorActivityId, long classNameId, long classPK)
\r
635 throws SystemException {
\r
637 if(!ENTMainUtilsLocalServiceUtil.getEntSocialActivityEnabled()){
\r
641 return socialActivityPersistence.countByM_C_C(
\r
642 mirrorActivityId, classNameId, classPK);
\r
646 * Returns the number of activities done on the asset identified by the
\r
647 * class name and class primary key that are mirrors of the activity
\r
648 * identified by the mirror activity ID.
\r
650 * @param mirrorActivityId the primary key of the mirror activity
\r
651 * @param className the target asset's class name
\r
652 * @param classPK the primary key of the target asset
\r
653 * @return the number of matching activities
\r
654 * @throws SystemException if a system exception occurred
\r
656 public int getActivitiesCount(
\r
657 long mirrorActivityId, String className, long classPK)
\r
658 throws SystemException {
\r
660 if(!ENTMainUtilsLocalServiceUtil.getEntSocialActivityEnabled()){
\r
664 long classNameId = PortalUtil.getClassNameId(className);
\r
666 return getActivitiesCount(mirrorActivityId, classNameId, classPK);
\r
670 * Returns the number of activities done on assets identified by class name.
\r
672 * @param className the target asset's class name
\r
673 * @return the number of matching activities
\r
674 * @throws SystemException if a system exception occurred
\r
676 public int getActivitiesCount(String className) throws SystemException {
\r
677 long classNameId = PortalUtil.getClassNameId(className);
\r
679 if(!ENTMainUtilsLocalServiceUtil.getEntSocialActivityEnabled()){
\r
683 return getActivitiesCount(classNameId);
\r
687 * Returns the activity identified by its primary key.
\r
689 * @param activityId the primary key of the activity
\r
690 * @return Returns the activity
\r
691 * @throws PortalException if the activity could not be found
\r
692 * @throws SystemException if a system exception occurred
\r
694 public SocialActivity getActivity(long activityId)
\r
695 throws PortalException, SystemException {
\r
697 if(!ENTMainUtilsLocalServiceUtil.getEntSocialActivityEnabled()){
\r
701 return socialActivityPersistence.findByPrimaryKey(activityId);
\r
705 * Returns a range of all the activities done in the group.
\r
708 * This method only finds activities without mirrors.
\r
712 * Useful when paginating results. Returns a maximum of <code>end -
\r
713 * start</code> instances. <code>start</code> and <code>end</code> are not
\r
714 * primary keys, they are indexes in the result set. Thus, <code>0</code>
\r
715 * refers to the first result in the set. Setting both <code>start</code>
\r
716 * and <code>end</code> to {@link
\r
717 * com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full
\r
721 * @param groupId the primary key of the group
\r
722 * @param start the lower bound of the range of results
\r
723 * @param end the upper bound of the range of results (not inclusive)
\r
724 * @return the range of matching activities
\r
725 * @throws SystemException if a system exception occurred
\r
727 public List<SocialActivity> getGroupActivities(
\r
728 long groupId, int start, int end)
\r
729 throws SystemException {
\r
731 if(!ENTMainUtilsLocalServiceUtil.getEntSocialActivityEnabled()){
\r
732 return new ArrayList<SocialActivity>();
\r
735 return socialActivityFinder.findByGroupId(groupId, start, end);
\r
739 * Returns the number of activities done in the group.
\r
742 * This method only counts activities without mirrors.
\r
745 * @param groupId the primary key of the group
\r
746 * @return the number of matching activities
\r
747 * @throws SystemException if a system exception occurred
\r
749 public int getGroupActivitiesCount(long groupId) throws SystemException {
\r
751 if(!ENTMainUtilsLocalServiceUtil.getEntSocialActivityEnabled()){
\r
755 return socialActivityFinder.countByGroupId(groupId);
\r
759 * Returns a range of activities done by users that are members of the
\r
763 * This method only finds activities without mirrors.
\r
767 * Useful when paginating results. Returns a maximum of <code>end -
\r
768 * start</code> instances. <code>start</code> and <code>end</code> are not
\r
769 * primary keys, they are indexes in the result set. Thus, <code>0</code>
\r
770 * refers to the first result in the set. Setting both <code>start</code>
\r
771 * and <code>end</code> to {@link
\r
772 * com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full
\r
776 * @param groupId the primary key of the group
\r
777 * @param start the lower bound of the range of results
\r
778 * @param end the upper bound of the range of results (not inclusive)
\r
779 * @return the range of matching activities
\r
780 * @throws SystemException if a system exception occurred
\r
782 public List<SocialActivity> getGroupUsersActivities(
\r
783 long groupId, int start, int end)
\r
784 throws SystemException {
\r
786 if(!ENTMainUtilsLocalServiceUtil.getEntSocialActivityEnabled()){
\r
787 return new ArrayList<SocialActivity>();
\r
790 return socialActivityFinder.findByGroupUsers(groupId, start, end);
\r
794 * Returns the number of activities done by users that are members of the
\r
798 * This method only counts activities without mirrors.
\r
801 * @param groupId the primary key of the group
\r
802 * @return the number of matching activities
\r
803 * @throws SystemException if a system exception occurred
\r
805 public int getGroupUsersActivitiesCount(long groupId)
\r
806 throws SystemException {
\r
808 if(!ENTMainUtilsLocalServiceUtil.getEntSocialActivityEnabled()){
\r
811 return socialActivityFinder.countByGroupUsers(groupId);
\r
815 * Returns the activity that has the mirror activity.
\r
817 * @param mirrorActivityId the primary key of the mirror activity
\r
818 * @return Returns the mirror activity
\r
819 * @throws PortalException if the mirror activity could not be found
\r
820 * @throws SystemException if a system exception occurred
\r
822 public SocialActivity getMirrorActivity(long mirrorActivityId)
\r
823 throws PortalException, SystemException {
\r
825 if(!ENTMainUtilsLocalServiceUtil.getEntSocialActivityEnabled()){
\r
829 return socialActivityPersistence.findByMirrorActivityId(
\r
834 * Returns a range of all the activities done in the organization. This
\r
835 * method only finds activities without mirrors.
\r
838 * Useful when paginating results. Returns a maximum of <code>end -
\r
839 * start</code> instances. <code>start</code> and <code>end</code> are not
\r
840 * primary keys, they are indexes in the result set. Thus, <code>0</code>
\r
841 * refers to the first result in the set. Setting both <code>start</code>
\r
842 * and <code>end</code> to {@link
\r
843 * com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full
\r
847 * @param organizationId the primary key of the organization
\r
848 * @param start the lower bound of the range of results
\r
849 * @param end the upper bound of the range of results (not inclusive)
\r
850 * @return the range of matching activities
\r
851 * @throws SystemException if a system exception occurred
\r
853 public List<SocialActivity> getOrganizationActivities(
\r
854 long organizationId, int start, int end)
\r
855 throws SystemException {
\r
857 if(!ENTMainUtilsLocalServiceUtil.getEntSocialActivityEnabled()){
\r
858 return new ArrayList<SocialActivity>();
\r
861 return socialActivityFinder.findByOrganizationId(
\r
862 organizationId, start, end);
\r
866 * Returns the number of activities done in the organization. This method
\r
867 * only counts activities without mirrors.
\r
869 * @param organizationId the primary key of the organization
\r
870 * @return the number of matching activities
\r
871 * @throws SystemException if a system exception occurred
\r
873 public int getOrganizationActivitiesCount(long organizationId)
\r
874 throws SystemException {
\r
876 if(!ENTMainUtilsLocalServiceUtil.getEntSocialActivityEnabled()){
\r
880 return socialActivityFinder.countByOrganizationId(organizationId);
\r
884 * Returns a range of all the activities done by users of the organization.
\r
885 * This method only finds activities without mirrors.
\r
888 * start</code> instances. <code>start</code> and <code>end</code> are not
\r
889 * Useful when paginating results. Returns a maximum of <code>end -
\r
890 * primary keys, they are indexes in the result set. Thus, <code>0</code>
\r
891 * refers to the first result in the set. Setting both <code>start</code>
\r
892 * and <code>end</code> to {@link
\r
893 * com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full
\r
897 * @param organizationId the primary key of the organization
\r
898 * @param start the lower bound of the range of results
\r
899 * @param end the upper bound of the range of results (not inclusive)
\r
900 * @return the range of matching activities
\r
901 * @throws SystemException if a system exception occurred
\r
903 public List<SocialActivity> getOrganizationUsersActivities(
\r
904 long organizationId, int start, int end)
\r
905 throws SystemException {
\r
907 if(!ENTMainUtilsLocalServiceUtil.getEntSocialActivityEnabled()){
\r
908 return new ArrayList<SocialActivity>();
\r
911 return socialActivityFinder.findByOrganizationUsers(
\r
912 organizationId, start, end);
\r
916 * Returns the number of activities done by users of the organization. This
\r
917 * method only counts activities without mirrors.
\r
919 * @param organizationId the primary key of the organization
\r
920 * @return the number of matching activities
\r
921 * @throws SystemException if a system exception occurred
\r
923 public int getOrganizationUsersActivitiesCount(long organizationId)
\r
924 throws SystemException {
\r
926 if(!ENTMainUtilsLocalServiceUtil.getEntSocialActivityEnabled()){
\r
930 return socialActivityFinder.countByOrganizationUsers(organizationId);
\r
934 * Returns a range of all the activities done by users in a relationship
\r
935 * with the user identified by the user ID.
\r
938 * Useful when paginating results. Returns a maximum of <code>end -
\r
939 * start</code> instances. <code>start</code> and <code>end</code> are not
\r
940 * primary keys, they are indexes in the result set. Thus, <>0</code> refers
\r
941 * to the first result in the set. Setting both <code>start</code> and
\r
942 * <code>end</code> to {@link
\r
943 * com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full
\r
947 * @param userId the primary key of the user
\r
948 * @param start the lower bound of the range of results
\r
949 * @param end the upper bound of the range of results (not inclusive)
\r
950 * @return the range of matching activities
\r
951 * @throws SystemException if a system exception occurred
\r
953 public List<SocialActivity> getRelationActivities(
\r
954 long userId, int start, int end)
\r
955 throws SystemException {
\r
957 if(!ENTMainUtilsLocalServiceUtil.getEntSocialActivityEnabled()){
\r
958 return new ArrayList<SocialActivity>();
\r
961 return socialActivityFinder.findByRelation(userId, start, end);
\r
965 * Returns a range of all the activities done by users in a relationship of
\r
966 * type <code>type</code> with the user identified by <code>userId</code>.
\r
967 * This method only finds activities without mirrors.
\r
970 * Useful when paginating results. Returns a maximum of <code>end -
\r
971 * start</code> instances. <code>start</code> and <code>end</code> are not
\r
972 * primary keys, they are indexes in the result set. Thus, <code>0</code>
\r
973 * refers to the first result in the set. Setting both <code>start</code>
\r
974 * and <code>end</code> to {@link
\r
975 * com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full
\r
979 * @param userId the primary key of the user
\r
980 * @param type the relationship type
\r
981 * @param start the lower bound of the range of results
\r
982 * @param end the upper bound of the range of results (not inclusive)
\r
983 * @return the range of matching activities
\r
984 * @throws SystemException if a system exception occurred
\r
986 public List<SocialActivity> getRelationActivities(
\r
987 long userId, int type, int start, int end)
\r
988 throws SystemException {
\r
990 if(!ENTMainUtilsLocalServiceUtil.getEntSocialActivityEnabled()){
\r
991 return new ArrayList<SocialActivity>();
\r
994 return socialActivityFinder.findByRelationType(
\r
995 userId, type, start, end);
\r
999 * Returns the number of activities done by users in a relationship with the
\r
1000 * user identified by userId.
\r
1002 * @param userId the primary key of the user
\r
1003 * @return the number of matching activities
\r
1004 * @throws SystemException if a system exception occurred
\r
1006 public int getRelationActivitiesCount(long userId) throws SystemException {
\r
1008 if(!ENTMainUtilsLocalServiceUtil.getEntSocialActivityEnabled()){
\r
1012 return socialActivityFinder.countByRelation(userId);
\r
1016 * Returns the number of activities done by users in a relationship of type
\r
1017 * <code>type</code> with the user identified by <code>userId</code>. This
\r
1018 * method only counts activities without mirrors.
\r
1020 * @param userId the primary key of the user
\r
1021 * @param type the relationship type
\r
1022 * @return the number of matching activities
\r
1023 * @throws SystemException if a system exception occurred
\r
1025 public int getRelationActivitiesCount(long userId, int type)
\r
1026 throws SystemException {
\r
1028 if(!ENTMainUtilsLocalServiceUtil.getEntSocialActivityEnabled()){
\r
1032 return socialActivityFinder.countByRelationType(userId, type);
\r
1036 * Returns a range of all the activities done by the user.
\r
1039 * Useful when paginating results. Returns a maximum of <code>end -
\r
1040 * start</code> instances. <code>start</code> and <code>end</code> are not
\r
1041 * primary keys, they are indexes in the result set. Thus, <code>0</code>
\r
1042 * refers to the first result in the set. Setting both <code>start</code>
\r
1043 * and <code>end</code> to {@link
\r
1044 * com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full
\r
1048 * @param userId the primary key of the user
\r
1049 * @param start the lower bound of the range of results
\r
1050 * @param end the upper bound of the range of results (not inclusive)
\r
1051 * @return the range of matching activities
\r
1052 * @throws SystemException if a system exception occurred
\r
1054 public List<SocialActivity> getUserActivities(
\r
1055 long userId, int start, int end)
\r
1056 throws SystemException {
\r
1058 if(!ENTMainUtilsLocalServiceUtil.getEntSocialActivityEnabled()){
\r
1059 return new ArrayList<SocialActivity>();
\r
1062 return socialActivityPersistence.findByUserId(userId, start, end);
\r
1066 * Returns the number of activities done by the user.
\r
1068 * @param userId the primary key of the user
\r
1069 * @return the number of matching activities
\r
1070 * @throws SystemException if a system exception occurred
\r
1072 public int getUserActivitiesCount(long userId) throws SystemException {
\r
1074 if(!ENTMainUtilsLocalServiceUtil.getEntSocialActivityEnabled()){
\r
1078 return socialActivityPersistence.countByUserId(userId);
\r
1082 * Returns a range of all the activities done in the user's groups. This
\r
1083 * method only finds activities without mirrors.
\r
1086 * Useful when paginating results. Returns a maximum of <code>end -
\r
1087 * start</code> instances. <code>start</code> and <code>end</code> are not
\r
1088 * primary keys, they are indexes in the result set. Thus, <code>0</code>
\r
1089 * refers to the first result in the set. Setting both <code>start</code>
\r
1090 * and <code>end</code> to {@link
\r
1091 * com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full
\r
1095 * @param userId the primary key of the user
\r
1096 * @param start the lower bound of the range of results
\r
1097 * @param end the upper bound of the range of results (not inclusive)
\r
1098 * @return the range of matching activities
\r
1099 * @throws SystemException if a system exception occurred
\r
1101 public List<SocialActivity> getUserGroupsActivities(
\r
1102 long userId, int start, int end)
\r
1103 throws SystemException {
\r
1105 if(!ENTMainUtilsLocalServiceUtil.getEntSocialActivityEnabled()){
\r
1106 return new ArrayList<SocialActivity>();
\r
1109 return socialActivityFinder.findByUserGroups(userId, start, end);
\r
1113 * Returns the number of activities done in user's groups. This method only
\r
1114 * counts activities without mirrors.
\r
1116 * @param userId the primary key of the user
\r
1117 * @return the number of matching activities
\r
1118 * @throws SystemException if a system exception occurred
\r
1120 public int getUserGroupsActivitiesCount(long userId)
\r
1121 throws SystemException {
\r
1123 if(!ENTMainUtilsLocalServiceUtil.getEntSocialActivityEnabled()){
\r
1127 return socialActivityFinder.countByUserGroups(userId);
\r
1131 * Returns a range of all the activities done in the user's groups and
\r
1132 * organizations. This method only finds activities without mirrors.
\r
1135 * Useful when paginating results. Returns a maximum of <code>end -
\r
1136 * start</code> instances. <code>start</code> and <code>end</code> are not
\r
1137 * primary keys, they are indexes in the result set. Thus, <code>0</code>
\r
1138 * refers to the first result in the set. Setting both <code>start</code>
\r
1139 * and <code>end</code> to {@link
\r
1140 * com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full
\r
1144 * @param userId the primary key of the user
\r
1145 * @param start the lower bound of the range of results
\r
1146 * @param end the upper bound of the range of results (not inclusive)
\r
1147 * @return the range of matching activities
\r
1148 * @throws SystemException if a system exception occurred
\r
1150 public List<SocialActivity> getUserGroupsAndOrganizationsActivities(
\r
1151 long userId, int start, int end)
\r
1152 throws SystemException {
\r
1154 if(!ENTMainUtilsLocalServiceUtil.getEntSocialActivityEnabled()){
\r
1155 return new ArrayList<SocialActivity>();
\r
1158 return socialActivityFinder.findByUserGroupsAndOrganizations(
\r
1159 userId, start, end);
\r
1163 * Returns the number of activities done in user's groups and organizations.
\r
1164 * This method only counts activities without mirrors.
\r
1166 * @param userId the primary key of the user
\r
1167 * @return the number of matching activities
\r
1168 * @throws SystemException if a system exception occurred
\r
1170 public int getUserGroupsAndOrganizationsActivitiesCount(long userId)
\r
1171 throws SystemException {
\r
1173 if(!ENTMainUtilsLocalServiceUtil.getEntSocialActivityEnabled()){
\r
1177 return socialActivityFinder.countByUserGroupsAndOrganizations(userId);
\r
1181 * Returns a range of all activities done in the user's organizations. This
\r
1182 * method only finds activities without mirrors.
\r
1185 * Useful when paginating results. Returns a maximum of <code>end -
\r
1186 * start</code> instances. <code>start</code> and <code>end</code> are not
\r
1187 * primary keys, they are indexes in the result set. Thus, <code>0</code>
\r
1188 * refers to the first result in the set. Setting both <code>start</code>
\r
1189 * and <code>end</code> to {@link
\r
1190 * com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full
\r
1194 * @param userId the primary key of the user
\r
1195 * @param start the lower bound of the range of results
\r
1196 * @param end the upper bound of the range of results (not inclusive)
\r
1197 * @return the range of matching activities
\r
1198 * @throws SystemException if a system exception occurred
\r
1200 public List<SocialActivity> getUserOrganizationsActivities(
\r
1201 long userId, int start, int end)
\r
1202 throws SystemException {
\r
1204 if(!ENTMainUtilsLocalServiceUtil.getEntSocialActivityEnabled()){
\r
1205 return new ArrayList<SocialActivity>();
\r
1208 return socialActivityFinder.findByUserOrganizations(userId, start, end);
\r
1212 * Returns the number of activities done in the user's organizations. This
\r
1213 * method only counts activities without mirrors.
\r
1215 * @param userId the primary key of the user
\r
1216 * @return the number of matching activities
\r
1217 * @throws SystemException if a system exception occurred
\r
1219 public int getUserOrganizationsActivitiesCount(long userId)
\r
1220 throws SystemException {
\r
1222 if(!ENTMainUtilsLocalServiceUtil.getEntSocialActivityEnabled()){
\r
1226 return socialActivityFinder.countByUserOrganizations(userId);
\r