(file) Return to WQLSelectStatementRep.cpp CVS log (file) (dir) Up to [Pegasus] / pegasus / src / Pegasus / WQL

  1 karl  1.11 //%2006////////////////////////////////////////////////////////////////////////
  2 chuck 1.1  //
  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) 2003 BMC Software; Hewlett-Packard Development Company, L.P.;
  6            // IBM Corp.; EMC Corporation, The Open Group.
  7            // Copyright (c) 2004 BMC Software; Hewlett-Packard Development Company, L.P.;
  8            // IBM Corp.; EMC Corporation; VERITAS Software Corporation; The Open Group.
  9 karl  1.2  // Copyright (c) 2005 Hewlett-Packard Development Company, L.P.; IBM Corp.;
 10            // EMC Corporation; VERITAS Software Corporation; The Open Group.
 11 karl  1.11 // Copyright (c) 2006 Hewlett-Packard Development Company, L.P.; IBM Corp.;
 12            // EMC Corporation; Symantec Corporation; The Open Group.
 13 chuck 1.1  //
 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.11 // 
 21 chuck 1.1  // 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            #include <iostream>
 35            #include <Pegasus/Common/Stack.h>
 36            #include "WQLSelectStatementRep.h"
 37            #include <Pegasus/Query/QueryCommon/QueryContext.h>
 38            #include <Pegasus/Query/QueryCommon/QueryException.h>
 39            #include "WQLInstancePropertySource.h"
 40            PEGASUS_USING_STD;
 41            
 42 chuck 1.1  PEGASUS_NAMESPACE_BEGIN
 43            
 44            template<class T>
 45            inline static Boolean _Compare(const T& x, const T& y, WQLOperation op)
 46            {
 47                switch (op)
 48                {
 49 karl  1.12         case WQL_EQ:
 50                        return x == y;
 51                
 52                    case WQL_NE:
 53                        return x != y;
 54                
 55                    case WQL_LT:
 56                        return x < y;
 57                    case WQL_LE:
 58                        return x <= y;
 59                
 60                    case WQL_GT:
 61                        return x > y;
 62                
 63                    case WQL_GE:
 64                        return x >= y;
 65                
 66                    default:
 67                        PEGASUS_ASSERT(0);
 68 chuck 1.1      }
 69            
 70 gs.keenan 1.6      return false;
 71 chuck     1.1  }
 72                
 73                static Boolean _Evaluate(
 74 david.dillard 1.3      const WQLOperand& lhs,
 75                        const WQLOperand& rhs,
 76 chuck         1.1      WQLOperation op)
 77                    {
 78                        switch (lhs.getType())
 79                        {
 80 karl          1.12         case WQLOperand::NULL_VALUE:
 81                            {
 82 dave.sudlik   1.10 #ifdef PEGASUS_SNIA_EXTENSIONS
 83                                return (rhs.getType() == WQLOperand::NULL_VALUE);
 84                    #else
 85 karl          1.12             // This cannot happen since expressions of the form
 86                                // OPERAND OPERATOR NULL are converted to unary form.
 87                                // For example: "count IS NULL" is treated as a unary
 88                                // operation in which IS_NULL is the unary operation
 89                                // and count is the the unary operand.
 90                        
 91                                PEGASUS_ASSERT(0);
 92                                break;
 93 dave.sudlik   1.10 #endif
 94 karl          1.12         }
 95 chuck         1.1  
 96 karl          1.12         case WQLOperand::INTEGER_VALUE:
 97                            {
 98                                return _Compare(
 99                                lhs.getIntegerValue(),
100                                rhs.getIntegerValue(),
101                                op);
102                            }
103                        
104                            case WQLOperand::DOUBLE_VALUE:
105                            {
106                                return _Compare(
107                                lhs.getDoubleValue(),
108                                rhs.getDoubleValue(),
109                                op);
110                            }
111                        
112                            case WQLOperand::BOOLEAN_VALUE:
113                            {
114                                return _Compare(
115                                lhs.getBooleanValue(),
116                                rhs.getBooleanValue(),
117 karl          1.12             op);
118                            }
119                        
120                            case WQLOperand::STRING_VALUE:
121                            {
122                                return _Compare(
123                                lhs.getStringValue(),
124                                rhs.getStringValue(),
125                                op);
126                            }
127                        
128                            default:
129                                PEGASUS_ASSERT(0);
130 chuck         1.1      }
131                    
132                        return false;
133                    }
134                    
135 kumpf         1.14 WQLSelectStatementRep::WQLSelectStatementRep(
136                        const String& queryLang,
137                        const String& query)
138 karl          1.12     :SelectStatementRep(queryLang,query)
139 chuck         1.1  {
140                        _operations.reserveCapacity(16);
141                        _operands.reserveCapacity(16);
142                    
143                        _allProperties = false;
144                    }
145                    
146 kumpf         1.14 WQLSelectStatementRep::WQLSelectStatementRep(
147                        const String& queryLang,
148                        const String& query,
149                        const QueryContext& inCtx)
150                        : SelectStatementRep(queryLang, query, inCtx)
151 chuck         1.1  {
152                        _operations.reserveCapacity(16);
153                        _operands.reserveCapacity(16);
154                    
155                        _allProperties = false;
156                    }
157                    
158                    WQLSelectStatementRep::WQLSelectStatementRep()
159 karl          1.12     :SelectStatementRep()
160 chuck         1.1  {
161                        //
162                        // Reserve space for a where clause with up to sixteen terms.
163                        //
164                    
165                        _operations.reserveCapacity(16);
166                        _operands.reserveCapacity(16);
167                    
168                        _allProperties = false;
169                    }
170                    
171                    WQLSelectStatementRep::WQLSelectStatementRep(const WQLSelectStatementRep& rep)
172 karl          1.12     : SelectStatementRep(rep),
173                        _className(rep._className),
174                        _allProperties(rep._allProperties),
175                        _selectPropertyNames(rep._selectPropertyNames),
176                        _wherePropertyNames(rep._wherePropertyNames),
177                        _operations(rep._operations),
178                        _operands(rep._operands)
179 chuck         1.1  {
180                    }
181                    
182                    WQLSelectStatementRep::~WQLSelectStatementRep()
183                    {
184                    
185                    }
186                    
187                    void WQLSelectStatementRep::clear()
188                    {
189                        _className.clear();
190                        _allProperties = false;
191                        _selectPropertyNames.clear();
192                        _operations.clear();
193                        _operands.clear();
194                    }
195                    
196                    Boolean WQLSelectStatementRep::getAllProperties() const
197                    {
198                        return _allProperties;
199                    }
200 chuck         1.1  
201                    void WQLSelectStatementRep::setAllProperties(const Boolean allProperties)
202                    {
203                        _allProperties = allProperties;
204                    }
205                    
206 kumpf         1.13 const CIMPropertyList WQLSelectStatementRep::getSelectPropertyList(
207                        const CIMObjectPath& inClassName) const
208 chuck         1.1  {
209                        //
210                        //  Check for "*"
211                        //
212                        if (_allProperties)
213                        {
214                            //
215                            //  Return null CIMPropertyList for all properties
216                            //
217                            return CIMPropertyList ();
218                        }
219 carolann.graves 1.4  
220                          CIMName className = inClassName.getClassName();
221                          if (className.isNull())
222                          {
223                              //
224 david.dillard   1.7          //  If the caller passed in an empty className, then the FROM class is
225 carolann.graves 1.4          //  to be used
226                              //
227                              className = _className;
228                          }
229                      
230                          //
231                          //  Check if inClassName is the FROM class
232                          //
233                          if (!(className == _className))
234 chuck           1.1      {
235                              //
236 carolann.graves 1.4          //  Check for NULL Query Context
237                              //
238                              if (_ctx == NULL)
239                              {
240                                  MessageLoaderParms parms
241                                      ("WQL.WQLSelectStatementRep.QUERY_CONTEXT_IS_NULL",
242                                      "Trying to process a query with a NULL Query Context.");
243 david.dillard   1.7              throw QueryRuntimeException(parms);
244 carolann.graves 1.4          }
245                      
246                              //
247                              //  Check if inClassName is a subclass of the FROM class
248 chuck           1.1          //
249 carolann.graves 1.4          if (!_ctx->isSubClass(_className,className))
250                              {
251                                  MessageLoaderParms parms
252                                      ("WQL.WQLSelectStatementRep.CLASS_NOT_FROM_LIST_CLASS",
253                                      "Class $0 does not match the FROM class or any of its "
254                                      "subclasses.",
255                                      className.getString());
256                                  throw QueryRuntimeException(parms);
257                              }
258 chuck           1.1      }
259 carolann.graves 1.4  
260                          //
261 david.dillard   1.7      //  Return CIMPropertyList for properties referenced in the projection
262 carolann.graves 1.4      //  list (SELECT clause)
263                          //
264                          return CIMPropertyList (_selectPropertyNames);
265 chuck           1.1  }
266                      
267 kumpf           1.13 const CIMPropertyList WQLSelectStatementRep::getWherePropertyList(
268                          const CIMObjectPath& inClassName) const
269 chuck           1.1  {
270 carolann.graves 1.4      CIMName className = inClassName.getClassName();
271                          if (className.isNull())
272                          {
273                              //
274 david.dillard   1.7          //  If the caller passed in an empty className, then the FROM class is
275 carolann.graves 1.4          //  to be used
276                              //
277                              className = _className;
278                          }
279                      
280                          //
281                          //  Check if inClassName is the FROM class
282                          //
283                          if (!(className == _className))
284                          {
285                              //
286                              //  Check for NULL Query Context
287                              //
288                              if (_ctx == NULL)
289                              {
290                                  MessageLoaderParms parms
291                                      ("WQL.WQLSelectStatementRep.QUERY_CONTEXT_IS_NULL",
292                                      "Trying to process a query with a NULL Query Context.");
293 david.dillard   1.7              throw QueryRuntimeException(parms);
294 carolann.graves 1.4          }
295                      
296                              //
297                              //  Check if inClassName is a subclass of the FROM class
298                              //
299                              if (!_ctx->isSubClass(_className,className))
300                              {
301                                  MessageLoaderParms parms
302                                      ("WQL.WQLSelectStatementRep.CLASS_NOT_FROM_LIST_CLASS",
303                                      "Class $0 does not match the FROM class or any of its "
304                                      "subclasses.",
305                                      className.getString());
306                                  throw QueryRuntimeException(parms);
307                              }
308                          }
309                      
310 chuck           1.1      //
311 david.dillard   1.3      //  Return CIMPropertyList for properties referenced in the condition
312 chuck           1.1      //  (WHERE clause)
313                          //  The list may be empty, but may not be NULL
314                          //
315                          return CIMPropertyList (_wherePropertyNames);
316                      }
317                      
318                      Boolean WQLSelectStatementRep::appendWherePropertyName(const CIMName& x)
319                      {
320                          //
321                          // Reject duplicate property names by returning false.
322                          //
323                      
324                          for (Uint32 i = 0, n = _wherePropertyNames.size(); i < n; i++)
325                          {
326 karl            1.12     if (_wherePropertyNames[i] == x)
327                              return false;
328 chuck           1.1      }
329                      
330                          //
331                          // Append the new property.
332                          //
333                      
334                          _wherePropertyNames.append(x);
335                          return true;
336                      }
337                      
338                      static inline void _ResolveProperty(
339                          WQLOperand& op,
340                          const WQLPropertySource* source)
341                      {
342                          //
343                          // Resolve the operand: if it's a property name, look up its value:
344                          //
345                      
346                          if (op.getType() == WQLOperand::PROPERTY_NAME)
347                          {
348 karl            1.12         const CIMName& propertyName = op.getPropertyName();
349                          
350                              if (!source->getValue(propertyName, op))
351                                  op = WQLOperand();
352 chuck           1.1      }
353                      }
354                      
355                      Boolean WQLSelectStatementRep::evaluateWhereClause(
356                          const WQLPropertySource* source) const
357                      {
358                          if (!hasWhereClause())
359 karl            1.12     return true;
360 chuck           1.1  
361                          Stack<Boolean> stack;
362                          stack.reserveCapacity(16);
363                      
364 david.dillard   1.3      //
365 chuck           1.1      // Counter for operands:
366                          //
367                      
368                          Uint32 j = 0;
369                      
370                          //
371                          // Process each of the operations:
372                          //
373                      
374                          for (Uint32 i = 0, n = _operations.size(); i < n; i++)
375                          {
376 kumpf           1.15     WQLOperation operation = _operations[i];
377 karl            1.12 
378 kumpf           1.15     switch (operation)
379 karl            1.12     {
380                              case WQL_OR:
381                              {
382                                  PEGASUS_ASSERT(stack.size() >= 2);
383                          
384 kumpf           1.15             Boolean operand1 = stack.top();
385 karl            1.12             stack.pop();
386                          
387 kumpf           1.15             Boolean operand2 = stack.top();
388 karl            1.12     
389 kumpf           1.15             stack.top() = operand1 || operand2;
390 karl            1.12             break;
391                              }
392 chuck           1.1  
393 karl            1.12         case WQL_AND:
394                              {
395                                  PEGASUS_ASSERT(stack.size() >= 2);
396                          
397 kumpf           1.15             Boolean operand1 = stack.top();
398 karl            1.12             stack.pop();
399                          
400 kumpf           1.15             Boolean operand2 = stack.top();
401 karl            1.12     
402 kumpf           1.15             stack.top() = operand1 && operand2;
403 karl            1.12             break;
404                              }
405                      
406                              case WQL_NOT:
407                              {
408                                  PEGASUS_ASSERT(stack.size() >= 1);
409                          
410 kumpf           1.15             Boolean operand = stack.top();
411                                  stack.top() = !operand;
412 karl            1.12             break;
413                              }
414                      
415                              case WQL_EQ:
416                              case WQL_NE:
417                              case WQL_LT:
418                              case WQL_LE:
419                              case WQL_GT:
420                              case WQL_GE:
421                              {
422                                  Array<WQLOperand> whereOperands(_operands);
423                                  PEGASUS_ASSERT(whereOperands.size() >= 2);
424                          
425                                  //
426                                  // Resolve the left-hand-side to a value (if not already
427                                  // a value).
428                                  //
429                          
430                                  WQLOperand& lhs = whereOperands[j++];
431                                  _ResolveProperty(lhs, source);
432                          
433 karl            1.12             //
434                                  // Resolve the right-hand-side to a value (if not already
435                                  // a value).
436                                  //
437                          
438                                  WQLOperand& rhs = whereOperands[j++];
439                                  _ResolveProperty(rhs, source);
440                          
441                                  //
442                                  // Check for a type mismatch:
443                                  //
444                          
445                                  // PEGASUS_OUT(lhs.toString());
446                                  // PEGASUS_OUT(rhs.toString());
447                          
448                                  if (rhs.getType() != lhs.getType())
449                                      throw TypeMismatchException();
450                          
451                                  //
452                                  // Now that the types are known to be alike, apply the
453                                  // operation:
454 karl            1.12             //
455                          
456 kumpf           1.15             stack.push(_Evaluate(lhs, rhs, operation));
457 karl            1.12             break;
458                              }
459                      
460                              case WQL_IS_TRUE:
461                              case WQL_IS_NOT_FALSE:
462                              {
463                                  PEGASUS_ASSERT(stack.size() >= 1);
464                                  break;
465                              }
466                      
467                              case WQL_IS_FALSE:
468                              case WQL_IS_NOT_TRUE:
469                              {
470                                  PEGASUS_ASSERT(stack.size() >= 1);
471                                  stack.top() = !stack.top();
472                                  break;
473                              }
474                      
475                              case WQL_IS_NULL:
476                              {
477                                  Array<WQLOperand> whereOperands(_operands);
478 karl            1.12             PEGASUS_ASSERT(whereOperands.size() >= 1);
479 kumpf           1.15             WQLOperand& operand = whereOperands[j++];
480                                  _ResolveProperty(operand, source);
481                                  stack.push(operand.getType() == WQLOperand::NULL_VALUE);
482 karl            1.12             break;
483                              }
484                      
485                              case WQL_IS_NOT_NULL:
486                              {
487                                  Array<WQLOperand> whereOperands(_operands);
488                                  PEGASUS_ASSERT(whereOperands.size() >= 1);
489 kumpf           1.15             WQLOperand& operand = whereOperands[j++];
490                                  _ResolveProperty(operand, source);
491                                  stack.push(operand.getType() != WQLOperand::NULL_VALUE);
492 karl            1.12             break;
493                              }
494                          }
495 chuck           1.1      }
496                      
497                          PEGASUS_ASSERT(stack.size() == 1);
498                          return stack.top();
499                      }
500                      
501 kumpf           1.9  template<class T>
502                      inline void wqlSelectStatementApplyProjection(
503                          T& object,
504                          Boolean allowMissing,
505                          const Array<CIMName>& selectPropertyNames)
506                      {
507                          for (int i=object.getPropertyCount(); i!=0; i--)
508                          {
509                              CIMName pn=object.getProperty(i-1).getName();
510                              Boolean foundInSel = false;
511                              for (int ii=0,mm=selectPropertyNames.size(); ii<mm; ii++)
512                              {
513                                  if (selectPropertyNames[ii]==pn)
514                                  {
515                                     foundInSel = true;
516                                     break;
517                                  }
518                              }
519                      
520                              if (!foundInSel)
521                              {
522 kumpf           1.9              object.removeProperty(i-1);
523                              }
524                          }
525                      
526                          //check for properties on select list missing from the instance
527                          if (!allowMissing)
528                          {
529                              Boolean foundInInst;
530                              for (Uint32 i=0; i < selectPropertyNames.size(); i++)
531                              {
532                                  foundInInst = false;
533                                  CIMName sn=selectPropertyNames[i];
534                                  for (Uint32 j = object.getPropertyCount(); j != 0; j--)
535                                  {
536                                      CIMName in = object.getProperty(j-1).getName();
537                                      if (sn == in) foundInInst = true;
538                                  }
539                      
540                                  if(!foundInInst)
541                                  {
542                                      MessageLoaderParms parms
543 kumpf           1.9                      ("WQL.WQLSelectStatementRep.MISSING_PROPERTY_ON_INSTANCE",
544                                          "A property in the Select list is missing from the "
545                                          "instance");
546                                      throw QueryRuntimePropertyException(parms);
547                                  }
548                              }
549                          }
550                      }
551                      
552 kumpf           1.13 void WQLSelectStatementRep::applyProjection(
553                          CIMInstance& ci,
554 david.dillard   1.7      Boolean allowMissing)
555 chuck           1.1  {
556 kumpf           1.9      if (_allProperties)
557                          {
558                              return;
559                          }
560                      
561                          wqlSelectStatementApplyProjection(ci, allowMissing, _selectPropertyNames);
562 chuck           1.8  }
563                      
564 kumpf           1.13 void WQLSelectStatementRep::applyProjection(
565                          CIMObject& ci,
566 chuck           1.8      Boolean allowMissing)
567                      {
568 kumpf           1.9      if (_allProperties)
569                          {
570                              return;
571                          }
572 chuck           1.1  
573 kumpf           1.9      wqlSelectStatementApplyProjection(ci, allowMissing, _selectPropertyNames);
574 chuck           1.1  }
575                      
576                      void WQLSelectStatementRep::print() const
577                      {
578                          //
579                          // Print the header:
580                          //
581 david.dillard   1.3  
582 chuck           1.1      cout << "WQLSelectStatement" << endl;
583                          cout << "{" << endl;
584                      
585                          //
586                          // Print the class name:
587                          //
588                      
589                          cout << "    _className: \"" << _className.getString() << '"' << endl;
590                      
591 david.dillard   1.3      //
592 chuck           1.1      // Print the select properties:
593                          //
594                      
595                          if (_allProperties)
596                          {
597                              cout << endl;
598                              cout << "    _allProperties: TRUE" << endl;
599                          }
600                      
601                          else for (Uint32 i = 0; i < _selectPropertyNames.size(); i++)
602                          {
603 karl            1.12     if (i == 0)
604                              cout << endl;
605 chuck           1.1  
606 karl            1.12     cout << "    _selectPropertyNames[" << i << "]: ";
607                          cout << '"' << _selectPropertyNames[i].getString() << '"' << endl;
608 chuck           1.1      }
609                      
610                          //
611                          // Print the operations:
612                          //
613                      
614                          for (Uint32 i = 0; i < _operations.size(); i++)
615                          {
616                              if (i == 0)
617                                  cout << endl;
618                      
619                              cout << "    _operations[" << i << "]: ";
620                              cout << '"' << WQLOperationToString(_operations[i]) << '"' << endl;
621                          }
622                      
623                          //
624                          // Print the operands:
625                          //
626                      
627                          for (Uint32 i = 0; i < _operands.size(); i++)
628                          {
629 chuck           1.1          if (i == 0)
630 karl            1.12         cout << endl;
631 chuck           1.1  
632 karl            1.12     cout << "    _operands[" << i << "]: ";
633                          cout << '"' << _operands[i].toString() << '"' << endl;
634 chuck           1.1      }
635                      
636                          //
637                          // Print the trailer:
638                          //
639                      
640                          cout << "}" << endl;
641                      }
642                      
643                      Boolean WQLSelectStatementRep::evaluate(const CIMInstance& inCI)
644                      {
645 karl            1.12     WQLInstancePropertySource source(inCI);
646                          return evaluateWhereClause(&source);
647 chuck           1.1  }
648 david.dillard   1.3  
649 david.dillard   1.7  void WQLSelectStatementRep::validate()
650 chuck           1.1  {
651 karl            1.12     if(_ctx == NULL){
652                              MessageLoaderParms parms(
653                                  "WQL.WQLSelectStatementRep.QUERY_CONTEXT_IS_NULL",
654                                  "Trying to process a query with a NULL Query Context.");
655 chuck           1.1        throw QueryValidationException(parms);
656                         }
657 karl            1.12     CIMClass fromClass;
658                          try
659 chuck           1.1     {
660                           fromClass = _ctx->getClass(_className);
661 david.dillard   1.7  
662 carolann.graves 1.4      CIMObjectPath className (String::EMPTY, _ctx->getNamespace (), _className);
663 david.dillard   1.7       Array<CIMName> whereProps =
664 carolann.graves 1.4          getWherePropertyList(className).getPropertyNameArray();
665 david.dillard   1.7       Array<CIMName> selectProps =
666 carolann.graves 1.4          getSelectPropertyList(className).getPropertyNameArray();
667 david.dillard   1.3  
668 carolann.graves 1.4       // make sure all properties match properties on the from class
669 chuck           1.1       for(Uint32 i = 0; i < whereProps.size(); i++){
670                               Uint32 index = fromClass.findProperty(whereProps[i]);
671 karl            1.12             if(index == PEG_NOT_FOUND){
672                                      MessageLoaderParms parms(
673                                          "WQL.WQLSelectStatementRep.PROP_NOT_FOUND",
674                                          "The property $0 was not found in the FROM class $1",
675                                          whereProps[i].getString(),
676                                          fromClass.getClassName().getString());
677 chuck           1.1              throw QueryMissingPropertyException(parms);
678 karl            1.12             }
679 chuck           1.1           else
680                               {
681                                 //
682                                 //  Property exists in class
683                                 //  Verify it is not an array property
684                                 //
685                                 CIMProperty classProperty = fromClass.getProperty(index);
686                                 if (classProperty.isArray ())
687                                 {
688 karl            1.12              MessageLoaderParms parms(
689                                       "WQL.WQLSelectStatementRep.WHERE_PROP_IS_ARRAY",
690                                       "Array property $0 is not supported in the WQL WHERE clause.",
691                                       whereProps[i].getString());
692 chuck           1.1               throw QueryValidationException(parms);
693                                 }
694                               }
695 karl            1.12         }
696 chuck           1.1  
697                           for(Uint32 i = 0; i < selectProps.size(); i++){
698                             if(fromClass.findProperty(selectProps[i]) == PEG_NOT_FOUND){
699 karl            1.12          MessageLoaderParms parms(
700                                   "WQL.WQLSelectStatementRep.PROP_NOT_FOUND",
701                                   "The property $0 was not found in the FROM class $1",
702                                   selectProps[i].getString(),
703                                   fromClass.getClassName().getString());
704 chuck           1.1           throw QueryMissingPropertyException(parms);
705                             }
706                           }
707                         }
708 david.dillard   1.3     catch (const CIMException& ce)
709 chuck           1.1     {
710                           if (ce.getCode() == CIM_ERR_INVALID_CLASS ||
711                               ce.getCode() == CIM_ERR_NOT_FOUND)
712                           {
713 karl            1.12        MessageLoaderParms parms(
714                                 "WQL.WQLSelectStatementRep.CLASSNAME_NOT_IN_REPOSITORY",
715                                 "The class name $0 was not found in the repository.",
716                                 _className.getString());
717 chuck           1.1         throw QueryValidationException(parms);
718                           }
719                           else
720                           {
721 david.dillard   1.3         throw;
722 chuck           1.1       }
723                         }
724                      }
725 david.dillard   1.3  
726 karl            1.12 CIMPropertyList WQLSelectStatementRep::getPropertyList(
727                              const CIMObjectPath& inClassName)
728 chuck           1.1  {
729 karl            1.12     if(_ctx == NULL){
730                              MessageLoaderParms parms(
731                                  "WQL.WQLSelectStatementRep.QUERY_CONTEXT_IS_NULL",
732                                  "Trying to process a query with a NULL Query Context.");
733 david.dillard   1.3        throw QueryRuntimeException(parms);
734 karl            1.12     }
735 chuck           1.1  
736 karl            1.12     if(_allProperties)
737 chuck           1.1       return CIMPropertyList();
738                      
739 karl            1.12     CIMName className = inClassName.getClassName();
740                          if (className.isNull())
741                          {
742 chuck           1.1       // If the caller passed in an empty className, then the
743                           // FROM class is to be used.
744                           className = _className;
745 karl            1.12     }
746 chuck           1.1  
747 karl            1.12     // check if inClassName is the From class
748                          if(!(className == _className)){
749                              // check if inClassName is a subclass of the From class
750                              if(!_ctx->isSubClass(_className,className)){
751                                  MessageLoaderParms parms(
752                                      "WQL.WQLSelectStatementRep.CLASS_NOT_FROM_LIST_CLASS",
753                                      "Class $0 does not match the FROM class or any of its"
754                                          " subclasses.",
755                                      className.getString());
756                                  throw QueryRuntimeException(parms);
757                              }
758                          }
759 chuck           1.1  
760 karl            1.12     Array<CIMName> names =
761 carolann.graves 1.4              getWherePropertyList(inClassName).getPropertyNameArray();
762 karl            1.12     Array<CIMName> selectList =
763 carolann.graves 1.4              getSelectPropertyList(inClassName).getPropertyNameArray();
764 david.dillard   1.7  
765 karl            1.12     // check for duplicates and remove them
766                          for(Uint32 i = 0; i < names.size(); i++){
767                              for(Uint32 j = 0; j < selectList.size(); j++){
768                                  if(names[i] == selectList[j])
769                                      selectList.remove(j);
770                                  }
771                          }
772                      
773                          names.appendArray(selectList);
774                          CIMPropertyList list = CIMPropertyList();
775                          list.set(names);
776                          return list;
777 chuck           1.1  }
778                      
779 kumpf           1.13 Array<CIMObjectPath> WQLSelectStatementRep::getClassPathList() const
780 chuck           1.1  {
781 karl            1.12     if(_ctx == NULL){
782                              MessageLoaderParms parms(
783                                  "WQL.WQLSelectStatementRep.QUERY_CONTEXT_IS_NULL",
784                                  "Trying to process a query with a NULL Query Context.");
785 chuck           1.1        throw QueryRuntimeException(parms);
786                         }
787 karl            1.12     CIMObjectPath path(String::EMPTY, _ctx->getNamespace(), _className);
788                          Array<CIMObjectPath> paths;
789                          paths.append(path);
790                          return paths;
791 chuck           1.1  }
792                      
793                      PEGASUS_NAMESPACE_END

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2