Class QuestionService


  • @Service
    public class QuestionService
    extends Object
    This class implements the high level persistence and business logic for the Question entity.
    • Constructor Detail

      • QuestionService

        @Autowired
        public QuestionService​(QuestionRepository questionRepository)
        Constructor that instantiates a new Question service object.
        Parameters:
        questionRepository - Question repository object.
    • Method Detail

      • get

        public Optional<Question> get​(UUID externalKey,
                                      User user)
        Returns a Question object identified by the external key for the current user.
        Parameters:
        externalKey - External key in the form of a universally unique identifier.
        user - A User object.
        Returns:
        An optional Question object.
      • delete

        public void delete​(UUID externalKey,
                           User user)
        Deletes a Question object identified by external key for the current user.
        Parameters:
        externalKey - External key in the form of a universally unique identifier.
        user - A User object.
      • getQuestions

        public List<Question> getQuestions()
        Returns a list of all Question in the database.
        Returns:
        A list of all Question objects.
      • get

        public Optional<Question> get​(UUID externalKey)
        Gets the current Question object records from the database identified by external key.
        Parameters:
        externalKey - Id in the form of a universally unique identifier.
        Returns:
        An optional Question object.
      • createQuestion

        public Question createQuestion​(Question question,
                                       User user)
        Creates a new Question object in the database for the current user.
        Parameters:
        question - A Question object.
        user - A User object.
        Returns:
        A Question object.
      • saveQuestion

        public Question saveQuestion​(Question question,
                                     User user)
        Saves a Question object to the database for the current user.
        Parameters:
        question - A Question object.
        user - A User object.
        Returns:
        A Question object.
      • getRandomQuestion

        public Question getRandomQuestion()
        Returns a random Question object from the database.
        Returns:
        A random Question object.
      • updateQuestion

        public Optional<Question> updateQuestion​(UUID externalKey,
                                                 Question question,
                                                 User user)
        Updates a Question object to the database for the current user.
        Parameters:
        externalKey - External key in the form of a universally unique identifier.
        question - A Question object.
        user - A User object.
        Returns:
        A Question object.