Example usage for org.springframework.jdbc.core RowMapper RowMapper

List of usage examples for org.springframework.jdbc.core RowMapper RowMapper

Introduction

In this page you can find the example usage for org.springframework.jdbc.core RowMapper RowMapper.

Prototype

RowMapper

Source Link

Usage

From source file:com.apbc.dao.AgentPayablesDAO.java

/**
 * select * from asbckodbnew.agent_payables
where payment_date/*from  w w  w.j  a va  2s . co  m*/
BETWEEN CAST('2016-01-01' AS DATE) AND CAST('2016-01-15' AS DATE)
;
 * @param lic TODO
 * @param i
 * @param j
        
 * @return
 */

public List<ExtractedAgentPaymentDetails> getPayablesRow(PayPeriod pp, final KnownAgentDAO agent,
        final AgentLicenceDAO lic) {
    Date d1 = pp.getFromDate();
    Date d2 = pp.getToDate();
    final Date d3 = pp.getUptoExtractDate();
    final Integer payperiodid = Integer.valueOf(pp.getPayperiodId());
    return template.query(
            "select *  from agent_payables " + "where payment_date <= '" + d3 + "' and status !=" + "'Paid'",

            new RowMapper<ExtractedAgentPaymentDetails>() {
                @Override
                public ExtractedAgentPaymentDetails mapRow(ResultSet rs, int rownumber) throws SQLException {
                    ExtractedAgentPaymentDetails e = new ExtractedAgentPaymentDetails();
                    e.setAgent_id(rs.getInt("agent_id"));
                    e.setPolicyid(rs.getString("policy_id"));
                    e.setCarrierid(rs.getInt("carrier_id"));
                    e.setProductcode(rs.getString("product_code"));
                    e.setAgentcommission(rs.getLong("agent_earned_commission"));
                    e.setCommissiontype(rs.getString("commission_type"));
                    e.setPaymentdate(rs.getDate("payment_date"));
                    e.setCreationdate(rs.getDate("creation_date"));
                    e.setPayperiodupto(d3); //PAYPERIOD UP TO COMING FROM STATIC TABLE FOR GIVEN PAY PERIOD ID TODO
                    e.setPayperiod(Integer.valueOf(payperiodid)); //TODO FROM PAYPERIOD INPUT VALUE
                    //e.setAgent_name("TEST NAME"); //TODO GET AGENT NAME FROM AGENT TABLE BY PROVIDING ID;
                    e.setAgent_name(getAgentName(agent, rs.getInt("agent_id")));
                    e.setAgentlicnum(getAgentLic(lic, rs.getInt("agent_id"))); // TODO get from agentlicensed table
                    e.setTrasactiontype(rs.getInt("transaction_type"));
                    e.setDesc("NORMAL");
                    return e;
                }

                private String getAgentLic(AgentLicenceDAO lic, int agentId) {
                    return lic.findByAgentId(Integer.valueOf(agentId));
                }
            });
}

From source file:com.sfs.whichdoctor.dao.CreditDAOImpl.java

/**
 * Used to load a CreditBean with a specific name and supplied load options.
 * A boolean parameter identifies whether to use the default reader
 * connection or optional writer connection datasource.
 *
 * @param creditId the credit id/*from   www . ja  va 2  s.co m*/
 * @param loadDetails the load details
 * @param useWriter the use writer
 *
 * @return the credit bean
 *
 * @throws WhichDoctorDaoException the which doctor dao exception
 */
private CreditBean load(final int creditId, final BuilderBean loadDetails, final boolean useWriter)
        throws WhichDoctorDaoException {

    CreditBean credit = null;

    dataLogger.info("Credit Id: " + creditId + " requested");

    final String loadSQL = getSQL().getValue("credit/load") + " AND credit.CreditId = ?";

    JdbcTemplate jdbcTemplate = this.getJdbcTemplateReader();
    if (useWriter) {
        jdbcTemplate = this.getJdbcTemplateWriter();
    }

    try {
        credit = (CreditBean) jdbcTemplate.queryForObject(loadSQL, new Object[] { creditId }, new RowMapper() {
            public Object mapRow(final ResultSet rs, final int rowNum) throws SQLException {
                return loadCredit(rs, loadDetails);
            }
        });

    } catch (IncorrectResultSizeDataAccessException ie) {
        dataLogger.debug("No results found for this search:" + ie.getMessage());
    }
    return credit;
}

From source file:admin.service.JdbcSearchableStepExecutionDao.java

public Collection<String> findStepNamesForJobExecution(String jobName, String excludesPattern) {

    List<String> list = getJdbcTemplate().query(getQuery(STEP_EXECUTIONS_FOR_JOB), new RowMapper<String>() {
        public String mapRow(java.sql.ResultSet rs, int rowNum) throws java.sql.SQLException {
            return rs.getString(1);
        }//from w  ww  .  j  ava 2 s  .  c  o m
    }, jobName);

    Set<String> stepNames = new LinkedHashSet<String>(list);
    for (Iterator<String> iterator = stepNames.iterator(); iterator.hasNext();) {
        String name = iterator.next();
        if (PatternMatcher.match(excludesPattern, name)) {
            iterator.remove();
        }
    }

    return stepNames;

}

