Package io.meeds.kudos.service
Class KudosService
java.lang.Object
io.meeds.kudos.service.KudosService
A service to manage kudos
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleancanSendKudosInSpace(Kudos kudos, org.exoplatform.social.core.space.model.Space space, String username) 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 timecountKudosByPeriodAndReceivers(List<Long> identitiesId, long startDateInSeconds, long endDateInSeconds) Count kudos received by a list of identities in a period of timelongcountKudosByPeriodAndSender(long senderIdentityId, long startDateInSeconds, long endDateInSeconds) Count kudos sent by an identity in a period of timecreateKudos(Kudos kudos, String currentUser) Create a new Kudos sent by current uservoiddeleteKudosById(long kudosId) Deletes a sent kudosvoiddeleteKudosById(long kudosId, String username) Deletes a sent kudosgetAccountSettings(String username) getKudosByActivityId(Long activityId) Retrieves kudos by activityIdgetKudosByActivityId(Long activityId, org.exoplatform.services.security.Identity currentUser) Retrieves kudos by activityIdgetKudosByEntity(String entityType, String entityId, int limit) Retrieves a list of kudos sent using a dedicated entity (activity, comment, profile header, tiptip...)getKudosByPeriod(long startDateInSeconds, long endDateInSeconds, int limit) Retrieves the list of kudos sent in a period of time.getKudosByPeriod(long dateInSeconds, KudosPeriodType periodType, int limit) Retrieves the list of kudos sent in a period of time.getKudosByPeriodAndReceiver(long identityId, long startDateInSeconds, long endDateInSeconds, int limit) Retrieves kudos received by an identity in a period of timegetKudosByPeriodAndSender(long senderIdentityId, long startDateInSeconds, long endDateInSeconds, int limit) Retrieves Kudos list by sender identity IdgetKudosByPeriodOfDate(long dateInSeconds, int limit) Retrieves the list of kudos sent in a period of time.getKudosListOfActivity(String activityId) Retrieves the list of kudos for a given parent entity id and with a set of entity typesgetKudosListOfActivity(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 typesgetKudosPeriodOfTime(long dateInSeconds) getKudosPeriodOfTime(KudosPeriodType periodType, long dateInSeconds) voidinit()booleanisActivityComment(Kudos kudos) voidsaveGlobalSettings(GlobalSettings settings) Stores new parameters of Kudos moduleupdateKudos(Kudos kudos) Updates a kudosvoidupdateKudosGeneratedActivityId(long kudosId, long activityId) Stores generated activity for createdKudos
-
Constructor Details
-
KudosService
public KudosService()
-
-
Method Details
-
init
@PostConstruct public void init() -
getGlobalSettings
- Returns:
GlobalSettingsof Kudos module
-
saveGlobalSettings
Stores new parameters of Kudos module- Parameters:
settings-GlobalSettings
-
getAccountSettings
- Parameters:
username- username to get its settings- Returns:
- kudos settings of a user
-
createKudos
Create a new Kudos sent by current user- Parameters:
kudos-Kudosto createcurrentUser- username of current user- Returns:
- created
Kudos - Throws:
IllegalAccessException- when receiver or sender aren't allowed.
-
canSendKudosInSpace
public boolean canSendKudosInSpace(Kudos kudos, org.exoplatform.social.core.space.model.Space space, String username) - Parameters:
kudos-Kudosto createspace- targetSpaceusername- user making the action- Returns:
- true if can redact on space or if is a comment/reply on an existing activity
-
deleteKudosById
public void deleteKudosById(long kudosId, String username) throws IllegalAccessException, org.exoplatform.commons.exception.ObjectNotFoundException, KudosAlreadyLinkedException Deletes a sent kudos- Parameters:
kudosId- Kudos technical identifier to deleteusername- User name deleting kudos- Throws:
IllegalAccessException- when user is not authorized to delete the kudosorg.exoplatform.commons.exception.ObjectNotFoundException- when the kudos identified by its technical identifier is not foundKudosAlreadyLinkedException- when the kudos is already linked to kudos entities
-
deleteKudosById
public void deleteKudosById(long kudosId) throws org.exoplatform.commons.exception.ObjectNotFoundException Deletes a sent kudos- Parameters:
kudosId- Kudos technical identifier to delete- Throws:
org.exoplatform.commons.exception.ObjectNotFoundException- when the kudos identified by its technical identifier is not found
-
isActivityComment
- Parameters:
kudos-Kudos- Returns:
- true if the associated Activity to generate is a comment or a reply to a comment, else false
-
updateKudosGeneratedActivityId
public void updateKudosGeneratedActivityId(long kudosId, long activityId) Stores generated activity for createdKudos- Parameters:
kudosId-Kudostechnical identifieractivityId-ExoSocialActivitytechnical identifier
-
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
Retrieves kudos by activityId- Parameters:
activityId-ExoSocialActivityidentifier- Returns:
Kudos
-
updateKudos
Updates a kudos -
getKudosByPeriod
Retrieves the list of kudos sent in a period of time. -
getKudosByPeriod
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
Retrieves the list of kudos sent in a period of time. Configured Period Type is retrieved fromGlobalSettings -
getKudosByEntity
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
-
countKudosByEntity
-
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
-
countKudosByPeriodAndReceivers
public Map<Long,Long> countKudosByPeriodAndReceivers(List<Long> identitiesId, long startDateInSeconds, long endDateInSeconds) Count kudos received by a list of identities in a period of time- Parameters:
identitiesId-IdentityList of technical idstartDateInSeconds- timestamp in secondsendDateInSeconds- timestamp in seconds- Returns:
- Map<identityId,kudoCount> the number of kudos by identity
-
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
-
getKudosListOfActivity
Retrieves the list of kudos for a given parent entity id and with a set of entity types -
getDefaultKudosPeriodType
-
getCurrentKudosPeriod
-
getKudosPeriodOfTime
-
getKudosPeriodOfTime
-