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