Class SocialActivityCounterLocalServiceImpl
- 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.SocialActivityCounter>
,com.liferay.portal.kernel.service.PersistedModelLocalService
,com.liferay.social.kernel.service.SocialActivityCounterLocalService
Under normal circumstances only the addActivityCounters(SocialActivity)
should be called directly and even that
is usually not necessary as it is automatically called by the social activity
service.
- Author:
- Zsolt Berentey, Shuyang Zhou
-
Field Summary
Fields inherited from class com.liferay.portlet.social.service.base.SocialActivityCounterLocalServiceBaseImpl
counterLocalService, socialActivityCounterFinder, socialActivityCounterLocalService, socialActivityCounterPersistence
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncom.liferay.social.kernel.model.SocialActivityCounter
addActivityCounter
(long groupId, long classNameId, long classPK, String name, int ownerType, int totalValue, long previousActivityCounterId, int periodLength) Adds an activity counter specifying a previous activity and period length.protected com.liferay.social.kernel.model.SocialActivityCounter
addActivityCounter
(long groupId, com.liferay.portal.kernel.model.User user, com.liferay.social.kernel.model.SocialActivity activity, com.liferay.social.kernel.model.SocialActivityCounterDefinition activityCounterDefinition) void
addActivityCounters
(com.liferay.social.kernel.model.SocialActivity activity) Adds or increments activity counters related to an activity.protected com.liferay.social.kernel.model.SocialActivityCounter
addAssetActivitiesCounter
(com.liferay.social.kernel.model.SocialActivity activity) protected com.liferay.social.kernel.model.SocialActivityCounter
addUserActivitiesCounter
(com.liferay.social.kernel.model.SocialActivity activity) protected void
adjustUserContribution
(com.liferay.asset.kernel.model.AssetEntry assetEntry, boolean enable) protected boolean
checkActivityLimit
(com.liferay.portal.kernel.model.User user, com.liferay.social.kernel.model.SocialActivity activity, com.liferay.social.kernel.model.SocialActivityCounterDefinition activityCounterDefinition) protected void
void
deleteActivityCounters
(long classNameId, long classPK) Deletes all activity counters, limits, and settings related to the entity identified by the class name ID and class primary key.void
deleteActivityCounters
(com.liferay.asset.kernel.model.AssetEntry assetEntry) Deletes all activity counters, limits, and settings related to the asset.void
deleteActivityCounters
(String className, long classPK) Deletes all activity counters for the entity identified by the class name and class primary key.void
disableActivityCounters
(long classNameId, long classPK) Disables all the counters of an asset identified by the class name ID and class primary key.void
disableActivityCounters
(String className, long classPK) Disables all the counters of an asset identified by the class name and class primary key.void
enableActivityCounters
(long classNameId, long classPK) Enables all activity counters of an asset identified by the class name ID and class primary key.void
enableActivityCounters
(String className, long classPK) Enables all the counters of an asset identified by the class name and class primary key.com.liferay.social.kernel.model.SocialActivityCounter
fetchActivityCounterByEndPeriod
(long groupId, long classNameId, long classPK, String name, int ownerType, int endPeriod) Returns the activity counter with the given name, owner, and end period that belong to the given entity.com.liferay.social.kernel.model.SocialActivityCounter
fetchActivityCounterByStartPeriod
(long groupId, long classNameId, long classPK, String name, int ownerType, int startPeriod) Returns the activity counter with the given name, owner, and start period that belong to the given entity.com.liferay.social.kernel.model.SocialActivityCounter
fetchLatestActivityCounter
(long groupId, long classNameId, long classPK, String name, int ownerType) Returns the latest activity counter with the given name and owner that belong to the given entity.protected long
getClassNameId
(com.liferay.asset.kernel.model.AssetEntry assetEntry, int ownerType) protected long
getClassPK
(com.liferay.portal.kernel.model.User user, com.liferay.asset.kernel.model.AssetEntry assetEntry, int ownerType) protected long
getLimitClassPK
(com.liferay.social.kernel.model.SocialActivity activity, com.liferay.social.kernel.model.SocialActivityCounterDefinition activityCounterDefinition) List<com.liferay.social.kernel.model.SocialActivityCounter>
getOffsetActivityCounters
(long groupId, String name, int startOffset, int endOffset) Returns all the activity counters with the given name and period offsets.List<com.liferay.social.kernel.model.SocialActivityCounter>
getOffsetDistributionActivityCounters
(long groupId, String name, int startOffset, int endOffset) Returns the distribution of the activity counters with the given name and period offsets.List<com.liferay.social.kernel.model.SocialActivityCounter>
getPeriodActivityCounters
(long groupId, String name, int startPeriod, int endPeriod) Returns all the activity counters with the given name and time period.List<com.liferay.social.kernel.model.SocialActivityCounter>
getPeriodDistributionActivityCounters
(long groupId, String name, int startPeriod, int endPeriod) Returns the distribution of activity counters with the given name and time period.List<com.liferay.portal.kernel.util.Tuple>
getUserActivityCounters
(long groupId, String[] rankingNames, String[] selectedNames, int start, int end) Returns the range of tuples that contain users and a list of activity counters.int
getUserActivityCountersCount
(long groupId, String[] rankingNames) Returns the number of users having a rank based on the given counters.protected void
incrementActivityCounter
(com.liferay.social.kernel.model.SocialActivityCounter activityCounter, com.liferay.social.kernel.model.SocialActivityCounterDefinition activityCounterDefinition) void
incrementUserAchievementCounter
(long userId, long groupId) Increments theuser.achievements
counter for a user.protected boolean
isAddActivityCounter
(com.liferay.portal.kernel.model.User user, com.liferay.portal.kernel.model.User assetEntryUser, com.liferay.asset.kernel.model.AssetEntry assetEntry, com.liferay.social.kernel.model.SocialActivityCounterDefinition activityCounterDefinition) protected com.liferay.social.kernel.model.SocialActivityCounter
lockProtectedAddActivityCounter
(long groupId, long classNameId, long classPK, String name, int ownerType, int totalValue, long previousActivityCounterId, int periodLength) protected void
lockProtectedGetActivityLimit
(long groupId, com.liferay.portal.kernel.model.User user, com.liferay.social.kernel.model.SocialActivity activity, com.liferay.social.kernel.model.SocialActivityCounterDefinition activityCounterDefinition) Methods inherited from class com.liferay.portlet.social.service.base.SocialActivityCounterLocalServiceBaseImpl
addSocialActivityCounter, afterPropertiesSet, createPersistedModel, createSocialActivityCounter, deletePersistedModel, deleteSocialActivityCounter, deleteSocialActivityCounter, destroy, dslQuery, dslQueryCount, dynamicQuery, dynamicQuery, dynamicQuery, dynamicQuery, dynamicQueryCount, dynamicQueryCount, fetchSocialActivityCounter, getActionableDynamicQuery, getBasePersistence, getCounterLocalService, getCTPersistence, getIndexableActionableDynamicQuery, getModelClass, getModelClassName, getOSGiServiceIdentifier, getPersistedModel, getSocialActivityCounter, getSocialActivityCounterFinder, getSocialActivityCounterLocalService, getSocialActivityCounterPersistence, getSocialActivityCounters, getSocialActivityCountersCount, initActionableDynamicQuery, runSQL, setCounterLocalService, setSocialActivityCounterFinder, setSocialActivityCounterLocalService, setSocialActivityCounterPersistence, updateSocialActivityCounter, updateWithUnsafeFunction
Methods inherited from class com.liferay.portal.kernel.service.BaseLocalServiceImpl
getClassLoader, getLocalizationMap
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.liferay.portal.kernel.service.PersistedModelLocalService
fetchPersistedModel
-
Constructor Details
-
SocialActivityCounterLocalServiceImpl
public SocialActivityCounterLocalServiceImpl()
-
-
Method Details
-
addActivityCounter
public com.liferay.social.kernel.model.SocialActivityCounter addActivityCounter(long groupId, long classNameId, long classPK, String name, int ownerType, int totalValue, long previousActivityCounterId, int periodLength) throws com.liferay.portal.kernel.exception.PortalException Adds an activity counter specifying a previous activity and period length.This method uses the lock service to guard against multiple threads trying to insert the same counter because this service is called asynchronously from the social activity service.
- Parameters:
groupId
- the primary key of the groupclassNameId
- the primary key of the entity's class this counter belongs toclassPK
- the primary key of the entity this counter belongs toname
- the counter nameownerType
- the counter's owner type. Acceptable values areTYPE_ACTOR
,TYPE_ASSET
andTYPE_CREATOR
defined inSocialActivityCounterConstants
.totalValue
- the counter's total value (optionally0
)previousActivityCounterId
- the primary key of the activity counter for the previous time period (optionally0
, if this is the first)periodLength
- the period length in days,PERIOD_LENGTH_INFINITE
for never ending counters orPERIOD_LENGTH_SYSTEM
for the period length defined inportal-ext.properties
. For more information seeSocialActivityCounterConstants
.- Returns:
- the added activity counter
- Throws:
com.liferay.portal.kernel.exception.PortalException
-
addActivityCounters
public void addActivityCounters(com.liferay.social.kernel.model.SocialActivity activity) throws com.liferay.portal.kernel.exception.PortalException Adds or increments activity counters related to an activity.This method is called asynchronously from the social activity service when the user performs an activity defined in
liferay-social.xml
.This method first calls the activity processor class, if there is one defined for the activity, checks for limits and increments all the counters that belong to the activity. Afterwards, it processes the activity with respect to achievement classes, if any. Lastly it increments the built-in
user.activities
andasset.activities
counters.- Parameters:
activity
- the social activity- Throws:
com.liferay.portal.kernel.exception.PortalException
-
deleteActivityCounters
public void deleteActivityCounters(com.liferay.asset.kernel.model.AssetEntry assetEntry) throws com.liferay.portal.kernel.exception.PortalException Deletes all activity counters, limits, and settings related to the asset.This method subtracts the asset's popularity from the owner's contribution points. It also creates a new contribution period if the latest one does not belong to the current period.
- Parameters:
assetEntry
- the asset entry- Throws:
com.liferay.portal.kernel.exception.PortalException
-
deleteActivityCounters
public void deleteActivityCounters(long classNameId, long classPK) throws com.liferay.portal.kernel.exception.PortalException Deletes all activity counters, limits, and settings related to the entity identified by the class name ID and class primary key.- Parameters:
classNameId
- the primary key of the entity's classclassPK
- the primary key of the entity- Throws:
com.liferay.portal.kernel.exception.PortalException
-
deleteActivityCounters
public void deleteActivityCounters(String className, long classPK) throws com.liferay.portal.kernel.exception.PortalException Deletes all activity counters for the entity identified by the class name and class primary key.- Parameters:
className
- the entity's class nameclassPK
- the primary key of the entity- Throws:
com.liferay.portal.kernel.exception.PortalException
-
disableActivityCounters
public void disableActivityCounters(long classNameId, long classPK) throws com.liferay.portal.kernel.exception.PortalException Disables all the counters of an asset identified by the class name ID and class primary key.This method is used by the recycle bin to disable all counters of assets put into the recycle bin. It adjusts the owner's contribution score.
- Parameters:
classNameId
- the primary key of the asset's classclassPK
- the primary key of the asset- Throws:
com.liferay.portal.kernel.exception.PortalException
-
disableActivityCounters
public void disableActivityCounters(String className, long classPK) throws com.liferay.portal.kernel.exception.PortalException Disables all the counters of an asset identified by the class name and class primary key.This method is used by the recycle bin to disable all counters of assets put into the recycle bin. It adjusts the owner's contribution score.
- Parameters:
className
- the asset's class nameclassPK
- the primary key of the asset- Throws:
com.liferay.portal.kernel.exception.PortalException
-
enableActivityCounters
public void enableActivityCounters(long classNameId, long classPK) throws com.liferay.portal.kernel.exception.PortalException Enables all activity counters of an asset identified by the class name ID and class primary key.This method is used by the recycle bin to enable all counters of assets restored from the recycle bin. It adjusts the owner's contribution score.
- Parameters:
classNameId
- the primary key of the asset's classclassPK
- the primary key of the asset- Throws:
com.liferay.portal.kernel.exception.PortalException
-
enableActivityCounters
public void enableActivityCounters(String className, long classPK) throws com.liferay.portal.kernel.exception.PortalException Enables all the counters of an asset identified by the class name and class primary key.This method is used by the recycle bin to enable all counters of assets restored from the recycle bin. It adjusts the owner's contribution score.
- Parameters:
className
- the asset's class nameclassPK
- the primary key of the asset- Throws:
com.liferay.portal.kernel.exception.PortalException
-
fetchActivityCounterByEndPeriod
public com.liferay.social.kernel.model.SocialActivityCounter fetchActivityCounterByEndPeriod(long groupId, long classNameId, long classPK, String name, int ownerType, int endPeriod) Returns the activity counter with the given name, owner, and end period that belong to the given entity.- Parameters:
groupId
- the primary key of the groupclassNameId
- the primary key of the entity's classclassPK
- the primary key of the entityname
- the counter nameownerType
- the owner typeendPeriod
- the end period,-1
for the latest one- Returns:
- the matching activity counter
-
fetchActivityCounterByStartPeriod
public com.liferay.social.kernel.model.SocialActivityCounter fetchActivityCounterByStartPeriod(long groupId, long classNameId, long classPK, String name, int ownerType, int startPeriod) Returns the activity counter with the given name, owner, and start period that belong to the given entity.- Parameters:
groupId
- the primary key of the groupclassNameId
- the primary key of the entity's classclassPK
- the primary key of the entityname
- the counter nameownerType
- the owner typestartPeriod
- the start period- Returns:
- the matching activity counter
-
fetchLatestActivityCounter
public com.liferay.social.kernel.model.SocialActivityCounter fetchLatestActivityCounter(long groupId, long classNameId, long classPK, String name, int ownerType) Returns the latest activity counter with the given name and owner that belong to the given entity.- Parameters:
groupId
- the primary key of the groupclassNameId
- the primary key of the entity's classclassPK
- the primary key of the entityname
- the counter nameownerType
- the owner type- Returns:
- the matching activity counter
-
getOffsetActivityCounters
public List<com.liferay.social.kernel.model.SocialActivityCounter> getOffsetActivityCounters(long groupId, String name, int startOffset, int endOffset) Returns all the activity counters with the given name and period offsets.The start and end offsets can belong to different periods. This method groups the counters by name and returns the sum of their current values.
- Parameters:
groupId
- the primary key of the groupname
- the counter namestartOffset
- the offset for the start periodendOffset
- the offset for the end period- Returns:
- the matching activity counters
-
getOffsetDistributionActivityCounters
public List<com.liferay.social.kernel.model.SocialActivityCounter> getOffsetDistributionActivityCounters(long groupId, String name, int startOffset, int endOffset) Returns the distribution of the activity counters with the given name and period offsets.The start and end offsets can belong to different periods. This method groups the counters by their owner entity (usually some asset) and returns a counter for each entity class with the sum of the counters' current values.
- Parameters:
groupId
- the primary key of the groupname
- the counter namestartOffset
- the offset for the start periodendOffset
- the offset for the end period- Returns:
- the distribution of matching activity counters
-
getPeriodActivityCounters
public List<com.liferay.social.kernel.model.SocialActivityCounter> getPeriodActivityCounters(long groupId, String name, int startPeriod, int endPeriod) Returns all the activity counters with the given name and time period.The start and end period values can belong to different periods. This method groups the counters by name and returns the sum of their current values.
- Parameters:
groupId
- the primary key of the groupname
- the counter namestartPeriod
- the start periodendPeriod
- the end period- Returns:
- the matching activity counters
-
getPeriodDistributionActivityCounters
public List<com.liferay.social.kernel.model.SocialActivityCounter> getPeriodDistributionActivityCounters(long groupId, String name, int startPeriod, int endPeriod) Returns the distribution of activity counters with the given name and time period.The start and end period values can belong to different periods. This method groups the counters by their owner entity (usually some asset) and returns a counter for each entity class with the sum of the counters' current values.
- Parameters:
groupId
- the primary key of the groupname
- the counter namestartPeriod
- the start periodendPeriod
- the end period- Returns:
- the distribution of matching activity counters
-
getUserActivityCounters
public List<com.liferay.portal.kernel.util.Tuple> getUserActivityCounters(long groupId, String[] rankingNames, String[] selectedNames, int start, int end) Returns the range of tuples that contain users and a list of activity counters.The counters returned for each user are passed to this method in the selectedNames array. The method also accepts an array of counter names that are used to rank the users.
Useful when paginating results. Returns a maximum of
end - start
instances.start
andend
are not primary keys, they are indexes in the result set. Thus,0
refers to the first result in the set. Setting bothstart
andend
toQueryUtil.ALL_POS
will return the full result set.- Parameters:
groupId
- the primary key of the grouprankingNames
- the ranking counter namesselectedNames
- the counter names that will be returned with each userstart
- the lower bound of the range of resultsend
- the upper bound of the range of results (not inclusive)- Returns:
- the range of matching tuples
-
getUserActivityCountersCount
Returns the number of users having a rank based on the given counters.- Parameters:
groupId
- the primary key of the grouprankingNames
- the ranking counter names- Returns:
- the number of matching users
-
incrementUserAchievementCounter
public void incrementUserAchievementCounter(long userId, long groupId) throws com.liferay.portal.kernel.exception.PortalException Increments theuser.achievements
counter for a user.This method should be used by an external achievement class when the users unlocks an achievement.
- Parameters:
userId
- the primary key of the usergroupId
- the primary key of the group- Throws:
com.liferay.portal.kernel.exception.PortalException
-
addActivityCounter
protected com.liferay.social.kernel.model.SocialActivityCounter addActivityCounter(long groupId, com.liferay.portal.kernel.model.User user, com.liferay.social.kernel.model.SocialActivity activity, com.liferay.social.kernel.model.SocialActivityCounterDefinition activityCounterDefinition) throws com.liferay.portal.kernel.exception.PortalException - Throws:
com.liferay.portal.kernel.exception.PortalException
-
addAssetActivitiesCounter
protected com.liferay.social.kernel.model.SocialActivityCounter addAssetActivitiesCounter(com.liferay.social.kernel.model.SocialActivity activity) throws com.liferay.portal.kernel.exception.PortalException - Throws:
com.liferay.portal.kernel.exception.PortalException
-
addUserActivitiesCounter
protected com.liferay.social.kernel.model.SocialActivityCounter addUserActivitiesCounter(com.liferay.social.kernel.model.SocialActivity activity) throws com.liferay.portal.kernel.exception.PortalException - Throws:
com.liferay.portal.kernel.exception.PortalException
-
adjustUserContribution
protected void adjustUserContribution(com.liferay.asset.kernel.model.AssetEntry assetEntry, boolean enable) throws com.liferay.portal.kernel.exception.PortalException - Throws:
com.liferay.portal.kernel.exception.PortalException
-
checkActivityLimit
protected boolean checkActivityLimit(com.liferay.portal.kernel.model.User user, com.liferay.social.kernel.model.SocialActivity activity, com.liferay.social.kernel.model.SocialActivityCounterDefinition activityCounterDefinition) throws com.liferay.portal.kernel.exception.PortalException - Throws:
com.liferay.portal.kernel.exception.PortalException
-
clearFinderCache
protected void clearFinderCache() -
getClassNameId
protected long getClassNameId(com.liferay.asset.kernel.model.AssetEntry assetEntry, int ownerType) -
getClassPK
protected long getClassPK(com.liferay.portal.kernel.model.User user, com.liferay.asset.kernel.model.AssetEntry assetEntry, int ownerType) -
getLimitClassPK
protected long getLimitClassPK(com.liferay.social.kernel.model.SocialActivity activity, com.liferay.social.kernel.model.SocialActivityCounterDefinition activityCounterDefinition) -
incrementActivityCounter
protected void incrementActivityCounter(com.liferay.social.kernel.model.SocialActivityCounter activityCounter, com.liferay.social.kernel.model.SocialActivityCounterDefinition activityCounterDefinition) -
isAddActivityCounter
protected boolean isAddActivityCounter(com.liferay.portal.kernel.model.User user, com.liferay.portal.kernel.model.User assetEntryUser, com.liferay.asset.kernel.model.AssetEntry assetEntry, com.liferay.social.kernel.model.SocialActivityCounterDefinition activityCounterDefinition) -
lockProtectedAddActivityCounter
protected com.liferay.social.kernel.model.SocialActivityCounter lockProtectedAddActivityCounter(long groupId, long classNameId, long classPK, String name, int ownerType, int totalValue, long previousActivityCounterId, int periodLength) throws com.liferay.portal.kernel.exception.PortalException - Throws:
com.liferay.portal.kernel.exception.PortalException
-
lockProtectedGetActivityLimit
protected void lockProtectedGetActivityLimit(long groupId, com.liferay.portal.kernel.model.User user, com.liferay.social.kernel.model.SocialActivity activity, com.liferay.social.kernel.model.SocialActivityCounterDefinition activityCounterDefinition) throws com.liferay.portal.kernel.exception.PortalException - Throws:
com.liferay.portal.kernel.exception.PortalException
-