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
    • 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)
      • 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,
                         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:
      • 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