KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > medor > query > rdb > api > RdbExpQueryLeaf


1 /**
2  * MEDOR: Middleware Enabling Distributed Object Requests
3  *
4  * Copyright (C) 2001-2003 France Telecom R&D
5  * Contact: alexandre.lefebvre@rd.francetelecom.com
6  *
7  * This library is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public
9  * License as published by the Free Software Foundation; either
10  * version 2.1 of the License, or (at your option) any later version.
11  *
12  * This library is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with this library; if not, write to the Free Software
19  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20  *
21  * Initial developers: M. Alia, A. Lefebvre
22  */

23
24 package org.objectweb.medor.query.rdb.api;
25
26 import org.objectweb.jorm.type.api.PType;
27 import org.objectweb.medor.api.QueryLeafException;
28 import org.objectweb.medor.api.MedorException;
29 import org.objectweb.medor.query.api.FilteredQueryTree;
30 import org.objectweb.jorm.mapper.rdb.adapter.api.RdbAdapter;
31 import java.util.List JavaDoc;
32
33 /**
34  * An RdbExpQueryLeaf is a particular type of RdbQueryLeaf for which the
35  * associated SQL query if not given as a SQL String, but is computed from
36  * an Expression (representing the filter) and from abstract information
37  * made of QualifiedTables, representing the FROM part of the SQL query.
38  * <p>
39  * The Medor optimizer can "reason" about RdbExpQueryLeaves, and merge several
40  * such query leaves into one if they have the same DataStore.
41  * <p>
42  * The life cycle of an RdbExpQueryLeaf is:
43  * <ul><li>create the leaf (constructor)</li>
44  * <li>add the fields (addRdbField)</li>
45  * <li>add the expression which is built on the fields</li>
46  * </ul>
47  *
48  * A RdbExpQueryLeaf can use a RdbAdapter to build a SQL query. The Rdb Adapter
49  * permits to manage the relational databases that are not conform to the jdbc
50  * specification.
51  *
52  * @author <A HREF="mailto:alia.mourad@rd.francetelecom.com><b>
53  * Mourad Alia
54  * </b></A>
55  * <A HREF="mailto:alexandre.lefebvre@rd.francetelecom.com><b>
56  * Alexandre Lefebvre
57  * </b></A>
58  */

59 public interface RdbExpQueryLeaf extends RdbQueryLeaf, FilteredQueryTree {
60     /**
61      * Adds a Field to the RdbExpQueryLeaf
62      * @param fieldName is the name of the Field to be added.
63      * @param type is the PTyme of the Field to be added.
64      * @param colName is the name of the column in the associated
65      * QualifiedTable.
66      * @param table is the QualifiedTable from which the Field is to be created.
67      * @return the created RdbExpField.
68      * @throws QueryLeafException if the QualifiedTable is not in the
69      * set of QualifiedTables associatged with the current RdbExpQueryLeaf.
70      */

71     RdbExpField addRdbField(String JavaDoc fieldName,
72                             PType type,
73                             String JavaDoc colName,
74                             QualifiedTable table) throws QueryLeafException;
75
76     /**
77      * Adds an RdbExpField to the RdbExpQueryLeaf. The QueryLeaf associated
78      * to the RdbExpField becomes the current RdbExpQueryLeaf.
79      * @param rdbField is the RdbField to be added.
80      */

81     RdbExpField addRdbField(RdbExpField rdbField)
82         throws QueryLeafException;
83
84     /**
85      * Adds an RdbExpField to the RdbExpQueryLeaf. The QueryLeaf associated
86      * to the RdbExpField becomes the current RdbExpQueryLeaf.
87      * @param rdbField is the RdbField to be added.
88      */

89     void removeRdbField(RdbExpField rdbField)
90         throws QueryLeafException;
91
92     /**
93      * Adds a groupBy Field. This RdbExpField must be in The TupleStructure of
94      * this QueryLeaf Object.
95      * @param groupBy : RdbExpField
96      * @throws QueryLeafException if this RdbExpField doesn't appears in
97      * the list of the fields which will be projected in Select clause
98      */

99     void addGroupBy(RdbExpField groupBy) throws QueryLeafException;
100
101      /**
102      * Gets the RdbExpFields of the GroupBy Clause.
103      * It returns null if there is no Result Grouping
104      * @return an array of RdbExpField
105      */

106     RdbExpField[] getGroupByFields();
107
108     /**
109      * Returns the associated QualifiedTables.
110      * @return the array of associated QualifiedTables.
111      */

112     QualifiedTable[] getQualifiedTables();
113
114     /**
115      * Adds a QualifiedTable to the QueryLeaf
116      * @param qt the QualifiedTable to be added
117      */

118     void addQualifiedTable(QualifiedTable qt);
119
120     /**
121      * Adds a QualifiedTable to the QueryLeaf
122      * @param qt the QualifiedTable to be added
123      * @throws MedorException if the QualifiedTable in not in the current leaf.
124      */

125     void removeQualifiedTable(QualifiedTable qt)
126     throws MedorException;
127
128     /**
129      * Checks if a QualifiedTable is in the list of QualifiedTables of this
130      * QueryLeaf
131      * @param qt the QualifiedTable to be tested
132      * @return true if qt is in the list of QualifiedTables for this QueryLeaf
133      */

134     boolean containsQualifiedTable(QualifiedTable qt);
135
136     /**
137      * It assignes the rdb adapter name.
138      * The RdbAdapter is used to adapte the sql queries to a relational database
139      */

140     void setRdbAdapterName(String JavaDoc name);
141
142     /**
143      * It retrieves the rdb adapter name.
144      * The RdbAdapter is used to adapte the sql queries to a relational database
145      */

146     String JavaDoc getRdbAdapterName();
147
148     /**
149      * It assigns the rdb adapter.
150      * The RdbAdapter is used to adapt sql queries to a relational database
151      */

152     void setRdbAdapter(RdbAdapter adapter);
153
154     /**
155      * It retrieves the rdb adapter.
156      * The RdbAdapter is used to adapt sql queries to a relational database
157      */

158     RdbAdapter getRdbAdapter();
159
160     void setRootJoinedTables(List JavaDoc rootjts);
161
162     /**
163      * In case the SQL query was already computed, resets it to null.
164      */

165     void resetSqlRequest();
166     
167     /**
168      * Requires that the GROUP BY clause not be output by the getSqlRequest method.
169      * @param noGroupBy is true if no GROUP BY clause should be output (false by
170      * default).
171      */

172     void setNoGroupBy(boolean noGroupBy);
173     
174     /**
175      * Returns the GROUP BY clause of the query leaf.
176      * @return the GROUP BY clause of the query leaf.
177      */

178     String JavaDoc getGroupBy();
179 }
180
Popular Tags