Class RuleServiceImpl
java.lang.Object
io.meeds.gamification.service.impl.RuleServiceImpl
- All Implemented Interfaces:
RuleService
-
Constructor Summary
ConstructorsConstructorDescriptionRuleServiceImpl(ProgramService programService, 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 Summary
Modifier and TypeMethodDescriptionintcountActiveRules(long programId) Returns the count of active rules of a given program identified by its id.intcountRules(RuleFilter ruleFilter) intcountRules(RuleFilter ruleFilter, String username) createRule(RuleDTO rule) Add Rule to DBcreateRule(RuleDTO rule, String username) Add Rule to DBdeleteRuleById(long ruleId) Deletes an existing ruledeleteRuleById(long ruleId, String username) Deletes an existing rulefindRuleById(long id) Get RuleEntity by idfindRuleById(long ruleId, String username) findRuleByTitle(String ruleTitle) Find a RuleEntity by titlegetPrerequisiteRules(long ruleId) Retrieve prerequisite rules to achieve in order to be gamified for a given rule by an earnergetRules(RuleFilter ruleFilter, int offset, int limit) Get Rules by filter using offset and limit.getRules(RuleFilter ruleFilter, String username, int offset, int limit) Get Rules accessible for a given user by filter using offset and limit.updateRule(RuleDTO ruleDTO) Update Rule to DBupdateRule(RuleDTO rule, String username) Update Rule to DB
-
Constructor Details
-
RuleServiceImpl
public RuleServiceImpl(ProgramService programService, 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
Description copied from interface:RuleServiceGet RuleEntity by id- Specified by:
findRuleByIdin interfaceRuleService- 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:
findRuleByIdin interfaceRuleService- Parameters:
ruleId- rule technical identifierusername- user accessing rule- Returns:
RuleDTO- Throws:
IllegalAccessException- when user doesn't have enough privileges to access ruleorg.exoplatform.commons.exception.ObjectNotFoundException- when rule with id isn't enabled or isn't found
-
findRuleByTitle
Description copied from interface:RuleServiceFind a RuleEntity by title- Specified by:
findRuleByTitlein interfaceRuleService- Parameters:
ruleTitle- : rule's title param- Returns:
- an instance of RuleDTO
- Throws:
IllegalArgumentException
-
getRules
Description copied from interface:RuleServiceGet Rules accessible for a given user by filter using offset and limit.- Specified by:
getRulesin interfaceRuleService- Parameters:
ruleFilter-RuleFilterused to filter rulesusername- User name accessing Programsoffset- Offset of resultlimit- Limit of result- Returns:
ListofRuleDTO
-
getRules
Description copied from interface:RuleServiceGet Rules by filter using offset and limit.- Specified by:
getRulesin interfaceRuleService- Parameters:
ruleFilter-RuleFilterused to filter rulesoffset- Offset of resultlimit- Limit of result- Returns:
ListofRuleDTO
-
countRules
- Specified by:
countRulesin interfaceRuleService- Parameters:
ruleFilter-RuleFilterused to count associated rulesusername- User name accessing Programs- Returns:
- count rules by filter accessible to a given user
-
countRules
- Specified by:
countRulesin interfaceRuleService- Parameters:
ruleFilter-RuleFilterused to count associated rules- Returns:
- count rules by filter
-
countActiveRules
public int countActiveRules(long programId) Description copied from interface:RuleServiceReturns 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:
countActiveRulesin interfaceRuleService- Parameters:
programId- Program technical identifier- Returns:
Integergot active rules count
-
deleteRuleById
public RuleDTO deleteRuleById(long ruleId, String username) throws IllegalAccessException, org.exoplatform.commons.exception.ObjectNotFoundException Description copied from interface:RuleServiceDeletes an existing rule- Specified by:
deleteRuleByIdin interfaceRuleService- Parameters:
ruleId- Rule technical identifier to deleteusername- User name of user attempting to delete a rule- Returns:
- deleted
RuleDTO - Throws:
IllegalAccessException- when user is not authorized to delete the ruleorg.exoplatform.commons.exception.ObjectNotFoundException- when the rule identified by its technical identifier is not found
-
deleteRuleById
Description copied from interface:RuleServiceDeletes an existing rule- Specified by:
deleteRuleByIdin interfaceRuleService- Parameters:
ruleId- Rule technical identifier to delete- Returns:
- deleted
RuleDTO
-
createRule
public RuleDTO createRule(RuleDTO rule, String username) throws IllegalAccessException, org.exoplatform.commons.ObjectAlreadyExistsException, org.exoplatform.commons.exception.ObjectNotFoundException Description copied from interface:RuleServiceAdd Rule to DB- Specified by:
createRulein interfaceRuleService- Parameters:
rule-RuleDTOto createusername- User name of user attempting to create a rule- Returns:
- created
RuleDTO - Throws:
IllegalAccessException- when user is not authorized to create a ruleorg.exoplatform.commons.ObjectAlreadyExistsException- when rule already existsorg.exoplatform.commons.exception.ObjectNotFoundException- when program doesn't exists
-
createRule
Description copied from interface:RuleServiceAdd Rule to DB- Specified by:
createRulein interfaceRuleService- Parameters:
rule-RuleDTOto create- Returns:
- created
RuleDTO
-
updateRule
public RuleDTO updateRule(RuleDTO rule, String username) throws org.exoplatform.commons.exception.ObjectNotFoundException, IllegalAccessException Description copied from interface:RuleServiceUpdate Rule to DB- Specified by:
updateRulein interfaceRuleService- Parameters:
rule-RuleDTOto updateusername- User name of user attempting to update a rule- Returns:
- updated
RuleDTO - Throws:
org.exoplatform.commons.exception.ObjectNotFoundException- when rule doesn't existsIllegalAccessException- 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:RuleServiceUpdate Rule to DB- Specified by:
updateRulein interfaceRuleService- Parameters:
ruleDTO-RuleDTOto update- Returns:
- updated
RuleDTO - Throws:
org.exoplatform.commons.exception.ObjectNotFoundException- when rule doesn't exists
-
getPrerequisiteRules
Description copied from interface:RuleServiceRetrieve prerequisite rules to achieve in order to be gamified for a given rule by an earner- Specified by:
getPrerequisiteRulesin interfaceRuleService- Parameters:
ruleId-RuleDTOidentifier- Returns:
ListofRuleDTO
-