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

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2