Package org.sakaiproject.poll.logic
Interface PollListManager
-
- All Superinterfaces:
org.sakaiproject.entity.api.EntityProducer
public interface PollListManager extends org.sakaiproject.entity.api.EntityProducerThis is the interface for the Manager for our poll tool, it handles the data access functionality of the tool, we currently have 2 implementations (memory and hibernate)- Author:
- DH
-
-
Field Summary
Fields Modifier and Type Field Description static StringPERMISSION_ADDstatic StringPERMISSION_DELETE_ANYstatic StringPERMISSION_DELETE_OWNstatic StringPERMISSION_EDIT_ANYstatic StringPERMISSION_EDIT_OWNstatic StringPERMISSION_VOTEstatic StringREF_POLL_TYPE
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description voiddeleteOption(Option option)Delete an option from the database.voiddeleteOption(Option option, boolean soft)Delete a poll option, either "hard" or "soft".booleandeletePoll(Poll t)Delete a pollList<Poll>findAllPolls(String siteId)Gets all the task objects for the siteList<Poll>findAllPollsForUserAndSitesAndPermission(String userId, String[] siteIds, String permissionConstant)Get all the polls for a user in a set of sites (can be one) given the permission, will return only polls that can be voted on if the permission isPERMISSION_VOTEOptiongetOptionById(Long optionId)Get a specific option by its idList<Option>getOptionsForPoll(Long pollId)Get all options for a specific pollList<Option>getOptionsForPoll(Poll poll)Get all options for a specific pollPollgetPoll(String ref)get a poll by its Entity ReferencePollgetPollById(Long pollId)Retrieve a specific pollPollgetPollById(Long pollId, boolean includeOptions)Retrieve a specific pollPollgetPollWithVotes(Long pollId)Get a specific poll with all its votesList<Option>getVisibleOptionsForPoll(Long pollId)Get options for the given poll that are not flagged as deleted.booleanisAllowedViewResults(Poll poll, String userId)Can the this user view the results for this poll?booleanisPollPublic(Poll poll)Is this poll public?booleansaveOption(Option t)Save an individual optionbooleansavePoll(Poll t)Save a pollbooleanuserCanDeletePoll(Poll poll)Is user allowed to delete the votes on a poll?
-
-
-
Field Detail
-
PERMISSION_VOTE
static final String PERMISSION_VOTE
- See Also:
- Constant Field Values
-
PERMISSION_ADD
static final String PERMISSION_ADD
- See Also:
- Constant Field Values
-
PERMISSION_DELETE_OWN
static final String PERMISSION_DELETE_OWN
- See Also:
- Constant Field Values
-
PERMISSION_DELETE_ANY
static final String PERMISSION_DELETE_ANY
- See Also:
- Constant Field Values
-
PERMISSION_EDIT_ANY
static final String PERMISSION_EDIT_ANY
- See Also:
- Constant Field Values
-
PERMISSION_EDIT_OWN
static final String PERMISSION_EDIT_OWN
- See Also:
- Constant Field Values
-
REF_POLL_TYPE
static final String REF_POLL_TYPE
- See Also:
- Constant Field Values
-
-
Method Detail
-
deleteOption
void deleteOption(Option option)
Delete an option from the database.- Parameters:
option- - The option to delete
-
deleteOption
void deleteOption(Option option, boolean soft)
Delete a poll option, either "hard" or "soft".- Parameters:
option- - The option to deletesoft- - true if you want to "soft" delete (flag the 'deleted' field) or false to "hard" delete (remove from database)
-
deletePoll
boolean deletePoll(Poll t) throws SecurityException, IllegalArgumentException
Delete a poll- Parameters:
t- - the poll object to remove- Returns:
- - true for success, false if failure
- Throws:
SecurityExceptionIllegalArgumentException
-
findAllPolls
List<Poll> findAllPolls(String siteId)
Gets all the task objects for the site- Parameters:
siteId- - the siteId of the site- Returns:
- - a collection of task objects (empty collection if none found)
-
findAllPollsForUserAndSitesAndPermission
List<Poll> findAllPollsForUserAndSitesAndPermission(String userId, String[] siteIds, String permissionConstant)
Get all the polls for a user in a set of sites (can be one) given the permission, will return only polls that can be voted on if the permission isPERMISSION_VOTE- Parameters:
userId- a sakai internal user id (not eid)siteIds- an array of site ids (can be null or empty to get the polls for all without security check)permissionConstant- either thePERMISSION_VOTE(for all polls a user can vote on) orPERMISSION_ADDfor all the polls the user can control- Returns:
- the list of all polls this user can access
-
getOptionsForPoll
List<Option> getOptionsForPoll(Long pollId)
Get all options for a specific poll- Parameters:
pollId- the id for a poll- Returns:
- all options OR empty if there are no options for this poll
- Throws:
IllegalArgumentException- if the pollId is invalid
-
getVisibleOptionsForPoll
List<Option> getVisibleOptionsForPoll(Long pollId)
Get options for the given poll that are not flagged as deleted.- Parameters:
pollId- the id of the poll- Returns:
- the options for the given poll that are not deleted OR empt if there are no "visible" options for this poll
- Throws:
IllegalArgumentException- if the pollId is invalid
-
getOptionsForPoll
List<Option> getOptionsForPoll(Poll poll)
Get all options for a specific poll- Parameters:
the- poll- Returns:
- all options OR empty if there are no options for this poll
- Throws:
IllegalArgumentException- if the pollId is invalid
-
getPollById
Poll getPollById(Long pollId) throws SecurityException
Retrieve a specific poll- Parameters:
pollId-- Returns:
- a single poll object
- Throws:
SecurityException
-
getPollById
Poll getPollById(Long pollId, boolean includeOptions) throws SecurityException
Retrieve a specific poll- Parameters:
pollId-includeOptions- if true then options included, else no options (poll only)- Returns:
- a single poll object
- Throws:
SecurityException
-
getPollWithVotes
Poll getPollWithVotes(Long pollId)
Get a specific poll with all its votes- Parameters:
pollId-- Returns:
- a poll object
-
isAllowedViewResults
boolean isAllowedViewResults(Poll poll, String userId)
Can the this user view the results for this poll?- Parameters:
poll-userId-- Returns:
- true if the user can view this poll
-
saveOption
boolean saveOption(Option t)
Save an individual option- Parameters:
t-- Returns:
-
savePoll
boolean savePoll(Poll t) throws SecurityException, IllegalArgumentException
Save a poll- Parameters:
t- - the poll object to save- Returns:
- - true for success, false if failure
- Throws:
SecurityExceptionIllegalArgumentException
-
isPollPublic
boolean isPollPublic(Poll poll)
Is this poll public?- Parameters:
poll-- Returns:
-
userCanDeletePoll
boolean userCanDeletePoll(Poll poll)
Is user allowed to delete the votes on a poll?- Parameters:
poll- - the poll object- Returns:
- true or false
-
-