1 package de.webman.acl.db.queries; 2 3 import java.sql.Connection ; 4 import java.sql.SQLException ; 5 import java.sql.ResultSet ; 6 import java.sql.Types ; 7 import com.teamkonzept.webman.mainint.WebmanExceptionHandler; 8 import com.teamkonzept.db.*; 9 import com.teamkonzept.webman.mainint.db.queries.accesscontrol.*; 10 11 18 public class ActionInsert 19 extends TKExtendedPrepQuery 20 { 21 22 24 public static final String [] ORDER = 25 { 26 "NAME" 27 }; 28 29 public static final Object [][] TYPES = 30 { 31 {"NAME", new Integer (Types.VARCHAR)} 32 }; 33 34 public static final boolean[] RELEVANTS = 35 { 36 true 37 }; 38 39 public static final String SQL = null; 40 41 protected static Class [] queryClasses = { 42 SelectIDWMAction.class, InsertWMAction.class, SelectWMAction.class }; 46 47 52 53 54 56 public boolean execute() { 57 try { 58 init(queryClasses); 59 60 boolean isNotOpen = aTKDBConnection.isAutoCommit(); 61 if (isNotOpen) { 62 aTKDBConnection.beginTransaction(); 63 } 64 65 queries[0].execute(); 67 ResultSet rs = queries[0].fetchResultSet(); 68 Integer wmActionId = null; 69 if (rs != null && rs.next()) { 70 int max = 1; 71 max = rs.getInt(1) + 1; wmActionId = new Integer (max); 73 } 74 75 queries[1].setQueryParams("WM_ACTION_ID", wmActionId); 76 queries[1].setQueryParams("NAME", queryParams.get("NAME")); 77 queries[1].execute(); 79 queries[2].setQueryParams("WM_ACTION_ID", wmActionId); 80 queries[2].execute(); 81 addResult(queries[2].fetchResultSet()); 83 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 |