1 5 package com.tdsecurities.itracker.converter; 6 7 import java.sql.PreparedStatement ; 8 import java.sql.ResultSet ; 9 import java.sql.SQLException ; 10 11 import org.apache.log4j.Logger; 12 13 import com.tdsecurities.itracker.common.DataSourceManager; 14 15 19 public class IssueHistoryConverter extends BasicConverter 20 { 21 private static final String SOURCE_SQL = "select * from bug_history where field_name = 'details' order by bug_id, date"; 22 private static final String TARGET_SQL = "insert into issuehistorybean (id,description,status,create_date,last_modified,issue_id,user_id) values (?,?,?,?,?,?,?)"; 23 private static final String LAST_ID_SQL = "select max(id) from issuehistorybean"; 24 25 private int historyId = 0; 26 27 private Logger log = Logger.getLogger(IssueHistoryConverter.class); 28 29 protected String getSourceQuery() 30 { 31 return SOURCE_SQL; 32 } 33 34 protected String getTargetQuery() 35 { 36 return TARGET_SQL; 37 } 38 39 protected String getIdStoreName() 40 { 41 return "issuehistory"; 42 } 43 44 protected String getLastIdQuery() 45 { 46 return LAST_ID_SQL; 47 } 48 49 protected int prepareTargetStatement(PreparedStatement targetStmt, ResultSet rs) throws Exception 50 { 51 int col = 1; 52 targetStmt.setInt(col++, historyId++); 53 targetStmt.setString(col++, rs.getString("old_value")); 54 targetStmt.setInt(col++, 1); 55 targetStmt.setTimestamp(col++, getDate(rs,"date")); 56 targetStmt.setTimestamp(col++, getDate(rs,"date")); 57 targetStmt.setInt(col++, rs.getInt("bug_id")); 58 targetStmt.setInt(col++, rs.getInt("mod_by")); 59 return BasicConverter.OK; 60 } 61 62 protected void additionalProcessing(PreparedStatement stmt, ResultSet rs) 63 throws SQLException 64 { 65 } 66 67 protected void preConversionProcessing() 68 { 69 log.info("Converting issue histories..."); 70 Object o = executeQuery(DataSourceManager.ITRACKER, "select max(id) from issuehistorybean"); 71 historyId = new Integer ("" + o).intValue() + 1; 72 log.info("History id " + historyId); 73 } 74 75 protected void postConversionProcessing() 76 { 77 log.info("Converted issue histories."); 78 } 79 } 80 | Popular Tags |