01: /*
02: * $Header: /cvsroot/webman-cms/source/webman/com/teamkonzept/webman/mainint/db/queries/Attic/TKDBPropGroupDelete.java,v 1.2 2001/08/15 13:16:28 markus Exp $
03: *
04: */
05: package com.teamkonzept.webman.mainint.db.queries;
06:
07: import java.sql.*;
08:
09: import com.teamkonzept.db.*;
10: import com.teamkonzept.webman.mainint.db.queries.properties.*;
11: import com.teamkonzept.webman.mainint.WebmanExceptionHandler;
12:
13: /*
14: * TKDBPropDelete
15: * input "PROP_NAME"
16: * output nada
17: * delete entry in PROPERTIES
18: */
19: public class TKDBPropGroupDelete extends TKExtendedPrepQuery {
20:
21: public final static boolean isPrepared = true;
22:
23: public final static String[] paramOrder = { "PROPGROUP_ID",
24: "PROPGROUP_ID" };
25:
26: public final static Object[][] paramTypes = { { "PROPGROUP_ID",
27: new Integer(Types.INTEGER) } };
28:
29: public final static boolean[] setRelevants = { true };
30:
31: /* public final static String sqlString =
32:
33: "BEGIN TRANSACTION " +
34:
35: "delete " +
36: "PROPERTY_GROUP_MEMBER " +
37: "where "+
38: " PROPERTY_GROUP_ID = ? " +
39:
40: "delete " +
41: "PROPERTY_GROUP " +
42: "where " +
43: " PROPERTY_GROUP_ID = ? " +
44:
45: "COMMIT TRANSACTION " ; */
46:
47: protected static Class[] queryClasses = {
48: DeletePropertyGroupMember.class, // [0]
49: DeletePropertyGroup.class // [1]
50: };
51:
52: public boolean execute() {
53: try {
54:
55: init(queryClasses); // init query objects
56:
57: // BEGIN TRANSACTION
58: boolean isNotOpen = aTKDBConnection.isAutoCommit();
59: if (isNotOpen) {
60: TKDBManager.beginTransaction(); // begin transaction
61: }
62:
63: Object propGroupId = queryParams.get("PROPGROUP_ID");
64: // NEW: DELETE PROPERTY_GROUP_MEMBER WHERE PROPERTY_GROUP_ID = ?
65: // PARAMS: PROPGROUP_ID
66: // CLASS: DeletePropertyGroupMember.class
67: // [0]
68: queries[0].setQueryParams("PROPGROUP_ID", propGroupId);
69: queries[0].execute();
70:
71: // DELETE PROPERTY_GROUP WHERE PROPERTY_GROUP_ID = ?
72: // PARAMS: PROPGROUP_ID
73: // CLASS: DeletePropertyGroup.class
74: // [1]
75: queries[1].setQueryParams("PROPGROUP_ID", propGroupId);
76: queries[1].execute();
77:
78: // COMMIT TRANSACTION
79: if (isNotOpen) {
80: aTKDBConnection.commitTransaction(); // commit all changes
81: }
82:
83: } catch (Throwable t) {
84: TKDBManager.safeRollbackTransaction(t);
85: }
86: return hasResults();
87: }
88:
89: public void initQuery(Connection con) {
90: super.initQuery(con, isPrepared, paramOrder, paramTypes,
91: setRelevants, sqlString);
92: }
93: }
|