Package org.exoplatform.kudos.service
Class KudosService
- java.lang.Object
-
- org.exoplatform.kudos.service.KudosService
-
- All Implemented Interfaces:
ExoKudosStatisticService,org.picocontainer.Startable
public class KudosService extends Object implements ExoKudosStatisticService, org.picocontainer.Startable
A service to manage kudos
-
-
Constructor Summary
Constructors Constructor Description KudosService(KudosStorage kudosStorage, org.exoplatform.commons.api.settings.SettingService settingService, org.exoplatform.social.core.manager.ActivityManager activityManager, org.exoplatform.social.core.space.spi.SpaceService spaceService, org.exoplatform.social.core.manager.IdentityManager identityManager, org.exoplatform.services.listener.ListenerService listenerService, org.exoplatform.container.PortalContainer container, org.exoplatform.container.xml.InitParams params)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description longcountKudosByEntity(String entityType, String entityId)longcountKudosByEntityAndSender(String entityType, String entityId, String senderIdentityId)Count kudos sent by an identity using a dedicated entity (activity, comment, profile header, tiptip...)longcountKudosByPeriodAndReceiver(long identityId, long startDateInSeconds, long endDateInSeconds)Count kudos received by an identity in a period of timelongcountKudosByPeriodAndSender(long senderIdentityId, long startDateInSeconds, long endDateInSeconds)Count kudos sent by an identity in a period of timeKudoscreateKudos(Kudos kudos, String currentUser)Create a new Kudos sent by current userAccountSettingsgetAccountSettings(String username)KudosPeriodgetCurrentKudosPeriod()KudosPeriodTypegetDefaultKudosPeriodType()GlobalSettingsgetGlobalSettings()KudosgetKudosByActivityId(Long activityId)Retrieves kudos by activityIdKudosgetKudosByActivityId(Long activityId, org.exoplatform.services.security.Identity currentUser)Retrieves kudos by activityIdList<Kudos>getKudosByEntity(String entityType, String entityId, int limit)Retrieves a list of kudos sent using a dedicated entity (activity, comment, profile header, tiptip...)List<Kudos>getKudosByPeriod(long startDateInSeconds, long endDateInSeconds, int limit)Retrieves the list of kudos sent in a period of time.List<Kudos>getKudosByPeriod(long dateInSeconds, KudosPeriodType periodType, int limit)Retrieves the list of kudos sent in a period of time.List<Kudos>getKudosByPeriodAndReceiver(long identityId, long startDateInSeconds, long endDateInSeconds, int limit)Retrieves kudos received by an identity in a period of timeList<Kudos>getKudosByPeriodAndSender(long senderIdentityId, long startDateInSeconds, long endDateInSeconds, int limit)Retrieves Kudos list by sender identity IdList<Kudos>getKudosByPeriodOfDate(long dateInSeconds, int limit)Retrieves the list of kudos sent in a period of time.List<Kudos>getKudosListOfActivity(String activityId, org.exoplatform.services.security.Identity currentUser)Retrieves the list of kudos for a given parent entity id and with a set of entity typesKudosPeriodgetKudosPeriodOfTime(long dateInSeconds)KudosPeriodgetKudosPeriodOfTime(KudosPeriodType periodType, long dateInSeconds)Map<String,Object>getStatisticParameters(String operation, Object result, Object... methodArgs)Retrieve statistic log parametersbooleanisAuthorizedOnKudosModule(String username)Check if user is authorized to send/receive KudosvoidsaveGlobalSettings(GlobalSettings settings)Stores new parameters of Kudos modulevoidstart()voidstop()KudosupdateKudos(Kudos kudos)Updates a kudosvoidupdateKudosGeneratedActivityId(long kudosId, long activityId)Stores generated activity for createdKudos
-
-
-
Constructor Detail
-
KudosService
public KudosService(KudosStorage kudosStorage, org.exoplatform.commons.api.settings.SettingService settingService, org.exoplatform.social.core.manager.ActivityManager activityManager, org.exoplatform.social.core.space.spi.SpaceService spaceService, org.exoplatform.social.core.manager.IdentityManager identityManager, org.exoplatform.services.listener.ListenerService listenerService, org.exoplatform.container.PortalContainer container, org.exoplatform.container.xml.InitParams params)
-
-
Method Detail
-
start
public void start()
- Specified by:
startin interfaceorg.picocontainer.Startable
-
stop
public void stop()
- Specified by:
stopin interfaceorg.picocontainer.Startable
-
getGlobalSettings
public GlobalSettings getGlobalSettings()
- Returns:
GlobalSettingsof Kudos module
-
saveGlobalSettings
public void saveGlobalSettings(GlobalSettings settings)
Stores new parameters of Kudos module- Parameters:
settings-GlobalSettings
-
getAccountSettings
public AccountSettings getAccountSettings(String username)
- Parameters:
username- username to get its settings- Returns:
- kudos settings of a user
-
createKudos
public Kudos createKudos(Kudos kudos, String currentUser) throws Exception
Create a new Kudos sent by current user
-
updateKudosGeneratedActivityId
public void updateKudosGeneratedActivityId(long kudosId, long activityId) throws ExceptionStores generated activity for createdKudos
-
getKudosByActivityId
public Kudos getKudosByActivityId(Long activityId, org.exoplatform.services.security.Identity currentUser) throws IllegalAccessException
Retrieves kudos by activityId- Parameters:
activityId-ExoSocialActivityidentifiercurrentUser-Identity- Returns:
Kudos- Throws:
IllegalAccessException- when user doesn't have access to kudos
-
getKudosByActivityId
public Kudos getKudosByActivityId(Long activityId)
Retrieves kudos by activityId- Parameters:
activityId-ExoSocialActivityidentifier- Returns:
Kudos
-
getKudosByPeriod
public List<Kudos> getKudosByPeriod(long startDateInSeconds, long endDateInSeconds, int limit)
Retrieves the list of kudos sent in a period of time.
-
getKudosByPeriod
public List<Kudos> getKudosByPeriod(long dateInSeconds, KudosPeriodType periodType, int limit)
Retrieves the list of kudos sent in a period of time.- Parameters:
dateInSeconds- timestamp in secondsperiodType-KudosPeriodTypeused to compute real start and end dates of periodlimit- limit of results size to retrieve- Returns:
ListofKudos
-
getKudosByPeriodOfDate
public List<Kudos> getKudosByPeriodOfDate(long dateInSeconds, int limit)
Retrieves the list of kudos sent in a period of time. Configured Period Type is retrieved fromGlobalSettings
-
getKudosByEntity
public List<Kudos> getKudosByEntity(String entityType, String entityId, int limit)
Retrieves a list of kudos sent using a dedicated entity (activity, comment, profile header, tiptip...)- Parameters:
entityType- entity type of typeKudosEntityTypeentityId- entity technical idlimit- limit of results size to retrieve- Returns:
ListofKudos
-
countKudosByEntityAndSender
public long countKudosByEntityAndSender(String entityType, String entityId, String senderIdentityId)
Count kudos sent by an identity using a dedicated entity (activity, comment, profile header, tiptip...)- Parameters:
entityType- entity type of typeKudosEntityTypeentityId- entity technical idsenderIdentityId-Identitytechnical id- Returns:
- 0 if identity not found, else kudos count
-
countKudosByPeriodAndSender
public long countKudosByPeriodAndSender(long senderIdentityId, long startDateInSeconds, long endDateInSeconds)Count kudos sent by an identity in a period of time- Parameters:
senderIdentityId-Identitytechnical idstartDateInSeconds- timestamp in secondsendDateInSeconds- timestamp in seconds- Returns:
- 0 if identity not found, else kudos count
-
getKudosByPeriodAndSender
public List<Kudos> getKudosByPeriodAndSender(long senderIdentityId, long startDateInSeconds, long endDateInSeconds, int limit)
Retrieves Kudos list by sender identity Id
-
countKudosByPeriodAndReceiver
public long countKudosByPeriodAndReceiver(long identityId, long startDateInSeconds, long endDateInSeconds)Count kudos received by an identity in a period of time- Parameters:
identityId-Identitytechnical idstartDateInSeconds- timestamp in secondsendDateInSeconds- timestamp in seconds- Returns:
- 0 if identity not found, else kudos count
-
getKudosByPeriodAndReceiver
public List<Kudos> getKudosByPeriodAndReceiver(long identityId, long startDateInSeconds, long endDateInSeconds, int limit)
Retrieves kudos received by an identity in a period of time
-
getKudosListOfActivity
public List<Kudos> getKudosListOfActivity(String activityId, org.exoplatform.services.security.Identity currentUser) throws IllegalAccessException
Retrieves the list of kudos for a given parent entity id and with a set of entity types- Parameters:
activityId-ExoSocialActivityidcurrentUser- user requesting access to kudos list- Returns:
ListofKudos- Throws:
IllegalAccessException- when user doesn't have access to kudos
-
isAuthorizedOnKudosModule
public boolean isAuthorizedOnKudosModule(String username)
Check if user is authorized to send/receive Kudos- Parameters:
username- username to check- Returns:
- true if authorised else return false
-
getStatisticParameters
public Map<String,Object> getStatisticParameters(String operation, Object result, Object... methodArgs)
Description copied from interface:ExoKudosStatisticServiceRetrieve statistic log parameters- Specified by:
getStatisticParametersin interfaceExoKudosStatisticService- Returns:
- a
Mapof parameters to include in statistic log
-
getDefaultKudosPeriodType
public KudosPeriodType getDefaultKudosPeriodType()
-
getCurrentKudosPeriod
public KudosPeriod getCurrentKudosPeriod()
-
getKudosPeriodOfTime
public KudosPeriod getKudosPeriodOfTime(long dateInSeconds)
-
getKudosPeriodOfTime
public KudosPeriod getKudosPeriodOfTime(KudosPeriodType periodType, long dateInSeconds)
-
-