01: /*
02: * $Header: /cvsroot/webman-cms/source/webman/com/teamkonzept/publishing/markups/db/queries/TKMarkupPropPut.java,v 1.8 2001/11/06 16:18:36 markus Exp $
03: *
04: */
05: package com.teamkonzept.publishing.markups.db.queries;
06:
07: import java.sql.*;
08:
09: import com.teamkonzept.db.*;
10: import com.teamkonzept.webman.mainint.db.queries.markups.*;
11: import com.teamkonzept.webman.mainint.db.queries.properties.*;
12:
13: import org.apache.log4j.Category;
14:
15: public class TKMarkupPropPut extends CompositeQuery {
16:
17: static final Category CAT = Category
18: .getInstance(TKMarkupPropPut.class.getName());
19:
20: TKQuery insert1 = null;
21: TKQuery insert2 = null;
22: TKQuery insert3 = null;
23:
24: protected void initConcreteCompositeQuery() throws SQLException {
25: registerQuery(DeleteProperty1.class);
26: registerQuery(DeleteProperty2.class);
27: registerQuery(DeleteProperty3.class);
28: insert1 = registerQuery(InsertProperty1.class);
29: insert2 = registerQuery(InsertProperty2.class);
30: insert3 = registerQuery(InsertProperty3.class);
31: }
32:
33: public boolean beforeExecution(int i) {
34: TKQuery q = getQuery(i);
35: if (q.equals(insert1)) {
36: try {
37: TKQuery selectMax = TKDBManager
38: .newQuery(SelectMaxProperty.class);
39: selectMax.execute();
40: ResultSet rs = selectMax.fetchResultSet();
41: int max = 0;
42: if (rs != null && rs.next()) {
43: max = rs.getInt(1);
44: }
45: CAT.debug("max property: " + max);
46: insert1
47: .setQueryParams("PROPERTY_MAX",
48: new Integer(max));
49: insert2.setQueryParams("PROPERTY_MAX", new Integer(
50: max + 1));
51: insert3.setQueryParams("PROPERTY_MAX", new Integer(
52: max + 2));
53: } catch (SQLException sqle) {
54: CAT
55: .error(
56: "Exception while retrieving max property value",
57: sqle);
58: return false;
59: }
60: }
61: return true;
62: }
63:
64: }
|