Package com.atlassian.jira.bc.issue.vote
Class DefaultVoteService
java.lang.Object
com.atlassian.jira.bc.issue.vote.DefaultVoteService
- All Implemented Interfaces:
VoteService
-
Nested Class Summary
Nested classes/interfaces inherited from interface com.atlassian.jira.bc.issue.vote.VoteService
VoteService.VoteValidationResult -
Constructor Summary
ConstructorsConstructorDescriptionDefaultVoteService(VoteManager voteManager, I18nHelper.BeanFactory beanFactory, ApplicationProperties applicationProperties, PermissionManager permissionManager, I18nHelper.BeanFactory i18nFactory) -
Method Summary
Modifier and TypeMethodDescriptionintaddVote(ApplicationUser remoteUser, VoteService.VoteValidationResult validationResult) Adds a new vote using the specified validation result.getVoterHistory(Issue issue, ApplicationUser remoteUser) Get the list of vote history for an issue.booleanhasVoted(Issue issue, ApplicationUser user) Find if the specified user has voted on an issuebooleanRetrieves the 'jira.option.voting' propertyintremoveVote(ApplicationUser remoteUser, VoteService.VoteValidationResult validationResult) Removes a new vote using the specified validation result.validateAddVote(ApplicationUser remoteUser, ApplicationUser voter, Issue issue) Validates if the user currently logged in may add a vote by the user supplied for the issue provided.validateRemoveVote(ApplicationUser remoteUser, ApplicationUser voter, Issue issue) Validates if the user currently logged in may remove a vote for the user supplied for the issue provided.viewVoters(Issue issue, ApplicationUser remoteUser) Get the list of all users who have voted on an issue.
-
Constructor Details
-
DefaultVoteService
public DefaultVoteService(VoteManager voteManager, I18nHelper.BeanFactory beanFactory, ApplicationProperties applicationProperties, PermissionManager permissionManager, I18nHelper.BeanFactory i18nFactory)
-
-
Method Details
-
validateAddVote
public VoteService.VoteValidationResult validateAddVote(ApplicationUser remoteUser, ApplicationUser voter, Issue issue) Description copied from interface:VoteServiceValidates if the user currently logged in may add a vote by the user supplied for the issue provided. The remoteUser and user arguments may be the same if the current user is voting him/herself. TheVoteService.VoteValidationResultproduced by this method should be used in conjunction with theVoteService.addVote(ApplicationUser, VoteValidationResult)method. The following conditions will fail validation:- remoteUser is null (i.e. not logged in)
- the user is the reporter of the issue
- the issue has already been resolved
- voting has been disabled system wide
- the user doesn't have permission to browse the issue
- Specified by:
validateAddVotein interfaceVoteService- Parameters:
remoteUser- The currently logged in uservoter- The user for whom a vote is being addedissue- The issue being voted on- Returns:
- A validation result containing all errors, as well as the user and issue being voted on
-
addVote
Description copied from interface:VoteServiceAdds a new vote using the specified validation result. The vote will not be added if the user already voted for the issue.- Specified by:
addVotein interfaceVoteService- Parameters:
remoteUser- The currently logged in uservalidationResult- Validation result for adding a new vote- Returns:
- The updated number of votes for the issue being voted for
-
validateRemoveVote
public VoteService.VoteValidationResult validateRemoveVote(ApplicationUser remoteUser, ApplicationUser voter, Issue issue) Description copied from interface:VoteServiceValidates if the user currently logged in may remove a vote for the user supplied for the issue provided. The remoteUser and user arguments may be the same if the current user is voting him/herself. TheVoteService.VoteValidationResultproduced by this method should be used in conjunction with theVoteService.removeVote(ApplicationUser, VoteValidationResult)method. The following conditions will fail validation:- remoteUser is null (i.e. not logged in)
- the user is the reporter of the issue
- the issue has already been resolved
- voting has been disabled system wide
- the user doesn't have permission to browse the issue
- Specified by:
validateRemoveVotein interfaceVoteService- Parameters:
remoteUser- The currently logged in uservoter- The user for whom a vote is being removedissue- The issue being voted on- Returns:
- A validation result containing all errors, as well as the user and issue being voted on
-
removeVote
public int removeVote(ApplicationUser remoteUser, VoteService.VoteValidationResult validationResult) Description copied from interface:VoteServiceRemoves a new vote using the specified validation result. The vote will not be removed if the user didn't voted for the issue.- Specified by:
removeVotein interfaceVoteService- Parameters:
remoteUser- The currently logged in uservalidationResult- Validation result for removing a new vote- Returns:
- The updated number of votes for the issue being voted for
-
viewVoters
public ServiceOutcome<Collection<ApplicationUser>> viewVoters(Issue issue, ApplicationUser remoteUser) Description copied from interface:VoteServiceGet the list of all users who have voted on an issue.- Specified by:
viewVotersin interfaceVoteService- Parameters:
issue- the issue to viewremoteUser- the user who wants to know- Returns:
- a service outcome. if valid you can obtain the users that have voted on the.
-
getVoterHistory
public ServiceOutcome<List<VoteHistoryEntry>> getVoterHistory(Issue issue, ApplicationUser remoteUser) Description copied from interface:VoteServiceGet the list of vote history for an issue. The history will be in time sequence.- Specified by:
getVoterHistoryin interfaceVoteService- Parameters:
issue- the issue to viewremoteUser- the user who wants to know- Returns:
- a service outcome. if valid you can obtain the users that have voted on the.
-
isVotingEnabled
public boolean isVotingEnabled()Description copied from interface:VoteServiceRetrieves the 'jira.option.voting' property- Specified by:
isVotingEnabledin interfaceVoteService- Returns:
- True if voting is enabled
-
hasVoted
Description copied from interface:VoteServiceFind if the specified user has voted on an issue- Specified by:
hasVotedin interfaceVoteService- Parameters:
issue- the issue to checkuser- the user to check- Returns:
- true if the user has voted on the issue
-