Class RuleServiceImpl

java.lang.Object
io.meeds.gamification.service.impl.RuleServiceImpl
All Implemented Interfaces:
RuleService

public class RuleServiceImpl extends Object implements RuleService
  • Constructor Details

    • RuleServiceImpl

      public RuleServiceImpl(ProgramService programService, EventService eventService, RuleStorage ruleStorage, RuleSearchConnector ruleSearchConnector, org.exoplatform.social.core.space.spi.SpaceService spaceService, org.exoplatform.social.core.manager.ActivityManager activityManager, org.exoplatform.social.core.manager.IdentityManager identityManager, org.exoplatform.services.listener.ListenerService listenerService)
  • Method Details

    • findRuleById

      public RuleDTO findRuleById(long id) throws IllegalArgumentException
      Description copied from interface: RuleService
      Get RuleEntity by id
      Specified by:
      findRuleById in interface RuleService
      Parameters:
      id - : rule's id param
      Returns:
      an instance of RuleDTO
      Throws:
      IllegalArgumentException
    • findRuleById

      public RuleDTO findRuleById(long ruleId, String username) throws IllegalAccessException, org.exoplatform.commons.exception.ObjectNotFoundException
      Specified by:
      findRuleById in interface RuleService
      Parameters:
      ruleId - rule technical identifier
      username - user accessing rule
      Returns:
      RuleDTO
      Throws:
      IllegalAccessException - when user doesn't have enough privileges to access rule
      org.exoplatform.commons.exception.ObjectNotFoundException - when rule with id isn't enabled or isn't found
    • findRuleByTitle

      public RuleDTO findRuleByTitle(String ruleTitle) throws IllegalArgumentException
      Description copied from interface: RuleService
      Find a RuleEntity by title
      Specified by:
      findRuleByTitle in interface RuleService
      Parameters:
      ruleTitle - : rule's title param
      Returns:
      an instance of RuleDTO
      Throws:
      IllegalArgumentException
    • getRules

      public List<RuleDTO> getRules(RuleFilter ruleFilter, String username, int offset, int limit)
      Description copied from interface: RuleService
      Get Rules accessible for a given user by filter using offset and limit.
      Specified by:
      getRules in interface RuleService
      Parameters:
      ruleFilter - RuleFilter used to filter rules
      username - User name accessing Programs
      offset - Offset of result
      limit - Limit of result
      Returns:
      List of RuleDTO
    • getRules

      public List<RuleDTO> getRules(RuleFilter ruleFilter, int offset, int limit)
      Description copied from interface: RuleService
      Get Rules by filter using offset and limit.
      Specified by:
      getRules in interface RuleService
      Parameters:
      ruleFilter - RuleFilter used to filter rules
      offset - Offset of result
      limit - Limit of result
      Returns:
      List of RuleDTO
    • countRules

      public int countRules(RuleFilter ruleFilter, String username)
      Specified by:
      countRules in interface RuleService
      Parameters:
      ruleFilter - RuleFilter used to count associated rules
      username - User name accessing Programs
      Returns:
      count rules by filter accessible to a given user
    • countRules

      public int countRules(RuleFilter ruleFilter)
      Specified by:
      countRules in interface RuleService
      Parameters:
      ruleFilter - RuleFilter used to count associated rules
      Returns:
      count rules by filter
    • countActiveRules

      public int countActiveRules(long programId)
      Description copied from interface: RuleService
      Returns the count of active rules of a given program identified by its id. The list of active rules corresponds to enabled rules which started or is upcoming.
      Specified by:
      countActiveRules in interface RuleService
      Parameters:
      programId - Program technical identifier
      Returns:
      Integer got active rules count
    • deleteRuleById

      public RuleDTO deleteRuleById(long ruleId, String username) throws IllegalAccessException, org.exoplatform.commons.exception.ObjectNotFoundException
      Description copied from interface: RuleService
      Deletes an existing rule
      Specified by:
      deleteRuleById in interface RuleService
      Parameters:
      ruleId - Rule technical identifier to delete
      username - User name of user attempting to delete a rule
      Returns:
      deleted RuleDTO
      Throws:
      IllegalAccessException - when user is not authorized to delete the rule
      org.exoplatform.commons.exception.ObjectNotFoundException - when the rule identified by its technical identifier is not found
    • deleteRuleById

      public RuleDTO deleteRuleById(long ruleId)
      Description copied from interface: RuleService
      Deletes an existing rule
      Specified by:
      deleteRuleById in interface RuleService
      Parameters:
      ruleId - Rule technical identifier to delete
      Returns:
      deleted RuleDTO
    • updateRuleStatus

      public void updateRuleStatus(long ruleId, String username) throws IllegalAccessException, org.exoplatform.commons.exception.ObjectNotFoundException
      Description copied from interface: RuleService
      Updates an existing rule status
      Specified by:
      updateRuleStatus in interface RuleService
      Parameters:
      ruleId - Rule technical identifier to delete
      username - User name of user attempting to delete a rule
      Throws:
      IllegalAccessException - when user is not authorized to update the rule status
      org.exoplatform.commons.exception.ObjectNotFoundException - when the rule identified by its technical identifier is not found
    • createRule

      public RuleDTO createRule(RuleDTO rule, String username) throws IllegalAccessException, org.exoplatform.commons.exception.ObjectNotFoundException
      Description copied from interface: RuleService
      Add Rule to DB
      Specified by:
      createRule in interface RuleService
      Parameters:
      rule - RuleDTO to create
      username - User name of user attempting to create a rule
      Returns:
      created RuleDTO
      Throws:
      IllegalAccessException - when user is not authorized to create a rule
      org.exoplatform.commons.exception.ObjectNotFoundException - when program doesn't exists
    • createRule

      public RuleDTO createRule(RuleDTO rule)
      Description copied from interface: RuleService
      Add Rule to DB
      Specified by:
      createRule in interface RuleService
      Parameters:
      rule - RuleDTO to create
      Returns:
      created RuleDTO
    • updateRule

      public RuleDTO updateRule(RuleDTO rule, String username) throws org.exoplatform.commons.exception.ObjectNotFoundException, IllegalAccessException
      Description copied from interface: RuleService
      Update Rule to DB
      Specified by:
      updateRule in interface RuleService
      Parameters:
      rule - RuleDTO to update
      username - User name of user attempting to update a rule
      Returns:
      updated RuleDTO
      Throws:
      org.exoplatform.commons.exception.ObjectNotFoundException - when rule doesn't exists
      IllegalAccessException - when user sin't allowed to update chosen rule
    • updateRule

      public RuleDTO updateRule(RuleDTO ruleDTO) throws org.exoplatform.commons.exception.ObjectNotFoundException
      Description copied from interface: RuleService
      Update Rule to DB
      Specified by:
      updateRule in interface RuleService
      Parameters:
      ruleDTO - RuleDTO to update
      Returns:
      updated RuleDTO
      Throws:
      org.exoplatform.commons.exception.ObjectNotFoundException - when rule doesn't exists
    • getPrerequisiteRules

      public List<RuleDTO> getPrerequisiteRules(long ruleId)
      Description copied from interface: RuleService
      Retrieve prerequisite rules to achieve in order to be gamified for a given rule by an earner
      Specified by:
      getPrerequisiteRules in interface RuleService
      Parameters:
      ruleId - RuleDTO identifier
      Returns:
      List of RuleDTO