Example #1
0
 /**
  * Creates an instance of KeyDescriptor by parsing a key predicate, also 
  * validates the KeyDescriptor
  * 
  * @param string       $segment      The uri segment in the form identifier
  *                                   (keyPredicate)
  * @param ResourceType $resourceType The Resource type whose keys need to 
  *                                   be parsed
  * @param string       $keyPredicate The key predicate to parse and generate 
  *                                   KeyDescriptor for
  * 
  * @return KeyDescriptor Describes the key values in the $keyPredicate
  * 
  * @throws ODataException Exception if any error occurs while parsing and 
  *                                  validating the key predicate
  */
 private function _createKeyDescriptor($segment, ResourceType $resourceType, $keyPredicate)
 {
     /**
      * @var KeyDescriptor
      */
     $keyDescriptor = null;
     if (!KeyDescriptor::tryParseKeysFromKeyPredicate($keyPredicate, $keyDescriptor)) {
         ODataException::createSyntaxError(Messages::syntaxError());
     }
     // Note: Currenlty WCF Data Service does not support multiple
     // 'Positional values' so Order_Details(10248, 11) is not valid
     if (!$keyDescriptor->isEmpty() && !$keyDescriptor->areNamedValues() && $keyDescriptor->valueCount() > 1) {
         ODataException::createSyntaxError(Messages::segmentParserKeysMustBeNamed($segment));
     }
     try {
         $keyDescriptor->validate($segment, $resourceType);
     } catch (ODataException $exception) {
         throw $exception;
     }
     return $keyDescriptor;
 }