List of usage examples for java.sql ResultSet getBoolean
boolean getBoolean(String columnLabel) throws SQLException;
ResultSet
object as a boolean
in the Java programming language. From source file:net.sourceforge.msscodefactory.cfasterisk.v2_1.CFAstPgSql.CFAstPgSqlSecGroupTable.java
public void deleteSecGroupByClusterIdx(CFAstAuthorization Authorization, long argClusterId) { final String S_ProcName = "deleteSecGroupByClusterIdx"; ResultSet resultSet = null; try {/* ww w . j av a 2 s.com*/ Connection cnx = schema.getCnx(); String sql = "SELECT " + schema.getLowerDbSchemaName() + ".sp_delete_secgrp_by_clusteridx( ?, ?, ?, ?, ?" + ", " + "?" + " ) as DeletedFlag"; if (stmtDeleteByClusterIdx == null) { stmtDeleteByClusterIdx = cnx.prepareStatement(sql); } int argIdx = 1; stmtDeleteByClusterIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtDeleteByClusterIdx.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecUserId().toString()); stmtDeleteByClusterIdx.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecSessionId().toString()); stmtDeleteByClusterIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtDeleteByClusterIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId()); stmtDeleteByClusterIdx.setLong(argIdx++, argClusterId); resultSet = stmtDeleteByClusterIdx.executeQuery(); if (resultSet.next()) { boolean deleteFlag = resultSet.getBoolean(1); if (resultSet.next()) { throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "Did not expect multi-record response"); } } else { throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "Expected 1 record result set to be returned by delete, not 0 rows"); } } catch (SQLException e) { throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e); } finally { if (resultSet != null) { try { resultSet.close(); } catch (SQLException e) { } resultSet = null; } } }
From source file:net.sourceforge.msscodefactory.cfasterisk.v2_4.CFAsteriskPgSql.CFAsteriskPgSqlISOCurrencyTable.java
public void deleteISOCurrencyByCcyNmIdx(CFSecurityAuthorization Authorization, String argName) { final String S_ProcName = "deleteISOCurrencyByCcyNmIdx"; ResultSet resultSet = null; try {//from www.ja v a 2s. c o m Connection cnx = schema.getCnx(); String sql = "SELECT " + schema.getLowerDbSchemaName() + ".sp_delete_iso_ccy_by_ccynmidx( ?, ?, ?, ?, ?" + ", " + "?" + " ) as DeletedFlag"; if (stmtDeleteByCcyNmIdx == null) { stmtDeleteByCcyNmIdx = cnx.prepareStatement(sql); } int argIdx = 1; stmtDeleteByCcyNmIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtDeleteByCcyNmIdx.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecUserId().toString()); stmtDeleteByCcyNmIdx.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecSessionId().toString()); stmtDeleteByCcyNmIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtDeleteByCcyNmIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId()); stmtDeleteByCcyNmIdx.setString(argIdx++, argName); resultSet = stmtDeleteByCcyNmIdx.executeQuery(); if (resultSet.next()) { boolean deleteFlag = resultSet.getBoolean(1); if (resultSet.next()) { throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "Did not expect multi-record response"); } } else { throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "Expected 1 record result set to be returned by delete, not 0 rows"); } } catch (SQLException e) { throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e); } finally { if (resultSet != null) { try { resultSet.close(); } catch (SQLException e) { } resultSet = null; } } }
From source file:net.sourceforge.msscodefactory.cfasterisk.v2_4.CFAsteriskPgSql.CFAsteriskPgSqlISOCurrencyTable.java
public void deleteISOCurrencyByCcyCdIdx(CFSecurityAuthorization Authorization, String argISOCode) { final String S_ProcName = "deleteISOCurrencyByCcyCdIdx"; ResultSet resultSet = null; try {//from w ww. j a va2 s . c om Connection cnx = schema.getCnx(); String sql = "SELECT " + schema.getLowerDbSchemaName() + ".sp_delete_iso_ccy_by_ccycdidx( ?, ?, ?, ?, ?" + ", " + "?" + " ) as DeletedFlag"; if (stmtDeleteByCcyCdIdx == null) { stmtDeleteByCcyCdIdx = cnx.prepareStatement(sql); } int argIdx = 1; stmtDeleteByCcyCdIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtDeleteByCcyCdIdx.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecUserId().toString()); stmtDeleteByCcyCdIdx.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecSessionId().toString()); stmtDeleteByCcyCdIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtDeleteByCcyCdIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId()); stmtDeleteByCcyCdIdx.setString(argIdx++, argISOCode); resultSet = stmtDeleteByCcyCdIdx.executeQuery(); if (resultSet.next()) { boolean deleteFlag = resultSet.getBoolean(1); if (resultSet.next()) { throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "Did not expect multi-record response"); } } else { throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "Expected 1 record result set to be returned by delete, not 0 rows"); } } catch (SQLException e) { throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e); } finally { if (resultSet != null) { try { resultSet.close(); } catch (SQLException e) { } resultSet = null; } } }
From source file:net.sourceforge.msscodefactory.cfasterisk.v2_4.CFAsteriskPgSql.CFAsteriskPgSqlTldTable.java
public void deleteTldByIdIdx(CFSecurityAuthorization Authorization, long argTenantId, long argTldId) { final String S_ProcName = "deleteTldByIdIdx"; ResultSet resultSet = null; try {//from w ww . j ava 2 s. c o m Connection cnx = schema.getCnx(); String sql = "SELECT " + schema.getLowerDbSchemaName() + ".sp_delete_tlddef_by_ididx( ?, ?, ?, ?, ?" + ", " + "?" + ", " + "?" + " ) as DeletedFlag"; if (stmtDeleteByIdIdx == null) { stmtDeleteByIdIdx = cnx.prepareStatement(sql); } int argIdx = 1; stmtDeleteByIdIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtDeleteByIdIdx.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecUserId().toString()); stmtDeleteByIdIdx.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecSessionId().toString()); stmtDeleteByIdIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtDeleteByIdIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId()); stmtDeleteByIdIdx.setLong(argIdx++, argTenantId); stmtDeleteByIdIdx.setLong(argIdx++, argTldId); resultSet = stmtDeleteByIdIdx.executeQuery(); if (resultSet.next()) { boolean deleteFlag = resultSet.getBoolean(1); if (resultSet.next()) { throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "Did not expect multi-record response"); } } else { throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "Expected 1 record result set to be returned by delete, not 0 rows"); } } catch (SQLException e) { throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e); } finally { if (resultSet != null) { try { resultSet.close(); } catch (SQLException e) { } resultSet = null; } } }
From source file:com.jd.survey.dao.survey.SurveyDAOImpl.java
/** * Reads a single survey page from the survey data table *//*from w w w . ja v a 2s .c o m*/ @Override public SurveyPage getPage(final Survey survey, final SurveyDefinitionPage surveyDefinitionPage, final String dateFormat) { try { boolean hasDatabaseQuestions = false; StringBuilder stringBuilder = new StringBuilder(); String pageVisibilityColumn = "p" + surveyDefinitionPage.getOrder() + "v"; stringBuilder.append("select survey_id, " + pageVisibilityColumn + ", "); for (Question question : surveyDefinitionPage.getQuestions()) { int optionsCount = question.getOptions().size(); int rowCount = question.getRowLabels().size(); int columnCount = question.getColumnLabels().size(); switch (question.getType()) { case YES_NO_DROPDOWN: //Yes No DropDown stringBuilder.append(" p" + surveyDefinitionPage.getOrder() + "q" + question.getOrder() + ","); hasDatabaseQuestions = true; break; case SHORT_TEXT_INPUT: //Short Text Input stringBuilder.append(" p" + surveyDefinitionPage.getOrder() + "q" + question.getOrder() + ","); hasDatabaseQuestions = true; break; case LONG_TEXT_INPUT: //Long Text Input stringBuilder.append(" p" + surveyDefinitionPage.getOrder() + "q" + question.getOrder() + ","); hasDatabaseQuestions = true; break; case HUGE_TEXT_INPUT: //Huge Text Input stringBuilder.append(" p" + surveyDefinitionPage.getOrder() + "q" + question.getOrder() + ","); hasDatabaseQuestions = true; break; case INTEGER_INPUT: //Integer Input stringBuilder.append(" p" + surveyDefinitionPage.getOrder() + "q" + question.getOrder() + ","); hasDatabaseQuestions = true; break; case CURRENCY_INPUT: //Currency Input stringBuilder.append(" p" + surveyDefinitionPage.getOrder() + "q" + question.getOrder() + ","); hasDatabaseQuestions = true; break; case DECIMAL_INPUT: //Decimal Input stringBuilder.append(" p" + surveyDefinitionPage.getOrder() + "q" + question.getOrder() + ","); hasDatabaseQuestions = true; break; case DATE_INPUT: //Date Input stringBuilder.append(" p" + surveyDefinitionPage.getOrder() + "q" + question.getOrder() + ","); hasDatabaseQuestions = true; break; case SINGLE_CHOICE_DROP_DOWN: //Single choice Drop Down stringBuilder.append(" p" + surveyDefinitionPage.getOrder() + "q" + question.getOrder() + ","); hasDatabaseQuestions = true; break; case MULTIPLE_CHOICE_CHECKBOXES: //Multiple Choice Checkboxes hasDatabaseQuestions = true; for (int o = 1; o <= optionsCount; o++) { stringBuilder.append( " p" + surveyDefinitionPage.getOrder() + "q" + question.getOrder() + "o" + o + ","); } //other support stringBuilder.append( " p" + surveyDefinitionPage.getOrder() + "q" + question.getOrder() + "text" + ","); break; case DATASET_DROP_DOWN: //DataSet Drop Down hasDatabaseQuestions = true; stringBuilder.append(" p" + surveyDefinitionPage.getOrder() + "q" + question.getOrder() + ","); break; case SINGLE_CHOICE_RADIO_BUTTONS: //Single Choice Radio Buttons hasDatabaseQuestions = true; stringBuilder.append(" p" + surveyDefinitionPage.getOrder() + "q" + question.getOrder() + ","); //other support stringBuilder.append( " p" + surveyDefinitionPage.getOrder() + "q" + question.getOrder() + "text" + ","); break; case YES_NO_DROPDOWN_MATRIX://Yes No DropDown Matrix hasDatabaseQuestions = true; for (int r = 1; r <= rowCount; r++) { for (int c = 1; c <= columnCount; c++) { stringBuilder.append(" p" + surveyDefinitionPage.getOrder() + "q" + question.getOrder() + "r" + r + "c" + c + ","); } } break; case SHORT_TEXT_INPUT_MATRIX://Short Text Input Matrix hasDatabaseQuestions = true; for (int r = 1; r <= rowCount; r++) { for (int c = 1; c <= columnCount; c++) { stringBuilder.append(" p" + surveyDefinitionPage.getOrder() + "q" + question.getOrder() + "r" + r + "c" + c + ","); } } break; case INTEGER_INPUT_MATRIX://Integer Input Matrix hasDatabaseQuestions = true; for (int r = 1; r <= rowCount; r++) { for (int c = 1; c <= columnCount; c++) { stringBuilder.append(" p" + surveyDefinitionPage.getOrder() + "q" + question.getOrder() + "r" + r + "c" + c + ","); } } break; case CURRENCY_INPUT_MATRIX://Currency Input Matrix hasDatabaseQuestions = true; for (int r = 1; r <= rowCount; r++) { for (int c = 1; c <= columnCount; c++) { stringBuilder.append(" p" + surveyDefinitionPage.getOrder() + "q" + question.getOrder() + "r" + r + "c" + c + ","); } } break; case DECIMAL_INPUT_MATRIX://Decimal Input Matrix hasDatabaseQuestions = true; for (int r = 1; r <= rowCount; r++) { for (int c = 1; c <= columnCount; c++) { stringBuilder.append(" p" + surveyDefinitionPage.getOrder() + "q" + question.getOrder() + "r" + r + "c" + c + ","); } } break; case DATE_INPUT_MATRIX://Date Input Matrix hasDatabaseQuestions = true; for (int r = 1; r <= rowCount; r++) { for (int c = 1; c <= columnCount; c++) { stringBuilder.append(" p" + surveyDefinitionPage.getOrder() + "q" + question.getOrder() + "r" + r + "c" + c + ","); } } break; case STAR_RATING: //Integer Input hasDatabaseQuestions = true; stringBuilder.append(" p" + surveyDefinitionPage.getOrder() + "q" + question.getOrder() + ","); break; case SMILEY_FACES_RATING: //Integer Input hasDatabaseQuestions = true; stringBuilder.append(" p" + surveyDefinitionPage.getOrder() + "q" + question.getOrder() + ","); break; } } stringBuilder.setLength(stringBuilder.length() - 1); if (!hasDatabaseQuestions) { stringBuilder.setLength(stringBuilder.length() - 1); } stringBuilder.append(" from survey_data_" + surveyDefinitionPage.getSurveyDefinition().getId()); stringBuilder.append(" where survey_id = ?"); SurveyPage surveyPage = this.jdbcTemplate.queryForObject(stringBuilder.toString(), new Object[] { survey.getId() }, new RowMapper<SurveyPage>() { public SurveyPage mapRow(ResultSet rs, int rowNum) throws SQLException { int optionsCount; int rowCount; int columnCount; Integer[] integerAnswerValuesArray; Long[][] longAnswerValuesMatrix; String[][] stringAnswerValuesMatrix; BigDecimal[][] bigDecimalAnswerValuesMatrix; Boolean[][] booleanAnswerValuesMatrix; Date[][] dateAnswerValuesMatrix; SurveyPage page = new SurveyPage(survey, surveyDefinitionPage); page.setVisible((rs.getBoolean("p" + surveyDefinitionPage.getOrder() + "v"))); QuestionAnswer questionAnswer; List<QuestionAnswer> questionAnswers = new ArrayList<QuestionAnswer>(); for (Question question : surveyDefinitionPage.getQuestions()) { questionAnswer = new QuestionAnswer(question); optionsCount = question.getOptions().size(); rowCount = question.getRowLabels().size(); columnCount = question.getColumnLabels().size(); switch (question.getType()) { case YES_NO_DROPDOWN: //Yes No DropDown questionAnswer.setBooleanAnswerValue((rs.getBoolean( "p" + surveyDefinitionPage.getOrder() + "q" + question.getOrder()))); break; case SHORT_TEXT_INPUT: //Short Text Input questionAnswer.setStringAnswerValue((rs.getString( "p" + surveyDefinitionPage.getOrder() + "q" + question.getOrder()))); break; case LONG_TEXT_INPUT: //Long Text Input questionAnswer.setStringAnswerValue((rs.getString( "p" + surveyDefinitionPage.getOrder() + "q" + question.getOrder()))); break; case HUGE_TEXT_INPUT: //Huge Text Input questionAnswer.setStringAnswerValue((rs.getString( "p" + surveyDefinitionPage.getOrder() + "q" + question.getOrder()))); break; case INTEGER_INPUT: //Integer Input questionAnswer.setLongAnswerValue((rs.getLong( "p" + surveyDefinitionPage.getOrder() + "q" + question.getOrder()))); if (rs.wasNull()) questionAnswer.setLongAnswerValue(null); questionAnswer .setStringAnswerValue(questionAnswer.getLongAnswerValue() == null ? "" : questionAnswer.getLongAnswerValue().toString()); break; case CURRENCY_INPUT: //Currency Input questionAnswer.setBigDecimalAnswerValue((rs.getBigDecimal( "p" + surveyDefinitionPage.getOrder() + "q" + question.getOrder()))); questionAnswer.setStringAnswerValue( questionAnswer.getBigDecimalAnswerValue() == null ? "" : CurrencyValidator.getInstance().format( questionAnswer.getBigDecimalAnswerValue(), LocaleContextHolder.getLocale())); break; case DECIMAL_INPUT: //Decimal Input questionAnswer.setBigDecimalAnswerValue((rs.getBigDecimal( "p" + surveyDefinitionPage.getOrder() + "q" + question.getOrder()))); questionAnswer.setStringAnswerValue( questionAnswer.getBigDecimalAnswerValue() == null ? "" : BigDecimalValidator.getInstance().format( questionAnswer.getBigDecimalAnswerValue(), LocaleContextHolder.getLocale())); break; case DATE_INPUT: //Date Input questionAnswer.setDateAnswerValue((rs.getDate( "p" + surveyDefinitionPage.getOrder() + "q" + question.getOrder()))); questionAnswer .setStringAnswerValue(questionAnswer.getDateAnswerValue() == null ? "" : DateValidator.getInstance().format( questionAnswer.getDateAnswerValue(), dateFormat)); break; case SINGLE_CHOICE_DROP_DOWN: //Single choice Drop Down questionAnswer.setStringAnswerValue((rs.getString( "p" + surveyDefinitionPage.getOrder() + "q" + question.getOrder()))); break; case MULTIPLE_CHOICE_CHECKBOXES: //Multiple Choice Checkboxes integerAnswerValuesArray = new Integer[optionsCount]; int index = 0; for (int o = 1; o <= optionsCount; o++) { if (rs.getBoolean("p" + surveyDefinitionPage.getOrder() + "q" + question.getOrder() + "o" + o)) { integerAnswerValuesArray[index] = o; index++; } } questionAnswer.setIntegerAnswerValuesArray(integerAnswerValuesArray); //other text data questionAnswer.setOtherStringAnswerValue( (rs.getString("p" + surveyDefinitionPage.getOrder() + "q" + question.getOrder() + "text"))); break; case DATASET_DROP_DOWN: //DataSet Drop Down questionAnswer.setStringAnswerValue((rs.getString( "p" + surveyDefinitionPage.getOrder() + "q" + question.getOrder()))); break; case SINGLE_CHOICE_RADIO_BUTTONS: //Single Choice Radio Buttons questionAnswer.setStringAnswerValue((rs.getString( "p" + surveyDefinitionPage.getOrder() + "q" + question.getOrder()))); //other text data questionAnswer.setOtherStringAnswerValue( (rs.getString("p" + surveyDefinitionPage.getOrder() + "q" + question.getOrder() + "text"))); break; case YES_NO_DROPDOWN_MATRIX://Yes No DropDown Matrix booleanAnswerValuesMatrix = new Boolean[rowCount][columnCount]; for (int r = 1; r <= rowCount; r++) { for (int c = 1; c <= columnCount; c++) { booleanAnswerValuesMatrix[r - 1][c - 1] = rs .getBoolean("p" + surveyDefinitionPage.getOrder() + "q" + question.getOrder() + "r" + r + "c" + c); } } questionAnswer.setBooleanAnswerValuesMatrix(booleanAnswerValuesMatrix); break; case SHORT_TEXT_INPUT_MATRIX://Short Text Input Matrix stringAnswerValuesMatrix = new String[rowCount][columnCount]; for (int r = 1; r <= rowCount; r++) { for (int c = 1; c <= columnCount; c++) { stringAnswerValuesMatrix[r - 1][c - 1] = rs .getString("p" + surveyDefinitionPage.getOrder() + "q" + question.getOrder() + "r" + r + "c" + c); } } questionAnswer.setStringAnswerValuesMatrix(stringAnswerValuesMatrix); break; case INTEGER_INPUT_MATRIX://Integer Input Matrix stringAnswerValuesMatrix = new String[rowCount][columnCount]; longAnswerValuesMatrix = new Long[rowCount][columnCount]; for (int r = 1; r <= rowCount; r++) { for (int c = 1; c <= columnCount; c++) { longAnswerValuesMatrix[r - 1][c - 1] = rs .getLong("p" + surveyDefinitionPage.getOrder() + "q" + question.getOrder() + "r" + r + "c" + c); if (rs.wasNull()) longAnswerValuesMatrix[r - 1][c - 1] = null; stringAnswerValuesMatrix[r - 1][c - 1] = longAnswerValuesMatrix[r - 1][c - 1] == null ? "" : longAnswerValuesMatrix[r - 1][c - 1].toString(); } } questionAnswer.setStringAnswerValuesMatrix(stringAnswerValuesMatrix); questionAnswer.setLongAnswerValuesMatrix(longAnswerValuesMatrix); break; case CURRENCY_INPUT_MATRIX://Currency Input Matrix stringAnswerValuesMatrix = new String[rowCount][columnCount]; bigDecimalAnswerValuesMatrix = new BigDecimal[rowCount][columnCount]; for (int r = 1; r <= rowCount; r++) { for (int c = 1; c <= columnCount; c++) { bigDecimalAnswerValuesMatrix[r - 1][c - 1] = rs .getBigDecimal("p" + surveyDefinitionPage.getOrder() + "q" + question.getOrder() + "r" + r + "c" + c); stringAnswerValuesMatrix[r - 1][c - 1] = bigDecimalAnswerValuesMatrix[r - 1][c - 1] == null ? "" : CurrencyValidator.getInstance().format( bigDecimalAnswerValuesMatrix[r - 1][c - 1], LocaleContextHolder.getLocale()); } } questionAnswer.setStringAnswerValuesMatrix(stringAnswerValuesMatrix); questionAnswer.setBigDecimalAnswerValuesMatrix(bigDecimalAnswerValuesMatrix); break; case DECIMAL_INPUT_MATRIX://Decimal Input Matrix stringAnswerValuesMatrix = new String[rowCount][columnCount]; bigDecimalAnswerValuesMatrix = new BigDecimal[rowCount][columnCount]; for (int r = 1; r <= rowCount; r++) { for (int c = 1; c <= columnCount; c++) { bigDecimalAnswerValuesMatrix[r - 1][c - 1] = rs .getBigDecimal("p" + surveyDefinitionPage.getOrder() + "q" + question.getOrder() + "r" + r + "c" + c); stringAnswerValuesMatrix[r - 1][c - 1] = bigDecimalAnswerValuesMatrix[r - 1][c - 1] == null ? "" : BigDecimalValidator.getInstance().format( bigDecimalAnswerValuesMatrix[r - 1][c - 1], LocaleContextHolder.getLocale()); } } questionAnswer.setStringAnswerValuesMatrix(stringAnswerValuesMatrix); questionAnswer.setBigDecimalAnswerValuesMatrix(bigDecimalAnswerValuesMatrix); break; case DATE_INPUT_MATRIX://Date Input Matrix stringAnswerValuesMatrix = new String[rowCount][columnCount]; dateAnswerValuesMatrix = new Date[rowCount][columnCount]; for (int r = 1; r <= rowCount; r++) { for (int c = 1; c <= columnCount; c++) { dateAnswerValuesMatrix[r - 1][c - 1] = rs .getDate("p" + surveyDefinitionPage.getOrder() + "q" + question.getOrder() + "r" + r + "c" + c); stringAnswerValuesMatrix[r - 1][c - 1] = dateAnswerValuesMatrix[r - 1][c - 1] == null ? "" : DateValidator.getInstance().format( dateAnswerValuesMatrix[r - 1][c - 1], dateFormat); } } questionAnswer.setStringAnswerValuesMatrix(stringAnswerValuesMatrix); questionAnswer.setDateAnswerValuesMatrix(dateAnswerValuesMatrix); break; case STAR_RATING: //Integer Input questionAnswer.setLongAnswerValue((rs.getLong( "p" + surveyDefinitionPage.getOrder() + "q" + question.getOrder()))); if (rs.wasNull()) questionAnswer.setLongAnswerValue(null); questionAnswer .setStringAnswerValue(questionAnswer.getLongAnswerValue() == null ? "" : questionAnswer.getLongAnswerValue().toString()); break; case SMILEY_FACES_RATING: //Integer Input questionAnswer.setLongAnswerValue((rs.getLong( "p" + surveyDefinitionPage.getOrder() + "q" + question.getOrder()))); if (rs.wasNull()) questionAnswer.setLongAnswerValue(null); questionAnswer .setStringAnswerValue(questionAnswer.getLongAnswerValue() == null ? "" : questionAnswer.getLongAnswerValue().toString()); break; } questionAnswers.add(questionAnswer); } page.setQuestionAnswers(questionAnswers); return page; } }); return surveyPage; } catch (Exception e) { log.error(e.getMessage(), e); throw (new RuntimeException(e)); } }
From source file:net.sourceforge.msscodefactory.cfacc.v2_0.CFAccPgSql.CFAccPgSqlTagTable.java
public void deleteTagByTenantIdx(CFAccAuthorization Authorization, long argTenantId) { final String S_ProcName = "deleteTagByTenantIdx"; ResultSet resultSet = null; try {/*w w w.ja v a2s . c om*/ Connection cnx = schema.getCnx(); String sql = "SELECT " + schema.getLowerSchemaDbName() + ".sp_delete_tag_by_tenantidx( ?, ?, ?, ?, ?" + ", " + "?" + " ) as DeletedFlag"; if (stmtDeleteByTenantIdx == null) { stmtDeleteByTenantIdx = cnx.prepareStatement(sql); } int argIdx = 1; stmtDeleteByTenantIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtDeleteByTenantIdx.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecUserId().toString()); stmtDeleteByTenantIdx.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecSessionId().toString()); stmtDeleteByTenantIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtDeleteByTenantIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId()); stmtDeleteByTenantIdx.setLong(argIdx++, argTenantId); resultSet = stmtDeleteByTenantIdx.executeQuery(); if (resultSet.next()) { boolean deleteFlag = resultSet.getBoolean(1); if (resultSet.next()) { throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "Did not expect multi-record response"); } } else { throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "Expected 1 record result set to be returned by delete, not 0 rows"); } } catch (SQLException e) { throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e); } finally { if (resultSet != null) { try { resultSet.close(); } catch (SQLException e) { } resultSet = null; } } }
From source file:net.sourceforge.msscodefactory.cfasterisk.v2_1.CFAstPgSql.CFAstPgSqlSchema.java
public boolean isSystemUser(CFAstAuthorization Authorization) { if (!inTransaction) { throw CFLib.getDefaultExceptionFactory().newUsageException(getClass(), "isSystemUser", "Not in a transaction"); }//from w w w . j ava 2s. c o m ResultSet resultSet = null; try { String sql = "SELECT " + lowerDbSchemaName + ".sp_is_system_user( ? ) as IsSystemUser"; if (stmtSelectIsSystemUser == null) { stmtSelectIsSystemUser = cnx.prepareStatement(sql); } stmtSelectIsSystemUser.setString(1, Authorization.getSecUserId().toString()); resultSet = stmtSelectIsSystemUser.executeQuery(); boolean resultFlag; if (resultSet.next()) { resultFlag = resultSet.getBoolean(1); } else { throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), "isSystemUser", "Query of sp_is_system_user() did not return a result row"); } resultSet.close(); return (resultFlag); } catch (SQLException e) { throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), "isSystemUser", e); } finally { if (resultSet != null) { try { resultSet.close(); } catch (SQLException e) { } resultSet = null; } } }
From source file:net.sourceforge.msscodefactory.cfacc.v2_0.CFAccPgSql.CFAccPgSqlSecAppTable.java
public void deleteSecAppByClusterIdx(CFAccAuthorization Authorization, long argClusterId) { final String S_ProcName = "deleteSecAppByClusterIdx"; ResultSet resultSet = null; try {/* w ww.j a v a 2 s . c om*/ Connection cnx = schema.getCnx(); String sql = "SELECT " + schema.getLowerSchemaDbName() + ".sp_delete_secapp_by_clusteridx( ?, ?, ?, ?, ?" + ", " + "?" + " ) as DeletedFlag"; if (stmtDeleteByClusterIdx == null) { stmtDeleteByClusterIdx = cnx.prepareStatement(sql); } int argIdx = 1; stmtDeleteByClusterIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtDeleteByClusterIdx.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecUserId().toString()); stmtDeleteByClusterIdx.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecSessionId().toString()); stmtDeleteByClusterIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtDeleteByClusterIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId()); stmtDeleteByClusterIdx.setLong(argIdx++, argClusterId); resultSet = stmtDeleteByClusterIdx.executeQuery(); if (resultSet.next()) { boolean deleteFlag = resultSet.getBoolean(1); if (resultSet.next()) { throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "Did not expect multi-record response"); } } else { throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "Expected 1 record result set to be returned by delete, not 0 rows"); } } catch (SQLException e) { throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e); } finally { if (resultSet != null) { try { resultSet.close(); } catch (SQLException e) { } resultSet = null; } } }
From source file:net.sourceforge.msscodefactory.cfasterisk.v2_0.CFAstPgSql.CFAstPgSqlSecAppTable.java
public void deleteSecAppByClusterIdx(CFAstAuthorization Authorization, long argClusterId) { final String S_ProcName = "deleteSecAppByClusterIdx"; ResultSet resultSet = null; try {/*from w w w .j a va 2s. c om*/ Connection cnx = schema.getCnx(); String sql = "SELECT " + schema.getLowerSchemaDbName() + ".sp_delete_secapp_by_clusteridx( ?, ?, ?, ?, ?" + ", " + "?" + " ) as DeletedFlag"; if (stmtDeleteByClusterIdx == null) { stmtDeleteByClusterIdx = cnx.prepareStatement(sql); } int argIdx = 1; stmtDeleteByClusterIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtDeleteByClusterIdx.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecUserId().toString()); stmtDeleteByClusterIdx.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecSessionId().toString()); stmtDeleteByClusterIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtDeleteByClusterIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId()); stmtDeleteByClusterIdx.setLong(argIdx++, argClusterId); resultSet = stmtDeleteByClusterIdx.executeQuery(); if (resultSet.next()) { boolean deleteFlag = resultSet.getBoolean(1); if (resultSet.next()) { throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "Did not expect multi-record response"); } } else { throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "Expected 1 record result set to be returned by delete, not 0 rows"); } } catch (SQLException e) { throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e); } finally { if (resultSet != null) { try { resultSet.close(); } catch (SQLException e) { } resultSet = null; } } }