01: /*
02: * $Header: /cvsroot/webman-cms/source/webman/com/teamkonzept/publishing/markups/db/queries/TKMarkupDefinitionNew.java,v 1.6 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.WebmanExceptionHandler;
12:
13: public class TKMarkupDefinitionNew extends CompositeQuery {
14:
15: TKQuery selectMax = null;
16: TKQuery insert = null;
17: TKQuery select = null;
18: Integer attributeId = null;
19:
20: protected void initConcreteCompositeQuery() throws SQLException {
21: selectMax = registerQuery(SelectMaxTextAttribute.class);
22: insert = registerQuery(InsertTextAttribute.class);
23: select = registerQuery(SelectTextAttribute.class);
24: }
25:
26: protected boolean beforeExecution(int i) {
27: try {
28: if (getQuery(i) == insert) {
29: ResultSet rs = selectMax.fetchResultSet();
30: int attrId = 1;
31: if (rs != null && rs.next()) {
32: attrId = rs.getInt(1) + 1;
33: }
34: attributeId = new Integer(attrId);
35: insert.setQueryParams("ATTRIBUTE_ID", attributeId);
36: select.setQueryParams("ATTRIBUTE_ID", attributeId);
37: }
38: } catch (SQLException sqle) {
39: WebmanExceptionHandler.getException(sqle);
40: }
41: return true;
42: }
43:
44: }
|