1 package com.teamkonzept.webman.mainint.db.queries; 2 3 import com.teamkonzept.db.*; 4 import java.sql.*; 5 import com.teamkonzept.webman.mainint.WebmanExceptionHandler; 6 import com.teamkonzept.webman.mainint.db.queries.content.*; 7 8 13 public class TKDBContentNewVersionByVersionId extends TKExtendedPrepQuery 14 { 15 16 public final static boolean ISPREPARED = true; 17 18 public final static String [] ORDER = { 19 "INSTANCE_ID", "VERSION_ID", "STATUS_ID", "VERS_INFO", "VERS_AUTHOR" 20 }; 21 22 public final static Object [][] TYPES = 23 { 24 {"VERS_INFO", new Integer (Types.VARCHAR)}, 25 {"VERS_AUTHOR", new Integer (Types.VARCHAR)} 26 }; 27 28 public final static boolean[] SETRELEVANTS = { false }; 29 30 protected static Class [] queryClasses = { 31 SelectContentIDFromContentVersion.class, 32 SelectMaxContentVersion.class, 33 InsertContentVersion.class 34 }; 35 36 public boolean execute() 37 { 38 try 39 { 40 init(queryClasses); 42 boolean isNotOpen = aTKDBConnection.isAutoCommit(); 43 if (isNotOpen) 44 { 45 TKDBManager.beginTransaction(); 46 } 47 48 int cont_id = 0; 49 52 queries[0].setQueryParams("VERSION_ID", queryParams.get("VERSION_ID")); 53 queries[0].execute(); 54 ResultSet rs = queries[0].fetchResultSet(); 55 if (rs != null && rs.next()) 56 { 57 cont_id = rs.getInt(1); 58 } 59 60 int new_vers_id = 1; 61 queries[1].execute(); 63 rs = queries[1].fetchResultSet(); 64 if (rs != null && rs.next()) 65 { 66 new_vers_id = rs.getInt(1) + 1; 67 } 68 69 queries[2].setQueryParams("VERSION_ID", new Integer (new_vers_id)); 74 queries[2].setQueryParams("INSTANCE_ID", 75 queryParams.get("INSTANCE_ID")); 76 queries[2].setQueryParams("CONTENT_ID", new Integer (cont_id)); 77 queries[2].setQueryParams("STATUS_ID", 78 queryParams.get("STATUS_ID")); 79 queries[2].setQueryParams("DATE", 80 new java.sql.Timestamp (System. 81 currentTimeMillis 82 ())); 83 queries[2].setQueryParams("VERS_INFO", 84 queryParams.get("VERS_INFO")); 85 queries[2].setQueryParams("VERS_AUTHOR", 86 queryParams.get("VERS_AUTHOR")); 87 queries[2].execute(); 88 89 if (isNotOpen) 90 { 91 aTKDBConnection.commitTransaction(); } 93 94 } 95 catch(Throwable t) 96 { 97 TKDBManager.safeRollbackTransaction(t); 98 } 99 return hasResults(); 100 } 101 102 public void initQuery(Connection con) 103 { 104 super.initQuery(con, ISPREPARED, ORDER, TYPES, SETRELEVANTS, null); 105 } 106 } 107 | Popular Tags |