/**
  * @param IOpenStackImplementationApiCoverage $capability
  * @return array
  */
 public static function convertCapabilityToArray(IOpenStackImplementationApiCoverage $capability)
 {
     $res = array();
     $res['id'] = $capability->getIdentifier();
     $release_api_version = $capability->getReleaseSupportedApiVersion();
     if ($release_api_version->ID === 0) {
         return null;
     }
     $res['component_id'] = $release_api_version->getOpenStackComponent()->getIdentifier();
     $res['supports_versioning'] = $release_api_version->getOpenStackComponent()->getSupportsVersioning();
     $res['release_id'] = $release_api_version->getRelease()->getIdentifier();
     $res['version_id'] = $release_api_version->getApiVersion()->getIdentifier();
     $res['version_name'] = $release_api_version->getApiVersion()->getVersion();
     $res['coverage'] = $capability->getCoveragePercent();
     return $res;
 }
 protected function registerCapability(IOpenStackImplementation $implementation, IOpenStackImplementationApiCoverage $capability)
 {
     //check release
     $release = $this->release_repository->getById($capability->getReleaseSupportedApiVersion()->getRelease()->getIdentifier());
     if (!$release) {
         throw new NotFoundEntityException('', '');
     }
     //check component
     $component = $this->component_repository->getById($capability->getReleaseSupportedApiVersion()->getOpenStackComponent()->getIdentifier());
     if (!$component) {
         throw new NotFoundEntityException('', '');
     }
     if (!$release->supportsComponent($component->getCodeName())) {
         throw new InvalidAggregateRootException('', '', '', '');
     }
     if ($component->getSupportsVersioning()) {
         //check api version
         $api_version = $this->api_version_repository->getByIdAndComponent($capability->getReleaseSupportedApiVersion()->getApiVersion()->getIdentifier(), $component->getIdentifier());
         if (!$api_version) {
             throw new NotFoundEntityException('', '');
         }
     } else {
         $api_version = $capability->getReleaseSupportedApiVersion()->getApiVersion();
         $api_version->setReleaseComponent($component);
     }
     $release_supported_api = $release->supportsApiVersion($api_version);
     if (!$release_supported_api) {
         throw new InvalidAggregateRootException('', '', '', '');
     }
     $capability->setReleaseSupportedApiVersion($release_supported_api);
     $implementation->addCapability($capability);
 }