KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > de > webman > form > db > queries > SelectReferencedForms


1 package de.webman.form.db.queries;
2
3 import java.sql.Connection JavaDoc;
4 import com.teamkonzept.db.TKPrepQuery;
5 import de.webman.form.db.FieldAttributeConstants;
6 import de.webman.form.db.FormConstants;
7
8 /**
9  * Selects all forms referenced by the specified form definition.
10  * <TABLE>
11  * <TR>
12  * <TD><B>Order</B></TD>
13  * <TD><B>Name</B></TD>
14  * <TD><B>Type</B></TD>
15  * </TR>
16  * <TR>
17  * <TD COLSPAN="3"><I>Parameters</I></TD>
18  * </TR>
19  * <TR>
20  * <TD><TT>1</TT></TD>
21  * <TD><TT>de.webman.form.db.FormConstants.FORM_ID</TT></TD>
22  * <TD><TT>java.lang.Integer</TT></TD>
23  * </TR>
24  * <TR>
25  * <TD COLSPAN="3"><I>Results</I></TD>
26  * </TR>
27  * <TR>
28  * <TD><TT>1</TT></TD>
29  * <TD><TT>de.webman.form.db.FormConstants.FORM_ID</TT></TD>
30  * <TD><TT>java.lang.Integer</TT></TD>
31  * </TR>
32  * </TABLE>
33  *
34  * @author $Author: uli $
35  * @version $Revision: 1.2 $
36  */

37 public class SelectReferencedForms
38     extends TKPrepQuery
39 {
40
41     // Constants.
42

43     /**
44      * The preparation state.
45      */

46     private final static boolean IS_PREPARED = true;
47
48     /**
49      * The parameter order.
50      */

51     private final static String JavaDoc[] PARAMETER_ORDER =
52     {
53         FieldAttributeConstants.COLUMN_NAMES[FieldAttributeConstants.VALUE]
54     };
55
56     /**
57      * The parameter types.
58      */

59     private final static Object JavaDoc[][] PARAMETER_TYPES =
60     {
61         {FieldAttributeConstants.COLUMN_NAMES[FieldAttributeConstants.VALUE], FieldAttributeConstants.COLUMN_TYPES[FieldAttributeConstants.VALUE]}
62     };
63
64     /**
65      * The relevance state.
66      */

67     private final static boolean[] SET_RELEVANTS =
68     {
69         true
70     };
71
72     /**
73      * The SQL statement.
74      */

75     private final static String JavaDoc SQL_STRING = "SELECT DISTINCT FORM_ID " +
76                                              "FROM FIELD_ATTRIBUTE " +
77                                              "WHERE NAME = 'FORM_ID' " +
78                                              "AND VALUE = ?";
79
80
81     // Implementation of 'com.teamkonzept.db.TKQuery'
82

83     /**
84      * Initializes the query with the given connection.
85      *
86      * @param connection the connection.
87      */

88     public void initQuery (Connection JavaDoc connection)
89     {
90         super.initQuery(connection,
91                         IS_PREPARED,
92                         PARAMETER_ORDER,
93                         PARAMETER_TYPES,
94                         SET_RELEVANTS,
95                         SQL_STRING);
96     }
97
98     /**
99      * Sets a query parameter.
100      *
101      * @param name the parameter name.
102      * @param value the parameter value.
103      */

104     public final void setQueryParams (String JavaDoc name, Object JavaDoc value)
105     {
106         if (FormConstants.COLUMN_NAMES[FormConstants.FORM_ID].equals(name))
107         {
108             super.setQueryParams(FieldAttributeConstants.COLUMN_NAMES[FieldAttributeConstants.VALUE],
109                                  value != null ? value.toString() : (String JavaDoc) null);
110         }
111         else
112         {
113             super.setQueryParams(name, value);
114         }
115     }
116
117 }
118
Popular Tags