1 karl 1.8 //%2006////////////////////////////////////////////////////////////////////////
|
2 chuck 1.2 //
|
3 karl 1.4 // Copyright (c) 2000, 2001, 2002 BMC Software; Hewlett-Packard Development
4 // Company, L.P.; IBM Corp.; The Open Group; Tivoli Systems.
5 // Copyright (c) 2003 BMC Software; Hewlett-Packard Development Company, L.P.;
|
6 chuck 1.2 // IBM Corp.; EMC Corporation, The Open Group.
|
7 karl 1.4 // Copyright (c) 2004 BMC Software; Hewlett-Packard Development Company, L.P.;
8 // IBM Corp.; EMC Corporation; VERITAS Software Corporation; The Open Group.
9 // Copyright (c) 2005 Hewlett-Packard Development Company, L.P.; IBM Corp.;
10 // EMC Corporation; VERITAS Software Corporation; The Open Group.
|
11 karl 1.8 // Copyright (c) 2006 Hewlett-Packard Development Company, L.P.; IBM Corp.;
12 // EMC Corporation; Symantec Corporation; The Open Group.
|
13 chuck 1.2 //
14 // Permission is hereby granted, free of charge, to any person obtaining a copy
15 // of this software and associated documentation files (the "Software"), to
16 // deal in the Software without restriction, including without limitation the
17 // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
18 // sell copies of the Software, and to permit persons to whom the Software is
19 // furnished to do so, subject to the following conditions:
|
20 karl 1.8 //
|
21 chuck 1.2 // THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN
22 // ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED
23 // "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
24 // LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
25 // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
26 // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
27 // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
28 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
29 //
30 //==============================================================================
31 //
32 //%/////////////////////////////////////////////////////////////////////////////
33
34 #ifndef Pegasus_CQLSelectStatement_h
35 #define Pegasus_CQLSelectStatement_h
36
|
37 david.dillard 1.7 #include <Pegasus/CQL/Linkage.h>
|
38 chuck 1.2 #include <Pegasus/Common/AutoPtr.h>
39 #include <Pegasus/Query/QueryCommon/SelectStatement.h>
40 #include <Pegasus/CQL/CQLChainedIdentifier.h>
41 #include <Pegasus/CQL/CQLPredicate.h>
42 #include <Pegasus/CQL/CQLIdentifier.h>
43
44
45 #ifdef PEGASUS_USE_EXPERIMENTAL_INTERFACES
46
47 PEGASUS_NAMESPACE_BEGIN
48
|
49 mike 1.9 class CQLSelectStatementRep;
|
50 chuck 1.2
|
51 david.dillard 1.6 /**
52 This class is derived from the SelectStatement base class.
|
53 chuck 1.2 The purpose of this class is to perform the select statement operations for
|
54 david.dillard 1.6 CIM Query Language (CQL).
|
55 chuck 1.3 */
|
56 chuck 1.2 class PEGASUS_CQL_LINKAGE CQLSelectStatement : public SelectStatement
57 {
58 public:
|
59 chuck 1.3
|
60 david.dillard 1.6 /**
|
61 chuck 1.3 Constructs a CQLSelectStatement default object.
|
62 david.dillard 1.6
|
63 chuck 1.3 <I><B>Experimental Interface</B></I><BR>
64 */
|
65 chuck 1.2 CQLSelectStatement();
66
|
67 david.dillard 1.6 /**
|
68 chuck 1.3 Constructs a CQLSelectStatement object.
|
69 david.dillard 1.6
|
70 chuck 1.3 @param inQlang - String containing the language of the query.
71 @param inQuery - String containing the query.
72 @param inCtx - Context in which the select statement is running.
73
74 <I><B>Experimental Interface</B></I><BR>
75 */
|
76 kumpf 1.12 CQLSelectStatement(
77 const String& inQlang,
78 const String& inQuery,
79 const QueryContext& inCtx);
|
80 chuck 1.3
|
81 david.dillard 1.6 /**
|
82 chuck 1.3 Constructs a CQLSelectStatement object.
|
83 david.dillard 1.6
|
84 chuck 1.3 @param inQlang - String containing the language of the query.
85 @param inQuery - String containing the query.
|
86 chuck 1.2
|
87 chuck 1.3 <I><B>Experimental Interface</B></I><BR>
88 */
|
89 kumpf 1.12 CQLSelectStatement(
90 const String& inQlang,
91 const String& inQuery);
|
92 chuck 1.2
|
93 david.dillard 1.6 /**
|
94 chuck 1.3 Copy constructs a CQLSelectStatement object.
|
95 david.dillard 1.6
|
96 chuck 1.3 @param statement - CQLSelectStatement to be copied.
97
98 <I><B>Experimental Interface</B></I><BR>
99 */
|
100 chuck 1.2 CQLSelectStatement(const CQLSelectStatement& statement);
101
|
102 david.dillard 1.6 /**
|
103 chuck 1.3 Destructs a CQLSelectStatement object.
|
104 david.dillard 1.6
|
105 chuck 1.3 <I><B>Experimental Interface</B></I><BR>
106 */
|
107 chuck 1.2 ~CQLSelectStatement();
108
|
109 david.dillard 1.6 /**
|
110 chuck 1.3 Assigns a CQLSelectStatement to this object.
|
111 david.dillard 1.6
|
112 chuck 1.3 @param rhs - CQLSelectStatement to be assigned to this object.
113 @return - Updated this object.
114 @throw - None.
115
116 <I><B>Experimental Interface</B></I><BR>
117 */
|
118 chuck 1.2 CQLSelectStatement& operator=(const CQLSelectStatement& rhs);
119
|
120 chuck 1.3 /**
|
121 david.dillard 1.6 Applies the class contexts from the FROM list to the
|
122 chuck 1.3 chained identifiers in the statement. This will transform
123 each chained identifier into a normalized form. The FROM
124 classname is prepended if needed, and all class aliases are resolved.
125
126 Note: there are cases where the FROM classname is not prepended.
|
127 david.dillard 1.6 This can occur for the classname on the right side of ISA,
|
128 chuck 1.3 or the classname at the beginning of a symbolic constant chained
129 identifier. Neither of these classnames need to be the FROM class.
|
130 david.dillard 1.6
|
131 chuck 1.3 This function also validates that each chained identifier
|
132 david.dillard 1.6 is well-formed. It is possible for a chained identifier
|
133 chuck 1.3 to be syntactically correct in the CQL language, but
|
134 david.dillard 1.6 cannot be processed by the CQL engine.
135
|
136 chuck 1.3 Pre-condition: QueryContext has been set into this object.
137 Post-condition: Chained identifiers have been normalized.
138
139 @throw CQLRuntimeException if the QueryContext had not been set.
140 @throw CQLValidationException if a chained identifier is not well formed.
|
141 karl 1.10 @throw CQLSyntaxErrorException if a chained identifier is not well
142 formed.
|
143 chuck 1.3
144 <I><B>Experimental Interface</B></I><BR>
145 */
146 void applyContext();
|
147 chuck 1.2
|
148 david.dillard 1.6 /**
|
149 chuck 1.3 Evaluates the WHERE clause of the select statement using
150 a CIM instance as the source of properties.
151
152 Pre-condition: QueryContext has been set into this object.
|
153 david.dillard 1.6 Post-condition: Chained identifiers have been normalized
|
154 chuck 1.3 ie.applyContext has been called. See the applyContext function.
|
155 david.dillard 1.6
|
156 chuck 1.3 @param inCI - The instance to be evaluated.
157 @return True, if the WHERE clause evaluates to true based on
158 the type of the instance and its properties.
159 @throw CQLRuntimeException if the instance cannot be evaluated
160 @throw CQLValidationException for applyContext error.
161 @throw CQLSyntaxErrorException for applyContext error.
162
163 <I><B>Experimental Interface</B></I><BR>
164 */
165 Boolean evaluate(const CIMInstance& inCI);
166
167 /**
168 Projects the properties in the SELECT list of the select
169 statement onto the instance. This involves checking that
|
170 david.dillard 1.6 all required properties exist on the instance passed in,
|
171 chuck 1.3 and removing any unneeded properties from that instance.
172
173 Pre-condition: QueryContext has been set into this object.
|
174 david.dillard 1.6 Post-condition: Chained identifiers have been normalized
|
175 chuck 1.3 ie.applyContext has been called. See the applyContext function.
176
177 @param inCI - The instance to be projected.
|
178 david.dillard 1.6 @param allowMissing indicates whether missing project properties are
|
179 carolann.graves 1.5 allowed
|
180 chuck 1.3 @throw CQLRuntimeException if the instance cannot be projected
181 @throw CQLValidationException for applyContext error.
182 @throw CQLSyntaxErrorException for applyContext error.
183
184 <I><B>Experimental Interface</B></I><BR>
185 */
|
186 david.dillard 1.6 void applyProjection(CIMInstance& inCI, Boolean allowMissing);
|
187 chuck 1.3
|
188 david.dillard 1.6 /**
|
189 chuck 1.3 Validates the classes and properties used in the select statement
190 against the class schema. The existence of classes and properties
191 are checked, along with class relationships defined in the CQL
192 specification.
193
194 Pre-condition: QueryContext has been set into this object.
|
195 david.dillard 1.6 Post-condition: Chained identifiers have been normalized
|
196 chuck 1.3 ie.applyContext has been called. See the applyContext function.
197
|
198 david.dillard 1.6 @throw CQLValidationException for applyContext error, the select
|
199 chuck 1.3 statement is invalid against the schema, or the QueryContext has
200 not been set.
201 @throw CQLSyntaxErrorException for applyContext error.
202
203 <I><B>Experimental Interface</B></I><BR>
204 */
|
205 david.dillard 1.6 void validate();
|
206 chuck 1.2
|
207 chuck 1.3 /**
|
208 david.dillard 1.6 Normalizes the predicates in the WHERE clause to a
|
209 chuck 1.3 disjunction of conjunctions.
|
210 chuck 1.2
|
211 david.dillard 1.6 Post-condition: Chained identifiers have been normalized
|
212 chuck 1.3 ie.applyContext has been called. See the applyContext function.
|
213 chuck 1.2
|
214 david.dillard 1.6 @param None
|
215 chuck 1.3 @return None
|
216 david.dillard 1.6 @throw None
|
217 chuck 1.2
|
218 chuck 1.3 <I><B>Experimental Interface</B></I><BR>
219 */
220 void normalizeToDOC();
|
221 chuck 1.2
|
222 david.dillard 1.6 /**
223 Returns an array of CIMObjectPath objects that are the
|
224 chuck 1.3 class paths in the FROM list of the select statement.
|
225 chuck 1.2
|
226 chuck 1.3 Note: Currently CQL only supports one class path in the
227 FROM list. This class path does not support WBEM-URI, so that
228 only the namespace and classname parts are filled in.
|
229 chuck 1.2
|
230 chuck 1.3 Pre-condition: QueryContext has been set into this object.
|
231 chuck 1.2
|
232 david.dillard 1.6 @param None
|
233 chuck 1.3 @return Array of FROM list class paths.
234 @throw CQLRuntimeException if the QueryContext had not been set.
|
235 chuck 1.2
|
236 chuck 1.3 <I><B>Experimental Interface</B></I><BR>
237 */
|
238 kumpf 1.11 Array<CIMObjectPath> getClassPathList() const;
|
239 chuck 1.2
|
240 david.dillard 1.6 /**
|
241 chuck 1.3 Returns the required properties from the combined SELECT and WHERE
242 clauses for the classname passed in. The classname parameter is
243 needed in case scoping operators are used in the select statement.
244 This function does not return properties for the classname if they
245 are required on embedded objects. This function does not return
246 required array indices.
|
247 david.dillard 1.6
|
248 chuck 1.3 Pre-condition: QueryContext has been set into this object.
|
249 david.dillard 1.6 Post-condition: Chained identifiers have been normalized
|
250 chuck 1.3 ie.applyContext has been called. See the applyContext function.
251
|
252 karl 1.10 @param inClassName - class to determine the required properties.
253 Defaults to the FROM class.
|
254 chuck 1.3 @return CIMPropertyList containing the required properties for the class.
255 If all the properties are required, a null CIMPropertyList is returned.
256 If no properties are required, an empty CIMPropertyList is returned.
257 @throw CQLRuntimeException if the QueryContext had not been set.
258 @throw CQLValidationException for applyContext error.
259 @throw CQLSyntaxErrorException for applyContext error.
260
261 <I><B>Experimental Interface</B></I><BR>
262 */
|
263 karl 1.10 CIMPropertyList getPropertyList(
|
264 kumpf 1.11 const CIMObjectPath& inClassName = CIMObjectPath());
|
265 chuck 1.3
|
266 david.dillard 1.6 /**
|
267 chuck 1.3 Returns the required properties from the SELECT clause for the
268 classname passed in. The classname parameter is needed in case
269 scoping operators are used in the select statement. This function
270 does not return properties for the classname if they are required
|
271 karl 1.10 on embedded objects. This function does not return required
272 array indices.
|
273 david.dillard 1.6
|
274 chuck 1.3 Pre-condition: QueryContext has been set into this object.
|
275 david.dillard 1.6 Post-condition: Chained identifiers have been normalized
|
276 chuck 1.3 ie.applyContext has been called. See the applyContext function.
277
|
278 karl 1.10 @param inClassName - class to determine the required properties.
279 Defaults to the FROM class.
|
280 chuck 1.3 @return CIMPropertyList containing the required properties for the class.
281 If all the properties are required, a null CIMPropertyList is returned.
282 If no properties are required, an empty CIMPropertyList is returned.
283 @throw CQLRuntimeException if the QueryContext had not been set.
284 @throw CQLValidationException for applyContext error.
285 @throw CQLSyntaxErrorException for applyContext error.
286
287 <I><B>Experimental Interface</B></I><BR>
288 */
|
289 karl 1.10 CIMPropertyList getSelectPropertyList(
|
290 kumpf 1.11 const CIMObjectPath& inClassName = CIMObjectPath());
|
291 chuck 1.3
|
292 david.dillard 1.6 /**
|
293 chuck 1.3 Returns the required properties from the WHERE clause for the
294 classname passed in. The classname parameter is needed in case
295 scoping operators are used in the select statement. This function
296 does not return properties for the classname if they are required
|
297 karl 1.10 on embedded objects. This function does not return required array
298 indices.
|
299 david.dillard 1.6
|
300 chuck 1.3 Pre-condition: QueryContext has been set into this object.
|
301 david.dillard 1.6 Post-condition: Chained identifiers have been normalized
|
302 chuck 1.3 ie.applyContext has been called. See the applyContext function.
303
|
304 karl 1.10 @param inClassName - class to determine the required properties.
305 Defaults to the FROM class.
|
306 chuck 1.3 @return CIMPropertyList containing the required properties for the class.
307 If all the properties are required, a null CIMPropertyList is returned.
308 If no properties are required, an empty CIMPropertyList is returned.
309 @throw CQLRuntimeException if the QueryContext had not been set.
310 @throw CQLValidationException for applyContext error.
311 @throw CQLSyntaxErrorException for applyContext error.
312
313 <I><B>Experimental Interface</B></I><BR>
314 */
|
315 karl 1.10 CIMPropertyList getWherePropertyList(
|
316 kumpf 1.11 const CIMObjectPath& inClassName = CIMObjectPath());
|
317 chuck 1.2
318 /**
|
319 chuck 1.3 Returns the chained identifiers from the SELECT clause. These chained
|
320 karl 1.10 identifiers contain the fully qualified property names, including
321 embedded objects, array indices, scoping operators,
322 and symbolic constants.
|
323 chuck 1.3
|
324 david.dillard 1.6 Post-condition: Chained identifiers have been normalized
|
325 chuck 1.3 ie.applyContext has been called. See the applyContext function.
326
327 @param None
328 @return Array of chained identifiers.
329 @throw CQLValidationException for applyContext error.
330 @throw CQLSyntaxErrorException for applyContext error.
331
332 <I><B>Experimental Interface</B></I><BR>
|
333 chuck 1.2 */
|
334 chuck 1.3 Array<CQLChainedIdentifier> getSelectChainedIdentifiers();
|
335 chuck 1.2
336 /**
|
337 chuck 1.3 Returns the chained identifiers from the WHERE clause. These chained
|
338 karl 1.10 identifiers contain the fully qualified property names, including
339 embedded objects, array indices, scoping operators,
340 and symbolic constants.
|
341 chuck 1.3
342 Pre-condition: QueryContext has been set into this object.
|
343 david.dillard 1.6 Post-condition: Chained identifiers have been normalized
|
344 chuck 1.3 ie.applyContext has been called. See the applyContext function.
345
346 @param None
347 @return Array of chained identifiers.
348 @throw CQLRuntimeException if the QueryContext had not been set.
|
349 david.dillard 1.6 @throw CQLValidationException for applyContext error.
|
350 chuck 1.3 @throw CQLSyntaxErrorException for applyContext error.
351
352 <I><B>Experimental Interface</B></I><BR>
|
353 chuck 1.2 */
|
354 chuck 1.3 Array<CQLChainedIdentifier> getWhereChainedIdentifiers();
355
|
356 david.dillard 1.6 /**
|
357 chuck 1.3 Gets the top-level CQLPredicate of this object.
358 This is the predicate that contains the top-level
359 of any nested boolean operations in the WHERE clause.
360
361 @param None.
362 @return Top-level predicate
363 @throw None.
364
365 <I><B>Experimental Interface</B></I><BR>
366 */
367 CQLPredicate getPredicate() const;
368
|
369 david.dillard 1.6 /**
|
370 chuck 1.3 Determines whether the select statement has a WHERE clause.
|
371 chuck 1.2
|
372 chuck 1.3 @param None
373 @return True if there is a WHERE clause.
374 @throw None
|
375 chuck 1.2
|
376 chuck 1.3 <I><B>Experimental Interface</B></I><BR>
377 */
|
378 kumpf 1.11 Boolean hasWhereClause() const;
|
379 chuck 1.2
|
380 david.dillard 1.6 /**
|
381 chuck 1.3 Returns the select statement in string form.
382 Note that this can be different than the original
383 statement after it has been parsed, and applyContext
384 has been called.
385
386 Pre-condition: QueryContext has been set into this object.
387
388 @param None
389 @return String containing the select statement.
|
390 david.dillard 1.6 @throw
|
391 chuck 1.3
392 <I><B>Experimental Interface</B></I><BR>
393 */
|
394 kumpf 1.11 String toString() const;
|
395 chuck 1.2
|
396 david.dillard 1.6 /*
|
397 chuck 1.3 ATTN - the following methods should only be set by CQLParser.
398 These should be made private, and CQLParser made a friend.
399 */
400
|
401 david.dillard 1.6 /**
|
402 chuck 1.3 Appends a CQLIdentifier/alias combination into the FROM list of the
403 statement. This method should only be called by the CQL parser.
404
405 @param inIdentifier - CQLIdentifier to append.
406 @param inAlias - Alias of the identifier.
407 @return None
408 @throw QueryException if the identifier/alias cannot be appended.
409
410 <I><B>Experimental Interface</B></I><BR>
411 */
|
412 kumpf 1.13 void insertClassPathAlias(
413 const CQLIdentifier& inIdentifier,
414 const String& inAlias);
|
415 chuck 1.3
|
416 david.dillard 1.6 /**
|
417 chuck 1.3 Appends a CQLIdentifier into the FROM list of the statement.
418 This method should only be called by the CQL parser.
419
420 @param inIdentifier - CQLIdentifier to append.
421 @return None
422 @throw QueryException if the identifier cannot be appended.
423
424 <I><B>Experimental Interface</B></I><BR>
425 */
426 void appendClassPath(const CQLIdentifier& inIdentifier);
427
|
428 david.dillard 1.6 /**
|
429 chuck 1.3 Appends a CQLChainedIdentifier to the select list.
430 This method should only be called by the CQL parser.
431
432 @param x - CQLChainedIdentifier to append.
433 @return None
434 @throw None
435
436 <I><B>Experimental Interface</B></I><BR>
437 */
438 void appendSelectIdentifier(const CQLChainedIdentifier& x);
439
440 /** Sets a predicate into this object. This method should only
441 be called by Bison.
442 */
|
443 david.dillard 1.6 /**
|
444 chuck 1.3 Sets the top-level CQLPredicate into this object.
445 This method should only be called by the CQL parser.
446
447 @param Predicate to set into this object.
448 @return None
449 @throw None.
450
451 <I><B>Experimental Interface</B></I><BR>
452 */
453 void setPredicate(const CQLPredicate& inPredicate);
454
|
455 david.dillard 1.6 /**
|
456 chuck 1.3 Sets the select statement to have a WHERE clause.
457 This method should only be called by the CQL parser.
458
459 @param None
460 @return None
461 @throw None
462
463 <I><B>Experimental Interface</B></I><BR>
464 */
465 void setHasWhereClause();
466
|
467 david.dillard 1.6 /**
|
468 chuck 1.3 Clears the internal data structures.
469 This method should only be called by the CQL parser.
470
471 Pre-condition: QueryContext has been set into this object.
472
473 @param None
474 @return None.
|
475 david.dillard 1.6 @throw CQLRuntimeException if the QueryContext had not been set.
|
476 chuck 1.3
477 <I><B>Experimental Interface</B></I><BR>
478 */
|
479 chuck 1.2 void clear();
480
481 private:
|
482 david.dillard 1.6 CQLSelectStatementRep* _rep;
|
483 chuck 1.2
484 };
485
486 PEGASUS_NAMESPACE_END
487 #endif
|
488 david.dillard 1.6 #endif
|