Class AnswerDAO
- java.lang.Object
-
- org.silverpeas.core.questioncontainer.answer.dao.AnswerDAO
-
public class AnswerDAO extends Object
This class is made to access database only (table SB_Question_Answer)- Author:
- neysseri
-
-
Field Summary
Fields Modifier and Type Field Description static String
ANSWERCOLUMNNAMES
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static void
addAnswersToAQuestion(Connection con, Collection<Answer> answers, ResourceReference questionPK)
Add some answers to a questionstatic void
addAnswerToAQuestion(Connection con, Answer answer, ResourceReference questionPK)
Add an answer to a questionstatic void
deleteAnswersToAllQuestions(Connection con, String instanceId)
Deletes all the answers of all the questions relative to the specified component instance.static void
deleteAnswersToAQuestion(Connection con, ResourceReference questionPK)
Delete all answers to a given questionstatic void
deleteAnswerToAQuestion(Connection con, ResourceReference questionPK, String answerId)
Delete an answer to a questionstatic Collection<Answer>
getAnswersByQuestionPK(Connection con, ResourceReference questionPK)
Get answers which composed the questionstatic void
recordThisAnswerAsVote(Connection con, ResourceReference questionPK, AnswerPK answerPK)
Record that the answer (answerPK) has been chosen to the question (questionPK)static void
updateAnswerToAQuestion(Connection con, ResourceReference questionPK, Answer answer)
Update an answer to a question
-
-
-
Field Detail
-
ANSWERCOLUMNNAMES
public static final String ANSWERCOLUMNNAMES
- See Also:
- Constant Field Values
-
-
Method Detail
-
getAnswersByQuestionPK
public static Collection<Answer> getAnswersByQuestionPK(Connection con, ResourceReference questionPK) throws SQLException
Get answers which composed the question- Parameters:
con
- the ConnectionquestionPK
- the QuestionPK (question id)- Returns:
- a Collection of Answer
- Throws:
SQLException
-
recordThisAnswerAsVote
public static void recordThisAnswerAsVote(Connection con, ResourceReference questionPK, AnswerPK answerPK) throws SQLException
Record that the answer (answerPK) has been chosen to the question (questionPK)- Parameters:
con
- the ConnectionquestionPK
- the QuestionPK (question id)answerPK
- the AnswerPK (answer id)- Throws:
SQLException
-
addAnswersToAQuestion
public static void addAnswersToAQuestion(Connection con, Collection<Answer> answers, ResourceReference questionPK) throws SQLException
Add some answers to a question- Parameters:
con
- the Connectionanswers
- a Collection of AnswerquestionPK
- the QuestionPK (question id)- Throws:
SQLException
-
addAnswerToAQuestion
public static void addAnswerToAQuestion(Connection con, Answer answer, ResourceReference questionPK) throws SQLException
Add an answer to a question- Parameters:
con
- the Connectionanswer
- the AnswerquestionPK
- the QuestionPK (question id)- Throws:
SQLException
-
deleteAnswersToAQuestion
public static void deleteAnswersToAQuestion(Connection con, ResourceReference questionPK) throws SQLException
Delete all answers to a given question- Parameters:
con
- the ConnectionquestionPK
- the QuestionPK (question id)- Throws:
SQLException
-
deleteAnswerToAQuestion
public static void deleteAnswerToAQuestion(Connection con, ResourceReference questionPK, String answerId) throws SQLException
Delete an answer to a question- Parameters:
con
- the ConnectionquestionPK
- the QuestionPK (question id)answerId
- the answer id- Throws:
SQLException
-
deleteAnswersToAllQuestions
public static void deleteAnswersToAllQuestions(Connection con, String instanceId) throws SQLException
Deletes all the answers of 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 answers.
-
updateAnswerToAQuestion
public static void updateAnswerToAQuestion(Connection con, ResourceReference questionPK, Answer answer) throws SQLException
Update an answer to a question- Parameters:
con
- the ConnectionquestionPK
- the QuestionPK (question id)answer
- the Answer- Throws:
SQLException
-
-