01: /*
02: * $Header: /cvsroot/webman-cms/source/webman/com/teamkonzept/publishing/markups/db/TKMarkupParamDefinitionDBData.java,v 1.7 2001/06/11 09:14:10 alex Exp $
03: *
04: */
05: package com.teamkonzept.publishing.markups.db;
06:
07: import java.sql.*;
08:
09: import com.teamkonzept.db.*;
10: import com.teamkonzept.lib.*;
11: import com.teamkonzept.publishing.markups.*;
12: import org.apache.log4j.Category;
13:
14: public class TKMarkupParamDefinitionDBData extends TKDBData {
15: private static final Category cat = Category
16: .getInstance(TKMarkupParamDefinitionDBData.class);
17:
18: public TKMarkupParamDefinition param;
19:
20: public TKMarkupParamDefinitionDBData() {
21:
22: this .param = null;
23: }
24:
25: public TKMarkupParamDefinitionDBData(TKMarkupParamDefinition param,
26: StringBuffer diagnostics) {
27:
28: this .param = param;
29: }
30:
31: public void insertPrimaryIntoQuery(TKQuery query)
32: throws SQLException {
33:
34: query.setQueryParams("PARAMETER_ID", new Integer(param.id));
35: }
36:
37: public void insertInitialIntoQuery(TKQuery query)
38: throws SQLException {
39:
40: query.setQueryParams("NAME", param.name);
41: query.setQueryParams("SELECTION_DATA", param.data());
42: query.setQueryParams("SELECTION_CLASS_ID", new Integer(
43: param.typeClass == null ? -1 : param.typeClass.id));
44: query.setQueryParams("IS_CASE_SENSITIVE", new Integer(
45: param.isCaseSensitive ? 1 : 0));
46: query.setQueryParams("DEFAULT_VALUE", param.defaultValue());
47: }
48:
49: public void insertIntoQuery(TKQuery query) throws SQLException {
50:
51: insertPrimaryIntoQuery(query);
52: insertInitialIntoQuery(query);
53: }
54:
55: public static TKMarkupParamDefinition newParamFromResultSet(
56: ResultSet r) {
57:
58: try {
59: int id = r.getInt("PARAMETER_ID");
60: String name = r.getString("NAME");
61: String data = r.getString("SELECTION_DATA");
62: int typeClassId = r.getInt("SELECTION_CLASS_ID");
63: boolean isCaseSensitive = r.getBoolean("IS_CASE_SENSITIVE");
64: String defaultValue = r.getString("DEFAULT_VALUE");
65:
66: return new TKMarkupParamDefinition(id, name, typeClassId,
67: isCaseSensitive, defaultValue, data);
68:
69: } catch (Exception ex) {
70: cat
71: .error(
72: "TKMarkupParamDefinitionDBData.newParamFromResultSet() failed",
73: ex);
74: return null;
75: }
76: }
77:
78: public void fill(ResultSet r) throws SQLException {
79:
80: param = newParamFromResultSet(r);
81: }
82:
83: public String toString() {
84:
85: return "(MARKUP_PARAM_DEFINITION :=" + param + ")";
86: }
87: }
|