1 package smile.stored; 2 3 import java.util.*; 4 import java.sql.*; 5 6 15 public class s_insertMap extends StoredProcedure implements ProcedureInterface { 16 17 String itemID; 19 20 String mappingCode; 21 22 String rank; 23 24 String timeStart = "01/01/1980"; 25 26 String timeEnd = "01/01/1980"; 27 28 String pubName; 29 30 String section; 31 32 String pubDate; 33 34 String doesExists; 35 36 39 public s_insertMap() { 40 } 41 42 50 public void init(HashMap initData, Connection con) { 51 super.init(initData, con); 53 itemID = utils.getString(data, "ITEMID", ""); 55 mappingCode = utils.getString(data, "MAPPINGCODE", ""); 56 rank = utils.getString(data, "RANK", ""); 57 } 58 59 65 public void checkParams() throws SQLException { 66 if (itemID.equals("")) 67 throw new SQLException("ERROR: required field PUBDATE was not sent."); 68 if (mappingCode.equals("")) 69 throw new SQLException("ERROR: required field MAPPINGCODE was not sent."); 70 if (rank.equals("")) 71 throw new SQLException("ERROR: required field RANK was not sent."); 72 73 if (timeStart.equals("1/1/1980")) { 74 timeStart = sdf.format(new java.util.Date ()); 75 } 76 if (timeEnd.equals("1/1/1980")) { 77 timeEnd = sdf.format(new java.util.Date ()); 78 } 79 80 StringBuffer v_sb = new StringBuffer (); 81 v_sb.append("SELECT count(*) ").append("FROM tblarticleorder ").append("WHERE mappingCode = '" + mappingCode + "' ").append( 82 "AND itemID = '" + itemID + "'"); 83 doesExists = execStatementToValue(v_sb.toString()); 84 85 } 86 87 93 public void checkAction() throws SQLException { 94 } 95 96 102 public void executeAction() throws SQLException { 103 if (Integer.parseInt(doesExists) > 0) { 104 StringBuffer v_sbDelete = new StringBuffer (); 105 v_sbDelete.append("DELETE FROM tblarticleorder ").append(" WHERE mappingCode = '" + mappingCode + "' ").append("AND itemID = '" + itemID + "'"); 106 107 execStatement(v_sbDelete.toString()); 108 } 109 110 StringBuffer v_sb1 = new StringBuffer (); 111 v_sb1.append("SELECT pubDate from tblarticles where itemID=" + itemID); 112 pubDate = execStatementToValue(v_sb1.toString()); 113 StringBuffer v_sb2 = new StringBuffer (); 114 v_sb2.append("SELECT pubName from tblsections where mappingCode=" + mappingCode); 115 pubName = execStatementToValue(v_sb2.toString()); 116 StringBuffer v_sb3 = new StringBuffer (); 117 v_sb3.append("SELECT section from tblsections where mappingCode=" + mappingCode); 118 section = execStatementToValue(v_sb3.toString()); 119 120 StringBuffer v_sbInsert = new StringBuffer (); 121 v_sbInsert.append("INSERT INTO tblarticleorder ").append("(itemID, rank, mappingCode, timeStart, timeEnd, ").append( 122 "mappingUpdateDate, pubName, section, pubDate) ").append( 123 " VALUES ('" + itemID + "', '" + rank + "', '" + mappingCode + "', '" + timeStart + "', '" + timeEnd + "', '" 124 + sdf.format(new java.util.Date ()) + "','" + pubName + "', '" + section + "', '" + pubDate + "')"); 125 126 execStatement(v_sbInsert.toString()); 127 128 StringBuffer v_sbUpdate = new StringBuffer (); 129 v_sbUpdate.append("UPDATE tblarticles ").append("SET updateDate = now() ").append("WHERE itemID = '" + itemID + "'"); 130 131 execStatement(v_sbUpdate.toString()); 132 133 s_updateArticlePreload sp_uap = new s_updateArticlePreload(); 134 sp_uap.init(data, psConnection); 135 sp_uap.setItemID(itemID); 136 sp_uap.setTargetDataStore(targetDataStore); 137 sp_uap.executeAction(); 138 139 execStatementToRS(queryResultOk); 140 141 } 142 } 143 | Popular Tags |