Class QuestionDAO


  • public class QuestionDAO
    extends Object
    This class is made to access database only (table SB_Question_Question)
    Author:
    neysseri
    • Method Detail

      • getQuestionsByFatherPK

        public static Collection<Question> getQuestionsByFatherPK​(Connection con,
                                                                  QuestionPK questionPK,
                                                                  String fatherId)
                                                           throws SQLException
        Return the questions linked to a given father
        Parameters:
        con - the Connection to dataBase
        questionPK - the question id
        fatherId - the father id
        Returns:
        a Collection of Question
        Throws:
        SQLException
      • createQuestion

        public static QuestionPK createQuestion​(Connection con,
                                                Question question)
                                         throws SQLException
        Create a new question
        Parameters:
        con - the Connection to dataBase
        question - the Question to create
        Returns:
        the QuestionPK of the new question
        Throws:
        SQLException
      • updateQuestion

        public static void updateQuestion​(Connection con,
                                          Question question)
                                   throws SQLException
        Update a question
        Parameters:
        con - the Connection to dataBase
        question - the Question to update
        Throws:
        SQLException
      • deleteQuestion

        public static void deleteQuestion​(Connection con,
                                          QuestionPK questionPK)
                                   throws SQLException
        Delete a question
        Parameters:
        con - the Connection to dataBase
        questionPK - the question id
        Throws:
        SQLException
      • deleteQuestionsByFatherPK

        public static void deleteQuestionsByFatherPK​(Connection con,
                                                     QuestionPK questionPK,
                                                     String fatherId)
                                              throws SQLException
        Delete all questions linked to a given father
        Parameters:
        con - the Connection to dataBase
        questionPK - to know the context
        fatherId - the father id
        Throws:
        SQLException
      • deleteAllQuestionsByInstanceId

        public static void deleteAllQuestionsByInstanceId​(Connection con,
                                                          String instanceId)
                                                   throws SQLException
        Deletes all the questions relative to the specified component instance.
        Parameters:
        con - the connection to the database.
        instanceId - the unique identifier of the component instance.
        Throws:
        SQLException - if an error occurs while deleting the questions.