From source file:om.edu.squ.squportal.portlet.dps.registration.postpone.db.PostponeDBImpl.java

/**
 * //www  . jav a 2 s  . co m
 * method name  : getExistingGrades
 * @param studentNo
 * @param locale
 * @return
 * PostponeDBImpl
 * return type  : List<Course>
 * 
 * purpose      : Get existing grades
 *
 * Date          :   Dec 25, 2017 10:44:04 PM
 */
public List<Course> getExistingGrades(String studentNo, Locale locale) {
    String SQL_POSTPONE_SELECT_EXISTING_GRADES = queryPostpone
            .getProperty(Constants.CONST_SQL_POSTPONE_SELECT_EXISTING_GRADES);
    RowMapper<Course> rowMapper = new RowMapper<Course>() {

        @Override
        public Course mapRow(ResultSet rs, int rowNum) throws SQLException {
            Course course = new Course();
            course.setlAbrCourseNo(rs.getString(Constants.CONST_COLMN_L_ABR_CRSNO));
            course.setCourseName(rs.getString(Constants.CONST_COLMN_COURSE_NAME));
            course.setGradeValue(rs.getString(Constants.CONST_COLMN_GRADE_VAL));
            return course;
        }
    };

    Map<String, String> namedParameterMap = new HashMap<String, String>();
    namedParameterMap.put("paramLocale", locale.getLanguage());
    namedParameterMap.put("paramStdNo", studentNo);

    return nPJdbcTemplDpsPostpone.query(SQL_POSTPONE_SELECT_EXISTING_GRADES, namedParameterMap, rowMapper);
}

From source file:com.sfs.whichdoctor.dao.SupervisorDAOImpl.java

/**
 * Used to get a SupervisorBean for a specified supervisor Id.
 *
 * @param supervisorId the supervisor id
 *
 * @return the supervisor bean/*from   w ww  . j av a2 s . c  o m*/
 *
 * @throws WhichDoctorDaoException the which doctor dao exception
 */
public final SupervisorBean load(final int supervisorId) throws WhichDoctorDaoException {

    dataLogger.info("SupervisorId: " + supervisorId + " requested");

    final String loadSupervisorId = getSQL().getValue("supervisor/load")
            + " WHERE supervisors.SupervisorId = ?";

    SupervisorBean supervisor = null;

    final BuilderBean loadDetails = new BuilderBean();
    loadDetails.setParameter("SUPERVISOR_PERSONOBJ", true);

    try {
        supervisor = (SupervisorBean) this.getJdbcTemplateReader().queryForObject(loadSupervisorId,
                new Object[] { supervisorId }, new RowMapper() {
                    public Object mapRow(final ResultSet rs, final int rowNum) throws SQLException {
                        return loadSupervisor(rs, loadDetails);
                    }
                });

    } catch (IncorrectResultSizeDataAccessException ie) {
        dataLogger.debug("No results found for search: " + ie.getMessage());
    }
    return supervisor;
}

From source file:dk.nsi.haiba.minipasconverter.dao.impl.MinipasDAOImpl.java

@Override
public Collection<MinipasTADM> getMinipasTADM(String year, long fromKRecnum, int batchSize) {
    Monitor mon = MonitorFactory.start("MinipasDAOImpl.getMinipasTADM");
    String tableName = "T_ADM" + year;
    // maybe this works - needs to find out if order by executes on resultset or before (before is the intend)
    List<MinipasTADM> query = jdbc.query("SELECT * FROM " + minipasPrefix + tableName
            + " WHERE K_RECNUM > ? ORDER BY K_RECNUM FETCH FIRST " + batchSize + " ROWS ONLY",
            new RowMapper<MinipasTADM>() {
                @Override//from w w  w.java  2  s  .  co  m
                public MinipasTADM mapRow(ResultSet rs, int rowNum) throws SQLException {
                    MinipasTADM returnValue = new MinipasTADM();
                    returnValue.setC_adiag(rs.getString("C_ADIAG"));
                    returnValue.setC_afd(rs.getString("C_AFD"));
                    returnValue.setC_bopamt(rs.getString("C_BOPAMT"));
                    returnValue.setC_hafd(rs.getString("C_HAFD"));
                    returnValue.setC_henm(rs.getString("C_HENM"));
                    returnValue.setC_hsgh(rs.getString("C_HSGH"));
                    returnValue.setC_indm(rs.getString("C_INDM"));
                    returnValue.setC_kom(rs.getString("C_KOM"));
                    returnValue.setC_kontaars(rs.getString("C_KONTAARS"));
                    returnValue.setC_pattype(rs.getString("C_PATTYPE"));
                    returnValue.setC_sex(rs.getString("C_SEX"));
                    returnValue.setC_sgh(rs.getString("C_SGH"));
                    returnValue.setC_sghamt(rs.getString("C_SGHAMT"));
                    returnValue.setC_spec(rs.getString("C_SPEC"));
                    returnValue.setC_udm(rs.getString("C_UDM"));
                    returnValue.setD_hendto(rs.getTimestamp("D_HENDTO"));
                    returnValue.setD_inddto(rs.getTimestamp("D_INDDTO"));
                    returnValue.setD_uddto(rs.getTimestamp("D_UDDTO"));
                    returnValue.setIdnummer(rs.getString("IDNUMMER"));
                    returnValue.setK_recnum(rs.getInt("K_RECNUM"));
                    returnValue.setSkemaopdat(rs.getTimestamp("SKEMAOPDAT"));
                    returnValue.setSkemaopret(rs.getTimestamp("SKEMAOPRET"));
                    returnValue.setV_alder(rs.getInt("V_ALDER"));
                    returnValue.setV_behdage(rs.getInt("V_BEHDAGE"));
                    returnValue.setV_cpr(rs.getString("V_CPR"));
                    returnValue.setV_sengdage(rs.getInt("V_SENGDAGE"));
                    return returnValue;
                }
            }, fromKRecnum);
    mon.stop();
    return query;
}

