/** * Method declaration * * @param con * @param questionContainerPK * @throws SQLException * @see */ public static void openQuestionContainer(Connection con, QuestionContainerPK questionContainerPK) throws SQLException { SilverTrace.info( "questionContainer", "QuestionContainerDAO.openQuestionContainer()", "root.MSG_GEN_ENTER_METHOD", "questionContainerPK = " + questionContainerPK); String updateStatement = "update " + questionContainerPK.getTableName() + " set qcIsClosed = 0 , instanceId = ?" + " where qcId = ? "; PreparedStatement prepStmt = null; try { prepStmt = con.prepareStatement(updateStatement); prepStmt.setString(1, questionContainerPK.getComponentName()); prepStmt.setInt(2, Integer.parseInt(questionContainerPK.getId())); prepStmt.executeUpdate(); } finally { DBUtil.close(prepStmt); } }
/** * Method declaration * * @param con * @param qcPK * @return * @throws SQLException * @see */ public static Collection<QuestionContainerHeader> getInWaitQuestionContainers( Connection con, QuestionContainerPK qcPK) throws SQLException { SilverTrace.info( "questionContainer", "QuestionContainerDAO.getInWaitQuestionContainers()", "root.MSG_GEN_ENTER_METHOD", "qcPK = " + qcPK); ResultSet rs = null; QuestionContainerHeader header = null; String selectStatement = "select " + QUESTIONCONTAINERCOLUMNNAMES + " from " + qcPK.getTableName() + " where ? < qcBeginDate and instanceId = ?"; PreparedStatement prepStmt = null; try { prepStmt = con.prepareStatement(selectStatement); prepStmt.setString(1, formatter.format(new java.util.Date())); prepStmt.setString(2, qcPK.getComponentName()); rs = prepStmt.executeQuery(); List<QuestionContainerHeader> list = new ArrayList<QuestionContainerHeader>(); while (rs.next()) { header = getQuestionContainerHeaderFromResultSet(rs, qcPK); list.add(header); } return list; } finally { DBUtil.close(rs, prepStmt); } }
public static Collection<QuestionContainerHeader> getQuestionContainers( Connection con, List<QuestionContainerPK> pks) throws SQLException { SilverTrace.info( "questionContainer", "QuestionContainerDAO.getQuestionContainers()", "root.MSG_GEN_ENTER_METHOD", "pks = " + pks.toString()); ResultSet rs = null; QuestionContainerHeader questionContainerHeader = null; QuestionContainerPK questionContainerPK = new QuestionContainerPK("unknown"); List<QuestionContainerHeader> list = new ArrayList<QuestionContainerHeader>(); StringBuffer whereClause = new StringBuffer(); if (pks != null && !pks.isEmpty()) { Iterator<QuestionContainerPK> it = pks.iterator(); QuestionContainerPK pk = null; whereClause.append("("); while (it.hasNext()) { pk = it.next(); whereClause.append(" qcId = ").append(pk.getId()); if (it.hasNext()) { whereClause.append(" or "); } else { whereClause.append(" ) "); } } String selectStatement = "select " + QUESTIONCONTAINERCOLUMNNAMES + " from " + questionContainerPK.getTableName() + " where " + whereClause.toString() + " and instanceId = '" + pk.getComponentName() + "' order by qcBeginDate DESC, qcEndDate DESC"; Statement stmt = null; try { stmt = con.createStatement(); rs = stmt.executeQuery(selectStatement); while (rs.next()) { questionContainerHeader = getQuestionContainerHeaderFromResultSet(rs, pk); list.add(questionContainerHeader); } } finally { DBUtil.close(rs, stmt); } } return list; }
/** * Method declaration * * @param con * @param questionContainerPK * @return * @throws SQLException * @see */ public static Collection<QuestionContainerHeader> getNotClosedQuestionContainers( Connection con, QuestionContainerPK questionContainerPK) throws SQLException { SilverTrace.info( "questionContainer", "QuestionContainerDAO.getNotClosedQuestionContainers()", "root.MSG_GEN_ENTER_METHOD", "questionContainerPK = " + questionContainerPK); ResultSet rs = null; QuestionContainerHeader questionContainerHeader = null; String selectStatement = "select " + QUESTIONCONTAINERCOLUMNNAMES + " from " + questionContainerPK.getTableName() + " where instanceId = '" + questionContainerPK.getComponentName() + "' " + " and qcIsClosed = 0 order by qcBeginDate DESC, qcEndDate DESC"; Statement stmt = null; try { stmt = con.createStatement(); rs = stmt.executeQuery(selectStatement); List<QuestionContainerHeader> list = new ArrayList<QuestionContainerHeader>(); while (rs.next()) { questionContainerHeader = getQuestionContainerHeaderFromResultSet(rs, questionContainerPK); list.add(questionContainerHeader); } return list; } finally { DBUtil.close(rs, stmt); } }