public class ChoiceDAO extends AbstractSurveyDAO implements IChoiceDAO {
@Override
public Choice loadChoice(int id) {
Choice choice = null;
Connection conn = null;
PreparedStatement stat = null;
ResultSet res = null;
try {
conn = this.getConnection();
stat = conn.prepareStatement(GET_CHOICE_BY_ID);
stat.setInt(1, id);
res = stat.executeQuery();
if (res.next()) {
choice = this.buildChoiceRecordFromResultSet(res, 1);
// process get extra info
int surveyId = res.getInt(6);
boolean questionnaire = res.getInt(7) == 1 ? true:false;
ApsProperties surveyTitle = new ApsProperties();
surveyTitle.loadFromXml(res.getString(8));
ApsProperties questionTitle = new ApsProperties();
questionTitle.loadFromXml(res.getString(9));
choice.setExtraInfo(surveyId, questionnaire, surveyTitle, questionTitle);
}
} catch (Throwable t) {
processDaoException(t, "Error while loading the choice of ID "+id, "loadChoice");
} finally {
closeDaoResources(res, stat, conn);