org.sakaiproject.poll.logic
Interface PollListManager

All Superinterfaces:
org.sakaiproject.entity.api.EntityProducer

public interface PollListManager
extends org.sakaiproject.entity.api.EntityProducer

This 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
static String PERMISSION_ADD
           
static String PERMISSION_DELETE_ANY
           
static String PERMISSION_DELETE_OWN
           
static String PERMISSION_EDIT_ANY
           
static String PERMISSION_EDIT_OWN
           
static String PERMISSION_VOTE
           
static String REF_POLL_TYPE
           
 
Method Summary
 void deleteOption(Option option)
          Delete an option from the database.
 void deleteOption(Option option, boolean soft)
          Delete a poll option, either "hard" or "soft".
 boolean deletePoll(Poll t)
          Delete a poll
 List<Poll> findAllPolls(String siteId)
          Gets all the task objects for the site
 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 is PERMISSION_VOTE
 Option getOptionById(Long optionId)
          Get a specific option by its id
 List<Option> getOptionsForPoll(Long pollId)
          Get all options for a specific poll
 List<Option> getOptionsForPoll(Poll poll)
          Get all options for a specific poll
 Poll getPoll(String ref)
          get a poll by its Entity Reference
 Poll getPollById(Long pollId)
          Retrieve a specific poll
 Poll getPollById(Long pollId, boolean includeOptions)
          Retrieve a specific poll
 Poll getPollWithVotes(Long pollId)
          Get a specific poll with all its votes
 List<Option> getVisibleOptionsForPoll(Long pollId)
          Get options for the given poll that are not flagged as deleted.
 boolean isAllowedViewResults(Poll poll, String userId)
          Can the this user view the results for this poll?
 boolean isPollPublic(Poll poll)
          Is this poll public?
 boolean saveOption(Option t)
          Save an individual option
 boolean savePoll(Poll t)
          Save a poll
 
Methods inherited from interface org.sakaiproject.entity.api.EntityProducer
archive, getEntity, getEntityAuthzGroups, getEntityDescription, getEntityResourceProperties, getEntityUrl, getHttpAccess, getLabel, merge, parseEntityReference, willArchiveMerge
 

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 delete
soft - - 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:
SecurityException
IllegalArgumentException

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 is PERMISSION_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 the PERMISSION_VOTE (for all polls a user can vote on) or PERMISSION_ADD for all the polls the user can control
Returns:
the list of all polls this user can access

getOptionById

Option getOptionById(Long optionId)
Get a specific option by its id


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

getPoll

Poll getPoll(String ref)
get a poll by its Entity Reference


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:
SecurityException
IllegalArgumentException

isPollPublic

boolean isPollPublic(Poll poll)
Is this poll public?

Parameters:
poll -
Returns:


Copyright © 2003-2013 Sakai Project. All Rights Reserved.