1 chuck 1.1.2.3 //%2004////////////////////////////////////////////////////////////////////////
2 //
3 // Copyright (c) 2000, 2001, 2002 BMC Software, Hewlett-Packard Development
4 // Company, L. P., IBM Corp., The Open Group, Tivoli Systems.
5 // Copyright (c) 2004 BMC Software; Hewlett-Packard Development Company, L. P.;
6 // IBM Corp.; EMC Corporation, The Open Group.
7 //
8 // Permission is hereby granted, free of charge, to any person obtaining a copy
9 // of this software and associated documentation files (the "Software"), to
10 // deal in the Software without restriction, including without limitation the
11 // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
12 // sell copies of the Software, and to permit persons to whom the Software is
13 // furnished to do so, subject to the following conditions:
14 //
15 // THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN
16 // ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED
17 // "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
18 // LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
19 // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
20 // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
21 // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22 chuck 1.1.2.3 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23 //
24 //==============================================================================
25 //
26 // Authors: David Rosckes (rosckes@us.ibm.com)
27 // Bert Rivero (hurivero@us.ibm.com)
28 // Chuck Carmack (carmack@us.ibm.com)
29 // Brian Lucier (lucier@us.ibm.com)
30 //
31 // Modified By:
32 //
33 //%/////////////////////////////////////////////////////////////////////////////
34
|
35 humberto 1.1.2.1 #ifndef Pegasus_CQLSelectStatementRep_h
36 #define Pegasus_CQLSelectStatementRep_h
37
38 #include <Pegasus/Common/Config.h>
39 #include <Pegasus/CQL/SelectStatementRep.h>
40 #include <Pegasus/CQL/CQLChainedIdentifier.h>
41 #include <Pegasus/CQL/CQLIdentifier.h>
42 #include <Pegasus/CQL/Linkage.h>
43
44
45 PEGASUS_NAMESPACE_BEGIN
46
|
47 chuck 1.1.2.6 struct PropertyNode;
|
48 chuck 1.1.2.5
|
49 humberto 1.1.2.1 /**
50 This class is derived from the SelectStatement base class.
51 The purpose of this class is to perform the select statement operations for
52 CIM Query Language (CQL).
53
54 Notes on CQLSelectStatement class:
55
56 (A) Contains a CQLPredicate for the WHERE clause
57 (B) Contains an array of CQLIdentifiers for the SELECT projection
58 (C) Contains an array of classpaths from the FROM clause
59
60
61 */
62 class PEGASUS_CQL_LINKAGE CQLSelectStatementRep : public SelectStatementRep
63 {
64 public:
65
|
66 chuck 1.1.2.3 CQLSelectStatementRep();
67
|
68 humberto 1.1.2.1 /** This is the constructor for the CQLSelectStatement object.
69 The ctor requires 3 parameters:
70 query language (qlang) which is CQL,
71 the query itself,
72 and the name of the CIM namespace.
73 */
74 CQLSelectStatementRep(
75 /** The query language is needed so the
76 base class can retrieve the query language.
77 The class member variable where this data
78 is stored is located in the base SelectStatement
79 class.
80 */
|
81 chuck 1.1.2.3 String& inQlang,
|
82 humberto 1.1.2.1 /** input parameter containing the query string.
83 */
|
84 chuck 1.1.2.3 String& inQuery,
|
85 humberto 1.1.2.1
|
86 chuck 1.1.2.3 QueryContext* inCtx);
|
87 humberto 1.1.2.1
|
88 chuck 1.1.2.3 CQLSelectStatementRep(const CQLSelectStatementRep& rep);
|
89 humberto 1.1.2.2
|
90 chuck 1.1.2.3 ~CQLSelectStatementRep();
91
92 CQLSelectStatementRep& operator=(const CQLSelectStatementRep& cqlss);
93
|
94 humberto 1.1.2.1 /** Implements the evaluate method from the
95 base SelectStatement class.
96
97 */
98 Boolean evaluate(
99 /** The CIM instance that will be evaluated.
100 The CIMInstance object is not modified by this method.
101 */
|
102 chuck 1.1.2.3 const CIMInstance& inCI);
|
103 humberto 1.1.2.1
104
105 /** Implements the applyProjection method from the
106 base SelectStatement class.
107 */
|
108 chuck 1.1.2.3 void applyProjection(
|
109 humberto 1.1.2.1 /** Input the CIMInstance object in which to apply the
110 projection.
111 */
|
112 chuck 1.1.2.3 CIMInstance& inCI) throw(Exception);
|
113 humberto 1.1.2.1
114 /** Implements the validatedClass method from the
115 base SelectStatement class.
116 */
117 void validateClass(const CIMObjectPath& inClassName) throw(Exception);
118
119 /** Implements the validatedProperties method from the
120 base SelectStatement class.
121 */
122 void validateProperties() throw(Exception);
123
124 /** Returns an array of CIMObjectPath objects that are the
125 class paths from the select statement in the FROM list.
126 */
|
127 chuck 1.1.2.3 Array<CIMObjectPath> getClassPathList();
|
128 humberto 1.1.2.1
129 /** Returns the required properties from the combined SELECT and WHERE
130 clauses for the classname passed in.
131
132 If all the properties for the input classname are required, a null
133 CIMPropertyList is returned.
134 */
135 CIMPropertyList getPropertyList(
136 /** The input parameter className is one of the
137 classes from the FROM list.
138 */
139 const CIMObjectPath& inClassName);
140
141 /** Modifier. This method should not be called by the user (only by the
142 parser).
143 Appends a CQLIdentifier to an array of CIMObjectPaths from the FROM
144 statement.
145 */
146 void appendClassPath(
147 /**
148 */
149 humberto 1.1.2.1 const CQLIdentifier& inIdentifier);
150
151 /** Sets a predicate into this object. This method should only
152 be called by Bison.
153 */
154 void setPredicate(
155 // CQLOperation is an enum similar to the WQLOperation enum in CVS:
156 // enum CQLOperation
157 // {
158 // <,
159 // >,
160 // =,
161 // >=,
162 // <=,
163 // +,
164 // -,
165 // *,
166 // /,
167 // CQL_IS_NULL,
168 // CQL_IS_NOT_NULL,
169 // CQL_IS_A,
170 humberto 1.1.2.1 // CQL_LIKE
171 // };
172 CQLPredicate inPredicate);
173
174 /** This method calls QueryContext::insertClassPathAlias() to insert a
175 classpath-alias pair
176 into the hash table. The record is keyed by the class alias.
177
178 This method is used by Bison.
179
180 TODO: think about exceptions such as duplicate key.
181 */
182 void insertClassPathAlias(
183 /** The CQLIdentifier object that contains the class path.
184 */
185 const CQLIdentifier& inIdentifier,
186 /** The alias for the class.
187 */
188 String inAlias);
189
190 /** Appends a CQL chained identifier to the CQL identifier list. The user
191 humberto 1.1.2.1 should
192 not call this method; it should only be called by the Bison.
193 */
194 void appendSelectIdentifier(const CQLChainedIdentifier& x);
195
196 /** Appends a CQL Identifier to the where CQL identifier list. The user
197 should not call this method; it should only be called by Bison.
198
199 @param x the CQL identifier.
200 @return false if that identifier already exists.
201
202
203 Since the identifiers in the WHERE clause must be distinct,
204 a boolean is returned indicating if the identifier is not distinct.
205
206 TODO: THIS MAY BE NEEDED IN A FUTURE RELEASE.
207 NOT IMPLEMENTED IN PEGASUS V2.5
208 */
209 Boolean appendWhereIdentifier(
210 /** Input the chained CQL identifiers to append.
211 */
212 humberto 1.1.2.1 const CQLChainedIdentifier& x);
213
|
214 chuck 1.1.2.5 /**
215 Applies the class contexts from the FROM list to the identifiers
216 in the statement.
217 */
218 void applyContext();
219
220 /**
221 Normalizes the WHERE clause to disjunction of conjunctions.
222 */
223 void normalizeToDOC();
224
|
225 chuck 1.1.2.4 String toString();
226
227 void setHasWhereClause();
228
229 Boolean hasWhereClause();
230
231 void clear();
232
|
233 humberto 1.1.2.1 protected:
234 /**
235 // The list of CQL identifiers being selected. For example, see
236 "firstName",
237 // and "lastName" below.
238 //
239 // SELECT firstName, lastName
240 // FROM TargetClass
241 // WHERE ...
242 //
243 // NOTE: duplicate identifiers are not removed from the select list
244 // (e.g. SELECT firstName, firstName FROM...) results in a list of
245 // two identifiers
246 //
247
248 */
|
249 chuck 1.1.2.3 Array<CQLChainedIdentifier> _selectIdentifiers;
|
250 humberto 1.1.2.1
251 /**
252 // The unique list of CQL query identifiers appearing in the WHERE clause.
253 // Although a property may occur many times in the WHERE clause, it will
254 // only appear once in this list.
255 //
256
257 TODO: THIS MAY BE NEEDED IN A FUTURE RELEASE.
258 NOT IMPLEMENTED IN PEGASUS V2.5
259 */
|
260 chuck 1.1.2.3 Array<CQLChainedIdentifier> _whereIdentifiers;
|
261 humberto 1.1.2.1
|
262 chuck 1.1.2.4 Boolean _hasWhereClause;
263
|
264 humberto 1.1.2.1 private:
|
265 chuck 1.1.2.5
|
266 chuck 1.1.2.6 void applyProjection(PropertyNode* node, CIMProperty& nodeProp);
|
267 chuck 1.1.2.5
268 void removeUnneededProperties(CIMInstance& inst,
269 Array<CIMName>& requiredProps);
270
271 void validateProperty(CQLChainedIdentifier& chainId);
272
273 CIMName lookupFromClass(const String& lookup);
274
275 Boolean addRequiredProperty(Array<CIMName>& reqProps,
276 CIMClass& theClass,
277 CQLChainedIdentifier& chainId);
278
279 Boolean containsProperty(const CIMName& name,
280 const Array<CIMName>& props);
281
282 Boolean isSubClass(const CIMName& derived,
283 const CIMName& base);
284
|
285 humberto 1.1.2.1 CQLPredicate _predicate;
286 };
287
288 PEGASUS_NAMESPACE_END
289
290 #endif
|