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