Interface CandidateAdminSession
- All Superinterfaces:
AutoCloseable, Closeable, OsidSession, OsidSession
- All Known Subinterfaces:
CandidateBatchAdminSession
This session creates, updates, and deletes Candidates . The
data for create and update is provided by the consumer via the form
object. OsidForms are requested for each create or update and may
not be reused.
Create and update operations differ in their usage. To create a
Candidate , a CandidateForm is requested using
getCandidateFormForCreate() specifying the Race and desired
record Types or none if no record Types are needed. The
returned CandidateForm will indicate that it is to be used with a
create operation and can be used to examine metdata or validate data prior
to creation. Once the CandidateForm is submiited to a create
operation, it cannot be reused with another create operation unless the
first operation was unsuccessful. Each CandidateForm corresponds
to an attempted transaction.
For updates, CandidateForms are requested to the
Candidate Id that is to be updated using
getCandidateFormForUpdate() . Similarly, the CandidateForm has
metadata about the data that can be updated and it can perform validation
before submitting the update. The CandidateForm can only be used
once for a successful update and cannot be reused.
The delete operations delete Candidates . To unmap a
Candidate from the current Polls , the
CandidatePollsAssignmentSession should be used. These delete operations
attempt to remove the Candidate itself thus removing it from all
known Polls catalogs.
This session includes an Id aliasing mechanism to assign an
external Id to an internally assigned Id.
-
Method Summary
Modifier and TypeMethodDescriptionvoidaliasCandidate(Id candidateId, Id aliasId) Adds anIdto aCandidatefor the purpose of creating compatibility.booleanTests if this user can createCandidates.booleancanCreateCandidateWithRecordTypes(Type[] candidateRecordTypes) Tests if this user can create a singleCandidateusing the desired record types.booleanTests if this user can deleteCandidates.booleanTests if this user can manageIdaliases forCandidates.booleanTests if this user can updateCandidates.createCandidate(CandidateForm candidateForm) Creates a newCandidate.voiddeleteCandidate(Id candidateId) Deletes aCandidate.getCandidateFormForCreate(Id resourceId, Id raceId, Type[] candidateRecordTypes) Gets the candidate form for creating new candidates.getCandidateFormForUpdate(Id candidateId) Gets the candidate form for updating an existing candidate.getPolls()Gets thePollsassociated with this session.Gets thePollsIdassociated with this session.voidupdateCandidate(CandidateForm candidateForm) Updates an existing candidate.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
Pollsassociated with this session - Throws:
OperationFailedException- unable to complete requestPermissionDeniedException- authorization failure- Compliance:
mandatory- This method must be implemented.
-
canCreateCandidates
boolean canCreateCandidates()Tests if this user can createCandidates. A return of true does not guarantee successful authorization. A return of false indicates that it is known creating aCandidatewill result in aPERMISSION_DENIED. This is intended as a hint to an application that may opt not to offer create operations to an unauthorized user.- Returns:
falseifCandidatecreation is not authorized,trueotherwise- Compliance:
mandatory- This method must be implemented.
-
canCreateCandidateWithRecordTypes
Tests if this user can create a singleCandidateusing the desired record types. WhileVotingManager.getCandidateRecordTypes()can be used to examine which records are supported, this method tests which record(s) are required for creating a specificCandidate. Providing an empty array tests if aCandidatecan be created with no records.- Parameters:
candidateRecordTypes- array of candidate record types- Returns:
trueifCandidatecreation using the specifiedTypesis supported,falseotherwise- Throws:
NullArgumentException-candidateRecordTypesisnull- Compliance:
mandatory- This method must be implemented.
-
getCandidateFormForCreate
CandidateForm getCandidateFormForCreate(Id resourceId, Id raceId, Type[] candidateRecordTypes) throws NotFoundException, OperationFailedException, PermissionDeniedException Gets the candidate form for creating new candidates. A new form should be requested for each create transaction.- Parameters:
resourceId- the resource IdraceId- the race IdcandidateRecordTypes- array of candidate record types- Returns:
- the candidate form
- Throws:
NotFoundException-resourceIdorraceIdis not foundNullArgumentException-resourceId, raceIdorcandidateRecordTypesisnullOperationFailedException- unable to complete requestPermissionDeniedException- authorization failureUnsupportedException- unable to get form with requested record types- Compliance:
mandatory- This method must be implemented.
-
createCandidate
Candidate createCandidate(CandidateForm candidateForm) throws OperationFailedException, PermissionDeniedException Creates a newCandidate.- Parameters:
candidateForm- the form for thisCandidate- Returns:
- the new
Candidate - Throws:
IllegalStateException-candidateFormalready used in a create transactionInvalidArgumentException- one or more of the form elements is invalidNullArgumentException-candidateFormisnullOperationFailedException- unable to complete requestPermissionDeniedException- authorization failureUnsupportedException-candidateFormdid not originate fromgetCandidateFormForCreate()- Compliance:
mandatory- This method must be implemented.
-
canUpdateCandidates
boolean canUpdateCandidates()Tests if this user can updateCandidates. A return of true does not guarantee successful authorization. A return of false indicates that it is known updating aCandidatewill result in aPERMISSION_DENIED. This is intended as a hint to an application that may opt not to offer update operations to an unauthorized user.- Returns:
falseifCandidatemodification is not authorized,trueotherwise- Compliance:
mandatory- This method must be implemented.
-
getCandidateFormForUpdate
CandidateForm getCandidateFormForUpdate(Id candidateId) throws NotFoundException, OperationFailedException, PermissionDeniedException Gets the candidate form for updating an existing candidate. A new candidate form should be requested for each update transaction.- Parameters:
candidateId- theIdof theCandidate- Returns:
- the candidate form
- Throws:
NotFoundException-candidateIdis not foundNullArgumentException-candidateIdisnullOperationFailedException- unable to complete requestPermissionDeniedException- authorization failure- Compliance:
mandatory- This method must be implemented.
-
updateCandidate
void updateCandidate(CandidateForm candidateForm) throws OperationFailedException, PermissionDeniedException Updates an existing candidate.- Parameters:
candidateForm- the form containing the elements to be updated- Throws:
IllegalStateException-candidateFormalready used in an update transactionInvalidArgumentException- the form contains an invalid valueNullArgumentException-candidateFormisnullOperationFailedException- unable to complete requestPermissionDeniedException- authorization failureUnsupportedException-candidateFormdid not originate fromgetCandidateFormForUpdate()- Compliance:
mandatory- This method must be implemented.
-
canDeleteCandidates
boolean canDeleteCandidates()Tests if this user can deleteCandidates. A return of true does not guarantee successful authorization. A return of false indicates that it is known deleting aCandidatewill result in aPERMISSION_DENIED. This is intended as a hint to an application that may opt not to offer delete operations to an unauthorized user.- Returns:
falseifCandidatedeletion is not authorized,trueotherwise- Compliance:
mandatory- This method must be implemented.
-
deleteCandidate
void deleteCandidate(Id candidateId) throws NotFoundException, OperationFailedException, PermissionDeniedException Deletes aCandidate.- Parameters:
candidateId- theIdof theCandidateto remove- Throws:
NotFoundException-candidateIdnot foundNullArgumentException-candidateIdisnullOperationFailedException- unable to complete requestPermissionDeniedException- authorization failure- Compliance:
mandatory- This method must be implemented.
-
canManageCandidateAliases
boolean canManageCandidateAliases()Tests if this user can manageIdaliases forCandidates. A return of true does not guarantee successful authorization. A return of false indicates that it is known changing an alias will result in aPERMISSION_DENIED. This is intended as a hint to an application that may opt not to offer alias operations to an unauthorized user.- Returns:
falseifCandidatealiasing is not authorized,trueotherwise- Compliance:
mandatory- This method must be implemented.
-
aliasCandidate
void aliasCandidate(Id candidateId, Id aliasId) throws AlreadyExistsException, NotFoundException, OperationFailedException, PermissionDeniedException Adds anIdto aCandidatefor the purpose of creating compatibility. The primaryIdof theCandidateis determined by the provider. The newIdperforms as an alias to the primaryId. If the alias is a pointer to another candidate it is reassigned to the given candidateId.- Parameters:
candidateId- theIdof aCandidatealiasId- the aliasId- Throws:
AlreadyExistsException-aliasIdis already assignedNotFoundException-candidateIdnot foundNullArgumentException-aliasIdorcandidateIdisnullOperationFailedException- unable to complete requestPermissionDeniedException- authorization failure- Compliance:
mandatory- This method must be implemented.
-