001: package de.webman.form.db.queries;
002:
003: import java.sql.Connection;
004: import com.teamkonzept.db.TKPrepQuery;
005: import de.webman.form.db.FieldAttributeConstants;
006: import de.webman.form.db.FormConstants;
007:
008: /**
009: * Selects all forms referenced by the specified form definition.
010: * <TABLE>
011: * <TR>
012: * <TD><B>Order</B></TD>
013: * <TD><B>Name</B></TD>
014: * <TD><B>Type</B></TD>
015: * </TR>
016: * <TR>
017: * <TD COLSPAN="3"><I>Parameters</I></TD>
018: * </TR>
019: * <TR>
020: * <TD><TT>1</TT></TD>
021: * <TD><TT>de.webman.form.db.FormConstants.FORM_ID</TT></TD>
022: * <TD><TT>java.lang.Integer</TT></TD>
023: * </TR>
024: * <TR>
025: * <TD COLSPAN="3"><I>Results</I></TD>
026: * </TR>
027: * <TR>
028: * <TD><TT>1</TT></TD>
029: * <TD><TT>de.webman.form.db.FormConstants.FORM_ID</TT></TD>
030: * <TD><TT>java.lang.Integer</TT></TD>
031: * </TR>
032: * </TABLE>
033: *
034: * @author $Author: uli $
035: * @version $Revision: 1.2 $
036: */
037: public class SelectReferencedForms extends TKPrepQuery {
038:
039: // Constants.
040:
041: /**
042: * The preparation state.
043: */
044: private final static boolean IS_PREPARED = true;
045:
046: /**
047: * The parameter order.
048: */
049: private final static String[] PARAMETER_ORDER = { FieldAttributeConstants.COLUMN_NAMES[FieldAttributeConstants.VALUE] };
050:
051: /**
052: * The parameter types.
053: */
054: private final static Object[][] PARAMETER_TYPES = { {
055: FieldAttributeConstants.COLUMN_NAMES[FieldAttributeConstants.VALUE],
056: FieldAttributeConstants.COLUMN_TYPES[FieldAttributeConstants.VALUE] } };
057:
058: /**
059: * The relevance state.
060: */
061: private final static boolean[] SET_RELEVANTS = { true };
062:
063: /**
064: * The SQL statement.
065: */
066: private final static String SQL_STRING = "SELECT DISTINCT FORM_ID "
067: + "FROM FIELD_ATTRIBUTE " + "WHERE NAME = 'FORM_ID' "
068: + "AND VALUE = ?";
069:
070: // Implementation of 'com.teamkonzept.db.TKQuery'
071:
072: /**
073: * Initializes the query with the given connection.
074: *
075: * @param connection the connection.
076: */
077: public void initQuery(Connection connection) {
078: super .initQuery(connection, IS_PREPARED, PARAMETER_ORDER,
079: PARAMETER_TYPES, SET_RELEVANTS, SQL_STRING);
080: }
081:
082: /**
083: * Sets a query parameter.
084: *
085: * @param name the parameter name.
086: * @param value the parameter value.
087: */
088: public final void setQueryParams(String name, Object value) {
089: if (FormConstants.COLUMN_NAMES[FormConstants.FORM_ID]
090: .equals(name)) {
091: super
092: .setQueryParams(
093: FieldAttributeConstants.COLUMN_NAMES[FieldAttributeConstants.VALUE],
094: value != null ? value.toString()
095: : (String) null);
096: } else {
097: super.setQueryParams(name, value);
098: }
099: }
100:
101: }
|