@Override public AcademicKPIAttribute mapRow(ResultSet rs, int rowNum) throws SQLException { AcademicKPIAttribute domain = new AcademicKPIAttribute(); domain.setAcademicKPIAtributeId(rs.getLong("kpi_attribute_id")); domain.setAcademicKPIId(rs.getLong("academic_kpi_id")); domain.setName(rs.getString("name")); domain.setCode(rs.getString("code")); domain.setAcademicKPICode(rs.getString("academic_kpi_code")); domain.setIsCalculate(rs.getString("is_calculate")); domain.setIsValidateNumber(rs.getString("is_validate_number")); domain.setAcademicYear(rs.getString("academic_year")); domain.setMandatory(rs.getString("mandatory")); return domain; }
@Override public Long create(AcademicKPI domain) { logger.info("domain : " + BeanUtils.getBeanString(domain)); final int nexCode = generateCodeUtil.getNextaAcademicKPI(domain); final AcademicKPI finalDomain = domain; KeyHolder keyHolder = new GeneratedKeyHolder(); jdbcTemplate.update( new PreparedStatementCreator() { public PreparedStatement createPreparedStatement(Connection connection) throws SQLException { PreparedStatement ps = connection.prepareStatement( "" + " insert into academic_kpi (name, code,work_type_code,mark,academic_year,unit_code,rule_code,order_no,description) values (?, ?,?,?,?,?,?,?,?)" + "", Statement.RETURN_GENERATED_KEYS); ps.setString(1, finalDomain.getName()); ps.setInt(2, nexCode); ps.setInt(3, new Integer(finalDomain.getWorkTypeCode())); ps.setBigDecimal(4, finalDomain.getMark()); ps.setString(5, finalDomain.getAcademicYear()); ps.setInt(6, new Integer(finalDomain.getUnitCode())); ps.setString(7, finalDomain.getMultiplyValue()); ps.setInt(8, new Integer(finalDomain.getOrderNo())); ps.setString(9, finalDomain.getDescription()); return ps; } }, keyHolder); Long returnid = keyHolder.getKey().longValue(); AcademicKPIAttribute academicKPIAttribute = new AcademicKPIAttribute(); academicKPIAttribute.setAcademicKPICode(nexCode + ""); academicKPIAttribute.setAcademicKPIId(returnid); academicKPIAttribute.setName("���ͧҹ"); // academicKPIAttribute.setMandatory("Y"); academicKPIAttribute.setAcademicYear(finalDomain.getAcademicYear()); addNewAttribute(academicKPIAttribute); return returnid; }
@Override public boolean isAttributeExistCreate(AcademicKPIAttribute academicKPIAttribute) { boolean returnValue = false; try { String sqltmp = "select count(*) as totalItem from academic_kpi_attribute t where t.name='" + StringEscapeUtils.escapeSql(academicKPIAttribute.getName()) + "' and t.academic_kpi_code=" + academicKPIAttribute.getAcademicKPICode() + " and t.academic_year='" + academicKPIAttribute.getAcademicYear() + "'"; Long found = this.jdbcTemplate.queryForLong(sqltmp); if (found != null && found.intValue() > 0) { returnValue = true; } } catch (Exception ex) { ex.printStackTrace(); } return returnValue; }
@Override public void edit(AcademicKPI domain) { logger.info("domain : " + BeanUtils.getBeanString(domain)); this.jdbcTemplate.update( "update academic_kpi set name=?,mark=?,unit_code=? ,rule_code=? ,order_no=?,description=? ," + " special_p1=?, special_p2=?, special_p3=?, special_p4=?, total_student_from=?, total_student_to=?,from_reg=? where academic_kpi_id=? ", domain.getName(), domain.getMark(), domain.getUnitCode(), domain.getMultiplyValue(), domain.getOrderNo(), domain.getDescription(), domain.getSpecialP1(), domain.getSpecialP2(), domain.getSpecialP3(), domain.getSpecialP4(), domain.getTotalStudentFrom(), domain.getTotalStudentTo(), domain.getFromRegis(), domain.getAcademicKPIId()); List<AcademicKPIAttribute> academicKPIAttributeList = domain.getAcademicKPIAttributeList(); if (academicKPIAttributeList != null && academicKPIAttributeList.size() > 0) { for (AcademicKPIAttribute tmp : academicKPIAttributeList) { logger.info(" checkValue:" + tmp.getIsCalculate()); String isCheckFlage = "on".equalsIgnoreCase(tmp.getIsCalculate()) ? "Y" : "N"; String isCheckFlage2 = "on".equalsIgnoreCase(tmp.getIsValidateNumber()) ? "Y" : "N"; logger.info( " Name :" + tmp.getName() + " isCal:" + isCheckFlage + " isValidateNumber:" + isCheckFlage2); this.jdbcTemplate.update( "update academic_kpi_attribute set name=?, is_calculate=?,is_validate_number=? where kpi_attribute_id=? ", tmp.getName(), isCheckFlage, isCheckFlage2, tmp.getAcademicKPIAtributeId()); } } }