Class KudosService

java.lang.Object
io.meeds.kudos.service.KudosService

@Service public class KudosService extends Object
A service to manage kudos
  • Constructor Details

    • KudosService

      public KudosService()
  • Method Details

    • init

      @PostConstruct public void init()
    • getGlobalSettings

      public GlobalSettings getGlobalSettings()
      Returns:
      GlobalSettings of 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 IllegalAccessException
      Create a new Kudos sent by current user
      Parameters:
      kudos - Kudos to create
      currentUser - 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 - Kudos to create
      space - target Space
      username - 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 delete
      username - User name deleting kudos
      Throws:
      IllegalAccessException - when user is not authorized to delete the kudos
      org.exoplatform.commons.exception.ObjectNotFoundException - when the kudos identified by its technical identifier is not found
      KudosAlreadyLinkedException - 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

      public boolean isActivityComment(Kudos kudos)
      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 created Kudos
      Parameters:
      kudosId - Kudos technical identifier
      activityId - ExoSocialActivity technical identifier
    • getKudosByActivityId

      public Kudos getKudosByActivityId(Long activityId, org.exoplatform.services.security.Identity currentUser) throws IllegalAccessException
      Retrieves kudos by activityId
      Parameters:
      activityId - ExoSocialActivity identifier
      currentUser - 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 - ExoSocialActivity identifier
      Returns:
      Kudos
    • updateKudos

      public Kudos updateKudos(Kudos kudos)
      Updates a kudos
      Parameters:
      kudos - Kudos
      Returns:
      Kudos
    • getKudosByPeriod

      public List<Kudos> getKudosByPeriod(long startDateInSeconds, long endDateInSeconds, int limit)
      Retrieves the list of kudos sent in a period of time.
      Parameters:
      startDateInSeconds - timestamp in seconds
      endDateInSeconds - timestamp in seconds
      limit - limit of results size to retrieve
      Returns:
      List of Kudos
    • 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 seconds
      periodType - KudosPeriodType used to compute real start and end dates of period
      limit - limit of results size to retrieve
      Returns:
      List of Kudos
    • 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 from GlobalSettings
      Parameters:
      dateInSeconds - timestamp in seconds to compute real start and end dates of period
      limit - limit of results size to retrieve
      Returns:
      List of Kudos
    • 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 type KudosEntityType
      entityId - entity technical id
      limit - limit of results size to retrieve
      Returns:
      List of Kudos
    • countKudosByEntity

      public long countKudosByEntity(String entityType, String entityId)
    • 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 type KudosEntityType
      entityId - entity technical id
      senderIdentityId - Identity technical 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 - Identity technical id
      startDateInSeconds - timestamp in seconds
      endDateInSeconds - 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
      Parameters:
      senderIdentityId - Identity technical id of sender
      startDateInSeconds - timestamp in seconds
      endDateInSeconds - timestamp in seconds
      limit - limit of results size to retrieve
      Returns:
      List of Kudos
    • countKudosByPeriodAndReceiver

      public long countKudosByPeriodAndReceiver(long identityId, long startDateInSeconds, long endDateInSeconds)
      Count kudos received by an identity in a period of time
      Parameters:
      identityId - Identity technical id
      startDateInSeconds - timestamp in seconds
      endDateInSeconds - 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 - Identity List of technical id
      startDateInSeconds - timestamp in seconds
      endDateInSeconds - 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
      Parameters:
      identityId - Identity technical id
      startDateInSeconds - timestamp in seconds
      endDateInSeconds - timestamp in seconds
      limit - limit of results size to retrieve
      Returns:
      List of Kudos. An empty list will be returned if the identity is not found.
    • 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 - ExoSocialActivity id
      currentUser - user requesting access to kudos list
      Returns:
      List of Kudos
      Throws:
      IllegalAccessException - when user doesn't have access to kudos
    • getKudosListOfActivity

      public List<Kudos> getKudosListOfActivity(String activityId)
      Retrieves the list of kudos for a given parent entity id and with a set of entity types
      Parameters:
      activityId - ExoSocialActivity id
      Returns:
      List of Kudos
    • getDefaultKudosPeriodType

      public KudosPeriodType getDefaultKudosPeriodType()
    • getCurrentKudosPeriod

      public KudosPeriod getCurrentKudosPeriod()
    • getKudosPeriodOfTime

      public KudosPeriod getKudosPeriodOfTime(long dateInSeconds)
    • getKudosPeriodOfTime

      public KudosPeriod getKudosPeriodOfTime(KudosPeriodType periodType, long dateInSeconds)