Class SocialActivityLocalServiceImpl

Object
com.liferay.portal.kernel.service.BaseLocalServiceImpl
com.liferay.portlet.social.service.base.SocialActivityLocalServiceBaseImpl
com.liferay.portlet.social.service.impl.SocialActivityLocalServiceImpl
All Implemented Interfaces:
com.liferay.portal.kernel.module.framework.service.IdentifiableOSGiService, com.liferay.portal.kernel.service.BaseLocalService, com.liferay.portal.kernel.service.change.tracking.CTService<com.liferay.social.kernel.model.SocialActivity>, com.liferay.portal.kernel.service.PersistedModelLocalService, com.liferay.social.kernel.service.SocialActivityLocalService

public class SocialActivityLocalServiceImpl extends SocialActivityLocalServiceBaseImpl
The social activity local service. This service provides the means to record and list social activities in groups and organizations.

Social activities are identified by their type and the type of asset they are done on. Each activity records the exact time of the action as well as human readable information needed for activity feeds.

Most of the get- methods in this service order activities in descending order by their execution times, so the most recent activities are listed first.

Author:
Brian Wing Shun Chan
  • Constructor Details

    • SocialActivityLocalServiceImpl

      public SocialActivityLocalServiceImpl()
  • Method Details

    • addActivity

      public void addActivity(long userId, long groupId, Date createDate, String className, long classPK, int type, String extraData, long receiverUserId) throws com.liferay.portal.kernel.exception.PortalException
      Records an activity with the given time in the database.

      This method records a social activity done on an asset, identified by its class name and class primary key, in the database. Additional information (such as the original message ID for a reply to a forum post) is passed in via the extraData in JSON format. For activities affecting another user, a mirror activity is generated that describes the action from the user's point of view. The target user's ID is passed in via the receiverUserId.

      Example for a mirrored activity:
      When a user replies to a message boards post, the reply action is stored in the database with the receiverUserId being the ID of the author of the original message. The extraData contains the ID of the original message in JSON format. A mirror activity is generated with the values of the userId and the receiverUserId swapped. This mirror activity basically describes a "replied to" event.

      Mirror activities are most often used in relation to friend requests and activities.

      Parameters:
      userId - the primary key of the acting user
      groupId - the primary key of the group
      createDate - the activity's date
      className - the target asset's class name
      classPK - the primary key of the target asset
      type - the activity's type
      extraData - any extra data regarding the activity
      receiverUserId - the primary key of the receiving user
      Throws:
      com.liferay.portal.kernel.exception.PortalException
    • addActivity

      public void addActivity(long userId, long groupId, String className, long classPK, int type, String extraData, long receiverUserId) throws com.liferay.portal.kernel.exception.PortalException
      Records an activity in the database, using a time based on the current time in an attempt to make the activity's time unique.
      Parameters:
      userId - the primary key of the acting user
      groupId - the primary key of the group
      className - the target asset's class name
      classPK - the primary key of the target asset
      type - the activity's type
      extraData - any extra data regarding the activity
      receiverUserId - the primary key of the receiving user
      Throws:
      com.liferay.portal.kernel.exception.PortalException
    • addActivity

      @Async public void addActivity(com.liferay.social.kernel.model.SocialActivity activity, com.liferay.social.kernel.model.SocialActivity mirrorActivity) throws com.liferay.portal.kernel.exception.PortalException
      Throws:
      com.liferay.portal.kernel.exception.PortalException
    • addUniqueActivity

      public void addUniqueActivity(long userId, long groupId, Date createDate, String className, long classPK, int type, String extraData, long receiverUserId) throws com.liferay.portal.kernel.exception.PortalException
      Records an activity in the database, but only if there isn't already an activity with the same parameters.

      For the main functionality see addActivity(long, long, Date, String, long, int, String, long)

      Parameters:
      userId - the primary key of the acting user
      groupId - the primary key of the group
      createDate - the activity's date
      className - the target asset's class name
      classPK - the primary key of the target asset
      type - the activity's type
      extraData - any extra data regarding the activity
      receiverUserId - the primary key of the receiving user
      Throws:
      com.liferay.portal.kernel.exception.PortalException
    • addUniqueActivity

      public void addUniqueActivity(long userId, long groupId, String className, long classPK, int type, String extraData, long receiverUserId) throws com.liferay.portal.kernel.exception.PortalException
      Records an activity with the current time in the database, but only if there isn't one with the same parameters.

      For the main functionality see addActivity(long, long, Date, String, long, int, String, long)

      Parameters:
      userId - the primary key of the acting user
      groupId - the primary key of the group
      className - the target asset's class name
      classPK - the primary key of the target asset
      type - the activity's type
      extraData - any extra data regarding the activity
      receiverUserId - the primary key of the receiving user
      Throws:
      com.liferay.portal.kernel.exception.PortalException
    • deleteActivities

      public void deleteActivities(com.liferay.asset.kernel.model.AssetEntry assetEntry) throws com.liferay.portal.kernel.exception.PortalException
      Removes stored activities for the asset.
      Parameters:
      assetEntry - the asset from which to remove stored activities
      Throws:
      com.liferay.portal.kernel.exception.PortalException
    • deleteActivities

      public void deleteActivities(long groupId)
    • deleteActivities

      public void deleteActivities(String className, long classPK) throws com.liferay.portal.kernel.exception.PortalException
      Removes stored activities for the asset identified by the class name and class primary key.
      Parameters:
      className - the target asset's class name
      classPK - the primary key of the target asset
      Throws:
      com.liferay.portal.kernel.exception.PortalException
    • deleteActivity

      public void deleteActivity(long activityId) throws com.liferay.portal.kernel.exception.PortalException
      Removes the stored activity from the database.
      Parameters:
      activityId - the primary key of the stored activity
      Throws:
      com.liferay.portal.kernel.exception.PortalException
    • deleteActivity

      public void deleteActivity(com.liferay.social.kernel.model.SocialActivity activity) throws com.liferay.portal.kernel.exception.PortalException
      Removes the stored activity and its mirror activity from the database.
      Parameters:
      activity - the activity to be removed
      Throws:
      com.liferay.portal.kernel.exception.PortalException
    • deleteUserActivities

      public void deleteUserActivities(long userId) throws com.liferay.portal.kernel.exception.PortalException
      Removes the user's stored activities from the database.

      This method removes all activities where the user is either the actor or the receiver.

      Parameters:
      userId - the primary key of the user
      Throws:
      com.liferay.portal.kernel.exception.PortalException
    • fetchFirstActivity

      public com.liferay.social.kernel.model.SocialActivity fetchFirstActivity(String className, long classPK, int type)
    • getActivities

      @Deprecated public List<com.liferay.social.kernel.model.SocialActivity> getActivities(long classNameId, int start, int end)
      Deprecated.
      As of Athanasius (7.3.x), replaced by getActivities(long, String, int, int) Returns a range of all the activities done on assets identified by the class name ID.

      Useful when paginating results. Returns a maximum of end - start instances. start and end are not primary keys, they are indexes in the result set. Thus, 0 refers to the first result in the set. Setting both start and end to QueryUtil.ALL_POS will return the full result set.

      Parameters:
      classNameId - the target asset's class name ID
      start - the lower bound of the range of results
      end - the upper bound of the range of results (not inclusive)
      Returns:
      the range of matching activities
    • getActivities

      public List<com.liferay.social.kernel.model.SocialActivity> getActivities(long mirrorActivityId, long classNameId, long classPK, int start, int end)
      Returns a range of all the activities done on the asset identified by the class name ID and class primary key that are mirrors of the activity identified by the mirror activity ID.

      Useful when paginating results. Returns a maximum of end - start instances. start and end are not primary keys, they are indexes in the result set. Thus, 0 refers to the first result in the set. Setting both start and end to QueryUtil.ALL_POS will return the full result set.

      Parameters:
      mirrorActivityId - the primary key of the mirror activity
      classNameId - the target asset's class name ID
      classPK - the primary key of the target asset
      start - the lower bound of the range of results
      end - the upper bound of the range of results (not inclusive)
      Returns:
      the range of matching activities
    • getActivities

      public List<com.liferay.social.kernel.model.SocialActivity> getActivities(long companyId, String className, int start, int end)
      Returns a range of all the activities done on assets identified by the company ID and class name.

      Useful when paginating results. Returns a maximum of end - start instances. start and end are not primary keys, they are indexes in the result set. Thus, 0 refers to the first result in the set. Setting both start and end to QueryUtil.ALL_POS will return the full result set.

      Parameters:
      companyId - the primary key of the company
      className - the target asset's class name
      start - the lower bound of the range of results
      end - the upper bound of the range of results (not inclusive)
      Returns:
      the range of matching activities
    • getActivities

      public List<com.liferay.social.kernel.model.SocialActivity> getActivities(long mirrorActivityId, String className, long classPK, int start, int end)
      Returns a range of all the activities done on the asset identified by the class name and the class primary key that are mirrors of the activity identified by the mirror activity ID.

      Useful when paginating results. Returns a maximum of end - start instances. start and end are not primary keys, they are indexes in the result set. Thus, 0 refers to the first result in the set. Setting both start and end to QueryUtil.ALL_POS will return the full result set.

      Parameters:
      mirrorActivityId - the primary key of the mirror activity
      className - the target asset's class name
      classPK - the primary key of the target asset
      start - the lower bound of the range of results
      end - the upper bound of the range of results (not inclusive)
      Returns:
      the range of matching activities
    • getActivitiesCount

      @Deprecated public int getActivitiesCount(long classNameId)
      Deprecated.
      As of Athanasius (7.3.x), replaced by getActivitiesCount(long, String)
      Parameters:
      classNameId - the target asset's class name ID
      Returns:
      the number of matching activities
    • getActivitiesCount

      public int getActivitiesCount(long userId, long groupId, Date createDate, String className, long classPK, int type, long receiverUserId)
    • getActivitiesCount

      public int getActivitiesCount(long mirrorActivityId, long classNameId, long classPK)
      Returns the number of activities done on the asset identified by the class name ID and class primary key that are mirrors of the activity identified by the mirror activity ID.
      Parameters:
      mirrorActivityId - the primary key of the mirror activity
      classNameId - the target asset's class name ID
      classPK - the primary key of the target asset
      Returns:
      the number of matching activities
    • getActivitiesCount

      public int getActivitiesCount(long companyId, String className)
      Returns the number of activities done on assets identified by company ID and class name.
      Parameters:
      companyId - the primary key of the company
      className - the target asset's class name
      Returns:
      the number of matching activities
    • getActivitiesCount

      public int getActivitiesCount(long mirrorActivityId, String className, long classPK)
      Returns the number of activities done on the asset identified by the class name and class primary key that are mirrors of the activity identified by the mirror activity ID.
      Parameters:
      mirrorActivityId - the primary key of the mirror activity
      className - the target asset's class name
      classPK - the primary key of the target asset
      Returns:
      the number of matching activities
    • getActivity

      public com.liferay.social.kernel.model.SocialActivity getActivity(long activityId) throws com.liferay.portal.kernel.exception.PortalException
      Returns the activity identified by its primary key.
      Parameters:
      activityId - the primary key of the activity
      Returns:
      Returns the activity
      Throws:
      com.liferay.portal.kernel.exception.PortalException
    • getActivitySetActivities

      public List<com.liferay.social.kernel.model.SocialActivity> getActivitySetActivities(long activitySetId, int start, int end)
    • getApprovedActivities

      public List<com.liferay.social.kernel.model.SocialActivity> getApprovedActivities(long classPK, double version)
    • getGroupActivities

      public List<com.liferay.social.kernel.model.SocialActivity> getGroupActivities(long groupId, int start, int end)
      Returns a range of all the activities done in the group.

      This method only finds activities without mirrors.

      Useful when paginating results. Returns a maximum of end - start instances. start and end are not primary keys, they are indexes in the result set. Thus, 0 refers to the first result in the set. Setting both start and end to QueryUtil.ALL_POS will return the full result set.

      Parameters:
      groupId - the primary key of the group
      start - the lower bound of the range of results
      end - the upper bound of the range of results (not inclusive)
      Returns:
      the range of matching activities
    • getGroupActivitiesCount

      public int getGroupActivitiesCount(long groupId)
      Returns the number of activities done in the group.

      This method only counts activities without mirrors.

      Parameters:
      groupId - the primary key of the group
      Returns:
      the number of matching activities
    • getGroupUsersActivities

      public List<com.liferay.social.kernel.model.SocialActivity> getGroupUsersActivities(long groupId, int start, int end)
      Returns a range of activities done by users that are members of the group.

      This method only finds activities without mirrors.

      Useful when paginating results. Returns a maximum of end - start instances. start and end are not primary keys, they are indexes in the result set. Thus, 0 refers to the first result in the set. Setting both start and end to QueryUtil.ALL_POS will return the full result set.

      Parameters:
      groupId - the primary key of the group
      start - the lower bound of the range of results
      end - the upper bound of the range of results (not inclusive)
      Returns:
      the range of matching activities
    • getGroupUsersActivitiesCount

      public int getGroupUsersActivitiesCount(long groupId)
      Returns the number of activities done by users that are members of the group.

      This method only counts activities without mirrors.

      Parameters:
      groupId - the primary key of the group
      Returns:
      the number of matching activities
    • getMirrorActivity

      public com.liferay.social.kernel.model.SocialActivity getMirrorActivity(long mirrorActivityId) throws com.liferay.portal.kernel.exception.PortalException
      Returns the activity that has the mirror activity.
      Parameters:
      mirrorActivityId - the primary key of the mirror activity
      Returns:
      Returns the mirror activity
      Throws:
      com.liferay.portal.kernel.exception.PortalException
    • getOrganizationActivities

      public List<com.liferay.social.kernel.model.SocialActivity> getOrganizationActivities(long organizationId, int start, int end)
      Returns a range of all the activities done in the organization. This method only finds activities without mirrors.

      Useful when paginating results. Returns a maximum of end - start instances. start and end are not primary keys, they are indexes in the result set. Thus, 0 refers to the first result in the set. Setting both start and end to QueryUtil.ALL_POS will return the full result set.

      Parameters:
      organizationId - the primary key of the organization
      start - the lower bound of the range of results
      end - the upper bound of the range of results (not inclusive)
      Returns:
      the range of matching activities
    • getOrganizationActivitiesCount

      public int getOrganizationActivitiesCount(long organizationId)
      Returns the number of activities done in the organization. This method only counts activities without mirrors.
      Parameters:
      organizationId - the primary key of the organization
      Returns:
      the number of matching activities
    • getOrganizationUsersActivities

      public List<com.liferay.social.kernel.model.SocialActivity> getOrganizationUsersActivities(long organizationId, int start, int end)
      Returns a range of all the activities done by users of the organization. This method only finds activities without mirrors.

      Useful when paginating results. Returns a maximum of end - start instances. start and end are not primary keys, they are indexes in the result set. Thus, 0 refers to the first result in the set. Setting both start and end to QueryUtil.ALL_POS will return the full result set.

      Parameters:
      organizationId - the primary key of the organization
      start - the lower bound of the range of results
      end - the upper bound of the range of results (not inclusive)
      Returns:
      the range of matching activities
    • getOrganizationUsersActivitiesCount

      public int getOrganizationUsersActivitiesCount(long organizationId)
      Returns the number of activities done by users of the organization. This method only counts activities without mirrors.
      Parameters:
      organizationId - the primary key of the organization
      Returns:
      the number of matching activities
    • getRelationActivities

      public List<com.liferay.social.kernel.model.SocialActivity> getRelationActivities(long userId, int start, int end)
      Returns a range of all the activities done by users in a relationship with the user identified by the user ID.

      Useful when paginating results. Returns a maximum of end - start instances. start and end are not primary keys, they are indexes in the result set. Thus, 0 refers to the first result in the set. Setting both start and end to QueryUtil.ALL_POS will return the full result set.

      Parameters:
      userId - the primary key of the user
      start - the lower bound of the range of results
      end - the upper bound of the range of results (not inclusive)
      Returns:
      the range of matching activities
    • getRelationActivities

      public List<com.liferay.social.kernel.model.SocialActivity> getRelationActivities(long userId, int type, int start, int end)
      Returns a range of all the activities done by users in a relationship of type type with the user identified by userId. This method only finds activities without mirrors.

      Useful when paginating results. Returns a maximum of end - start instances. start and end are not primary keys, they are indexes in the result set. Thus, 0 refers to the first result in the set. Setting both start and end to QueryUtil.ALL_POS will return the full result set.

      Parameters:
      userId - the primary key of the user
      type - the relationship type
      start - the lower bound of the range of results
      end - the upper bound of the range of results (not inclusive)
      Returns:
      the range of matching activities
    • getRelationActivitiesCount

      public int getRelationActivitiesCount(long userId)
      Returns the number of activities done by users in a relationship with the user identified by userId.
      Parameters:
      userId - the primary key of the user
      Returns:
      the number of matching activities
    • getRelationActivitiesCount

      public int getRelationActivitiesCount(long userId, int type)
      Returns the number of activities done by users in a relationship of type type with the user identified by userId. This method only counts activities without mirrors.
      Parameters:
      userId - the primary key of the user
      type - the relationship type
      Returns:
      the number of matching activities
    • getUserActivities

      public List<com.liferay.social.kernel.model.SocialActivity> getUserActivities(long userId, int start, int end)
      Returns a range of all the activities done by the user.

      Useful when paginating results. Returns a maximum of end - start instances. start and end are not primary keys, they are indexes in the result set. Thus, 0 refers to the first result in the set. Setting both start and end to QueryUtil.ALL_POS will return the full result set.

      Parameters:
      userId - the primary key of the user
      start - the lower bound of the range of results
      end - the upper bound of the range of results (not inclusive)
      Returns:
      the range of matching activities
    • getUserActivitiesCount

      public int getUserActivitiesCount(long userId)
      Returns the number of activities done by the user.
      Parameters:
      userId - the primary key of the user
      Returns:
      the number of matching activities
    • getUserGroupsActivities

      public List<com.liferay.social.kernel.model.SocialActivity> getUserGroupsActivities(long userId, int start, int end)
      Returns a range of all the activities done in the user's groups. This method only finds activities without mirrors.

      Useful when paginating results. Returns a maximum of end - start instances. start and end are not primary keys, they are indexes in the result set. Thus, 0 refers to the first result in the set. Setting both start and end to QueryUtil.ALL_POS will return the full result set.

      Parameters:
      userId - the primary key of the user
      start - the lower bound of the range of results
      end - the upper bound of the range of results (not inclusive)
      Returns:
      the range of matching activities
    • getUserGroupsActivitiesCount

      public int getUserGroupsActivitiesCount(long userId)
      Returns the number of activities done in user's groups. This method only counts activities without mirrors.
      Parameters:
      userId - the primary key of the user
      Returns:
      the number of matching activities
    • getUserGroupsAndOrganizationsActivities

      public List<com.liferay.social.kernel.model.SocialActivity> getUserGroupsAndOrganizationsActivities(long userId, int start, int end)
      Returns a range of all the activities done in the user's groups and organizations. This method only finds activities without mirrors.

      Useful when paginating results. Returns a maximum of end - start instances. start and end are not primary keys, they are indexes in the result set. Thus, 0 refers to the first result in the set. Setting both start and end to QueryUtil.ALL_POS will return the full result set.

      Parameters:
      userId - the primary key of the user
      start - the lower bound of the range of results
      end - the upper bound of the range of results (not inclusive)
      Returns:
      the range of matching activities
    • getUserGroupsAndOrganizationsActivitiesCount

      public int getUserGroupsAndOrganizationsActivitiesCount(long userId)
      Returns the number of activities done in user's groups and organizations. This method only counts activities without mirrors.
      Parameters:
      userId - the primary key of the user
      Returns:
      the number of matching activities
    • getUserOrganizationsActivities

      public List<com.liferay.social.kernel.model.SocialActivity> getUserOrganizationsActivities(long userId, int start, int end)
      Returns a range of all activities done in the user's organizations. This method only finds activities without mirrors.

      Useful when paginating results. Returns a maximum of end - start instances. start and end are not primary keys, they are indexes in the result set. Thus, 0 refers to the first result in the set. Setting both start and end to QueryUtil.ALL_POS will return the full result set.

      Parameters:
      userId - the primary key of the user
      start - the lower bound of the range of results
      end - the upper bound of the range of results (not inclusive)
      Returns:
      the range of matching activities
    • getUserOrganizationsActivitiesCount

      public int getUserOrganizationsActivitiesCount(long userId)
      Returns the number of activities done in the user's organizations. This method only counts activities without mirrors.
      Parameters:
      userId - the primary key of the user
      Returns:
      the number of matching activities
    • deleteActivities

      protected void deleteActivities(long classNameId, long classPK) throws com.liferay.portal.kernel.exception.PortalException
      Throws:
      com.liferay.portal.kernel.exception.PortalException
    • isLogActivity

      protected boolean isLogActivity(com.liferay.social.kernel.model.SocialActivity activity)