Interface VotingSession
- All Superinterfaces:
AutoCloseable, Closeable, OsidSession, OsidSession
- All Known Subinterfaces:
VotingBatchSession
This session provides methods for voting on a ballot.
-
Method Summary
Modifier and TypeMethodDescriptionbooleanTests if this user can change a vote by deleting a vote and voting again.booleancanVote()Tests if this user can vote.booleancanVoteWithRecordTypes(Id raceId, Type[] voteRecordTypes) Tests if this user can create a singleVoteusing the desired record interface types.voiddeleteMyVote(Id voteId) Deletes a vote in a race.getMyUncastRacesForBallot(Id ballotId) Gets allRaceson this ballot for which a vote has not been cast.getMyVotesForBallot(Id ballotId) Gets all myVotescast on a ballot.getMyVotesForRace(Id raceId) Gets all myVotescast on this ballot for the given race.getPolls()Gets thePollsassociated with this session.Gets thePollsIdassociated with this session.Gets a race.getRacesForBallot(Id ballotId) Gets allRaceson this ballot.getVoteForm(Id raceId, Id candidateId, Type[] voteRecordTypes) Gets a vote form for a race.getVotingAllocation(Id raceId) Gets the voter allocation for a race.booleanisOpen()Tests if this ballot is open.Votes for a candidate in a race.Methods inherited from interface OsidSession
closeMethods inherited from interface OsidSession
getAuthenticatedAgent, getAuthenticatedAgentId, getClockRate, getDate, getEffectiveAgent, getEffectiveAgentId, getFormatType, getLocale, isAuthenticated, startTransaction, supportsTransactionsModifier and TypeMethodDescriptionGets the agent authenticated to this session.Gets theIdof the agent authenticated to this session.Gets the rate of the service clock.getDate()Gets the service date which may be the current date or the effective date in which this session exists.Gets the effective agent in use by this session.Gets theIdof the effective agent in use by this session.Gets theDisplayTextformatTypepreference in effect for this session.Gets the locale indicating the localization preferences in effect for this session.booleanTests if an agent is authenticated to this session.Starts a new transaction for this sesson.booleanTests for the availability of transactions.
-
Method Details
-
getPollsId
Id getPollsId()Gets thePollsIdassociated with this session.- Returns:
- the
Polls Idassociated with this session - Compliance:
mandatory- This method must be implemented.
-
getPolls
Gets thePollsassociated with this session.- Returns:
- the polls
- Throws:
OperationFailedException- unable to complete requestPermissionDeniedException- authorization failure- Compliance:
mandatory- This method must be implemented.
-
isOpen
boolean isOpen()Tests if this ballot is open.- Returns:
trueif the ballot is open,falseotherwise- Compliance:
mandatory- This method must be implemented.
-
canVote
boolean canVote()Tests if this user can vote. A return of true does not guarantee successful authorization. A return of false indicates that it is known all methods in this session will result in aPERMISSION_DENIED. This is intended as a hint to an application that may opt not to offer relationship operations.- Returns:
falseif voting methods are not authorized,trueotherwise- Compliance:
mandatory- This method must be implemented.
-
getRace
Race getRace(Id raceId) throws NotFoundException, OperationFailedException, PermissionDeniedException Gets a race.- Parameters:
raceId-Idof theRace- Returns:
- the race
- Throws:
NotFoundException-raceIdnot foundNullArgumentException-raceIdisnullOperationFailedException- unable to complete requestPermissionDeniedException- authorization failure- Compliance:
mandatory- This method is must be implemented.
-
getRacesForBallot
RaceList getRacesForBallot(Id ballotId) throws NotFoundException, OperationFailedException, PermissionDeniedException Gets allRaceson this ballot.- Parameters:
ballotId-Idof theBallot- Returns:
- the races
- Throws:
NotFoundException-ballotIdnot foundNullArgumentException-ballotIdisnullOperationFailedException- unable to complete requestPermissionDeniedException- authorization failure- Compliance:
mandatory- This method must be implemented.
-
getMyUncastRacesForBallot
RaceList getMyUncastRacesForBallot(Id ballotId) throws NotFoundException, OperationFailedException, PermissionDeniedException Gets allRaceson this ballot for which a vote has not been cast.- Parameters:
ballotId-Idof theBallot- Returns:
- the uncast races
- Throws:
NotFoundException-ballotIdnot foundNullArgumentException-ballotIdisnullOperationFailedException- unable to complete requestPermissionDeniedException- authorization failure- Compliance:
mandatory- This method must be implemented.
-
canVoteWithRecordTypes
Tests if this user can create a singleVoteusing the desired record interface types. WhileVotingManager.getVoteRecordTypes()can be used to examine which records are supported, this method tests which record(s) are required for creating a specificVote. Providing an empty array tests if anVotecan be created with no records.- Parameters:
raceId- a raceIdvoteRecordTypes- array of vote record types- Returns:
trueifVotecreation using the specified recordTypesis supported,falseotherwise- Throws:
NullArgumentException-ballotIdorvoteRecordTypesisnull- Compliance:
mandatory- This method must be implemented.
-
getVotingAllocation
VoterAllocation getVotingAllocation(Id raceId) throws NotFoundException, OperationFailedException, PermissionDeniedException Gets the voter allocation for a race.- Parameters:
raceId-Idof theRace- Returns:
- the allocation
- Throws:
NotFoundException-raceIdnot foundNullArgumentException-raceIdisnullOperationFailedException- unable to complete requestPermissionDeniedException- authorization failure- Compliance:
mandatory- This method is must be implemented.
-
getVoteForm
VoteForm getVoteForm(Id raceId, Id candidateId, Type[] voteRecordTypes) throws NotFoundException, OperationFailedException, PermissionDeniedException Gets a vote form for a race.- Parameters:
raceId-Idof theRacecandidateId- a candidatevoteRecordTypes- array of vote record types- Returns:
- the race
- Throws:
NotFoundException-raceIdorcandidateIdnot foundNullArgumentException-raceId, candidateId, orvoteRecordTypesisnullOperationFailedException- unable to complete requestPermissionDeniedException- authorization failureUnsupportedException- cannot get form with requested record types- Compliance:
mandatory- This method is must be implemented.
-
vote
Votes for a candidate in a race.- Parameters:
voteForm- the vote form- Returns:
- the vote
- Throws:
IllegalStateException-voteFormalready used in a voting transactionInvalidArgumentException- form is invalidNullArgumentException-voteFormisnullOperationFailedException- unable to complete requestPermissionDeniedException- authorization failureUnsupportedException-voteFormdid not originate fromgetVoteForm()- Compliance:
mandatory- This method must be implemented.
-
getMyVotesForBallot
VoteList getMyVotesForBallot(Id ballotId) throws NotFoundException, OperationFailedException, PermissionDeniedException Gets all myVotescast on a ballot.- Parameters:
ballotId- a ballot- Returns:
- the votes
- Throws:
NotFoundException-ballotIdis not foundNullArgumentException-ballotIdisnullOperationFailedException- unable to complete requestPermissionDeniedException- authorization failure- Compliance:
mandatory- This method must be implemented.
-
getMyVotesForRace
VoteList getMyVotesForRace(Id raceId) throws NotFoundException, OperationFailedException, PermissionDeniedException Gets all myVotescast on this ballot for the given race.- Parameters:
raceId- a race- Returns:
- the votes
- Throws:
NotFoundException-raceIdis not foundNullArgumentException-raceIdisnullOperationFailedException- unable to complete requestPermissionDeniedException- authorization failure- Compliance:
mandatory- This method must be implemented.
-
canRevote
boolean canRevote(Id ballotId) throws NotFoundException, OperationFailedException, PermissionDeniedException Tests if this user can change a vote by deleting a vote and voting again.- Parameters:
ballotId- a ballot- Returns:
trueif changing a vote is permitted,falseotherwise- Throws:
NotFoundException-ballotIdis not foundNullArgumentException-ballotIdisnullOperationFailedException- unable to complete requestPermissionDeniedException- authorization failure- Compliance:
mandatory- This method must be implemented.
-
deleteMyVote
void deleteMyVote(Id voteId) throws NotFoundException, OperationFailedException, PermissionDeniedException Deletes a vote in a race.- Parameters:
voteId- a vote- Throws:
IllegalStateException-canRevote()isfalseNotFoundException-voteIdis not foundNullArgumentException-voteIdisnullOperationFailedException- unable to complete requestPermissionDeniedException- authorization failure- Compliance:
mandatory- This method must be implemented.
-