Virginia Tech's My Courses Query
This was Below you will find a screenshot of VT's My Courses channel along with some code we use to generate the query. The query was developed for the portal team by a Banner developer on our Student Team . I so I don't exactly understand every aspect of the code. There are also a lot of supporting I also have all the supporting files for the actual portal that I can provideportlet if others are interested.
Ken Ken McCrery
Code Block | ||||
---|---|---|---|---|
| ||||
package edu.vt.es.ips.portlet.dao;
import java.sql.Types;
import java.util.Date;
import java.util.Map;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.SqlOutParameter;
import org.springframework.jdbc.core.SqlParameter;
import org.springframework.jdbc.core.namedparam.MapSqlParameterSource;
import org.springframework.jdbc.core.namedparam.SqlParameterSource;
import org.springframework.jdbc.core.simple.SimpleJdbcCall;
import edu.vt.es.ips.portlet.model.AccountSummary;
public class AccountSummaryDaoImpl implements AccountSummaryDao {
private static final String GET_PIDM_QUERY = "SELECT gzbtpid_pidm FROM gzbtpid WHERE gzbtpid_end_date IS NULL AND gzbtpid_pid = ?";
private static final String CATALOG_NAME = "TZKMYVT";
private static final String PROCEDURE_NAME = "p_acct_summary";
public static final String PIDM = "PIDM";
public static final String LAST_STATEMENT_DUE_DATE = "LastStmtDueDate";
public static final String LAST_STATEMENT_DATE = "LastStmtDate";
public static final String LAST_STATEMENT_BALANCE = "LastStmtBalance";
public static final String CURRENT_BALANCE = "CurrentBalance";
private JdbcTemplate jdbcTemplate;
private SimpleJdbcCall simpleJdbcCall;
public JdbcTemplate getJdbcTemplate()
{ return jdbcTemplate; }
public void setJdbcTemplate(JdbcTemplate jdbcTemplate)
{ this.jdbcTemplate = jdbcTemplate; }
/\* (non-Javadoc)
* @see edu.vt.es.ips.portlet.dao.AccountSummaryDao#getAccountSummary(int)
\*/
@SuppressWarnings("unchecked")
public AccountSummary getAccountSummary(int pidm) {
SqlParameterSource parameterSource = new MapSqlParameterSource().addValue(PIDM, pidm);
AccountSummary accountSummary = new AccountSummary();
Map out = getSimpleJdbcCall().execute(parameterSource);
if (out.get(CURRENT_BALANCE) \!= null)
{ accountSummary.setCurrentBalance( (Double)out.get(CURRENT_BALANCE)); }
if (out.get(LAST_STATEMENT_BALANCE) \!= null)
{ accountSummary.setLastStatementBalance((Double)out.get(LAST_STATEMENT_BALANCE)); }
accountSummary.setLastStatementDate((Date)out.get(LAST_STATEMENT_DATE));
accountSummary.setLastStatementDueDate((Date)out.get(LAST_STATEMENT_DUE_DATE));
return accountSummary;
}
public int getPidm(String pid) {
return jdbcTemplate.queryForInt(GET_PIDM_QUERY,
new Object\[\]
{pid}
);
}
public void setSimpleJdbcCall(SimpleJdbcCall simpleJdbcCall)
{ this.simpleJdbcCall = simpleJdbcCall; }
private SimpleJdbcCall getSimpleJdbcCall() {
if ( this.simpleJdbcCall == null )
{ this.simpleJdbcCall = new SimpleJdbcCall(jdbcTemplate) .withProcedureName(PROCEDURE_NAME) .withCatalogName(CATALOG_NAME) .withoutProcedureColumnMetaDataAccess() .useInParameterNames(PIDM) .declareParameters( new SqlParameter(PIDM, Types.NUMERIC), new SqlOutParameter(CURRENT_BALANCE, Types.DOUBLE), new SqlOutParameter(LAST_STATEMENT_DATE, Types.DATE), new SqlOutParameter(LAST_STATEMENT_DUE_DATE, Types.DATE), new SqlOutParameter(LAST_STATEMENT_BALANCE, Types.DOUBLE)); }
return this.simpleJdbcCall;
}
}
|