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