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 ProfileInsert 19 extends TKExtendedPrepQuery 20 { 21 22 24 public static final String [] ORDER = 25 { 26 "WM_PROFILE_ID", 27 "WM_USER_ID" 28 }; 29 30 public static final Object [][] TYPES = 31 { 32 {"WM_PROFILE_ID", new Integer (Types.INTEGER)}, 33 {"WM_USER_ID", new Integer (Types.INTEGER)} 34 }; 35 36 public static final boolean[] RELEVANTS = 37 { 38 true 39 }; 40 41 47 48 public static final String SQL = null; 49 50 51 protected static Class [] queryClasses = {SelectIDWMProfile.class, InsertWMProfile.class }; 52 53 55 public boolean execute() { 56 try { 57 init(queryClasses); 58 59 boolean isNotOpen = aTKDBConnection.isAutoCommit(); 60 if (isNotOpen) { aTKDBConnection.beginTransaction(); } 61 queries[0].setQueryParams("WM_PROFILE_ID", queryParams.get("WM_PROFILE_ID")); 62 queries[0].execute(); ResultSet rs = queries[0].fetchResultSet(); 64 Integer priority = null; 65 if (rs != null && rs.next()) { 66 int max = 1; 67 max = rs.getInt(1) + 1; priority = new Integer (max); 69 } 70 71 queries[1].setQueryParams("PRIORITY", priority); 72 queries[1].setQueryParams("WM_PROFILE_ID", queryParams.get("WM_PROFILE_ID")); 73 queries[1].setQueryParams("WM_USER_ID", queryParams.get("WM_USER_ID")); 74 queries[1].execute(); 76 if (isNotOpen) { aTKDBConnection.commitTransaction(); } 77 78 } 79 catch (SQLException sqle) { 80 WebmanExceptionHandler.getException(sqle); 81 try { 82 aTKDBConnection.rollbackTransaction(); 83 } 84 catch (SQLException sqle2) { 85 WebmanExceptionHandler.getException(sqle2); 86 } 87 } 88 finally { 89 return hasResults(); 90 } 91 } 92 93 public void initQuery (Connection connection) 94 { 95 super.initQuery(connection, 96 true, 97 ORDER, 98 TYPES, 99 RELEVANTS, 100 SQL); 101 } 102 103 } 104 | Popular Tags |