public function getComponent()
 {
     $component_id = intval($this->request->param('COMPONENT_ID'));
     $res = $this->component_repository->getById($component_id);
     if (!$res) {
         return $this->notFound();
     }
     return $this->ok(self::convertComponentToArray($res));
 }
 protected function addCapability(array $capability_data, IOpenStackImplementation $implementation)
 {
     $validator = $this->validator_factory->buildValidatorForCapability($capability_data);
     if ($validator->fails()) {
         return $this->validationError($validator->messages());
     }
     $component = $this->component_repository->getById(intval($capability_data['component_id']));
     if (!$component) {
         throw new NotFoundEntityException('OpenStackComponent', sprintf('id %', intval($capability_data['component_id'])));
     }
     $release = $this->release_repository->getById(intval($capability_data['release_id']));
     if (!$release) {
         throw new NotFoundEntityException('OpenStackRelease', sprintf('id %', intval($capability_data['release_id'])));
     }
     if (!$release->supportsComponent($component->getCodeName())) {
         throw new NonSupportedComponent($release, $component);
     }
     $supported_version = null;
     if ($component->getSupportsVersioning()) {
         $version = $this->api_version_repository->getById(intval($capability_data['version_id']));
         if (!$version) {
             throw new NotFoundEntityException('OpenStackApiVersion', sprintf('id %', intval($capability_data['version_id'])));
         }
         $supported_version = $release->supportsApiVersion($version);
     } else {
         $supported_version = $this->supported_version_repository->getByReleaseAndComponentAndApiVersion(intval($capability_data['release_id']), intval($capability_data['component_id']), 0);
     }
     if (!$supported_version) {
         throw new NotFoundEntityException('OpenStackReleaseSupportedVersion', '');
     }
     $capability = $this->factory->buildCapability(intval($capability_data['coverage']), $supported_version, $implementation);
     $this->registerCapability($implementation, $capability);
 }
Ejemplo n.º 3
0
 public function ReleasesByComponent()
 {
     $res = array();
     $query = new QueryObject();
     list($list, $size) = $this->components_repository->getAll($query, 0, 999999);
     foreach ($list as $component) {
         $res2 = array();
         $releases = $component->getSupportedReleases();
         foreach ($releases as $release) {
             array_push($res2, array("id" => $release->getIdentifier(), "name" => $release->getName()));
         }
         $res[$component->getCodeName()] = $res2;
     }
     return json_encode($res);
 }
 /**
  * @param int $release_id
  * @param int $component_id
  * @return IOpenStackApiVersion[]
  * @throws NotFoundEntityException
  * @throws InvalidAggregateRootException
  */
 public function getReleaseSupportedVersionsByComponent($release_id, $component_id)
 {
     $release = $this->release_repository->getById($release_id);
     if (!$release) {
         throw new NotFoundEntityException('OpenStackRelease', sprintf('id %s', $release_id));
     }
     $component = $this->component_repository->getById($component_id);
     if (!$component) {
         throw new NotFoundEntityException('OpenStackComponent', sprintf('id %s', $component));
     }
     if (!$release->supportsComponent($component->getCodeName())) {
         throw new InvalidAggregateRootException('OpenStackRelease', $release_id, 'OpenStackComponent', $component_id);
     }
     $res = array();
     foreach ($this->version_repository->getByReleaseAndComponent($release_id, $component_id) as $version) {
         if ($release->supportsApiVersion($version)) {
             array_push($res, $version);
         }
     }
     return $res;
 }
 /**
  * @param ICompanyService $consultant
  * @param array $data
  * @return ICompanyService|void
  * @throws EntityValidationException
  * @throws NotFoundEntityException
  */
 protected function updateCollections(ICompanyService $consultant, array $data)
 {
     $consultant = parent::updateCollections($consultant, $data);
     //languages
     if (array_key_exists('languages_spoken', $data) && is_array($data['languages_spoken'])) {
         $languages_data = $data['languages_spoken'];
         $lang_order = 0;
         foreach ($languages_data as $language_name) {
             $language = $this->language_repository->getByName($language_name);
             if (!$language) {
                 $language = $this->factory->buildSpokenLanguage($language_name);
                 $this->language_repository->add($language);
             }
             $consultant->addSpokenLanguages($language, $lang_order++);
         }
     }
     //config management
     if (array_key_exists('configuration_management', $data) && is_array($data['configuration_management'])) {
         $configuration_management_expertise_data = $data['configuration_management'];
         foreach ($configuration_management_expertise_data as $config_id) {
             $config = $this->configuration_management_expertise_repository->getById($config_id);
             if (!$config) {
                 throw new NotFoundEntityException('ConfigurationManagementType', sprintf(' id %s', $config_id));
             }
             $consultant->addConfigurationManagementExpertise($config);
         }
     }
     //services offered
     if (array_key_exists('services_offered', $data) && is_array($data['services_offered'])) {
         $services_offered_data = $data['services_offered'];
         foreach ($services_offered_data as $service_data) {
             $service = $this->service_offered_repository->getById(intval($service_data['id']));
             if (!$service) {
                 throw new NotFoundEntityException('ConsultantServiceOfferedType', sprintf(' id %s', intval($service['id'])));
             }
             if (array_key_exists('regions', $service_data) && is_array($service_data['regions'])) {
                 $regions = $service_data['regions'];
                 foreach ($regions as $region_id) {
                     $region = $this->region_repository->getById(intval($region_id));
                     if (!$region) {
                         throw new NotFoundEntityException('Region', sprintf(' id %s', intval($region_id)));
                     }
                     $consultant->addServiceOffered($service, $region);
                 }
             }
         }
     }
     //Areas of OpenStack Expertise
     if (array_key_exists('expertise_areas', $data) && is_array($data['expertise_areas'])) {
         $expertise_areas_data = $data['expertise_areas'];
         foreach ($expertise_areas_data as $expertise_area_id) {
             $component = $this->component_repository->getById(intval($expertise_area_id));
             if (!$component) {
                 throw new NotFoundEntityException('OpenStackComponent', sprintf(' id %s', intval($expertise_area_id)));
             }
             $consultant->addExpertiseArea($component);
         }
     }
     //Reference Clients
     if (array_key_exists('reference_clients', $data) && is_array($data['reference_clients'])) {
         $reference_clients_data = $data['reference_clients'];
         foreach ($reference_clients_data as $client_name) {
             $client = $this->factory->buildClient(trim($client_name));
             $consultant->addPreviousClients($client);
         }
     }
     //Offices
     if (array_key_exists('offices', $data) && is_array($data['offices'])) {
         $reference_offices_data = $data['offices'];
         foreach ($reference_offices_data as $office_data) {
             $validator = $this->validator_factory->buildValidatorForOffice($office_data);
             if ($validator->fails()) {
                 return $this->validationError($validator->messages());
             }
             $address_info = new AddressInfo($office_data['address_1'], $office_data['address_2'], $office_data['zip_code'], $office_data['state'], $office_data['city'], $office_data['country']);
             //list($lat,$lng) = $this->geo_coding_service->getAddressCoordinates($address_info);
             $office = $this->factory->buildOffice($address_info);
             $office->setLat((double) $office_data['lat']);
             $office->setLng((double) $office_data['lng']);
             $consultant->addOffice($office);
         }
     }
     return $consultant;
 }