Class KudosService

    • 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:
        start in interface org.picocontainer.Startable
      • stop

        public void stop()
        Specified by:
        stop in interface org.picocontainer.Startable
      • 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
        Parameters:
        kudos - Kudos to create
        currentUser - username of current user
        Returns:
        created Kudos
        Throws:
        Exception - when receiver or sender aren't allowed.
      • updateKudosGeneratedActivityId

        public void updateKudosGeneratedActivityId​(long kudosId,
                                                   long activityId)
                                            throws Exception
        Stores generated activity for created Kudos
        Parameters:
        kudosId - Kudos technical identifier
        activityId - ExoSocialActivity technical identifier
        Throws:
        Exception - when an error happens when broadcasting event or saving activityId of Kudos
      • 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
      • 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
      • 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
      • getDefaultKudosPeriodType

        public KudosPeriodType getDefaultKudosPeriodType()
      • getCurrentKudosPeriod

        public KudosPeriod getCurrentKudosPeriod()
      • getKudosPeriodOfTime

        public KudosPeriod getKudosPeriodOfTime​(long dateInSeconds)