From source file:com.sfs.whichdoctor.dao.ReportDAOImpl.java

/**
 * Used to get a ReportBean for a specified reportId.
 *
 * @param reportId the report id/*from www . j  a v  a 2s .  c  o  m*/
 * @return the report bean
 * @throws WhichDoctorDaoException the which doctor dao exception
 */
@SuppressWarnings("unchecked")
public final ReportBean load(final int reportId) throws WhichDoctorDaoException {

    dataLogger.info("reportId: " + reportId + " requested");

    final String loadId = getSQL().getValue("report/load") + " WHERE report.reportId = ?";

    ReportBean report = null;
    try {
        report = (ReportBean) this.getJdbcTemplateReader().queryForObject(loadId, new Object[] { reportId },
                new RowMapper() {
                    public Object mapRow(final ResultSet rs, final int rowNum) throws SQLException {
                        return loadReport(rs);
                    }
                });

    } catch (IncorrectResultSizeDataAccessException ie) {
        dataLogger.debug("No results found for this search: " + ie.getMessage());
    }
    return report;
}

From source file:com.nishayani.school.board.rest.dao.db.SchoolBoardDbImpl.java

/**
 * // w w  w  .j a  v  a  2s .c  om
 */
public List<Student> getStudent(String grNo) {
    String SQL_PROP_STUDENT_GRNO = properties.getProperty(Constants.SQL_PROP_STUDENT_GRNO);
    RowMapper<Student> mapper = new RowMapper<Student>() {

        @Override
        public Student mapRow(ResultSet rs, int arg1) throws SQLException {

            return getStudent(rs);
        }
    };

    Map<String, String> paramMap = new HashMap<String, String>();
    paramMap.put("paramGrNo", grNo);

    return namedParameterJdbcTemplate.query(SQL_PROP_STUDENT_GRNO, paramMap, mapper);

}

From source file:com.sfs.whichdoctor.dao.OnlineToolDAOImpl.java

/**
 * Loads an array of online tool beans for the supplied reference GUID.
 *
 * @param referenceGUID the reference GUID
 *
 * @return the collection< online tool bean>
 *
 * @throws WhichDoctorDaoException the which doctor dao exception
 *//*from ww  w  .  jav a 2s. co  m*/
@SuppressWarnings("unchecked")
public final Collection<OnlineToolBean> load(final int referenceGUID) throws WhichDoctorDaoException {

    Collection<OnlineToolBean> onlineTools = new ArrayList<OnlineToolBean>();

    try {
        onlineTools = this.getJdbcTemplateReader().query(this.getSQL().getValue("onlineTool/load"),
                new Object[] { referenceGUID }, new RowMapper() {
                    public Object mapRow(final ResultSet rs, final int rowNum) throws SQLException {
                        return loadOnlineTool(rs);
                    }
                });

    } catch (IncorrectResultSizeDataAccessException ie) {
        dataLogger.debug("No results found for this search: " + ie.getMessage());
    }

    return onlineTools;
}

From source file:Implement.DAO.CommonDAOImpl.java

@Override
public int getAccountIDByEmailRegister(String email) {
    int providerID;
    String sql = "SELECT NewsletterID AS id FROM NewsletterEmail WHERE Email = ? ";
    try {//from  www.ja va  2 s .co m
        providerID = jdbcTemplate.queryForObject(sql, new RowMapper<Integer>() {

            @Override
            public Integer mapRow(ResultSet rs, int i) throws SQLException {
                try {
                    return rs.getInt("id");
                } catch (Exception e) {
                    return 0;
                }
            }
        }, email);
    } catch (EmptyResultDataAccessException e) {
        providerID = 0;
    }

    return providerID;
}