1 package de.webman.acl.db.queries; 2 3 import java.sql.Connection ; 4 import java.sql.Types ; 5 import java.sql.SQLException ; 6 import java.sql.ResultSet ; 7 import com.teamkonzept.db.*; 8 import com.teamkonzept.webman.mainint.db.queries.accesscontrol.*; 9 import com.teamkonzept.webman.mainint.WebmanExceptionHandler; 10 11 18 public class ContextInsert 19 extends TKExtendedPrepQuery 20 { 21 22 24 public static final String [] ORDER = 25 { 26 "NAME", 27 "SHORTCUT" 28 }; 29 30 public static final Object [][] TYPES = 31 { 32 {"NAME", new Integer (Types.VARCHAR)}, 33 {"SHORTCUT", new Integer (Types.VARCHAR)} 34 }; 35 36 public static final boolean[] RELEVANTS = 37 { 38 true 39 }; 40 41 46 47 public static final String SQL = null; 48 49 protected static Class [] queryClasses = { 50 SelectIDWMContext.class, InsertWMContext.class, SelectWMContext.class }; 54 55 57 public boolean execute() { 58 try { 59 init(queryClasses); 60 61 boolean isNotOpen = aTKDBConnection.isAutoCommit(); 62 if (isNotOpen) { 63 aTKDBConnection.beginTransaction(); 64 } 65 66 queries[0].execute(); ResultSet rs = queries[0].fetchResultSet(); 68 Integer wmContextId = null; 69 if (rs != null && rs.next()) { 70 int max = 1; 71 max = rs.getInt(1) + 1; wmContextId = new Integer (max); 73 } 74 75 queries[1].setQueryParams("WM_CONTEXT_ID", wmContextId); 76 queries[1].execute(); 78 queries[2].setQueryParams("WM_CONTEXT_ID", wmContextId); 79 queries[2].setQueryParams("NAME", queryParams.get("NAME")); 80 queries[2].setQueryParams("SHORTCUT", queryParams.get("SHORTCUT")); 81 queries[2].execute(); 82 addResult(queries[2].fetchResultSet()); if (isNotOpen) { 84 aTKDBConnection.commitTransaction(); 85 } 86 } 87 catch (SQLException sqle) { 88 WebmanExceptionHandler.getException(sqle); 89 try { 90 aTKDBConnection.rollbackTransaction(); 91 } 92 catch (SQLException sqle2) { 93 WebmanExceptionHandler.getException(sqle2); 94 } 95 } 96 finally { 97 return hasResults(); 98 } 99 } 100 101 public void initQuery (Connection connection) 102 { 103 super.initQuery(connection, 104 true, 105 ORDER, 106 TYPES, 107 RELEVANTS, 108 SQL); 109 } 110 111 } 112 | Popular Tags |