/**
  * Iterate over the resource type of the given resource set, 
  * derived resource types base resource types and complex types 
  * used in these resource types and cache them.
  * 
  * @param ResourceSetWrapper $resourceSetWrapper The resource set to inspect
  * 
  * @return void
  * 
  * @throws InvalidOperationException Throws exception in floowing cases:
  * (1) If IDSMP::getDerivedTypes returns any type other than null or array
  * (2) If Named streams are found on derived types
  */
 private function _populateResourceTypeForSet(ResourceSetWrapper $resourceSetWrapper)
 {
     $derivedTypes = $this->metadataQueryproviderWrapper->getDerivedTypes($resourceSetWrapper->getResourceType());
     if (!is_null($derivedTypes)) {
         if (!is_array($derivedTypes)) {
             throw new InvalidOperationException(Messages::metadataAssociationTypeSetInvalidGetDerivedTypesReturnType($resourceSetWrapper->getName()));
         }
         //Populate Resource type for derived types and
         //complex types in derived types
         foreach ($derivedTypes as $derivedType) {
             if ($derivedType->hasNamedStream()) {
                 throw new InvalidOperationException(Messages::metadataResourceTypeSetNamedStreamsOnDerivedEntityTypesNotSupported($resourceSetWrapper->getName(), $derivedType->getFullName()));
             }
             $this->_populateResourceTypes($derivedType);
             $this->_populateComplexTypes($derivedType);
         }
     }
     //Populate Resource type for for this type and
     //base types and complex types in this type and base types
     $resourceType = $resourceSetWrapper->getResourceType();
     while ($resourceType != null) {
         $this->_populateResourceTypes($resourceType);
         $this->_populateComplexTypes($resourceType);
         $resourceType = $resourceType->getBaseType();
     }
 }
 /**
  * Populate association set and type for the given resource (entity) set
  * 
  * @param ResourceSetWrapper $resourceSetWrapper The resource set to inspect
  * 
  * @return void
  * 
  * @throws InvalidOperationException If IDSMP::getDerivedTypes 
  * returns invalid type
  */
 private function _populateAssociationForSet(ResourceSetWrapper $resourceSetWrapper)
 {
     $derivedTypes = $this->metadataQueryproviderWrapper->getDerivedTypes($resourceSetWrapper->getResourceType());
     if (!is_null($derivedTypes)) {
         if (!is_array($derivedTypes)) {
             throw new InvalidOperationException(Messages::metadataAssociationTypeSetInvalidGetDerivedTypesReturnType($resourceSetWrapper->getName()));
         }
         //Populate ResourceAssociationSet and ResourceAssociationType
         //for derived types
         foreach ($derivedTypes as $derivedType) {
             $this->_populateAssociationForSetAndType($resourceSetWrapper, $derivedType);
         }
     }
     //Populate ResourceAssociationSet and ResourceAssociationType
     //for this type and base types
     $resourceType = $resourceSetWrapper->getResourceType();
     while ($resourceType != null) {
         $this->_populateAssociationForSetAndType($resourceSetWrapper, $resourceType);
         $resourceType = $resourceType->getBaseType();
     }
 }