diff --git a/Libs/ModelSerializers/AbstractSerializer.php b/Libs/ModelSerializers/AbstractSerializer.php index 855c3df0..e12c4111 100644 --- a/Libs/ModelSerializers/AbstractSerializer.php +++ b/Libs/ModelSerializers/AbstractSerializer.php @@ -128,16 +128,23 @@ abstract class AbstractSerializer implements IModelSerializer */ public function serialize($expand = null, array $fields = array(), array $relations = array(), array $params = array() ) { - $values = array(); + $values = []; + $method_prefix = ['get', 'is']; if(!count($fields)) $fields = $this->getAllowedFields(); $mappings = $this->getAttributeMappings(); - if (count($mappings)) { - $new_values = array(); + $new_values = []; foreach ($mappings as $attribute => $mapping) { - $mapping = preg_split('/:/',$mapping); + $mapping = preg_split('/:/', $mapping); if(count($fields) > 0 && !in_array($mapping[0], $fields)) continue; - $value = call_user_func( array( $this->object, 'get'.$attribute ) ); + + foreach($method_prefix as $prefix){ + if(method_exists($this->object, $prefix.$attribute)){ + $value = call_user_func([$this->object, $prefix.$attribute ]); + break; + } + } + if(count($mapping) > 1) { //we have a formatter ... diff --git a/app/Http/Controllers/Apis/Marketplace/AbstractCompanyServiceApiController.php b/app/Http/Controllers/Apis/Marketplace/AbstractCompanyServiceApiController.php new file mode 100644 index 00000000..ac686985 --- /dev/null +++ b/app/Http/Controllers/Apis/Marketplace/AbstractCompanyServiceApiController.php @@ -0,0 +1,127 @@ +repository = $repository; + } + + /** + * @return mixed + */ + public function getAll(){ + $values = Input::all(); + + $rules = array + ( + 'page' => 'integer|min:1', + 'per_page' => 'required_with:page|integer|min:5|max:100', + ); + + try { + + $validation = Validator::make($values, $rules); + + if ($validation->fails()) { + $ex = new ValidationException(); + throw $ex->setMessages($validation->messages()->toArray()); + } + + // default values + $page = 1; + $per_page = 5; + + if (Input::has('page')) { + $page = intval(Input::get('page')); + $per_page = intval(Input::get('per_page')); + } + + $filter = null; + + if (Input::has('filter')) { + $filter = FilterParser::parse(Input::get('filter'), array + ( + 'name' => ['=@', '=='], + 'company' => ['=@', '=='], + )); + } + + $order = null; + + if (Input::has('order')) + { + $order = OrderParser::parse(Input::get('order'), array + ( + 'name', + 'company', + 'id', + )); + } + + if(is_null($filter)) $filter = new Filter(); + + $data = $this->repository->getAllByPage(new PagingInfo($page, $per_page), $filter, $order); + $fields = Request::input('fields', ''); + $fields = !empty($fields) ? explode(',', $fields) : []; + $relations = Request::input('relations', ''); + $relations = !empty($relations) ? explode(',', $relations) : []; + return $this->ok + ( + $data->toArray + ( + Request::input('expand', ''), + $fields, + $relations + ) + ); + } + catch (EntityNotFoundException $ex1) { + Log::warning($ex1); + return $this->error404(); + } + catch (ValidationException $ex2) { + Log::warning($ex2); + return $this->error412($ex2->getMessages()); + } + catch (\Exception $ex) { + Log::error($ex); + return $this->error500($ex); + } + } +} \ No newline at end of file diff --git a/app/Http/Controllers/Apis/Marketplace/AppliancesApiController.php b/app/Http/Controllers/Apis/Marketplace/AppliancesApiController.php new file mode 100644 index 00000000..54397a79 --- /dev/null +++ b/app/Http/Controllers/Apis/Marketplace/AppliancesApiController.php @@ -0,0 +1,45 @@ +error500($ex); } - } } \ No newline at end of file diff --git a/app/Http/Controllers/apis/protected/main/OAuth2TeamInvitationsApiController.php b/app/Http/Controllers/Apis/Protected/Main/OAuth2TeamInvitationsApiController.php similarity index 100% rename from app/Http/Controllers/apis/protected/main/OAuth2TeamInvitationsApiController.php rename to app/Http/Controllers/Apis/Protected/Main/OAuth2TeamInvitationsApiController.php diff --git a/app/Http/Controllers/apis/protected/main/OAuth2TeamsApiController.php b/app/Http/Controllers/Apis/Protected/Main/OAuth2TeamsApiController.php similarity index 100% rename from app/Http/Controllers/apis/protected/main/OAuth2TeamsApiController.php rename to app/Http/Controllers/Apis/Protected/Main/OAuth2TeamsApiController.php diff --git a/app/Http/Controllers/apis/protected/summit/CheckAttendeeStrategyFactory.php b/app/Http/Controllers/Apis/Protected/Summit/CheckAttendeeStrategyFactory.php similarity index 100% rename from app/Http/Controllers/apis/protected/summit/CheckAttendeeStrategyFactory.php rename to app/Http/Controllers/Apis/Protected/Summit/CheckAttendeeStrategyFactory.php diff --git a/app/Http/Controllers/apis/protected/summit/CheckSpeakerStrategyFactory.php b/app/Http/Controllers/Apis/Protected/Summit/CheckSpeakerStrategyFactory.php similarity index 100% rename from app/Http/Controllers/apis/protected/summit/CheckSpeakerStrategyFactory.php rename to app/Http/Controllers/Apis/Protected/Summit/CheckSpeakerStrategyFactory.php diff --git a/app/Http/Controllers/apis/protected/summit/ICheckAttendeeStrategy.php b/app/Http/Controllers/Apis/Protected/Summit/ICheckAttendeeStrategy.php similarity index 100% rename from app/Http/Controllers/apis/protected/summit/ICheckAttendeeStrategy.php rename to app/Http/Controllers/Apis/Protected/Summit/ICheckAttendeeStrategy.php diff --git a/app/Http/Controllers/apis/protected/summit/ICheckSpeakerStrategy.php b/app/Http/Controllers/Apis/Protected/Summit/ICheckSpeakerStrategy.php similarity index 100% rename from app/Http/Controllers/apis/protected/summit/ICheckSpeakerStrategy.php rename to app/Http/Controllers/Apis/Protected/Summit/ICheckSpeakerStrategy.php diff --git a/app/Http/Controllers/apis/protected/summit/ISummitFinderStrategy.php b/app/Http/Controllers/Apis/Protected/Summit/ISummitFinderStrategy.php similarity index 100% rename from app/Http/Controllers/apis/protected/summit/ISummitFinderStrategy.php rename to app/Http/Controllers/Apis/Protected/Summit/ISummitFinderStrategy.php diff --git a/app/Http/Controllers/apis/protected/summit/OAuth2PresentationApiController.php b/app/Http/Controllers/Apis/Protected/Summit/OAuth2PresentationApiController.php similarity index 100% rename from app/Http/Controllers/apis/protected/summit/OAuth2PresentationApiController.php rename to app/Http/Controllers/Apis/Protected/Summit/OAuth2PresentationApiController.php diff --git a/app/Http/Controllers/apis/protected/summit/OAuth2SummitApiController.php b/app/Http/Controllers/Apis/Protected/Summit/OAuth2SummitApiController.php similarity index 100% rename from app/Http/Controllers/apis/protected/summit/OAuth2SummitApiController.php rename to app/Http/Controllers/Apis/Protected/Summit/OAuth2SummitApiController.php diff --git a/app/Http/Controllers/apis/protected/summit/OAuth2SummitAttendeesApiController.php b/app/Http/Controllers/Apis/Protected/Summit/OAuth2SummitAttendeesApiController.php similarity index 100% rename from app/Http/Controllers/apis/protected/summit/OAuth2SummitAttendeesApiController.php rename to app/Http/Controllers/Apis/Protected/Summit/OAuth2SummitAttendeesApiController.php diff --git a/app/Http/Controllers/apis/protected/summit/OAuth2SummitEventsApiController.php b/app/Http/Controllers/Apis/Protected/Summit/OAuth2SummitEventsApiController.php similarity index 100% rename from app/Http/Controllers/apis/protected/summit/OAuth2SummitEventsApiController.php rename to app/Http/Controllers/Apis/Protected/Summit/OAuth2SummitEventsApiController.php diff --git a/app/Http/Controllers/apis/protected/summit/OAuth2SummitLocationsApiController.php b/app/Http/Controllers/Apis/Protected/Summit/OAuth2SummitLocationsApiController.php similarity index 100% rename from app/Http/Controllers/apis/protected/summit/OAuth2SummitLocationsApiController.php rename to app/Http/Controllers/Apis/Protected/Summit/OAuth2SummitLocationsApiController.php diff --git a/app/Http/Controllers/apis/protected/summit/OAuth2SummitMembersApiController.php b/app/Http/Controllers/Apis/Protected/Summit/OAuth2SummitMembersApiController.php similarity index 100% rename from app/Http/Controllers/apis/protected/summit/OAuth2SummitMembersApiController.php rename to app/Http/Controllers/Apis/Protected/Summit/OAuth2SummitMembersApiController.php diff --git a/app/Http/Controllers/apis/protected/summit/OAuth2SummitNotificationsApiController.php b/app/Http/Controllers/Apis/Protected/Summit/OAuth2SummitNotificationsApiController.php similarity index 92% rename from app/Http/Controllers/apis/protected/summit/OAuth2SummitNotificationsApiController.php rename to app/Http/Controllers/Apis/Protected/Summit/OAuth2SummitNotificationsApiController.php index 42bfe476..f7f51383 100644 --- a/app/Http/Controllers/apis/protected/summit/OAuth2SummitNotificationsApiController.php +++ b/app/Http/Controllers/Apis/Protected/Summit/OAuth2SummitNotificationsApiController.php @@ -38,6 +38,12 @@ class OAuth2SummitNotificationsApiController extends OAuth2ProtectedController */ private $summit_repository; + /** + * OAuth2SummitNotificationsApiController constructor. + * @param ISummitRepository $summit_repository + * @param ISummitNotificationRepository $notification_repository + * @param IResourceServerContext $resource_server_context + */ public function __construct ( ISummitRepository $summit_repository, @@ -115,13 +121,12 @@ class OAuth2SummitNotificationsApiController extends OAuth2ProtectedController )); } - $result = $this->repository->getAllByPage($summit, new PagingInfo($page, $per_page), $filter, $order); + $result = $this->repository->getAllByPageBySummit($summit, new PagingInfo($page, $per_page), $filter, $order); return $this->ok ( $result->toArray(Request::input('expand', ''),[],[],['summit_id' => $summit_id]) ); - } catch (EntityNotFoundException $ex1) { diff --git a/app/Http/Controllers/apis/protected/summit/OAuth2SummitSpeakersApiController.php b/app/Http/Controllers/Apis/Protected/Summit/OAuth2SummitSpeakersApiController.php similarity index 100% rename from app/Http/Controllers/apis/protected/summit/OAuth2SummitSpeakersApiController.php rename to app/Http/Controllers/Apis/Protected/Summit/OAuth2SummitSpeakersApiController.php diff --git a/app/Http/Controllers/apis/protected/summit/strategies/CheckMeAttendeeStrategy.php b/app/Http/Controllers/Apis/Protected/Summit/Strategies/CheckMeAttendeeStrategy.php similarity index 100% rename from app/Http/Controllers/apis/protected/summit/strategies/CheckMeAttendeeStrategy.php rename to app/Http/Controllers/Apis/Protected/Summit/Strategies/CheckMeAttendeeStrategy.php diff --git a/app/Http/Controllers/apis/protected/summit/strategies/CheckMeSpeakerStrategy.php b/app/Http/Controllers/Apis/Protected/Summit/Strategies/CheckMeSpeakerStrategy.php similarity index 100% rename from app/Http/Controllers/apis/protected/summit/strategies/CheckMeSpeakerStrategy.php rename to app/Http/Controllers/Apis/Protected/Summit/Strategies/CheckMeSpeakerStrategy.php diff --git a/app/Http/Controllers/apis/protected/summit/strategies/CheckMyOwnAttendeeStrategy.php b/app/Http/Controllers/Apis/Protected/Summit/Strategies/CheckMyOwnAttendeeStrategy.php similarity index 100% rename from app/Http/Controllers/apis/protected/summit/strategies/CheckMyOwnAttendeeStrategy.php rename to app/Http/Controllers/Apis/Protected/Summit/Strategies/CheckMyOwnAttendeeStrategy.php diff --git a/app/Http/Controllers/apis/protected/summit/strategies/CurrentSummitFinderStrategy.php b/app/Http/Controllers/Apis/Protected/Summit/Strategies/CurrentSummitFinderStrategy.php similarity index 100% rename from app/Http/Controllers/apis/protected/summit/strategies/CurrentSummitFinderStrategy.php rename to app/Http/Controllers/Apis/Protected/Summit/Strategies/CurrentSummitFinderStrategy.php diff --git a/app/Http/Controllers/apis/protected/summit/strategies/events/RetrieveAllPublishedSummitEventsStrategy.php b/app/Http/Controllers/Apis/Protected/Summit/Strategies/events/RetrieveAllPublishedSummitEventsStrategy.php similarity index 100% rename from app/Http/Controllers/apis/protected/summit/strategies/events/RetrieveAllPublishedSummitEventsStrategy.php rename to app/Http/Controllers/Apis/Protected/Summit/Strategies/events/RetrieveAllPublishedSummitEventsStrategy.php diff --git a/app/Http/Controllers/apis/protected/summit/strategies/events/RetrieveAllSummitEventsBySummitStrategy.php b/app/Http/Controllers/Apis/Protected/Summit/Strategies/events/RetrieveAllSummitEventsBySummitStrategy.php similarity index 100% rename from app/Http/Controllers/apis/protected/summit/strategies/events/RetrieveAllSummitEventsBySummitStrategy.php rename to app/Http/Controllers/Apis/Protected/Summit/Strategies/events/RetrieveAllSummitEventsBySummitStrategy.php diff --git a/app/Http/Controllers/apis/protected/summit/strategies/events/RetrieveAllSummitEventsStrategy.php b/app/Http/Controllers/Apis/Protected/Summit/Strategies/events/RetrieveAllSummitEventsStrategy.php similarity index 100% rename from app/Http/Controllers/apis/protected/summit/strategies/events/RetrieveAllSummitEventsStrategy.php rename to app/Http/Controllers/Apis/Protected/Summit/Strategies/events/RetrieveAllSummitEventsStrategy.php diff --git a/app/Http/Controllers/apis/protected/summit/strategies/events/RetrievePublishedSummitEventsBySummitStrategy.php b/app/Http/Controllers/Apis/Protected/Summit/Strategies/events/RetrievePublishedSummitEventsBySummitStrategy.php similarity index 100% rename from app/Http/Controllers/apis/protected/summit/strategies/events/RetrievePublishedSummitEventsBySummitStrategy.php rename to app/Http/Controllers/Apis/Protected/Summit/Strategies/events/RetrievePublishedSummitEventsBySummitStrategy.php diff --git a/app/Http/Controllers/apis/protected/summit/strategies/events/RetrieveSummitEventsStrategy.php b/app/Http/Controllers/Apis/Protected/Summit/Strategies/events/RetrieveSummitEventsStrategy.php similarity index 100% rename from app/Http/Controllers/apis/protected/summit/strategies/events/RetrieveSummitEventsStrategy.php rename to app/Http/Controllers/Apis/Protected/Summit/Strategies/events/RetrieveSummitEventsStrategy.php diff --git a/app/Http/Controllers/apis/protected/summit/SummitFinderStrategyFactory.php b/app/Http/Controllers/Apis/Protected/Summit/SummitFinderStrategyFactory.php similarity index 100% rename from app/Http/Controllers/apis/protected/summit/SummitFinderStrategyFactory.php rename to app/Http/Controllers/Apis/Protected/Summit/SummitFinderStrategyFactory.php diff --git a/app/Http/Controllers/apis/protected/marketplace/OAuth2CloudApiController.php b/app/Http/Controllers/apis/protected/marketplace/OAuth2CloudApiController.php deleted file mode 100644 index f99ae4f3..00000000 --- a/app/Http/Controllers/apis/protected/marketplace/OAuth2CloudApiController.php +++ /dev/null @@ -1,86 +0,0 @@ -getCompanyServices(); - } - - /** - * @param $id - * @return mixed - */ - public function getCloud($id) - { - return $this->getCompanyService($id); - } - - /** - * @param $id - * @return mixed - */ - public function getCloudDataCenters($id) - { - try { - $cloud = $this->repository->getById($id); - - if (!$cloud) - { - return $this->error404(); - } - - $data_center_regions = $cloud->datacenters_regions(); - - $res = array(); - - foreach ($data_center_regions as $region) - { - $data = $region->toArray(); - $locations = $region->locations(); - $data_locations = array(); - foreach ($locations as $loc) - { - array_push($data_locations, $loc->toArray()); - } - $data['locations'] = $data_locations; - array_push($res, $data); - } - - return $this->ok(array('datacenters' => $res )); - } - catch (Exception $ex) - { - Log::error($ex); - return $this->error500($ex); - } - } -} \ No newline at end of file diff --git a/app/Http/Controllers/apis/protected/marketplace/OAuth2CompanyServiceApiController.php b/app/Http/Controllers/apis/protected/marketplace/OAuth2CompanyServiceApiController.php deleted file mode 100644 index 8f264beb..00000000 --- a/app/Http/Controllers/apis/protected/marketplace/OAuth2CompanyServiceApiController.php +++ /dev/null @@ -1,143 +0,0 @@ - 'The :attribute field is does not has a valid value (all, active, non_active).', - 'order' => 'The :attribute field is does not has a valid value (date, name).', - 'order_dir' => 'The :attribute field is does not has a valid value (desc, asc).', - ); - - $rules = array( - 'page' => 'integer|min:1', - 'per_page' => 'required_with:page|integer|min:10|max:100', - 'status' => 'status', - 'order_by' => 'order', - 'order_dir' => 'required_with:order_by|order_dir', - ); - // Creates a Validator instance and validates the data. - $validation = Validator::make($values, $rules, $messages); - - if ($validation->fails()) - { - $messages = $validation->messages()->toArray(); - return $this->error412($messages); - } - - if (Input::has('page')) - { - $page = intval(Input::get('page')); - $per_page = intval(Input::get('per_page')); - } - - if (Input::has('status')) - { - $status = Input::get('status'); - } - - if (Input::has('order_by')) - { - $order_by = Input::get('order_by'); - $order_dir = Input::get('order_dir'); - } - - $data = $this->repository->getAll($page, $per_page, $status, $order_by, $order_dir); - return $this->ok($data); - } - catch (Exception $ex) - { - Log::error($ex); - return $this->error500($ex); - } - } - - /** - * @param $id - * @return mixed - */ - public function getCompanyService($id) - { - try - { - $data = $this->repository->getById($id); - return ($data)? $this->ok($data) : $this->error404(); - } - catch (Exception $ex) - { - Log::error($ex); - return $this->error500($ex); - } - } -} \ No newline at end of file diff --git a/app/Http/Controllers/apis/protected/marketplace/OAuth2ConsultantsApiController.php b/app/Http/Controllers/apis/protected/marketplace/OAuth2ConsultantsApiController.php deleted file mode 100644 index 286f34f4..00000000 --- a/app/Http/Controllers/apis/protected/marketplace/OAuth2ConsultantsApiController.php +++ /dev/null @@ -1,89 +0,0 @@ -repository = $repository; - } - - /** - * query string params: - * page: You can specify further pages - * per_page: custom page size up to 100 ( min 10) - * status: cloud status ( active , not active, all) - * order_by: order by field - * order_dir: order direction - * @return mixed - */ - public function getConsultants() - { - return $this->getCompanyServices(); - } - - /** - * @param $id - * @return mixed - */ - public function getConsultant($id) - { - return $this->getCompanyService($id); - } - - /** - * @param $id - * @return mixed - */ - public function getOffices($id) - { - try - { - $consultant = $this->repository->getById($id); - - if (!$consultant) - { - return $this->error404(); - } - - $offices = $consultant->offices(); - $res = array(); - - foreach ($offices as $office) - { - array_push($res, $office->toArray()); - } - return $this->ok(array('offices' => $res)); - } - catch (Exception $ex) - { - Log::error($ex); - return $this->error500($ex); - } - } -} \ No newline at end of file diff --git a/app/Http/Controllers/apis/protected/marketplace/OAuth2PrivateCloudApiController.php b/app/Http/Controllers/apis/protected/marketplace/OAuth2PrivateCloudApiController.php deleted file mode 100644 index f1a40b48..00000000 --- a/app/Http/Controllers/apis/protected/marketplace/OAuth2PrivateCloudApiController.php +++ /dev/null @@ -1,36 +0,0 @@ -repository = $repository; - } -} \ No newline at end of file diff --git a/app/Http/Controllers/apis/protected/marketplace/OAuth2PublicCloudApiController.php b/app/Http/Controllers/apis/protected/marketplace/OAuth2PublicCloudApiController.php deleted file mode 100644 index 29049015..00000000 --- a/app/Http/Controllers/apis/protected/marketplace/OAuth2PublicCloudApiController.php +++ /dev/null @@ -1,30 +0,0 @@ -repository = $repository; - } -} \ No newline at end of file diff --git a/app/Http/routes.php b/app/Http/routes.php index 2b59c62c..c471712e 100644 --- a/app/Http/routes.php +++ b/app/Http/routes.php @@ -29,6 +29,7 @@ Route::group([ Route::group(['prefix'=>'members'], function() { Route::get('', 'OAuth2MembersApiController@getMembers'); }); + // summits Route::group(['prefix'=>'summits'], function() { Route::get('', [ 'middleware' => 'cache:'.Config::get('cache_api_response.get_summit_response_lifetime', 600), 'uses' => 'OAuth2SummitApiController@getSummits']); @@ -43,6 +44,33 @@ Route::group([ }); }); + // marketplace + Route::group(array('prefix' => 'marketplace'), function () { + + Route::group(array('prefix' => 'appliances'), function () { + Route::get('', 'AppliancesApiController@getAll'); + }); + + Route::group(array('prefix' => 'distros'), function () { + Route::get('', 'DistributionsApiController@getAll'); + }); + + Route::group(array('prefix' => 'consultants'), function () { + Route::get('', 'ConsultantsApiController@getAll'); + }); + + Route::group(array('prefix' => 'hosted-private-clouds'), function () { + Route::get('', 'PrivateCloudsApiController@getAll'); + }); + + Route::group(array('prefix' => 'remotely-managed-private-clouds'), function () { + Route::get('', 'RemoteCloudsApiController@getAll'); + }); + + Route::group(array('prefix' => 'public-clouds'), function () { + Route::get('', 'PublicCloudsApiController@getAll'); + }); + }); }); //OAuth2 Protected API @@ -54,28 +82,6 @@ Route::group([ 'middleware' => ['ssl', 'oauth2.protected', 'rate.limit','etags'] ], function () { - Route::group(array('prefix' => 'marketplace'), function () { - - Route::group(array('prefix' => 'public-clouds'), function () { - Route::get('', 'OAuth2PublicCloudApiController@getClouds'); - Route::get('/{id}', 'OAuth2PublicCloudApiController@getCloud'); - Route::get('/{id}/data-centers', 'OAuth2PublicCloudApiController@getCloudDataCenters'); - }); - - Route::group(array('prefix' => 'private-clouds'), function () { - Route::get('', 'OAuth2PrivateCloudApiController@getClouds'); - Route::get('/{id}', 'OAuth2PrivateCloudApiController@getCloud'); - Route::get('/{id}/data-centers', 'OAuth2PrivateCloudApiController@getCloudDataCenters'); - }); - - Route::group(array('prefix' => 'consultants'), function () { - Route::get('', 'OAuth2ConsultantsApiController@getConsultants'); - Route::get('/{id}', 'OAuth2ConsultantsApiController@getConsultant'); - Route::get('/{id}/offices', 'OAuth2ConsultantsApiController@getOffices'); - }); - - }); - // members Route::group(['prefix'=>'members'], function(){ Route::get('', 'OAuth2MembersApiController@getMembers'); diff --git a/app/ModelSerializers/Marketplace/ApplianceSerializer.php b/app/ModelSerializers/Marketplace/ApplianceSerializer.php new file mode 100644 index 00000000..51a35290 --- /dev/null +++ b/app/ModelSerializers/Marketplace/ApplianceSerializer.php @@ -0,0 +1,22 @@ +object; + if(!$service instanceof CloudServiceOffered) return []; + if(!count($relations)) $relations = $this->getAllowedRelations(); + $values = parent::serialize($expand, $fields, $relations, $params); + + if(in_array('pricing_schemas', $relations)){ + $res = []; + foreach ($service->getPricingSchemas() as $schema){ + $res[] = SerializerRegistry::getInstance() + ->getSerializer($schema) + ->serialize($expand); + } + $values['pricing_schemas'] = $res; + } + + if (!empty($expand)) { + $exp_expand = explode(',', $expand); + foreach ($exp_expand as $relation) { + switch (trim($relation)) { + + } + } + } + return $values; + } +} \ No newline at end of file diff --git a/app/ModelSerializers/Marketplace/CloudServiceSerializer.php b/app/ModelSerializers/Marketplace/CloudServiceSerializer.php new file mode 100644 index 00000000..2762e2d0 --- /dev/null +++ b/app/ModelSerializers/Marketplace/CloudServiceSerializer.php @@ -0,0 +1,70 @@ +object; + if(!$cloud_service instanceof CloudService) return []; + if(!count($relations)) $relations = $this->getAllowedRelations(); + $values = parent::serialize($expand, $fields, $relations, $params); + + if(in_array('data_centers', $relations)){ + $res = []; + foreach ($cloud_service->getDataCenters() as $dataCenter){ + $res[] = SerializerRegistry::getInstance() + ->getSerializer($dataCenter) + ->serialize($expand); + } + $values['data_centers'] = $res; + } + + if(in_array('data_center_regions', $relations)){ + $res = []; + foreach ($cloud_service->getDataCenterRegions() as $region){ + $res[] = SerializerRegistry::getInstance() + ->getSerializer($region) + ->serialize($expand); + } + $values['data_center_regions'] = $res; + } + + if (!empty($expand)) { + $exp_expand = explode(',', $expand); + foreach ($exp_expand as $relation) { + switch (trim($relation)) { + + } + } + } + return $values; + } +} \ No newline at end of file diff --git a/app/ModelSerializers/Marketplace/CompanyServiceSerializer.php b/app/ModelSerializers/Marketplace/CompanyServiceSerializer.php new file mode 100644 index 00000000..72f5152e --- /dev/null +++ b/app/ModelSerializers/Marketplace/CompanyServiceSerializer.php @@ -0,0 +1,81 @@ + 'name:json_string', + 'Overview' => 'overview:json_string', + 'Call2ActionUrl' => 'call_2_action_url:json_string', + 'CompanyId' => 'company_id:json_int', + 'TypeId' => 'type_id:json_int', + ]; + + protected static $allowed_relations = [ + 'reviews', + ]; + + /** + * @param null $expand + * @param array $fields + * @param array $relations + * @param array $params + * @return array + */ + public function serialize($expand = null, array $fields = array(), array $relations = array(), array $params = array()) + { + $company_service = $this->object; + if(!$company_service instanceof CompanyService) return []; + $values = parent::serialize($expand, $fields, $relations, $params); + + if (!empty($expand)) { + $exp_expand = explode(',', $expand); + foreach ($exp_expand as $relation) { + switch (trim($relation)) { + case 'company': { + unset($values['company_id']); + $values['company'] = SerializerRegistry::getInstance()->getSerializer($company_service->getCompany())->serialize(null, [], ['none']);; + } + break; + case 'type': { + unset($values['type_id']); + $values['type'] = SerializerRegistry::getInstance()->getSerializer($company_service->getType())->serialize(null, [], ['none']);; + } + break; + case 'reviews': + { + if(in_array('reviews', $relations)){ + $reviews = []; + foreach ($company_service->getApprovedReviews() as $r) { + $reviews[] = SerializerRegistry::getInstance()->getSerializer($r)->serialize(); + } + $values['reviews'] = $reviews; + } + } + break; + } + } + } + return $values; + } +} \ No newline at end of file diff --git a/app/ModelSerializers/Marketplace/ConfigurationManagementTypeSerializer.php b/app/ModelSerializers/Marketplace/ConfigurationManagementTypeSerializer.php new file mode 100644 index 00000000..e192f22f --- /dev/null +++ b/app/ModelSerializers/Marketplace/ConfigurationManagementTypeSerializer.php @@ -0,0 +1,28 @@ + 'type:json_string', + ]; +} \ No newline at end of file diff --git a/app/ModelSerializers/Marketplace/ConsultantClientSerializer.php b/app/ModelSerializers/Marketplace/ConsultantClientSerializer.php new file mode 100644 index 00000000..6068e7d6 --- /dev/null +++ b/app/ModelSerializers/Marketplace/ConsultantClientSerializer.php @@ -0,0 +1,27 @@ + 'name:json_string', + ]; +} \ No newline at end of file diff --git a/app/ModelSerializers/Marketplace/ConsultantSerializer.php b/app/ModelSerializers/Marketplace/ConsultantSerializer.php new file mode 100644 index 00000000..611ffd78 --- /dev/null +++ b/app/ModelSerializers/Marketplace/ConsultantSerializer.php @@ -0,0 +1,116 @@ +object; + if(!$consultant instanceof Consultant) return []; + if(!count($relations)) $relations = $this->getAllowedRelations(); + $values = parent::serialize($expand, $fields, $relations, $params); + + if(in_array('offices', $relations)){ + $res = []; + foreach ($consultant->getOffices() as $office){ + $res[] = SerializerRegistry::getInstance() + ->getSerializer($office) + ->serialize($expand); + } + $values['offices'] = $res; + } + + if(in_array('clients', $relations)){ + $res = []; + foreach ($consultant->getClients() as $client){ + $res[] = SerializerRegistry::getInstance() + ->getSerializer($client) + ->serialize($expand); + } + $values['clients'] = $res; + } + + if(in_array('spoken_languages', $relations)){ + $res = []; + foreach ($consultant->getSpokenLanguages() as $lang){ + $res[] = SerializerRegistry::getInstance() + ->getSerializer($lang) + ->serialize($expand); + } + $values['spoken_languages'] = $res; + } + + if(in_array('configuration_management_expertise', $relations)){ + $res = []; + foreach ($consultant->getConfigurationManagementExpertise() as $exp){ + $res[] = SerializerRegistry::getInstance() + ->getSerializer($exp) + ->serialize($expand); + } + $values['configuration_management_expertise'] = $res; + } + + if(in_array('expertise_areas', $relations)){ + $res = []; + foreach ($consultant->getExpertiseAreas() as $area){ + $res[] = SerializerRegistry::getInstance() + ->getSerializer($area) + ->serialize($expand); + } + $values['expertise_areas'] = $res; + } + + if(in_array('services_offered', $relations)){ + $res = []; + foreach ($consultant->getServicesOffered() as $service){ + $res[] = SerializerRegistry::getInstance() + ->getSerializer($service) + ->serialize($expand); + } + $values['services_offered'] = $res; + } + + if (!empty($expand)) { + $exp_expand = explode(',', $expand); + foreach ($exp_expand as $relation) { + switch (trim($relation)) { + + } + } + } + return $values; + } +} \ No newline at end of file diff --git a/app/ModelSerializers/Marketplace/ConsultantServiceOfferedTypeSerializer.php b/app/ModelSerializers/Marketplace/ConsultantServiceOfferedTypeSerializer.php new file mode 100644 index 00000000..5736007f --- /dev/null +++ b/app/ModelSerializers/Marketplace/ConsultantServiceOfferedTypeSerializer.php @@ -0,0 +1,72 @@ +object; + if(!$service instanceof ConsultantServiceOfferedType) return []; + if(!count($relations)) $relations = $this->getAllowedRelations(); + $values = parent::serialize($expand, $fields, $relations, $params); + + if(in_array('service_offered_type', $relations)){ + $values['service_offered_type'] = SerializerRegistry::getInstance() + ->getSerializer($service->getServiceOffered()) + ->serialize($expand); + } + + if(in_array('region', $relations)){ + $values['region'] = SerializerRegistry::getInstance() + ->getSerializer($service->getRegion()) + ->serialize($expand); + } + + if (!empty($expand)) { + $exp_expand = explode(',', $expand); + foreach ($exp_expand as $relation) { + switch (trim($relation)) { + + } + } + } + return $values; + } +} \ No newline at end of file diff --git a/app/ModelSerializers/Marketplace/DataCenterLocationSerializer.php b/app/ModelSerializers/Marketplace/DataCenterLocationSerializer.php new file mode 100644 index 00000000..ccc79590 --- /dev/null +++ b/app/ModelSerializers/Marketplace/DataCenterLocationSerializer.php @@ -0,0 +1,65 @@ + 'city:json_string', + 'State' => 'state:json_string', + 'Country' => 'country:json_string', + 'Lat' => 'lat:json_float', + 'Lng' => 'lng:json_float', + 'RegionId' => 'region_id:json_int', + ]; + + /** + * @param null $expand + * @param array $fields + * @param array $relations + * @param array $params + * @return array + */ + public function serialize($expand = null, array $fields = array(), array $relations = array(), array $params = array()) + { + + $location = $this->object; + if(!$location instanceof DataCenterLocation) return []; + if(!count($relations)) $relations = $this->getAllowedRelations(); + $values = parent::serialize($expand, $fields, $relations, $params); + + if (!empty($expand)) { + $exp_expand = explode(',', $expand); + foreach ($exp_expand as $relation) { + switch (trim($relation)) { + case 'region': + unset($values['region_id']); + $values['region'] = SerializerRegistry ::getInstance() + ->getSerializer($location->getRegion()) + ->serialize($expand); + break; + } + } + } + return $values; + } +} \ No newline at end of file diff --git a/app/ModelSerializers/Marketplace/DataCenterRegionSerializer.php b/app/ModelSerializers/Marketplace/DataCenterRegionSerializer.php new file mode 100644 index 00000000..8f0142ba --- /dev/null +++ b/app/ModelSerializers/Marketplace/DataCenterRegionSerializer.php @@ -0,0 +1,28 @@ + 'name:json_string', + 'Endpoint' => 'endpoint:json_string', + ]; +} \ No newline at end of file diff --git a/app/ModelSerializers/Marketplace/DistributionSerializer.php b/app/ModelSerializers/Marketplace/DistributionSerializer.php new file mode 100644 index 00000000..444a29f8 --- /dev/null +++ b/app/ModelSerializers/Marketplace/DistributionSerializer.php @@ -0,0 +1,23 @@ + 'type:json_string', + ]; + +} \ No newline at end of file diff --git a/app/ModelSerializers/Marketplace/HyperVisorTypeSerializer.php b/app/ModelSerializers/Marketplace/HyperVisorTypeSerializer.php new file mode 100644 index 00000000..530479b5 --- /dev/null +++ b/app/ModelSerializers/Marketplace/HyperVisorTypeSerializer.php @@ -0,0 +1,28 @@ + 'type:json_string', + ]; + +} \ No newline at end of file diff --git a/app/ModelSerializers/Marketplace/MarketPlaceReviewSerializer.php b/app/ModelSerializers/Marketplace/MarketPlaceReviewSerializer.php new file mode 100644 index 00000000..44ef6b19 --- /dev/null +++ b/app/ModelSerializers/Marketplace/MarketPlaceReviewSerializer.php @@ -0,0 +1,29 @@ + 'title:json_string', + 'Comment' => 'comment:json_string', + 'Rating' => 'rating:json_int', + ]; +} \ No newline at end of file diff --git a/app/ModelSerializers/Marketplace/OfficeSerializer.php b/app/ModelSerializers/Marketplace/OfficeSerializer.php new file mode 100644 index 00000000..e615dd1f --- /dev/null +++ b/app/ModelSerializers/Marketplace/OfficeSerializer.php @@ -0,0 +1,36 @@ + 'address:json_string', + 'Address2' => 'address2:json_string', + 'State' => 'state:json_string', + 'ZipCode' => 'zip_code:json_string', + 'City' => 'city:json_string', + 'Country' => 'country:json_string', + 'Lat' => 'lat:json_float', + 'Lng' => 'lng:json_float', + ]; +} \ No newline at end of file diff --git a/app/ModelSerializers/Marketplace/OpenStackImplementationApiCoverageSerializer.php b/app/ModelSerializers/Marketplace/OpenStackImplementationApiCoverageSerializer.php new file mode 100644 index 00000000..ac45ff2b --- /dev/null +++ b/app/ModelSerializers/Marketplace/OpenStackImplementationApiCoverageSerializer.php @@ -0,0 +1,72 @@ + 'api_coverage:json_int', + ]; + + /** + * @param null $expand + * @param array $fields + * @param array $relations + * @param array $params + * @return array + */ + public function serialize($expand = null, array $fields = array(), array $relations = array(), array $params = array()) + { + $api_coverage = $this->object; + if(!$api_coverage instanceof OpenStackImplementationApiCoverage) return []; + $values = parent::serialize($expand, $fields, $relations, $params); + if(!$api_coverage->hasReleaseSupportedApiVersion()) return $values; + + $release_api_version = $api_coverage->getReleaseSupportedApiVersion(); + if($release_api_version->hasApiVersion() && $release_api_version->getApiVersion()->hasComponent()){ + $values["component"] = SerializerRegistry::getInstance() + ->getSerializer($release_api_version->getApiVersion()->getComponent()) + ->serialize(); + } + else if($release_api_version->hasComponent()){ + $values["component"] = SerializerRegistry::getInstance() + ->getSerializer($release_api_version->getComponent()) + ->serialize(); + } + + if($release_api_version->hasRelease()){ + $values["release"] = SerializerRegistry::getInstance() + ->getSerializer($release_api_version->getRelease()) + ->serialize(); + } + + if (!empty($expand)) { + $exp_expand = explode(',', $expand); + foreach ($exp_expand as $relation) { + switch (trim($relation)) { + + } + } + } + return $values; + } +} \ No newline at end of file diff --git a/app/ModelSerializers/Marketplace/OpenStackImplementationSerializer.php b/app/ModelSerializers/Marketplace/OpenStackImplementationSerializer.php new file mode 100644 index 00000000..318e97e1 --- /dev/null +++ b/app/ModelSerializers/Marketplace/OpenStackImplementationSerializer.php @@ -0,0 +1,99 @@ + 'is_compatible_with_storage:json_boolean', + 'CompatibleWithCompute' => 'is_compatible_with_compute:json_boolean', + 'CompatibleWithFederatedIdentity' => 'is_compatible_with_federated_identity:json_boolean', + 'CompatibleWithPlatform' => 'is_compatible_with_platform:json_boolean', + 'OpenStackPowered' => 'is_openstack_powered:json_boolean', + 'OpenStackTested' => 'is_openstack_tested:json_boolean', + 'OpenStackTestedLabel' => 'openstack_tested_info:json_string', + ]; + + protected static $allowed_relations = [ + 'capabilities', + 'guests', + 'hypervisors', + ]; + + /** + * @param null $expand + * @param array $fields + * @param array $relations + * @param array $params + * @return array + */ + public function serialize($expand = null, array $fields = array(), array $relations = array(), array $params = array()) + { + + $implementation = $this->object; + if(!$implementation instanceof OpenStackImplementation) return []; + if(!count($relations)) $relations = $this->getAllowedRelations(); + $values = parent::serialize($expand, $fields, $relations, $params); + + if(in_array('capabilities', $relations)){ + $res = []; + foreach ($implementation->getCapabilities() as $capability){ + $res[] = SerializerRegistry::getInstance() + ->getSerializer($capability) + ->serialize($expand); + } + $values['capabilities'] = $res; + } + + if(in_array('hypervisors', $relations)){ + $res = []; + foreach ($implementation->getHypervisors() as $hypervisor){ + $res[] = SerializerRegistry::getInstance() + ->getSerializer($hypervisor) + ->serialize($expand); + } + $values['hypervisors'] = $res; + } + + if(in_array('guests', $relations)){ + $res = []; + foreach ($implementation->getGuests() as $guest){ + $res[] = SerializerRegistry::getInstance() + ->getSerializer($guest) + ->serialize($expand); + } + $values['guests'] = $res; + } + + if (!empty($expand)) { + $exp_expand = explode(',', $expand); + foreach ($exp_expand as $relation) { + switch (trim($relation)) { + + } + } + } + return $values; + } +} \ No newline at end of file diff --git a/app/ModelSerializers/Marketplace/PricingSchemaTypeSerializer.php b/app/ModelSerializers/Marketplace/PricingSchemaTypeSerializer.php new file mode 100644 index 00000000..bc9fc683 --- /dev/null +++ b/app/ModelSerializers/Marketplace/PricingSchemaTypeSerializer.php @@ -0,0 +1,25 @@ + 'type:json_string', + ]; + +} \ No newline at end of file diff --git a/app/ModelSerializers/Marketplace/PrivateCloudServiceSerializer.php b/app/ModelSerializers/Marketplace/PrivateCloudServiceSerializer.php new file mode 100644 index 00000000..6b754079 --- /dev/null +++ b/app/ModelSerializers/Marketplace/PrivateCloudServiceSerializer.php @@ -0,0 +1,21 @@ + 'name:json_string', + ]; +} \ No newline at end of file diff --git a/app/ModelSerializers/Marketplace/RegionalSupportSerializer.php b/app/ModelSerializers/Marketplace/RegionalSupportSerializer.php new file mode 100644 index 00000000..32eb9f43 --- /dev/null +++ b/app/ModelSerializers/Marketplace/RegionalSupportSerializer.php @@ -0,0 +1,71 @@ +object; + if(!$regional_support instanceof RegionalSupport) return []; + if(!count($relations)) $relations = $this->getAllowedRelations(); + $values = parent::serialize($expand, $fields, $relations, $params); + + if(in_array('supported_channel_types', $relations)){ + $res = []; + foreach ($regional_support->getSupportedChannelTypes() as $channel_type){ + $res[] = SerializerRegistry::getInstance() + ->getSerializer($channel_type) + ->serialize(); + } + $values['supported_channel_types'] = $res; + } + + if (!empty($expand)) { + $exp_expand = explode(',', $expand); + foreach ($exp_expand as $relation) { + switch (trim($relation)) { + case 'region': + unset($values['region_id']); + $values['region'] = SerializerRegistry::getInstance() + ->getSerializer($regional_support->getRegion()) + ->serialize(); + break; + } + } + } + return $values; + } +} \ No newline at end of file diff --git a/app/ModelSerializers/Marketplace/RegionalSupportedCompanyServiceSerializer.php b/app/ModelSerializers/Marketplace/RegionalSupportedCompanyServiceSerializer.php new file mode 100644 index 00000000..5bd54205 --- /dev/null +++ b/app/ModelSerializers/Marketplace/RegionalSupportedCompanyServiceSerializer.php @@ -0,0 +1,62 @@ +object; + if(!$regional_service instanceof RegionalSupportedCompanyService) return []; + if(!count($relations)) $relations = $this->getAllowedRelations(); + $values = parent::serialize($expand, $fields, $relations, $params); + + if(in_array('supported_regions', $relations)){ + $res = []; + foreach ($regional_service->getRegionalSupports() as $region){ + $res[] = SerializerRegistry::getInstance() + ->getSerializer($region) + ->serialize($expand = 'region'); + } + $values['supported_regions'] = $res; + } + + if (!empty($expand)) { + $exp_expand = explode(',', $expand); + foreach ($exp_expand as $relation) { + switch (trim($relation)) { + + } + } + } + return $values; + } +} \ No newline at end of file diff --git a/app/ModelSerializers/Marketplace/RemoteCloudServiceSerializer.php b/app/ModelSerializers/Marketplace/RemoteCloudServiceSerializer.php new file mode 100644 index 00000000..cf7eaf50 --- /dev/null +++ b/app/ModelSerializers/Marketplace/RemoteCloudServiceSerializer.php @@ -0,0 +1,30 @@ + 'hardware_spec:json_string', + 'PricingModels' => 'pricing_models:json_string', + 'PublishedSla' => 'published_sla:json_string', + 'VendorManagedUpgrades' => 'is_vendor_managed_upgrades:json_boolean', + ]; +} \ No newline at end of file diff --git a/app/ModelSerializers/Marketplace/ServiceOfferedTypeSerializer.php b/app/ModelSerializers/Marketplace/ServiceOfferedTypeSerializer.php new file mode 100644 index 00000000..d444aa7a --- /dev/null +++ b/app/ModelSerializers/Marketplace/ServiceOfferedTypeSerializer.php @@ -0,0 +1,27 @@ + 'type:json_string', + ]; +} \ No newline at end of file diff --git a/app/ModelSerializers/Marketplace/SpokenLanguageSerializer.php b/app/ModelSerializers/Marketplace/SpokenLanguageSerializer.php new file mode 100644 index 00000000..30660d59 --- /dev/null +++ b/app/ModelSerializers/Marketplace/SpokenLanguageSerializer.php @@ -0,0 +1,28 @@ + 'name:json_string', + ]; +} \ No newline at end of file diff --git a/app/ModelSerializers/Marketplace/SupportChannelTypeSerializer.php b/app/ModelSerializers/Marketplace/SupportChannelTypeSerializer.php new file mode 100644 index 00000000..980f9f0e --- /dev/null +++ b/app/ModelSerializers/Marketplace/SupportChannelTypeSerializer.php @@ -0,0 +1,27 @@ + 'type:json_string', + ]; +} \ No newline at end of file diff --git a/app/ModelSerializers/SerializerRegistry.php b/app/ModelSerializers/SerializerRegistry.php index 1dc8a9fc..80ff2c06 100644 --- a/app/ModelSerializers/SerializerRegistry.php +++ b/app/ModelSerializers/SerializerRegistry.php @@ -1,8 +1,29 @@ registry['ChatTeamMember'] = ChatTeamMemberSerializer::class; $this->registry['ChatTeamInvitation'] = ChatTeamInvitationSerializer::class; $this->registry['ChatTeamPushNotificationMessage'] = ChatTeamPushNotificationMessageSerializer::class; + + // marketplace + + $this->registry['Appliance'] = ApplianceSerializer::class; + $this->registry["Distribution"] = DistributionSerializer::class; + $this->registry['MarketPlaceReview'] = MarketPlaceReviewSerializer::class; + $this->registry['OpenStackImplementationApiCoverage'] = OpenStackImplementationApiCoverageSerializer::class; + $this->registry['GuestOSType'] = GuestOSTypeSerializer::class; + $this->registry['HyperVisorType'] = HyperVisorTypeSerializer::class; + $this->registry['Region'] = RegionSerializer::class; + $this->registry['RegionalSupport'] = RegionalSupportSerializer::class; + $this->registry['SupportChannelType'] = SupportChannelTypeSerializer::class; + $this->registry['Office'] = OfficeSerializer::class; + $this->registry['Consultant'] = ConsultantSerializer::class; + $this->registry['ConsultantClient'] = ConsultantClientSerializer::class; + $this->registry['SpokenLanguage'] = SpokenLanguageSerializer::class; + $this->registry['ConfigurationManagementType'] = ConfigurationManagementTypeSerializer::class; + $this->registry['ServiceOfferedType'] = ServiceOfferedTypeSerializer::class; + $this->registry['ConsultantServiceOfferedType'] = ConsultantServiceOfferedTypeSerializer::class; + $this->registry['DataCenterLocation'] = DataCenterLocationSerializer::class; + $this->registry['DataCenterRegion'] = DataCenterRegionSerializer::class; + $this->registry['PricingSchemaType'] = PricingSchemaTypeSerializer::class; + $this->registry['PrivateCloudService'] = PrivateCloudServiceSerializer::class; + $this->registry['PublicCloudService'] = PublicCloudServiceSerializer::class; + $this->registry['RemoteCloudService'] = RemoteCloudServiceSerializer::class; + $this->registry['CloudServiceOffered'] = CloudServiceOfferedSerializer::class; + // software + + $this->registry['OpenStackComponent'] = OpenStackComponentSerializer::class; + $this->registry['OpenStackRelease'] = OpenStackReleaseSerializer::class; } /** @@ -115,6 +165,7 @@ final class SerializerRegistry * @return IModelSerializer */ public function getSerializer($object, $type = self::SerializerType_Public){ + if(is_null($object)) return null; $reflect = new \ReflectionClass($object); $class = $reflect->getShortName(); if(!isset($this->registry[$class])) diff --git a/app/ModelSerializers/Software/OpenStackComponentSerializer.php b/app/ModelSerializers/Software/OpenStackComponentSerializer.php new file mode 100644 index 00000000..26a7e835 --- /dev/null +++ b/app/ModelSerializers/Software/OpenStackComponentSerializer.php @@ -0,0 +1,29 @@ + 'name:json_string', + 'CodeName' => 'code_name:json_string', + ]; + +} \ No newline at end of file diff --git a/app/ModelSerializers/Software/OpenStackReleaseSerializer.php b/app/ModelSerializers/Software/OpenStackReleaseSerializer.php new file mode 100644 index 00000000..2a5eb4f5 --- /dev/null +++ b/app/ModelSerializers/Software/OpenStackReleaseSerializer.php @@ -0,0 +1,29 @@ + 'name:json_string', + 'ReleaseNumber' => 'release_number:json_string', + ]; + +} \ No newline at end of file diff --git a/app/Models/Foundation/Main/Member.php b/app/Models/Foundation/Main/Member.php index 97ba1b19..760cad9a 100644 --- a/app/Models/Foundation/Main/Member.php +++ b/app/Models/Foundation/Main/Member.php @@ -31,7 +31,7 @@ use Doctrine\ORM\Mapping AS ORM; /** * @ORM\Entity * @ORM\Table(name="Member") - * @ORM\Entity(repositoryClass="repositories\summit\DoctrineMemberRepository") + * @ORM\Entity(repositoryClass="App\Repositories\Summit\DoctrineMemberRepository") * Class Member * @package models\main */ diff --git a/app/Models/Foundation/Main/SummitMemberFavorite.php b/app/Models/Foundation/Main/SummitMemberFavorite.php index e759dc3a..30d8e7c5 100644 --- a/app/Models/Foundation/Main/SummitMemberFavorite.php +++ b/app/Models/Foundation/Main/SummitMemberFavorite.php @@ -12,9 +12,10 @@ * limitations under the License. **/ +use App\Models\Utils\BaseEntity; use Doctrine\ORM\Mapping AS ORM; use models\summit\SummitEvent; -use models\utils\IEntity; + /** * @ORM\Entity @@ -22,22 +23,8 @@ use models\utils\IEntity; * Class SummitMemberSchedule * @package models\main */ -final class SummitMemberFavorite +final class SummitMemberFavorite extends BaseEntity { - /** - * @ORM\Id - * @ORM\GeneratedValue - * @ORM\Column(name="ID", type="integer", unique=true, nullable=false) - */ - private $id; - - /** - * @return int - */ - public function getId() - { - return $this->id; - } /** * @return Member @@ -77,17 +64,9 @@ final class SummitMemberFavorite $this->event = $event; } - /** - * @return int - */ - public function getIdentifier() - { - return $this->id; - } - /** * @ORM\ManyToOne(targetEntity="Member", inversedBy="favorites") - * @ORM\JoinColumn(name="MemberID", referencedColumnName="ID", nullable=true ) + * @ORM\JoinColumn(name="MemberID", referencedColumnName="ID") * @var Member */ private $member; diff --git a/app/Models/Foundation/Main/SummitMemberSchedule.php b/app/Models/Foundation/Main/SummitMemberSchedule.php index cb39bdac..67542ab4 100644 --- a/app/Models/Foundation/Main/SummitMemberSchedule.php +++ b/app/Models/Foundation/Main/SummitMemberSchedule.php @@ -11,33 +11,22 @@ * See the License for the specific language governing permissions and * limitations under the License. **/ - +use App\Models\Utils\BaseEntity; use Doctrine\ORM\Mapping AS ORM; use models\summit\SummitEvent; use models\utils\IEntity; - /** * @ORM\Entity * @ORM\Table(name="Member_Schedule") * Class SummitMemberSchedule * @package models\main */ -final class SummitMemberSchedule implements IEntity +final class SummitMemberSchedule extends BaseEntity { - public function __construct() - { - } - - /** - * @ORM\Id - * @ORM\GeneratedValue - * @ORM\Column(name="ID", type="integer", unique=true, nullable=false) - */ - private $id; /** * @ORM\ManyToOne(targetEntity="Member", inversedBy="schedule") - * @ORM\JoinColumn(name="MemberID", referencedColumnName="ID", nullable=true ) + * @ORM\JoinColumn(name="MemberID", referencedColumnName="ID") * @var Member */ private $member; @@ -49,22 +38,6 @@ final class SummitMemberSchedule implements IEntity */ private $event; - /** - * @return int - */ - public function getIdentifier() - { - return $this->id; - } - - /** - * @return int - */ - public function getId() - { - return $this->id; - } - /** * @return Member */ diff --git a/app/Models/Foundation/Marketplace/Appliance.php b/app/Models/Foundation/Marketplace/Appliance.php new file mode 100644 index 00000000..44830dc1 --- /dev/null +++ b/app/Models/Foundation/Marketplace/Appliance.php @@ -0,0 +1,24 @@ +data_centers = new ArrayCollection(); + $this->capabilities_offered = new ArrayCollection(); + $this->data_center_regions = new ArrayCollection(); + } + + /** + * @return DataCenterLocation[] + */ + public function getDataCenters() + { + return $this->data_centers->toArray(); + } + + /** + * @return DataCenterRegion[] + */ + public function getDataCenterRegions() + { + return $this->data_center_regions->toArray(); + } + +} \ No newline at end of file diff --git a/app/Models/Foundation/Marketplace/CloudServiceOffered.php b/app/Models/Foundation/Marketplace/CloudServiceOffered.php new file mode 100644 index 00000000..88271c1b --- /dev/null +++ b/app/Models/Foundation/Marketplace/CloudServiceOffered.php @@ -0,0 +1,61 @@ +type; + } + + public function __construct() + { + parent::__construct(); + $this->pricing_schemas = new ArrayCollection(); + } + + /** + * @return PricingSchemaType[] + */ + public function getPricingSchemas() + { + return $this->pricing_schemas->toArray(); + } +} \ No newline at end of file diff --git a/app/Models/Foundation/Marketplace/CompanyService.php b/app/Models/Foundation/Marketplace/CompanyService.php index 16334009..765dd4ce 100644 --- a/app/Models/Foundation/Marketplace/CompanyService.php +++ b/app/Models/Foundation/Marketplace/CompanyService.php @@ -1,4 +1,4 @@ -reviews = new ArrayCollection(); + $this->videos = new ArrayCollection(); + $this->resources = new ArrayCollection(); + } + + /** + * @return string + */ + public function getName() + { + return $this->name; + } + + /** + * @return string + */ + public function getSlug() + { + return $this->slug; + } + + /** + * @return string + */ + public function getOverview() + { + return $this->overview; + } + + /** + * @return bool + */ + public function isActive() + { + return $this->is_active; + } + + /** + * @return Company + */ + public function getCompany() + { + return $this->company; + } + + /** + * @return Company + */ + public function getType() + { + return $this->type; + } /** * @return int */ - public function getIdentifier() + public function getCompanyId() { - return (int)$this->ID; + try { + return !is_null($this->company)? $this->company->getId():0; + } + catch(\Exception $ex){ + return 0; + } + } + + /** + * @return int + */ + public function getTypeId() + { + try { + return !is_null($this->type)? $this->type->getId():0; + } + catch(\Exception $ex){ + return 0; + } + } + + /** + * @return MarketPlaceReview[] + */ + public function getApprovedReviews(){ + $criteria = Criteria::create(); + $criteria->where(Criteria::expr()->eq('is_approved', true)); + return $this->reviews->matching($criteria)->toArray(); + } + + /** + * @return string + */ + public function getCall2ActionUrl() + { + return $this->call_2_action_url; + } + + /** + * @return MarketPlaceReview[] + */ + public function getReviews() + { + return $this->reviews->toArray(); + } + + /** + * @return MarketPlaceVideo[] + */ + public function getVideos() + { + return $this->videos->toArray(); + } + + /** + * @return CompanyServiceResource[] + */ + public function getResources() + { + return $this->resources->toArray(); } } \ No newline at end of file diff --git a/app/Models/Foundation/Marketplace/CompanyServiceResource.php b/app/Models/Foundation/Marketplace/CompanyServiceResource.php new file mode 100644 index 00000000..18e9f7ba --- /dev/null +++ b/app/Models/Foundation/Marketplace/CompanyServiceResource.php @@ -0,0 +1,81 @@ +name; + } + + /** + * @return string + */ + public function getUri() + { + return $this->uri; + } + + /** + * @return int + */ + public function getOrder() + { + return $this->order; + } + + /** + * @return CompanyService + */ + public function getCompanyService() + { + return $this->company_service; + } + +} \ No newline at end of file diff --git a/app/Models/Foundation/Marketplace/ConfigurationManagementType.php b/app/Models/Foundation/Marketplace/ConfigurationManagementType.php new file mode 100644 index 00000000..cc55bfcd --- /dev/null +++ b/app/Models/Foundation/Marketplace/ConfigurationManagementType.php @@ -0,0 +1,37 @@ +type; + } +} \ No newline at end of file diff --git a/app/Models/Foundation/Marketplace/Consultant.php b/app/Models/Foundation/Marketplace/Consultant.php index 6e304cdb..18308e99 100644 --- a/app/Models/Foundation/Marketplace/Consultant.php +++ b/app/Models/Foundation/Marketplace/Consultant.php @@ -1,7 +1,6 @@ -offices = new ArrayCollection(); + $this->clients = new ArrayCollection(); + $this->spoken_languages = new ArrayCollection(); + $this->configuration_management_expertises = new ArrayCollection(); + $this->expertise_areas = new ArrayCollection(); + $this->services_offered = new ArrayCollection(); + } /** * @return Office[] */ - public function offices() + public function getOffices() { - return $this->hasMany('models\marketplace\Office', 'ConsultantID', 'ID')->get(); + return $this->offices->toArray(); + } + + /** + * @return ConsultantClient[] + */ + public function getClients(){ + return $this->clients->toArray(); + } + + /** + * @return SpokenLanguage[] + */ + public function getSpokenLanguages() + { + return $this->spoken_languages->toArray(); + } + + /** + * @return ConfigurationManagementType[] + */ + public function getConfigurationManagementExpertise() + { + return $this->configuration_management_expertise->toArray(); + } + + /** + * @return OpenStackComponent[] + */ + public function getExpertiseAreas() + { + return $this->expertise_areas->toArray(); + } + + /** + * @return ConsultantServiceOfferedType[] + */ + public function getServicesOffered() + { + return $this->services_offered->toArray(); } } \ No newline at end of file diff --git a/app/Models/Foundation/Marketplace/ConsultantClient.php b/app/Models/Foundation/Marketplace/ConsultantClient.php new file mode 100644 index 00000000..1836f9f2 --- /dev/null +++ b/app/Models/Foundation/Marketplace/ConsultantClient.php @@ -0,0 +1,66 @@ +name; + } + + /** + * @return int + */ + public function getOrder() + { + return $this->order; + } + + /** + * @return Consultant + */ + public function getConsultant() + { + return $this->consultant; + } +} \ No newline at end of file diff --git a/app/Models/Foundation/Marketplace/ConsultantServiceOfferedType.php b/app/Models/Foundation/Marketplace/ConsultantServiceOfferedType.php new file mode 100644 index 00000000..b979233c --- /dev/null +++ b/app/Models/Foundation/Marketplace/ConsultantServiceOfferedType.php @@ -0,0 +1,68 @@ +consultant; + } + + /** + * @return ServiceOfferedType + */ + public function getServiceOffered() + { + return $this->service_offered; + } + + /** + * @return Region + */ + public function getRegion() + { + return $this->region; + } +} \ No newline at end of file diff --git a/app/Models/Foundation/Marketplace/DataCenterLocation.php b/app/Models/Foundation/Marketplace/DataCenterLocation.php index 6e28b528..323d32f0 100644 --- a/app/Models/Foundation/Marketplace/DataCenterLocation.php +++ b/app/Models/Foundation/Marketplace/DataCenterLocation.php @@ -1,37 +1,136 @@ -belongsTo('models\marketplace\DataCenterRegion', 'DataCenterRegionID'); - } + /** + * @ORM\Column(name="Lat", type="float") + * @var float + */ + private $lat; + + /** + * @ORM\Column(name="Lng", type="float") + * @var float + */ + private $lng; + + /** + * @ORM\ManyToOne(targetEntity="CloudService",inversedBy="data_centers", fetch="LAZY") + * @ORM\JoinColumn(name="CloudServiceID", referencedColumnName="ID") + * @var CloudService + */ + private $cloud_service; + + /** + * @ORM\ManyToOne(targetEntity="DataCenterRegion",inversedBy="locations", fetch="LAZY") + * @ORM\JoinColumn(name="DataCenterRegionID", referencedColumnName="ID") + * @var DataCenterRegion + */ + private $region; + + /** + * @return string + */ + public function getCity() + { + return $this->city; + } + + /** + * @return string + */ + public function getState() + { + return $this->state; + } + + /** + * @return string + */ + public function getCountry() + { + return $this->country; + } + + /** + * @return float + */ + public function getLat() + { + return $this->lat; + } + + /** + * @return float + */ + public function getLng() + { + return $this->lng; + } + + /** + * @return CloudService + */ + public function getCloudService() + { + return $this->cloud_service; + } + + /** + * @return DataCenterRegion + */ + public function getRegion() + { + return $this->region; + } + + /** + * @return int + */ + public function getRegionId(){ + try{ + return !is_null($this->region) ? $this->region->getId(): 0; + } + catch (\Exception $ex){ + return 0; + } + } } \ No newline at end of file diff --git a/app/Models/Foundation/Marketplace/DataCenterRegion.php b/app/Models/Foundation/Marketplace/DataCenterRegion.php index dbb74aa0..86dc0dde 100644 --- a/app/Models/Foundation/Marketplace/DataCenterRegion.php +++ b/app/Models/Foundation/Marketplace/DataCenterRegion.php @@ -1,38 +1,101 @@ -hasMany('models\marketplace\DataCenterLocation', 'DataCenterRegionID', 'ID')->get(); - } + /** + * @ORM\OneToMany(targetEntity="DataCenterLocation", mappedBy="region", cascade={"persist"}, orphanRemoval=true) + * @var DataCenterLocation[] + */ + private $locations; + /** + * @ORM\ManyToOne(targetEntity="CloudService",inversedBy="data_center_regions", fetch="LAZY") + * @ORM\JoinColumn(name="CloudServiceID", referencedColumnName="ID") + * @var CloudService + */ + private $cloud_service; + + public function __construct() + { + parent::__construct(); + $this->locations = new ArrayCollection(); + } + + /** + * @return string + */ + public function getName() + { + return $this->name; + } + + /** + * @return string + */ + public function getEndpoint() + { + return $this->endpoint; + } + + /** + * @return string + */ + public function getColor() + { + return $this->color; + } + + /** + * @return DataCenterLocation[] + */ + public function getLocations() + { + return $this->locations->toArray(); + } + + /** + * @return CloudService + */ + public function getCloudService() + { + return $this->cloud_service; + } } \ No newline at end of file diff --git a/app/Models/Foundation/Marketplace/Distribution.php b/app/Models/Foundation/Marketplace/Distribution.php new file mode 100644 index 00000000..58a0c2cc --- /dev/null +++ b/app/Models/Foundation/Marketplace/Distribution.php @@ -0,0 +1,24 @@ +type; + } +} \ No newline at end of file diff --git a/app/Models/Foundation/Marketplace/HyperVisorType.php b/app/Models/Foundation/Marketplace/HyperVisorType.php new file mode 100644 index 00000000..4a97d409 --- /dev/null +++ b/app/Models/Foundation/Marketplace/HyperVisorType.php @@ -0,0 +1,37 @@ +type; + } +} \ No newline at end of file diff --git a/app/Models/Foundation/Marketplace/IApplianceRepository.php b/app/Models/Foundation/Marketplace/IApplianceRepository.php new file mode 100644 index 00000000..ede3ef52 --- /dev/null +++ b/app/Models/Foundation/Marketplace/IApplianceRepository.php @@ -0,0 +1,23 @@ +name; + } + + /** + * @return string + */ + public function getDescripion() + { + return $this->descripion; + } + + /** + * @return string + */ + public function getStatus() + { + return $this->status; + } + + /** + * @return InteropCapabilityType + */ + public function getType() + { + return $this->type; + } +} \ No newline at end of file diff --git a/app/Models/Foundation/Marketplace/InteropCapabilityType.php b/app/Models/Foundation/Marketplace/InteropCapabilityType.php new file mode 100644 index 00000000..9b7018fc --- /dev/null +++ b/app/Models/Foundation/Marketplace/InteropCapabilityType.php @@ -0,0 +1,38 @@ +name; + } +} \ No newline at end of file diff --git a/app/Models/Foundation/Marketplace/InteropDesignatedSection.php b/app/Models/Foundation/Marketplace/InteropDesignatedSection.php new file mode 100644 index 00000000..d143ffa6 --- /dev/null +++ b/app/Models/Foundation/Marketplace/InteropDesignatedSection.php @@ -0,0 +1,80 @@ +name; + } + + /** + * @return string + */ + public function getStatus() + { + return $this->status; + } + + /** + * @return string + */ + public function getGuidance() + { + return $this->guidance; + } + + /** + * @return string + */ + public function getComment() + { + return $this->comment; + } +} \ No newline at end of file diff --git a/app/Models/Foundation/Marketplace/InteropProgramVersion.php b/app/Models/Foundation/Marketplace/InteropProgramVersion.php new file mode 100644 index 00000000..2eb0ba07 --- /dev/null +++ b/app/Models/Foundation/Marketplace/InteropProgramVersion.php @@ -0,0 +1,68 @@ +capabilities = new ArrayCollection(); + $this->designated_sections = new ArrayCollection(); + } + + /** + * @return string + */ + public function getName() + { + return $this->name; + } + + + +} \ No newline at end of file diff --git a/app/Models/Foundation/Marketplace/MarketPlaceReview.php b/app/Models/Foundation/Marketplace/MarketPlaceReview.php new file mode 100644 index 00000000..6631936c --- /dev/null +++ b/app/Models/Foundation/Marketplace/MarketPlaceReview.php @@ -0,0 +1,96 @@ +title; + } + + /** + * @return string + */ + public function getComment() + { + return $this->comment; + } + + /** + * @return string + */ + public function getRating() + { + return $this->rating; + } + + /** + * @return bool + */ + public function isApproved() + { + return $this->is_approved; + } + + /** + * @return CompanyService + */ + public function getCompanyService() + { + return $this->company_service; + } + +} \ No newline at end of file diff --git a/app/Models/Foundation/Marketplace/MarketPlaceType.php b/app/Models/Foundation/Marketplace/MarketPlaceType.php new file mode 100644 index 00000000..0138b84e --- /dev/null +++ b/app/Models/Foundation/Marketplace/MarketPlaceType.php @@ -0,0 +1,66 @@ +name; + } + + /** + * @return string + */ + public function getSlug() + { + return $this->slug; + } + + /** + * @return bool + */ + public function isActive() + { + return $this->is_active; + } +} \ No newline at end of file diff --git a/app/Models/Foundation/Marketplace/MarketPlaceVideo.php b/app/Models/Foundation/Marketplace/MarketPlaceVideo.php new file mode 100644 index 00000000..f3d29a9a --- /dev/null +++ b/app/Models/Foundation/Marketplace/MarketPlaceVideo.php @@ -0,0 +1,95 @@ +name; + } + + /** + * @return string + */ + public function getDescription() + { + return $this->description; + } + + /** + * @return string + */ + public function getYoutubeId() + { + return $this->youtube_id; + } + + /** + * @return MarketPlaceVideoType + */ + public function getType() + { + return $this->type; + } + + /** + * @return CompanyService + */ + public function getCompanyService() + { + return $this->company_service; + } +} \ No newline at end of file diff --git a/app/Models/Foundation/Marketplace/MarketPlaceVideoType.php b/app/Models/Foundation/Marketplace/MarketPlaceVideoType.php new file mode 100644 index 00000000..b39b39ce --- /dev/null +++ b/app/Models/Foundation/Marketplace/MarketPlaceVideoType.php @@ -0,0 +1,37 @@ +type; + } +} \ No newline at end of file diff --git a/app/Models/Foundation/Marketplace/Office.php b/app/Models/Foundation/Marketplace/Office.php index 5aa7e11f..a9a17b56 100644 --- a/app/Models/Foundation/Marketplace/Office.php +++ b/app/Models/Foundation/Marketplace/Office.php @@ -1,38 +1,151 @@ -address; + } + + /** + * @return string + */ + public function getAddress2() + { + return $this->address2; + } + + /** + * @return string + */ + public function getState() + { + return $this->state; + } + + /** + * @return string + */ + public function getZipCode() + { + return $this->zip_code; + } + + /** + * @return string + */ + public function getCity() + { + return $this->city; + } + + /** + * @return string + */ + public function getCountry() + { + return $this->country; + } + + /** + * @return float + */ + public function getLat() + { + return $this->lat; + } + + /** + * @return float + */ + public function getLng() + { + return $this->lng; + } + + /** + * @return Consultant + */ + public function getConsultant() + { + return $this->consultant; + } - /** - * @return Consultant - */ - public function consultant() - { - return $this->belongsTo('models\marketplace\Consultant', 'ConsultantID'); - } } \ No newline at end of file diff --git a/app/Models/Foundation/Marketplace/OpenStackImplementation.php b/app/Models/Foundation/Marketplace/OpenStackImplementation.php new file mode 100644 index 00000000..ff2c352a --- /dev/null +++ b/app/Models/Foundation/Marketplace/OpenStackImplementation.php @@ -0,0 +1,247 @@ +hypervisors = new ArrayCollection(); + $this->guests = new ArrayCollection(); + $this->capabilities = new ArrayCollection(); + } + + /** + * @return bool + */ + public function isCompatibleWithStorage() + { + return $this->is_compatible_with_storage; + } + + /** + * @return bool + */ + public function isCompatibleWithCompute() + { + return $this->is_compatible_with_compute; + } + + /** + * @return bool + */ + public function isCompatibleWithFederatedIdentity() + { + return $this->is_compatible_with_federated_identity; + } + + /*** + * @return bool + */ + public function isCompatibleWithPlatform() + { + return $this->isCompatibleWithStorage() && $this->isCompatibleWithCompute(); + } + + /*** + * @return bool + */ + public function isOpenStackPowered() + { + $storage = $this->isCompatibleWithStorage(); + $compute = $this->isCompatibleWithCompute(); + $platform = $this->isCompatibleWithPlatform(); + return ($storage || $compute || $platform) && !$this->isOpenStackPoweredExpired(); + } + + /** + * @return bool + */ + public function isOpenStackPoweredExpired() + { + $res = false; + if(!$this->expire_date) return $res; + $utc_timezone = new DateTimeZone("UTC"); + $time_zone = new DateTimeZone('America/Chicago'); + $expiry_date = new DateTime($this->expire_date->format(DateTime::ISO8601), $time_zone); + $expiry_date = $expiry_date->setTimezone($utc_timezone); + $utc_now = new DateTime(null, new DateTimeZone("UTC")); + return $utc_now > $expiry_date; + } + + /** + * @return string + */ + public function getTestedCapabilityTypeLabel() + { + if ($this->isCompatibleWithPlatform()) { + return 'Platform'; + } else if ($this->isCompatibleWithCompute()) { + return 'Compute'; + } else if ($this->isCompatibleWithStorage()) { + return 'Storage'; + } + } + + /** + * @return bool + */ + public function isOpenStackTested() + { + try { + $program_version = $this->program_version; + return !is_null($program_version) && $program_version->getId() > 0; + } + catch(\Exception $ex){ + return false; + } + } + + /** + * @return null|string + */ + public function getOpenStackTestedLabel(){ + if(!$this->isOpenStackTested()) return null; + return $this->getTestedCapabilityTypeLabel().' '.$this->program_version->getName(); + } + /** + * @return DateTime + */ + public function getExpireDate() + { + return $this->expire_date; + } + + /** + * @return string + */ + public function getNotes() + { + return $this->notes; + } + + /** + * @return OpenStackImplementationApiCoverage + */ + public function getCapabilities() + { + return $this->capabilities->toArray(); + } + + /** + * @return HyperVisorType[] + */ + public function getHypervisors() + { + return $this->hypervisors->toArray(); + } + + /** + * @return GuestOSType[] + */ + public function getGuests() + { + return $this->guests->toArray(); + } +} \ No newline at end of file diff --git a/app/Models/Foundation/Marketplace/OpenStackImplementationApiCoverage.php b/app/Models/Foundation/Marketplace/OpenStackImplementationApiCoverage.php new file mode 100644 index 00000000..dd9a1976 --- /dev/null +++ b/app/Models/Foundation/Marketplace/OpenStackImplementationApiCoverage.php @@ -0,0 +1,88 @@ +percent; + } + + /** + * @return OpenStackReleaseSupportedApiVersion + */ + public function getReleaseSupportedApiVersion() + { + return $this->release_supported_api_version; + } + + /** + * @return OpenStackImplementation + */ + public function getImplementation() + { + return $this->implementation; + } + + /** + * @return bool + */ + public function hasReleaseSupportedApiVersion(){ + try{ + if(is_null($this->release_supported_api_version)) return false; + return $this->release_supported_api_version->getId() > 0; + } + catch (\Exception $ex){ + return false; + } + } +} \ No newline at end of file diff --git a/app/Models/Foundation/Marketplace/PricingSchemaType.php b/app/Models/Foundation/Marketplace/PricingSchemaType.php new file mode 100644 index 00000000..8e2349f8 --- /dev/null +++ b/app/Models/Foundation/Marketplace/PricingSchemaType.php @@ -0,0 +1,37 @@ +type; + } +} \ No newline at end of file diff --git a/app/Models/Foundation/Marketplace/PrivateCloudService.php b/app/Models/Foundation/Marketplace/PrivateCloudService.php index 50865f11..dfcaf7c8 100644 --- a/app/Models/Foundation/Marketplace/PrivateCloudService.php +++ b/app/Models/Foundation/Marketplace/PrivateCloudService.php @@ -1,31 +1,24 @@ -hasMany('models\marketplace\DataCenterRegion', 'CloudServiceID', 'ID')->get(); - } - } \ No newline at end of file diff --git a/app/Models/Foundation/Marketplace/PublicCloudService.php b/app/Models/Foundation/Marketplace/PublicCloudService.php index d9c97925..b3c0f4f6 100644 --- a/app/Models/Foundation/Marketplace/PublicCloudService.php +++ b/app/Models/Foundation/Marketplace/PublicCloudService.php @@ -1,32 +1,24 @@ -hasMany('models\marketplace\DataCenterRegion', 'CloudServiceID', 'ID')->get(); - } } \ No newline at end of file diff --git a/app/Models/Foundation/Marketplace/Region.php b/app/Models/Foundation/Marketplace/Region.php new file mode 100644 index 00000000..c4c603fb --- /dev/null +++ b/app/Models/Foundation/Marketplace/Region.php @@ -0,0 +1,37 @@ +name; + } +} \ No newline at end of file diff --git a/app/Models/Foundation/Marketplace/RegionalSupport.php b/app/Models/Foundation/Marketplace/RegionalSupport.php new file mode 100644 index 00000000..b1be0ead --- /dev/null +++ b/app/Models/Foundation/Marketplace/RegionalSupport.php @@ -0,0 +1,91 @@ +supported_channel_types = new ArrayCollection(); + } + + /** + * @return int + */ + public function getOrder() + { + return $this->order; + } + + /** + * @return Region + */ + public function getRegion() + { + return $this->region; + } + + /** + * @return RegionalSupportedCompanyService + */ + public function getCompanyService() + { + return $this->company_service; + } + + /** + * @return SupportChannelType[] + */ + public function getSupportedChannelTypes() + { + return $this->supported_channel_types->toArray(); + } +} \ No newline at end of file diff --git a/app/Models/Foundation/Marketplace/RegionalSupportedCompanyService.php b/app/Models/Foundation/Marketplace/RegionalSupportedCompanyService.php new file mode 100644 index 00000000..ad2fd479 --- /dev/null +++ b/app/Models/Foundation/Marketplace/RegionalSupportedCompanyService.php @@ -0,0 +1,45 @@ +regional_supports = new ArrayCollection(); + } + + /** + * @return RegionalSupport[] + */ + public function getRegionalSupports() + { + return $this->regional_supports->toArray(); + } +} \ No newline at end of file diff --git a/app/Models/Foundation/Marketplace/RemoteCloudService.php b/app/Models/Foundation/Marketplace/RemoteCloudService.php new file mode 100644 index 00000000..4f5f5bbf --- /dev/null +++ b/app/Models/Foundation/Marketplace/RemoteCloudService.php @@ -0,0 +1,78 @@ +hardware_spec; + } + + /** + * @return string + */ + public function getPricingModels() + { + return $this->pricing_models; + } + + /** + * @return string + */ + public function getPublishedSla() + { + return $this->published_sla; + } + + /** + * @return bool + */ + public function isVendorManagedUpgrades() + { + return $this->vendor_managed_upgrades; + } +} \ No newline at end of file diff --git a/app/Models/Foundation/Marketplace/ServiceOfferedType.php b/app/Models/Foundation/Marketplace/ServiceOfferedType.php new file mode 100644 index 00000000..fa0b2e53 --- /dev/null +++ b/app/Models/Foundation/Marketplace/ServiceOfferedType.php @@ -0,0 +1,37 @@ +type; + } +} \ No newline at end of file diff --git a/app/Models/Foundation/Marketplace/SpokenLanguage.php b/app/Models/Foundation/Marketplace/SpokenLanguage.php new file mode 100644 index 00000000..d5bbc57a --- /dev/null +++ b/app/Models/Foundation/Marketplace/SpokenLanguage.php @@ -0,0 +1,37 @@ +name; + } +} \ No newline at end of file diff --git a/app/Models/Foundation/Marketplace/SupportChannelType.php b/app/Models/Foundation/Marketplace/SupportChannelType.php new file mode 100644 index 00000000..5233aa7a --- /dev/null +++ b/app/Models/Foundation/Marketplace/SupportChannelType.php @@ -0,0 +1,38 @@ +type; + } +} \ No newline at end of file diff --git a/app/Models/Foundation/Software/OpenStackApiVersion.php b/app/Models/Foundation/Software/OpenStackApiVersion.php new file mode 100644 index 00000000..2e89ca5f --- /dev/null +++ b/app/Models/Foundation/Software/OpenStackApiVersion.php @@ -0,0 +1,81 @@ +version; + } + + /** + * @return string + */ + public function getStatus() + { + return $this->status; + } + + /** + * @return OpenStackComponent + */ + public function getComponent() + { + return $this->component; + } + + /** + * @return bool + */ + public function hasComponent(){ + try{ + if(is_null($this->component)) return false; + return $this->component->getId() > 0 ; + } + catch (\Exception $ex){ + return false; + } + } + +} \ No newline at end of file diff --git a/app/Models/Foundation/Software/OpenStackComponent.php b/app/Models/Foundation/Software/OpenStackComponent.php new file mode 100644 index 00000000..361bfe01 --- /dev/null +++ b/app/Models/Foundation/Software/OpenStackComponent.php @@ -0,0 +1,65 @@ +name; + } + + /** + * @return string + */ + public function getCodeName() + { + return $this->code_name; + } + + /** + * @return string + */ + public function getDescription() + { + return $this->description; + } +} \ No newline at end of file diff --git a/app/Models/Foundation/Software/OpenStackRelease.php b/app/Models/Foundation/Software/OpenStackRelease.php new file mode 100644 index 00000000..cde01b09 --- /dev/null +++ b/app/Models/Foundation/Software/OpenStackRelease.php @@ -0,0 +1,66 @@ +name; + } + + /** + * @return string + */ + public function getReleaseNumber() + { + return $this->release_number; + } + + /** + * @return DateTime + */ + public function getReleaseDate() + { + return $this->release_date; + } +} \ No newline at end of file diff --git a/app/Models/Foundation/Software/OpenStackReleaseSupportedApiVersion.php b/app/Models/Foundation/Software/OpenStackReleaseSupportedApiVersion.php new file mode 100644 index 00000000..afdbd647 --- /dev/null +++ b/app/Models/Foundation/Software/OpenStackReleaseSupportedApiVersion.php @@ -0,0 +1,135 @@ +version; + } + + /** + * @return string + */ + public function getStatus() + { + return $this->status; + } + + /** + * @return OpenStackComponent + */ + public function getComponent() + { + return $this->component; + } + + /** + * @return OpenStackApiVersion + */ + public function getApiVersion() + { + return $this->api_version; + } + + /** + * @return OpenStackRelease + */ + public function getRelease() + { + return $this->release; + } + + /** + * @return bool + */ + public function hasApiVersion(){ + try{ + if(is_null($this->api_version)) return false; + return $this->api_version->getId() > 0 ; + } + catch (\Exception $ex){ + return false; + } + } + + /** + * @return bool + */ + public function hasComponent(){ + try{ + if(is_null($this->component)) return false; + return $this->component->getId() > 0 ; + } + catch (\Exception $ex){ + return false; + } + } + + /** + * @return bool + */ + public function hasRelease(){ + try{ + if(is_null($this->release)) return false; + return $this->release->getId() > 0 ; + } + catch (\Exception $ex){ + return false; + } + } +} \ No newline at end of file diff --git a/app/Models/Foundation/Summit/Attendees/SummitAttendee.php b/app/Models/Foundation/Summit/Attendees/SummitAttendee.php index 28127dc2..15a16819 100644 --- a/app/Models/Foundation/Summit/Attendees/SummitAttendee.php +++ b/app/Models/Foundation/Summit/Attendees/SummitAttendee.php @@ -24,7 +24,7 @@ use models\utils\SilverstripeBaseModel; /** * @ORM\Entity * @ORM\Table(name="SummitAttendee") - * @ORM\Entity(repositoryClass="repositories\summit\DoctrineSummitAttendeeRepository") + * @ORM\Entity(repositoryClass="App\Repositories\Summit\DoctrineSummitAttendeeRepository") * Class SummitAttendee * @package models\summit */ diff --git a/app/Models/Foundation/Summit/Attendees/SummitAttendeeTicket.php b/app/Models/Foundation/Summit/Attendees/SummitAttendeeTicket.php index fbb4e8d9..98b55ceb 100644 --- a/app/Models/Foundation/Summit/Attendees/SummitAttendeeTicket.php +++ b/app/Models/Foundation/Summit/Attendees/SummitAttendeeTicket.php @@ -17,7 +17,7 @@ use Doctrine\ORM\Mapping AS ORM; /** * @ORM\Entity * @ORM\Table(name="SummitAttendeeTicket") - * @ORM\Entity(repositoryClass="repositories\summit\DoctrineSummitAttendeeTicketRepository") + * @ORM\Entity(repositoryClass="App\Repositories\Summit\DoctrineSummitAttendeeTicketRepository") * Class SummitAttendeeTicket * @package models\summit */ diff --git a/app/Models/Foundation/Summit/CalendarSync/CalendarSyncInfo.php b/app/Models/Foundation/Summit/CalendarSync/CalendarSyncInfo.php index e0f5246c..ae726ebd 100644 --- a/app/Models/Foundation/Summit/CalendarSync/CalendarSyncInfo.php +++ b/app/Models/Foundation/Summit/CalendarSync/CalendarSyncInfo.php @@ -19,7 +19,7 @@ use models\summit\SummitOwned; use models\utils\SilverstripeBaseModel; /** - * @ORM\Entity(repositoryClass="repositories\summit\DoctrineCalendarSyncInfoRepository") + * @ORM\Entity(repositoryClass="App\Repositories\Summit\DoctrineCalendarSyncInfoRepository") * @ORM\Table(name="CalendarSyncInfo") * @ORM\InheritanceType("JOINED") * @ORM\DiscriminatorColumn(name="ClassName", type="string") diff --git a/app/Models/Foundation/Summit/CalendarSync/ScheduleCalendarSyncInfo.php b/app/Models/Foundation/Summit/CalendarSync/ScheduleCalendarSyncInfo.php index 9fcd8e31..09bc8135 100644 --- a/app/Models/Foundation/Summit/CalendarSync/ScheduleCalendarSyncInfo.php +++ b/app/Models/Foundation/Summit/CalendarSync/ScheduleCalendarSyncInfo.php @@ -19,7 +19,7 @@ use models\summit\SummitEvent; use models\utils\SilverstripeBaseModel; /** - * @ORM\Entity(repositoryClass="repositories\summit\DoctrineScheduleCalendarSyncInfoRepository") + * @ORM\Entity(repositoryClass="App\Repositories\Summit\DoctrineScheduleCalendarSyncInfoRepository") * @ORM\Table(name="ScheduleCalendarSyncInfo") * @package models\summit\CalendarSync */ diff --git a/app/Models/Foundation/Summit/CalendarSync/WorkQueue/AbstractCalendarSyncWorkRequest.php b/app/Models/Foundation/Summit/CalendarSync/WorkQueue/AbstractCalendarSyncWorkRequest.php index fcf8fa66..740e69eb 100644 --- a/app/Models/Foundation/Summit/CalendarSync/WorkQueue/AbstractCalendarSyncWorkRequest.php +++ b/app/Models/Foundation/Summit/CalendarSync/WorkQueue/AbstractCalendarSyncWorkRequest.php @@ -14,7 +14,7 @@ use Doctrine\ORM\Mapping AS ORM; use models\utils\SilverstripeBaseModel; /** - * @ORM\Entity(repositoryClass="repositories\summit\DoctrineAbstractCalendarSyncWorkRequestRepository") + * @ORM\Entity(repositoryClass="App\Repositories\Summit\DoctrineAbstractCalendarSyncWorkRequestRepository") * @ORM\Table(name="AbstractCalendarSyncWorkRequest") * @ORM\InheritanceType("JOINED") * @ORM\DiscriminatorColumn(name="ClassName", type="string") diff --git a/app/Models/Foundation/Summit/Events/Presentations/PresentationSpeaker.php b/app/Models/Foundation/Summit/Events/Presentations/PresentationSpeaker.php index 1e4dcc37..7f309a94 100644 --- a/app/Models/Foundation/Summit/Events/Presentations/PresentationSpeaker.php +++ b/app/Models/Foundation/Summit/Events/Presentations/PresentationSpeaker.php @@ -22,7 +22,7 @@ use Doctrine\Common\Collections\ArrayCollection; /** * @ORM\Entity * @ORM\Table(name="PresentationSpeaker") - * @ORM\Entity(repositoryClass="repositories\summit\DoctrineSpeakerRepository") + * @ORM\Entity(repositoryClass="App\Repositories\Summit\DoctrineSpeakerRepository") * Class PresentationSpeaker * @package models\summit */ diff --git a/app/Models/Foundation/Summit/Events/RSVP.php b/app/Models/Foundation/Summit/Events/RSVP.php index a8d539cc..4ad3112a 100644 --- a/app/Models/Foundation/Summit/Events/RSVP.php +++ b/app/Models/Foundation/Summit/Events/RSVP.php @@ -21,7 +21,7 @@ use Doctrine\Common\Collections\ArrayCollection; /** * @ORM\Entity * @ORM\Table(name="RSVP") - * @ORM\Entity(repositoryClass="repositories\summit\DoctrineRSVPRepository") + * @ORM\Entity(repositoryClass="App\Repositories\Summit\DoctrineRSVPRepository") * Class RSVP * @package models\summit */ diff --git a/app/Models/Foundation/Summit/Events/SummitEntityEvent.php b/app/Models/Foundation/Summit/Events/SummitEntityEvent.php index bea99939..238b20d2 100644 --- a/app/Models/Foundation/Summit/Events/SummitEntityEvent.php +++ b/app/Models/Foundation/Summit/Events/SummitEntityEvent.php @@ -20,7 +20,7 @@ use Doctrine\ORM\Mapping AS ORM; /** * @ORM\Entity * @ORM\Table(name="SummitEntityEvent") - * @ORM\Entity(repositoryClass="repositories\summit\DoctrineSummitEntityEventRepository") + * @ORM\Entity(repositoryClass="App\Repositories\Summit\DoctrineSummitEntityEventRepository") * Class SummitEntityEvent * @package models\summit */ diff --git a/app/Models/Foundation/Summit/Events/SummitEvent.php b/app/Models/Foundation/Summit/Events/SummitEvent.php index ceb96f30..69c35035 100644 --- a/app/Models/Foundation/Summit/Events/SummitEvent.php +++ b/app/Models/Foundation/Summit/Events/SummitEvent.php @@ -30,18 +30,149 @@ use Illuminate\Support\Facades\Config; use Cocur\Slugify\Slugify; /** - * @ORM\Entity + * @ORM\Entity(repositoryClass="App\Repositories\Summit\DoctrineSummitEventRepository") * @ORM\Table(name="SummitEvent") * @ORM\InheritanceType("JOINED") * @ORM\DiscriminatorColumn(name="ClassName", type="string") * @ORM\DiscriminatorMap({"SummitEvent" = "SummitEvent", "Presentation" = "Presentation", "SummitGroupEvent" = "SummitGroupEvent", "SummitEventWithFile" = "SummitEventWithFile"}) - * @ORM\Entity(repositoryClass="repositories\summit\DoctrineSummitEventRepository") * @ORM\HasLifecycleCallbacks * Class SummitEvent * @package models\summit */ class SummitEvent extends SilverstripeBaseModel { + /** + * @ORM\Column(name="Title", type="string") + * @var string + */ + protected $title; + + /** + * @ORM\Column(name="Abstract", type="string") + * @var string + */ + protected $abstract; + + /** + * @ORM\Column(name="SocialSummary", type="string") + * @var string + */ + protected $social_summary; + + /** + * @ORM\Column(name="StartDate", type="datetime") + * @var \DateTime + */ + protected $start_date; + + /** + * @ORM\Column(name="EndDate", type="datetime") + * @var \DateTime + */ + protected $end_date; + + /** + * @ORM\Column(name="Published", type="boolean") + * @var bool + */ + protected $published; + + /** + * @ORM\Column(name="PublishedDate", type="datetime") + * @var \DateTime + */ + protected $published_date; + + /** + * @ORM\Column(name="AllowFeedBack", type="boolean") + * @var bool + */ + protected $allow_feedback; + + /** + * @ORM\Column(name="AvgFeedbackRate", type="float") + * @var float + */ + protected $avg_feedback; + + /** + * @ORM\Column(name="RSVPLink", type="string") + * @var string + */ + protected $rsvp_link; + + /** + * @ORM\Column(name="HeadCount", type="integer") + * @var int + */ + protected $head_count; + + /** + * @ORM\Column(name="RSVPTemplateID", type="integer") + * @var int + */ + protected $rsvp_template_id; + + /** + * @ORM\OneToMany(targetEntity="models\summit\RSVP", mappedBy="event", cascade={"persist"}) + * @var RSVP[] + */ + protected $rsvp; + + /** + * @ORM\ManyToOne(targetEntity="PresentationCategory", fetch="EXTRA_LAZY") + * @ORM\JoinColumn(name="CategoryID", referencedColumnName="ID") + * @var PresentationCategory + */ + protected $category = null; + + /** + * @ORM\ManyToOne(targetEntity="SummitEventType", fetch="EXTRA_LAZY") + * @ORM\JoinColumn(name="TypeID", referencedColumnName="ID") + * @var SummitEventType + */ + protected $type; + + /** + * @ORM\ManyToOne(targetEntity="SummitAbstractLocation", fetch="EXTRA_LAZY") + * @ORM\JoinColumn(name="LocationID", referencedColumnName="ID") + */ + protected $location = null; + + /** + * @ORM\ManyToMany(targetEntity="models\main\Company", inversedBy="sponsorships", fetch="EXTRA_LAZY") + * @ORM\JoinTable(name="SummitEvent_Sponsors", + * joinColumns={@ORM\JoinColumn(name="SummitEventID", referencedColumnName="ID")}, + * inverseJoinColumns={@ORM\JoinColumn(name="CompanyID", referencedColumnName="ID")} + * ) + */ + protected $sponsors; + + /** + * @ORM\ManyToMany(targetEntity="models\summit\SummitAttendee") + * @ORM\JoinTable(name="SummitAttendee_Schedule", + * joinColumns={@ORM\JoinColumn(name="SummitEventID", referencedColumnName="ID")}, + * inverseJoinColumns={@ORM\JoinColumn(name="SummitAttendeeID", referencedColumnName="ID")} + * ) + */ + protected $attendees; + + /** + * @ORM\OneToMany(targetEntity="models\summit\SummitEventFeedback", mappedBy="event", cascade={"persist"}) + * @ORM\Cache("NONSTRICT_READ_WRITE") + * @var SummitEventFeedback[] + */ + protected $feedback; + + /** + * @ORM\ManyToMany(targetEntity="models\main\Tag", cascade={"persist"}) + * @ORM\JoinTable(name="SummitEvent_Tags", + * joinColumns={@ORM\JoinColumn(name="SummitEventID", referencedColumnName="ID")}, + * inverseJoinColumns={@ORM\JoinColumn(name="TagID", referencedColumnName="ID")} + * ) + */ + protected $tags; + /** * @return string */ @@ -85,13 +216,6 @@ class SummitEvent extends SilverstripeBaseModel $this->rsvp = new ArrayCollection(); } - /** - * @ORM\ManyToOne(targetEntity="PresentationCategory", fetch="EXTRA_LAZY") - * @ORM\JoinColumn(name="CategoryID", referencedColumnName="ID") - * @var PresentationCategory - */ - private $category = null; - /** * @param PresentationCategory $category * @return $this @@ -121,12 +245,6 @@ class SummitEvent extends SilverstripeBaseModel } } - /** - * @ORM\Column(name="Title", type="string") - * @var string - */ - protected $title; - /** * @param string $title * @return $this @@ -176,30 +294,6 @@ class SummitEvent extends SilverstripeBaseModel $this->social_summary = $social_summary; } - /** - * @ORM\Column(name="Abstract", type="string") - * @var string - */ - protected $abstract; - - /** - * @ORM\Column(name="SocialSummary", type="string") - * @var string - */ - protected $social_summary; - - /** - * @ORM\Column(name="StartDate", type="datetime") - * @var \DateTime - */ - protected $start_date; - - /** - * @ORM\Column(name="RSVPTemplateID", type="integer") - * @var int - */ - protected $rsvp_template_id; - /** * @return DateTime */ @@ -305,49 +399,6 @@ class SummitEvent extends SilverstripeBaseModel $this->head_count = $head_count; } - /** - * @ORM\Column(name="EndDate", type="datetime") - * @var \DateTime - */ - protected $end_date; - - /** - * @ORM\Column(name="Published", type="boolean") - * @var bool - */ - protected $published; - - /** - * @ORM\Column(name="PublishedDate", type="datetime") - * @var \DateTime - */ - protected $published_date; - - /** - * @ORM\Column(name="AllowFeedBack", type="boolean") - * @var bool - */ - protected $allow_feedback; - - /** - * @ORM\Column(name="AvgFeedbackRate", type="float") - * @var float - */ - protected $avg_feedback; - - /** - * @ORM\Column(name="RSVPLink", type="string") - * @var string - */ - protected $rsvp_link; - - - /** - * @ORM\Column(name="HeadCount", type="integer") - * @var int - */ - protected $head_count; - /** * @return bool */ @@ -471,13 +522,6 @@ class SummitEvent extends SilverstripeBaseModel } } - /** - * @ORM\ManyToOne(targetEntity="SummitEventType", fetch="EXTRA_LAZY") - * @ORM\JoinColumn(name="TypeID", referencedColumnName="ID") - * @var SummitEventType - */ - private $type; - /** * @param SummitEventType $type * @return $this @@ -495,12 +539,6 @@ class SummitEvent extends SilverstripeBaseModel return $this->type; } - /** - * @ORM\ManyToOne(targetEntity="SummitAbstractLocation", fetch="EXTRA_LAZY") - * @ORM\JoinColumn(name="LocationID", referencedColumnName="ID") - */ - private $location = null; - /** * @param SummitAbstractLocation $location * @return $this @@ -529,15 +567,6 @@ class SummitEvent extends SilverstripeBaseModel })->toArray(); } - /** - * @ORM\ManyToMany(targetEntity="models\main\Company", inversedBy="sponsorships", fetch="EXTRA_LAZY") - * @ORM\JoinTable(name="SummitEvent_Sponsors", - * joinColumns={@ORM\JoinColumn(name="SummitEventID", referencedColumnName="ID")}, - * inverseJoinColumns={@ORM\JoinColumn(name="CompanyID", referencedColumnName="ID")} - * ) - */ - protected $sponsors; - /** * @return Company[] */ @@ -546,15 +575,6 @@ class SummitEvent extends SilverstripeBaseModel return $this->sponsors; } - /** - * @ORM\ManyToMany(targetEntity="models\summit\SummitAttendee") - * @ORM\JoinTable(name="SummitAttendee_Schedule", - * joinColumns={@ORM\JoinColumn(name="SummitEventID", referencedColumnName="ID")}, - * inverseJoinColumns={@ORM\JoinColumn(name="SummitAttendeeID", referencedColumnName="ID")} - * ) - */ - protected $attendees; - /** * @return SummitAttendee[] */ @@ -565,13 +585,6 @@ class SummitEvent extends SilverstripeBaseModel return $this->attendees->matching($criteria); } - /** - * @ORM\OneToMany(targetEntity="models\summit\SummitEventFeedback", mappedBy="event", cascade={"persist"}) - * @ORM\Cache("NONSTRICT_READ_WRITE") - * @var SummitEventFeedback[] - */ - protected $feedback; - public function addFeedBack(SummitEventFeedback $feedback) { $this->feedback->add($feedback); @@ -587,15 +600,6 @@ class SummitEvent extends SilverstripeBaseModel return $this->feedback->matching($criteria); } - /** - * @ORM\ManyToMany(targetEntity="models\main\Tag", cascade={"persist"}) - * @ORM\JoinTable(name="SummitEvent_Tags", - * joinColumns={@ORM\JoinColumn(name="SummitEventID", referencedColumnName="ID")}, - * inverseJoinColumns={@ORM\JoinColumn(name="TagID", referencedColumnName="ID")} - * ) - */ - protected $tags; - /** * @return ArrayCollection */ @@ -792,12 +796,6 @@ class SummitEvent extends SilverstripeBaseModel ); } - /** - * @ORM\OneToMany(targetEntity="models\summit\RSVP", mappedBy="event", cascade={"persist"}) - * @var RSVP[] - */ - protected $rsvp; - /** * @return ArrayCollection */ diff --git a/app/Models/Foundation/Summit/Events/SummitEventFeedback.php b/app/Models/Foundation/Summit/Events/SummitEventFeedback.php index 6f1dac9a..e3c828c5 100644 --- a/app/Models/Foundation/Summit/Events/SummitEventFeedback.php +++ b/app/Models/Foundation/Summit/Events/SummitEventFeedback.php @@ -20,7 +20,7 @@ use models\main\Member; /** * @ORM\Entity * @ORM\Table(name="SummitEventFeedback") - * @ORM\Entity(repositoryClass="repositories\summit\DoctrineEventFeedbackRepository") + * @ORM\Entity(repositoryClass="App\Repositories\Summit\DoctrineEventFeedbackRepository") * @ORM\Cache(usage="NONSTRICT_READ_WRITE", region="summit_event_feedback_region") * Class SummitEventFeedback * @package models\summit diff --git a/app/Models/Foundation/Summit/Locations/SummitAbstractLocation.php b/app/Models/Foundation/Summit/Locations/SummitAbstractLocation.php index b591c6b3..3ff72200 100644 --- a/app/Models/Foundation/Summit/Locations/SummitAbstractLocation.php +++ b/app/Models/Foundation/Summit/Locations/SummitAbstractLocation.php @@ -16,6 +16,16 @@ use models\utils\SilverstripeBaseModel; use Doctrine\ORM\Mapping AS ORM; +/** + * @see https://github.com/doctrine/doctrine2/commit/ff28507b88ffd98830c44762 + * //@ORM\AssociationOverrides({ + * // @ORM\AssociationOverride( + * // name="summit", + * // inversedBy="locations" + * // ) + * // }) + */ + /** * @ORM\Entity * @ORM\Table(name="SummitAbstractLocation") diff --git a/app/Models/Foundation/Summit/Repositories/ISummitNotificationRepository.php b/app/Models/Foundation/Summit/Repositories/ISummitNotificationRepository.php index f30074d8..2a3f4682 100644 --- a/app/Models/Foundation/Summit/Repositories/ISummitNotificationRepository.php +++ b/app/Models/Foundation/Summit/Repositories/ISummitNotificationRepository.php @@ -31,5 +31,5 @@ interface ISummitNotificationRepository extends IBaseRepository * @param Order|null $order * @return PagingResponse */ - public function getAllByPage(Summit $summit, PagingInfo $paging_info, Filter $filter = null, Order $order = null); + public function getAllByPageBySummit(Summit $summit, PagingInfo $paging_info, Filter $filter = null, Order $order = null); } \ No newline at end of file diff --git a/app/Models/Foundation/Summit/Summit.php b/app/Models/Foundation/Summit/Summit.php index 27e27755..64b55b84 100644 --- a/app/Models/Foundation/Summit/Summit.php +++ b/app/Models/Foundation/Summit/Summit.php @@ -11,12 +11,11 @@ * See the License for the specific language governing permissions and * limitations under the License. **/ - +use Doctrine\ORM\Mapping AS ORM; use Doctrine\ORM\Cache; use models\main\File; use models\main\Member; use models\utils\SilverstripeBaseModel; -use Doctrine\ORM\Mapping AS ORM; use Doctrine\Common\Collections\Criteria; use Doctrine\Common\Collections\ArrayCollection; use DateTimeZone; @@ -24,14 +23,44 @@ use DateTime; use models\main\Company; /** - * @ORM\Entity + * @ORM\Entity(repositoryClass="App\Repositories\Summit\DoctrineSummitRepository") * @ORM\Table(name="Summit") - * @ORM\Entity(repositoryClass="repositories\summit\DoctrineSummitRepository") * Class Summit * @package models\summit */ class Summit extends SilverstripeBaseModel { + + /** + * @ORM\Column(name="Title", type="string") + * @var string + */ + private $name; + + /** + * @ORM\Column(name="DateLabel", type="string") + * @var string + */ + private $dates_label; + + /** + * @ORM\Column(name="SummitBeginDate", type="datetime") + * @var \DateTime + */ + private $begin_date; + + /** + * @ORM\Column(name="SummitEndDate", type="datetime") + * @var \DateTime + */ + private $end_date; + + /** + * @ORM\Column(name="Active", type="boolean") + * @var bool + */ + private $active; + /** * @return string */ @@ -175,36 +204,6 @@ class Summit extends SilverstripeBaseModel $this->start_showing_venues_date = $start_showing_venues_date; } - /** - * @ORM\Column(name="Title", type="string") - * @var string - */ - private $name; - - /** - * @ORM\Column(name="DateLabel", type="string") - * @var string - */ - private $dates_label; - - /** - * @ORM\Column(name="SummitBeginDate", type="datetime") - * @var \DateTime - */ - private $begin_date; - - /** - * @ORM\Column(name="SummitEndDate", type="datetime") - * @var \DateTime - */ - private $end_date; - - /** - * @ORM\Column(name="Active", type="boolean") - * @var bool - */ - private $active; - /** * @return boolean */ diff --git a/app/Models/Foundation/Summit/SummitPushNotification.php b/app/Models/Foundation/Summit/SummitPushNotification.php index 74c11792..10afc394 100644 --- a/app/Models/Foundation/Summit/SummitPushNotification.php +++ b/app/Models/Foundation/Summit/SummitPushNotification.php @@ -48,9 +48,8 @@ final class SummitPushNotificationChannel { } /** - * @ORM\Entity + * @ORM\Entity(repositoryClass="App\Repositories\Summit\DoctrineSummitNotificationRepository") * @ORM\Table(name="SummitPushNotification") - * @ORM\Entity(repositoryClass="repositories\summit\DoctrineSummitNotificationRepository") * Class SummitPushNotification * @package models\summit */ diff --git a/app/Models/Utils/BaseEntity.php b/app/Models/Utils/BaseEntity.php new file mode 100644 index 00000000..39736cb4 --- /dev/null +++ b/app/Models/Utils/BaseEntity.php @@ -0,0 +1,45 @@ +id; + } + + /** + * @return int + */ + public function getId() + { + return $this->getIdentifier(); + } +} \ No newline at end of file diff --git a/app/Models/Utils/BaseModelEloquent.php b/app/Models/Utils/BaseModelEloquent.php deleted file mode 100644 index fd7b888e..00000000 --- a/app/Models/Utils/BaseModelEloquent.php +++ /dev/null @@ -1,405 +0,0 @@ -where($filter['name'], $filter['op'], $filter['value']); - } - - return $query; - } - - public function __construct($attributes = array()) - { - parent::__construct($attributes); - $this->class = new ReflectionClass(get_class($this)); - if ($this->useSti()) { - $this->setAttribute($this->stiClassField, $this->class->getName()); - } - } - - /** - * @return array - */ - public function getAttributeMappings(){ - $mappings = array(); - - $hierarchy = $this->getClassHierarchy(); - foreach($hierarchy as $class_name){ - if($class_name == $this->class->getName()) continue; - $class = new $class_name; - if($class instanceof BaseModelEloquent) - $mappings = array_merge($mappings, $class->getSelfMappings()); - } - $mappings = array_merge($mappings, $this->getSelfMappings()); - return $mappings; - } - - public function getSelfMappings(){ - return static::$array_mappings; - } - - /** - * @return array - */ - public function getClassHierarchy(){ - $class_hierarchy = array(); - - if ($this->useMti()) { - $class = $this->class->getName(); - $parents = $this->get_class_lineage(new $class); - - if ($this->mtiClassType === 'concrete') { - $base_class_name = $this->class->getName(); - array_push($class_hierarchy, $base_class_name); - } - - foreach ($parents as $parent) { - - if (!$this->isAllowedParent($parent)) { - continue; - } - - $parent = new $parent; - if ($parent->mtiClassType === 'abstract') { - continue; - } - - array_push($class_hierarchy, $parent->class->getName()); - } - } - return array_reverse($class_hierarchy); - } - - public function toArray() - { - $values = parent::toArray(); - $mappings = $this->getAttributeMappings(); - if (count($mappings)) { - $new_values = array(); - foreach ($mappings as $old_key => $new_key) { - $value = isset($values[$old_key])? $values[$old_key] : - ( - isset($values['pivot'])? ( - isset($values['pivot'][$old_key]) ? $values['pivot'][$old_key] : null - ): null - ); - - $new_key = preg_split('/:/',$new_key); - if(count($new_key) > 1) - { - //we have a formatter ... - switch(strtolower($new_key[1])) - { - case 'datetime_epoch': - { - if(!is_null($value)) { - $datetime = new \DateTime($value); - $value = $datetime->getTimestamp(); - } - } - break; - case 'json_string': - { - $value = JsonUtils::toJsonString($value); - } - break; - case 'json_boolean': - { - $value = JsonUtils::toJsonBoolean($value); - } - break; - case 'json_int': - { - $value = JsonUtils::toJsonInt($value); - } - break; - case 'json_float': - { - $value = JsonUtils::toJsonFloat($value); - } - break; - } - } - $new_values[$new_key[0]] = $value; - } - $values = $new_values; - } - - return $values; - } - - private function useSti() - { - return ($this->stiClassField && $this->stiBaseClass); - } - - private function useMti() - { - return $this->mtiClassType; - } - - public function newQuery($excludeDeleted = true) - { - $builder = parent::newQuery($excludeDeleted); - // If I am using STI, and I am not the base class, - // then filter on the class name. - if ($this->useMti()) { - $query = $builder->getQuery(); - $class = $this->class->getName(); - $parents = $this->get_class_lineage(new $class); - $base_table_set = false; - $current_class_name = null; - if ($this->mtiClassType === 'concrete') { - $current_class_name = $this->class->getShortName(); - $query = $query->from($current_class_name); - $base_table_set = true; - } - - foreach ($parents as $parent) { - - if(!$this->isAllowedParent($parent)) - { - continue; - } - - $parent = new $parent; - if ($parent->mtiClassType === 'abstract') { - continue; - } - - $table_name = $parent->class->getShortName(); - - if ($base_table_set === true) { - $query->leftJoin($table_name, $current_class_name . '.ID', '=', $table_name . '.ID'); - } else { - $query = $query->from($table_name); - $base_table_set = true; - $current_class_name = $table_name; - } - } - - } else { - if ($this->useSti() && get_class(new $this->stiBaseClass) !== get_class($this)) { - $builder->where($this->stiClassField, "=", $this->class->getShortName()); - } - } - - return $builder; - } - - protected function isAllowedParent($parent_name) - { - $res = str_contains($parent_name, $this->class->getShortName()) || - str_contains($parent_name,'Illuminate\Database\Eloquent\Model') || - str_contains($parent_name, 'models\utils\BaseModelEloquent'); - return !$res; - } - - private function get_class_lineage($object) - { - $class_name = get_class($object); - $parents = array_values(class_parents($class_name)); - - return array_merge(array($class_name), $parents); - } - - public function newFromBuilder($attributes = array(), $connection = null) - { - if ($this->useSti() && $attributes->{$this->stiClassField}) { - $class = $this->class->getName(); - $instance = new $class; - $instance->exists = true; - $instance->setRawAttributes((array)$attributes, true); - - return $instance; - } else { - return parent::newFromBuilder($attributes, $connection); - } - } - - /** - * Define a one-to-many relationship. - * - * @param string $related - * @param string $foreignKey - * @param string $localKey - * @param bool $prefix_fkey - * @return \Illuminate\Database\Eloquent\Relations\HasMany - */ - public function hasMany($related, $foreignKey = null, $localKey = null, $prefix_fkey = true) - { - $foreignKey = $foreignKey ?: $this->getForeignKey(); - $instance = new $related; - $table_name = $instance->getTable(); - - $localKey = $localKey ?: $this->getKeyName(); - if($prefix_fkey) $foreignKey = $table_name . '.' . $foreignKey; - - return new HasMany($instance->newQuery(), $this, $foreignKey, $localKey); - } - - /** - * Save the model to the database. - * - * @param array $options - * @return bool - */ - public function save(array $options = array()) - { - $query = $this->newQueryWithoutScopes(); - - // If the "saving" event returns false we'll bail out of the save and return - // false, indicating that the save failed. This provides a chance for any - // listeners to cancel save operations if validations fail or whatever. - if ($this->fireModelEvent('saving') === false) - { - return false; - } - - // If the model already exists in the database we can just update our record - // that is already in this database using the current IDs in this "where" - // clause to only update this model. Otherwise, we'll just insert them. - if ($this->exists) - { - $saved = $this->performUpdate($query, $options); - } - - // If the model is brand new, we'll insert it into our database and set the - // ID attribute on the model to the value of the newly inserted row's ID - // which is typically an auto-increment value managed by the database. - else - { - $saved = $this->performInsert($query, $options); - } - - if ($saved) $this->finishSave($options); - - return $saved; - } - - /** - * Perform a model insert operation. - * - * @param \Illuminate\Database\Eloquent\Builder $query - * @param array $options - * @return bool - */ - protected function performInsert(Builder $query, array $options = []) - { - if ($this->fireModelEvent('creating') === false) return false; - - // First we'll need to create a fresh query instance and touch the creation and - // update timestamps on this model, which are maintained by us for developer - // convenience. After, we will just continue saving these model instances. - if ($this->timestamps && array_get($options, 'timestamps', true)) - { - $this->updateTimestamps(); - } - - $class_hierarchy = array(); - - if ($this->useMti()) - { - $class = $this->class->getName(); - $parents = $this->get_class_lineage(new $class); - - if ($this->mtiClassType === 'concrete') - { - $base_class_name = $this->class->getShortName(); - array_push($class_hierarchy, $base_class_name); - } - - foreach ($parents as $parent) { - - if(!$this->isAllowedParent($parent)) - { - continue; - } - - $parent = new $parent; - if ($parent->mtiClassType === 'abstract') { - continue; - } - - array_push($class_hierarchy, $parent->class->getShortName()); - } - $attributes = $this->attributes; - do{ - $table = array_pop($class_hierarchy); - $class = new $table; - - }while(true); - } - else { - // If the model has an incrementing key, we can use the "insertGetId" method on - // the query builder, which will give us back the final inserted ID for this - // table from the database. Not all tables have to be incrementing though. - $attributes = $this->attributes; - - if ($this->incrementing) { - $this->insertAndSetId($query, $attributes); - } - - // If the table is not incrementing we'll simply insert this attributes as they - // are, as this attributes arrays must contain an "id" column already placed - // there by the developer as the manually determined key for these models. - else { - $query->insert($attributes); - } - } - // We will go ahead and set the exists property to true, so that it is set when - // the created event is fired, just in case the developer tries to update it - // during the event. This will allow them to do so and run an update here. - $this->exists = true; - - $this->fireModelEvent('created', false); - - return true; - } -} \ No newline at end of file diff --git a/app/Models/Utils/EloquentBaseRepository.php b/app/Models/Utils/EloquentBaseRepository.php deleted file mode 100644 index 9527e6ca..00000000 --- a/app/Models/Utils/EloquentBaseRepository.php +++ /dev/null @@ -1,62 +0,0 @@ -entity->find($id); - } - - /** - * @param IEntity $entity - * @return void - */ - public function add($entity) - { - $entity->save(); - } - - - /** - * @param IEntity $entity - * @return void - */ - public function delete($entity) - { - $entity->delete(); - } - - /** - * @return IEntity[] - */ - public function getAll() - { - return $this->entity->all()->all(); - } -} \ No newline at end of file diff --git a/app/Models/Utils/IBaseRepository.php b/app/Models/Utils/IBaseRepository.php index ce62d984..83e65fcb 100644 --- a/app/Models/Utils/IBaseRepository.php +++ b/app/Models/Utils/IBaseRepository.php @@ -1,5 +1,20 @@ last_edited = $last_edited; } - /** - * @ORM\Id - * @ORM\GeneratedValue - * @ORM\Column(name="ID", type="integer", unique=true, nullable=false) - */ - protected $id; - /** * @ORM\Column(name="Created", type="datetime") */ @@ -103,18 +95,6 @@ class SilverstripeBaseModel implements IEntity */ protected $last_edited; - /** - * @return int - */ - public function getIdentifier() - { - return (int)$this->id; - } - - public function getId(){ - return $this->getIdentifier(); - } - public function __construct() { $now = new \DateTime('now', new \DateTimeZone(self::DefaultTimeZone)); diff --git a/app/Repositories/DoctrineRepository.php b/app/Repositories/DoctrineRepository.php index c84fb874..21acbc9d 100644 --- a/app/Repositories/DoctrineRepository.php +++ b/app/Repositories/DoctrineRepository.php @@ -1,4 +1,4 @@ -findAll(); } + /** + * @return string + */ + protected abstract function getBaseEntity(); + + /** + * @return array + */ + protected abstract function getFilterMappings(); + + /** + * @return array + */ + protected abstract function getOrderMappings(); + + /** + * @param QueryBuilder $query + * @return QueryBuilder + */ + protected abstract function applyExtraFilters(QueryBuilder $query); + + /** + * @param PagingInfo $paging_info + * @param Filter|null $filter + * @param Order|null $order + * @return PagingResponse + */ + public function getAllByPage(PagingInfo $paging_info, Filter $filter = null, Order $order = null){ + + $query = $this->getEntityManager() + ->createQueryBuilder() + ->select("e") + ->from($this->getBaseEntity(), "e"); + + $query = $this->applyExtraFilters($query); + + if(!is_null($filter)){ + $filter->apply2Query($query, $this->getFilterMappings()); + } + + if(!is_null($order)){ + $order->apply2Query($query, $this->getOrderMappings()); + } + + $query= $query + ->setFirstResult($paging_info->getOffset()) + ->setMaxResults($paging_info->getPerPage()); + + $paginator = new Paginator($query, $fetchJoinCollection = true); + $total = $paginator->count(); + $data = array(); + + foreach($paginator as $entity) + array_push($data, $entity); + + return new PagingResponse + ( + $total, + $paging_info->getPerPage(), + $paging_info->getCurrentPage(), + $paging_info->getLastPage($total), + $data + ); + } + } \ No newline at end of file diff --git a/app/Repositories/Main/Doctrine/DoctrineChatTeamInvitationRepository.php b/app/Repositories/Main/DoctrineChatTeamInvitationRepository.php similarity index 92% rename from app/Repositories/Main/Doctrine/DoctrineChatTeamInvitationRepository.php rename to app/Repositories/Main/DoctrineChatTeamInvitationRepository.php index dbc30f1c..451b147e 100644 --- a/app/Repositories/Main/Doctrine/DoctrineChatTeamInvitationRepository.php +++ b/app/Repositories/Main/DoctrineChatTeamInvitationRepository.php @@ -13,7 +13,7 @@ **/ use models\main\ChatTeamInvitation; use models\main\IChatTeamInvitationRepository; -use repositories\SilverStripeDoctrineRepository; +use App\Repositories\SilverStripeDoctrineRepository; use Doctrine\ORM\Query\Expr\Join; /** * Class DoctrineChatTeamInvitationRepository @@ -67,4 +67,12 @@ final class DoctrineChatTeamInvitationRepository ->where('i.is_accepted = true') ->setParameter('member_id', $invitee_id)->getQuery()->getResult(); } + + /** + * @return string + */ + protected function getBaseEntity() + { + return ChatTeamInvitation::class; + } } \ No newline at end of file diff --git a/app/Repositories/Main/Doctrine/DoctrineChatTeamPushNotificationMessageRepository.php b/app/Repositories/Main/DoctrineChatTeamPushNotificationMessageRepository.php similarity index 94% rename from app/Repositories/Main/Doctrine/DoctrineChatTeamPushNotificationMessageRepository.php rename to app/Repositories/Main/DoctrineChatTeamPushNotificationMessageRepository.php index 1232b626..4e254047 100644 --- a/app/Repositories/Main/Doctrine/DoctrineChatTeamPushNotificationMessageRepository.php +++ b/app/Repositories/Main/DoctrineChatTeamPushNotificationMessageRepository.php @@ -12,8 +12,9 @@ * limitations under the License. **/ use Doctrine\ORM\Tools\Pagination\Paginator; +use models\main\ChatTeamPushNotificationMessage; use models\main\IChatTeamPushNotificationMessageRepository; -use repositories\SilverStripeDoctrineRepository; +use App\Repositories\SilverStripeDoctrineRepository; use utils\DoctrineJoinFilterMapping; use utils\Filter; use utils\Order; @@ -134,4 +135,12 @@ final class DoctrineChatTeamPushNotificationMessageRepository $data ); } + + /** + * @return string + */ + protected function getBaseEntity() + { + return ChatTeamPushNotificationMessage::class; + } } \ No newline at end of file diff --git a/app/Repositories/Main/Doctrine/DoctrineChatTeamRepository.php b/app/Repositories/Main/DoctrineChatTeamRepository.php similarity index 91% rename from app/Repositories/Main/Doctrine/DoctrineChatTeamRepository.php rename to app/Repositories/Main/DoctrineChatTeamRepository.php index 95319b1f..2aea8f71 100644 --- a/app/Repositories/Main/Doctrine/DoctrineChatTeamRepository.php +++ b/app/Repositories/Main/DoctrineChatTeamRepository.php @@ -14,7 +14,7 @@ use models\main\ChatTeam; use models\main\IChatTeamRepository; use models\main\Member; -use repositories\SilverStripeDoctrineRepository; +use App\Repositories\SilverStripeDoctrineRepository; use Doctrine\ORM\Query\Expr\Join; /** * Class DoctrineChatTeamRepository @@ -50,4 +50,12 @@ final class DoctrineChatTeamRepository extends SilverStripeDoctrineRepository im $ids = array_map('current', $result); return $ids; } + + /** + * @return string + */ + protected function getBaseEntity() + { + return ChatTeam::class; + } } \ No newline at end of file diff --git a/app/Repositories/Main/Doctrine/DoctrineTagRepository.php b/app/Repositories/Main/DoctrineTagRepository.php similarity index 88% rename from app/Repositories/Main/Doctrine/DoctrineTagRepository.php rename to app/Repositories/Main/DoctrineTagRepository.php index 7d53bd04..be88f451 100644 --- a/app/Repositories/Main/Doctrine/DoctrineTagRepository.php +++ b/app/Repositories/Main/DoctrineTagRepository.php @@ -13,7 +13,7 @@ **/ use models\main\ITagRepository; use models\main\Tag; -use repositories\SilverStripeDoctrineRepository; +use App\Repositories\SilverStripeDoctrineRepository; /** * Class DoctrineTagRepository @@ -40,4 +40,12 @@ final class DoctrineTagRepository extends SilverStripeDoctrineRepository impleme return null; } } + + /** + * @return string + */ + protected function getBaseEntity() + { + return Tag::class; + } } \ No newline at end of file diff --git a/app/Repositories/Marketplace/EloquentConsultantRepository.php b/app/Repositories/Marketplace/DoctrineApplianceRepository.php similarity index 54% rename from app/Repositories/Marketplace/EloquentConsultantRepository.php rename to app/Repositories/Marketplace/DoctrineApplianceRepository.php index aca8e209..b7216f66 100644 --- a/app/Repositories/Marketplace/EloquentConsultantRepository.php +++ b/app/Repositories/Marketplace/DoctrineApplianceRepository.php @@ -1,7 +1,6 @@ -entity = $consultant; + return Appliance::class; } } \ No newline at end of file diff --git a/app/Repositories/Marketplace/DoctrineCompanyServiceRepository.php b/app/Repositories/Marketplace/DoctrineCompanyServiceRepository.php new file mode 100644 index 00000000..3f95b7cf --- /dev/null +++ b/app/Repositories/Marketplace/DoctrineCompanyServiceRepository.php @@ -0,0 +1,59 @@ +where('e.is_active = 1'); + return $query; + } + + /** + * @return array + */ + protected function getFilterMappings() + { + return [ + 'name' => 'e.name', + 'company' => new DoctrineJoinFilterMapping + ( + 'e.company', + 'c', + "c.name :operator ':value'" + ), + ]; + } + + /** + * @return array + */ + protected function getOrderMappings() + { + return [ + 'id' => 'e.id', + 'name' => 'e.name', + ]; + } +} \ No newline at end of file diff --git a/app/Repositories/Marketplace/DoctrineConsultantRepository.php b/app/Repositories/Marketplace/DoctrineConsultantRepository.php new file mode 100644 index 00000000..535fa215 --- /dev/null +++ b/app/Repositories/Marketplace/DoctrineConsultantRepository.php @@ -0,0 +1,31 @@ +entity = $private_cloud; + return PrivateCloudService::class; } - } \ No newline at end of file diff --git a/app/Repositories/Marketplace/EloquentPublicCloudServiceRepository.php b/app/Repositories/Marketplace/DoctrinePublicCloudServiceRepository.php similarity index 55% rename from app/Repositories/Marketplace/EloquentPublicCloudServiceRepository.php rename to app/Repositories/Marketplace/DoctrinePublicCloudServiceRepository.php index 605026b5..d5f5047e 100644 --- a/app/Repositories/Marketplace/EloquentPublicCloudServiceRepository.php +++ b/app/Repositories/Marketplace/DoctrinePublicCloudServiceRepository.php @@ -1,7 +1,6 @@ -entity = $public_cloud; + return PublicCloudService::class; } } \ No newline at end of file diff --git a/app/Repositories/Marketplace/DoctrineRemoteCloudServiceRepository.php b/app/Repositories/Marketplace/DoctrineRemoteCloudServiceRepository.php new file mode 100644 index 00000000..ad6c9c57 --- /dev/null +++ b/app/Repositories/Marketplace/DoctrineRemoteCloudServiceRepository.php @@ -0,0 +1,33 @@ + 'Active', - 'op' => '=', - 'value' => true - ) - ); - break; - case ICompanyServiceRepository::Status_non_active: - array_push( - $filters, - array( - 'name' => 'Active', - 'op' => '=', - 'value' => false - ) - ); - break; - } - - $query = $this->entity->Filter($filters); - - switch ($order_by) { - case ICompanyServiceRepository::Order_date: - $query = $query->orderBy('Created', $order_dir); - break; - case ICompanyServiceRepository::Order_name: - $query = $query->orderBy('Name', $order_dir); - break; - } - - return $query->paginate($per_page, $fields)->toArray(); - } -} \ No newline at end of file diff --git a/app/Repositories/RepositoriesProvider.php b/app/Repositories/RepositoriesProvider.php index bf7a5129..2003f484 100644 --- a/app/Repositories/RepositoriesProvider.php +++ b/app/Repositories/RepositoriesProvider.php @@ -1,4 +1,4 @@ -getPerPage(), $paging_info->getCurrentPage(), $last_page, $speakers); } + + /** + * @return string + */ + protected function getBaseEntity() + { + return PresentationSpeaker::class; + } } \ No newline at end of file diff --git a/app/Repositories/Summit/Doctrine/DoctrineSummitAttendeeRepository.php b/app/Repositories/Summit/DoctrineSummitAttendeeRepository.php similarity index 62% rename from app/Repositories/Summit/Doctrine/DoctrineSummitAttendeeRepository.php rename to app/Repositories/Summit/DoctrineSummitAttendeeRepository.php index b4117775..c6862d9a 100644 --- a/app/Repositories/Summit/Doctrine/DoctrineSummitAttendeeRepository.php +++ b/app/Repositories/Summit/DoctrineSummitAttendeeRepository.php @@ -1,4 +1,4 @@ - 0 ? $tickets[0] : null; } + + /** + * @return string + */ + protected function getBaseEntity() + { + return SummitAttendeeTicket::class; + } } \ No newline at end of file diff --git a/app/Repositories/Summit/Doctrine/DoctrineSummitEntityEventRepository.php b/app/Repositories/Summit/DoctrineSummitEntityEventRepository.php similarity index 93% rename from app/Repositories/Summit/Doctrine/DoctrineSummitEntityEventRepository.php rename to app/Repositories/Summit/DoctrineSummitEntityEventRepository.php index 3ee3c140..4b212a10 100644 --- a/app/Repositories/Summit/Doctrine/DoctrineSummitEntityEventRepository.php +++ b/app/Repositories/Summit/DoctrineSummitEntityEventRepository.php @@ -1,4 +1,4 @@ -_em->getConnection()->executeQuery($query)->fetchColumn(0)); } + + /** + * @return string + */ + protected function getBaseEntity() + { + return SummitEntityEvent::class; + } } \ No newline at end of file diff --git a/app/Repositories/Summit/Doctrine/DoctrineSummitEventRepository.php b/app/Repositories/Summit/DoctrineSummitEventRepository.php similarity index 62% rename from app/Repositories/Summit/Doctrine/DoctrineSummitEventRepository.php rename to app/Repositories/Summit/DoctrineSummitEventRepository.php index e7d9e55f..36d0ae16 100644 --- a/app/Repositories/Summit/Doctrine/DoctrineSummitEventRepository.php +++ b/app/Repositories/Summit/DoctrineSummitEventRepository.php @@ -1,4 +1,4 @@ -setParameter('end_date', $end_date)->getQuery()->getResult(); } + /** + * @return array + */ + protected function getFilterMappings() + { + return [ + 'title' => 'e.title:json_string', + 'published' => 'e.published', + 'start_date' => 'e.start_date:datetime_epoch', + 'end_date' => 'e.end_date:datetime_epoch', + 'tags' => new DoctrineJoinFilterMapping + ( + 'e.tags', + 't', + "t.tag :operator ':value'" + ), + 'location_id'=> new DoctrineJoinFilterMapping + ( + 'e.location', + 'l', + "l.id :operator :value" + ), + 'summit_id'=> new DoctrineJoinFilterMapping + ( + 'e.summit', + 's', + "s.id :operator :value" + ), + 'event_type_id' => new DoctrineJoinFilterMapping + ( + 'e.type', + 'et', + "et.id :operator :value" + ), + 'track_id' => new DoctrineJoinFilterMapping + ( + 'e.category', + 'c', + "c.id :operator :value" + ), + 'speaker' => new DoctrineJoinFilterMapping + ( + 'e.speakers', + 'sp', + "concat(sp.first_name, ' ', sp.last_name) :operator ':value'" + ), + ]; + } + + /** + * @return array + */ + protected function getOrderMappings() + { + return [ + 'title' => 'e.title', + 'id' => 'e.id', + 'start_date' => 'e.start_date', + 'end_date' => 'e.end_date', + 'created' => 'e.created', + ]; + } /** * @param PagingInfo $paging_info @@ -77,61 +141,11 @@ final class DoctrineSummitEventRepository extends SilverStripeDoctrineRepository if(!is_null($filter)){ - $filter->apply2Query($query, array - ( - 'title' => 'e.title:json_string', - 'published' => 'e.published', - 'start_date' => 'e.start_date:datetime_epoch', - 'end_date' => 'e.end_date:datetime_epoch', - 'tags' => new DoctrineJoinFilterMapping - ( - 'e.tags', - 't', - "t.tag :operator ':value'" - ), - 'location_id'=> new DoctrineJoinFilterMapping - ( - 'e.location', - 'l', - "l.id :operator :value" - ), - 'summit_id'=> new DoctrineJoinFilterMapping - ( - 'e.summit', - 's', - "s.id :operator :value" - ), - 'event_type_id' => new DoctrineJoinFilterMapping - ( - 'e.type', - 'et', - "et.id :operator :value" - ), - 'track_id' => new DoctrineJoinFilterMapping - ( - 'e.category', - 'c', - "c.id :operator :value" - ), - 'speaker' => new DoctrineJoinFilterMapping - ( - 'e.speakers', - 'sp', - "concat(sp.first_name, ' ', sp.last_name) :operator ':value'" - ), - )); + $filter->apply2Query($query, $this->getFilterMappings()); } if (!is_null($order)) { - - $order->apply2Query($query,[ - - 'title' => 'e.title', - 'id' => 'e.id', - 'start_date' => 'e.start_date', - 'end_date' => 'e.end_date', - 'created' => 'e.created', - ]); + $order->apply2Query($query, $this->getOrderMappings()); } else { //default order $query = $query->addOrderBy("e.start_date",'ASC'); @@ -160,7 +174,6 @@ final class DoctrineSummitEventRepository extends SilverStripeDoctrineRepository ); } - /** * @param int $event_id */ @@ -170,4 +183,11 @@ final class DoctrineSummitEventRepository extends SilverStripeDoctrineRepository $this->_em->getConnection()->executeUpdate($query); } + /** + * @return string + */ + protected function getBaseEntity() + { + return SummitEvent::class; + } } \ No newline at end of file diff --git a/app/Repositories/Summit/Doctrine/DoctrineSummitNotificationRepository.php b/app/Repositories/Summit/DoctrineSummitNotificationRepository.php similarity index 64% rename from app/Repositories/Summit/Doctrine/DoctrineSummitNotificationRepository.php rename to app/Repositories/Summit/DoctrineSummitNotificationRepository.php index 4714268e..9cbe54cd 100644 --- a/app/Repositories/Summit/Doctrine/DoctrineSummitNotificationRepository.php +++ b/app/Repositories/Summit/DoctrineSummitNotificationRepository.php @@ -1,4 +1,4 @@ - 'e.id:json_int', + 'channel' => 'n.channel:json_string', + 'sent_date' => 'n.sent_date:datetime_epoch', + 'created' => 'n.created:datetime_epoch', + 'is_sent' => 'n.is_sent:json_int', + ]; + } + + /** + * @return array + */ + protected function getOrderMappings() + { + return [ + 'sent_date' => 'n.sent_date', + 'created' => 'n.created', + 'id' => 'n.id', + ]; + } /** * @param Summit $summit @@ -41,7 +66,7 @@ final class DoctrineSummitNotificationRepository * @param Order|null $order * @return PagingResponse */ - public function getAllByPage(Summit $summit, PagingInfo $paging_info, Filter $filter = null, Order $order = null) + public function getAllByPageBySummit(Summit $summit, PagingInfo $paging_info, Filter $filter = null, Order $order = null) { $query = $this->getEntityManager()->createQueryBuilder() ->select("n") @@ -52,32 +77,18 @@ final class DoctrineSummitNotificationRepository if (!is_null($filter)) { - $filter->apply2Query($query, array - ( - 'event_id' => 'e.id:json_int', - 'channel' => 'n.channel:json_string', - 'sent_date' => 'n.sent_date:datetime_epoch', - 'created' => 'n.created:datetime_epoch', - 'is_sent' => 'n.is_sent:json_int', - )); + $filter->apply2Query($query, $this->getFilterMappings()); } if (!is_null($order)) { - - $order->apply2Query($query, array - ( - 'sent_date' => 'n.sent_date', - 'created' => 'n.created', - 'id' => 'n.id', - )); + $order->apply2Query($query, $this->getOrderMappings()); } else { //default order $query = $query->orderBy('n.id', Criteria::DESC); } $query = $query - ->setFirstResult($paging_info->getOffset()) - ->setMaxResults($paging_info->getPerPage()); + ->setFirstResult($paging_info->getOffset())->setMaxResults($paging_info->getPerPage()); $paginator = new Paginator($query, $fetchJoinCollection = true); $total = $paginator->count(); @@ -96,4 +107,11 @@ final class DoctrineSummitNotificationRepository ); } + /** + * @return string + */ + protected function getBaseEntity() + { + return SummitPushNotification::class; + } } \ No newline at end of file diff --git a/app/Repositories/Summit/Doctrine/DoctrineSummitRepository.php b/app/Repositories/Summit/DoctrineSummitRepository.php similarity index 81% rename from app/Repositories/Summit/Doctrine/DoctrineSummitRepository.php rename to app/Repositories/Summit/DoctrineSummitRepository.php index 19f5ffcb..6e21d371 100644 --- a/app/Repositories/Summit/Doctrine/DoctrineSummitRepository.php +++ b/app/Repositories/Summit/DoctrineSummitRepository.php @@ -1,4 +1,4 @@ -getQuery() ->getResult(); } + + /** + * @return string + */ + protected function getBaseEntity() + { + return Summit::class; + } } \ No newline at end of file diff --git a/app/Services/Model/MemberActionsCalendarSyncProcessingService.php b/app/Services/Model/MemberActionsCalendarSyncProcessingService.php index 28b5a02e..e5d1c9d0 100644 --- a/app/Services/Model/MemberActionsCalendarSyncProcessingService.php +++ b/app/Services/Model/MemberActionsCalendarSyncProcessingService.php @@ -11,7 +11,6 @@ * See the License for the specific language governing permissions and * limitations under the License. **/ - use App\Services\Apis\CalendarSync\Exceptions\RateLimitExceededException; use CalDAVClient\Facade\Exceptions\ForbiddenException; use CalDAVClient\Facade\Exceptions\NotFoundResourceException; diff --git a/composer.lock b/composer.lock index 6b404ded..f2181548 100644 --- a/composer.lock +++ b/composer.lock @@ -687,12 +687,12 @@ "source": { "type": "git", "url": "https://github.com/doctrine/doctrine2.git", - "reference": "e1b851f2e93a4afd82fb7e7f32c6f114d0ea7b71" + "reference": "049470c787467e2c7f5a267b8b86c5a5d28498fc" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/doctrine/doctrine2/zipball/e1b851f2e93a4afd82fb7e7f32c6f114d0ea7b71", - "reference": "e1b851f2e93a4afd82fb7e7f32c6f114d0ea7b71", + "url": "https://api.github.com/repos/doctrine/doctrine2/zipball/049470c787467e2c7f5a267b8b86c5a5d28498fc", + "reference": "049470c787467e2c7f5a267b8b86c5a5d28498fc", "shasum": "" }, "require": { @@ -755,7 +755,7 @@ "database", "orm" ], - "time": "2017-10-23T18:26:03+00:00" + "time": "2017-11-12T11:25:46+00:00" }, { "name": "eluceo/ical", @@ -946,12 +946,12 @@ "source": { "type": "git", "url": "https://github.com/google/google-api-php-client.git", - "reference": "b69b8ac4bf6501793c389d4e013a79d09c85c5f2" + "reference": "0c4a7b6eaefe8b0a6334c044feab9790095b2ddb" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/google/google-api-php-client/zipball/b69b8ac4bf6501793c389d4e013a79d09c85c5f2", - "reference": "b69b8ac4bf6501793c389d4e013a79d09c85c5f2", + "url": "https://api.github.com/repos/google/google-api-php-client/zipball/0c4a7b6eaefe8b0a6334c044feab9790095b2ddb", + "reference": "0c4a7b6eaefe8b0a6334c044feab9790095b2ddb", "shasum": "" }, "require": { @@ -966,7 +966,7 @@ }, "require-dev": { "cache/filesystem-adapter": "^0.3.2", - "phpunit/phpunit": "~4", + "phpunit/phpunit": "~4.8.36", "squizlabs/php_codesniffer": "~2.3", "symfony/css-selector": "~2.1", "symfony/dom-crawler": "~2.1" @@ -997,20 +997,20 @@ "keywords": [ "google" ], - "time": "2017-11-03T01:19:53+00:00" + "time": "2017-11-08T19:28:50+00:00" }, { "name": "google/apiclient-services", - "version": "v0.33", + "version": "v0.34", "source": { "type": "git", "url": "https://github.com/google/google-api-php-client-services.git", - "reference": "6399eb82c725aef79124cd6b543e1984cd13d207" + "reference": "4d0d438e323929579cabf0b4d420177a96835c6d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/google/google-api-php-client-services/zipball/6399eb82c725aef79124cd6b543e1984cd13d207", - "reference": "6399eb82c725aef79124cd6b543e1984cd13d207", + "url": "https://api.github.com/repos/google/google-api-php-client-services/zipball/4d0d438e323929579cabf0b4d420177a96835c6d", + "reference": "4d0d438e323929579cabf0b4d420177a96835c6d", "shasum": "" }, "require": { @@ -1034,7 +1034,7 @@ "keywords": [ "google" ], - "time": "2017-11-06T00:24:21+00:00" + "time": "2017-11-11T00:27:24+00:00" }, { "name": "google/auth", @@ -1720,12 +1720,12 @@ "source": { "type": "git", "url": "https://github.com/thephpleague/flysystem.git", - "reference": "910d698be2274c22509e800dbcdb5cdd73247b0b" + "reference": "8f4639a34cabf69c300814258e6eadc13b0f1aed" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/thephpleague/flysystem/zipball/910d698be2274c22509e800dbcdb5cdd73247b0b", - "reference": "910d698be2274c22509e800dbcdb5cdd73247b0b", + "url": "https://api.github.com/repos/thephpleague/flysystem/zipball/8f4639a34cabf69c300814258e6eadc13b0f1aed", + "reference": "8f4639a34cabf69c300814258e6eadc13b0f1aed", "shasum": "" }, "require": { @@ -1797,7 +1797,7 @@ "sftp", "storage" ], - "time": "2017-11-04T05:38:03+00:00" + "time": "2017-11-10T20:20:27+00:00" }, { "name": "league/oauth2-client", @@ -2146,12 +2146,12 @@ "source": { "type": "git", "url": "https://github.com/phpseclib/phpseclib.git", - "reference": "12090c138e267cc7781729210244ec2444b80cd3" + "reference": "6a65ea28ecac752eb58814076f43d93bb161d9e7" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpseclib/phpseclib/zipball/12090c138e267cc7781729210244ec2444b80cd3", - "reference": "12090c138e267cc7781729210244ec2444b80cd3", + "url": "https://api.github.com/repos/phpseclib/phpseclib/zipball/6a65ea28ecac752eb58814076f43d93bb161d9e7", + "reference": "6a65ea28ecac752eb58814076f43d93bb161d9e7", "shasum": "" }, "require": { @@ -2230,7 +2230,7 @@ "x.509", "x509" ], - "time": "2017-11-05T17:42:33+00:00" + "time": "2017-11-12T05:15:00+00:00" }, { "name": "predis/predis", @@ -2885,12 +2885,12 @@ "source": { "type": "git", "url": "https://github.com/symfony/event-dispatcher.git", - "reference": "10d9a1b5dbf23dfaa38737b69a09f8882821f666" + "reference": "ca20b8f9ef149f40ff656d52965f240d85f7a8e4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/10d9a1b5dbf23dfaa38737b69a09f8882821f666", - "reference": "10d9a1b5dbf23dfaa38737b69a09f8882821f666", + "url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/ca20b8f9ef149f40ff656d52965f240d85f7a8e4", + "reference": "ca20b8f9ef149f40ff656d52965f240d85f7a8e4", "shasum": "" }, "require": { @@ -2940,7 +2940,7 @@ ], "description": "Symfony EventDispatcher Component", "homepage": "https://symfony.com", - "time": "2017-11-05T16:10:10+00:00" + "time": "2017-11-09T14:14:31+00:00" }, { "name": "symfony/finder", @@ -3722,12 +3722,12 @@ "source": { "type": "git", "url": "https://github.com/fzaninotto/Faker.git", - "reference": "910a79d58e264630477292a3ca06b9966673ac09" + "reference": "9cda1a418ca4b2b71c9b921ebaea6c2e61e270b4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/fzaninotto/Faker/zipball/910a79d58e264630477292a3ca06b9966673ac09", - "reference": "910a79d58e264630477292a3ca06b9966673ac09", + "url": "https://api.github.com/repos/fzaninotto/Faker/zipball/9cda1a418ca4b2b71c9b921ebaea6c2e61e270b4", + "reference": "9cda1a418ca4b2b71c9b921ebaea6c2e61e270b4", "shasum": "" }, "require": { @@ -3735,7 +3735,7 @@ }, "require-dev": { "ext-intl": "*", - "phpunit/phpunit": "^4.0 || ^5.0", + "phpunit/phpunit": "^4.8.35 || ^5.7", "squizlabs/php_codesniffer": "^1.5" }, "type": "library", @@ -3764,7 +3764,7 @@ "faker", "fixtures" ], - "time": "2017-11-06T09:42:24+00:00" + "time": "2017-11-13T07:51:09+00:00" }, { "name": "hamcrest/hamcrest-php", @@ -3856,7 +3856,7 @@ ], "authors": [ { - "name": "Padraic Brady", + "name": "Pádraic Brady", "email": "padraic.brady@gmail.com", "homepage": "http://blog.astrumfutura.com" }, @@ -4954,12 +4954,12 @@ "source": { "type": "git", "url": "https://github.com/symfony/yaml.git", - "reference": "dcf3a9dfac146a0e10757a91de0b541fcd79de4f" + "reference": "0938408c4faa518d95230deabb5f595bf0de31b9" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/yaml/zipball/dcf3a9dfac146a0e10757a91de0b541fcd79de4f", - "reference": "dcf3a9dfac146a0e10757a91de0b541fcd79de4f", + "url": "https://api.github.com/repos/symfony/yaml/zipball/0938408c4faa518d95230deabb5f595bf0de31b9", + "reference": "0938408c4faa518d95230deabb5f595bf0de31b9", "shasum": "" }, "require": { @@ -5001,7 +5001,7 @@ ], "description": "Symfony Yaml Component", "homepage": "https://symfony.com", - "time": "2017-10-06T12:26:09+00:00" + "time": "2017-11-10T18:26:04+00:00" }, { "name": "webmozart/assert", diff --git a/config/app.php b/config/app.php index a12b083c..ec7ca408 100644 --- a/config/app.php +++ b/config/app.php @@ -159,11 +159,11 @@ return [ App\Providers\AuthServiceProvider::class, App\Providers\EventServiceProvider::class, App\Providers\RouteServiceProvider::class, - \repositories\RepositoriesProvider::class, - \services\ServicesProvider::class, - \factories\FactoriesProvider::class, - \libs\utils\CustomDoctrineServiceProvider::class, - \LaravelDoctrine\Extensions\BeberleiExtensionsServiceProvider::class, + App\Repositories\RepositoriesProvider::class, + services\ServicesProvider::class, + factories\FactoriesProvider::class, + libs\utils\CustomDoctrineServiceProvider::class, + LaravelDoctrine\Extensions\BeberleiExtensionsServiceProvider::class, ], /* diff --git a/database/seeds/ApiEndpointsSeeder.php b/database/seeds/ApiEndpointsSeeder.php index e645ec4a..0e8e1651 100644 --- a/database/seeds/ApiEndpointsSeeder.php +++ b/database/seeds/ApiEndpointsSeeder.php @@ -28,9 +28,6 @@ class ApiEndpointsSeeder extends Seeder DB::table('endpoint_api_scopes')->delete(); DB::table('api_endpoints')->delete(); - $this->seedPublicCloudsEndpoints(); - $this->seedPrivateCloudsEndpoints(); - $this->seedConsultantsEndpoints(); $this->seedSummitEndpoints(); $this->seedMemberEndpoints(); $this->seedTeamEndpoints(); @@ -68,98 +65,6 @@ class ApiEndpointsSeeder extends Seeder EntityManager::flush(); } - private function seedPublicCloudsEndpoints() - { - - $current_realm = Config::get('app.url'); - - $this->seedApiEndpoints('public-clouds', [ - array( - 'name' => 'get-public-clouds', - 'active' => true, - 'route' => '/api/v1/marketplace/public-clouds', - 'http_method' => 'GET', - 'scopes' => [ - sprintf('%s/public-clouds/read', $current_realm), - ], - ), - array( - 'name' => 'get-public-cloud', - 'active' => true, - 'route' => '/api/v1/marketplace/public-clouds/{id}', - 'http_method' => 'GET', - 'scopes' => [ - sprintf('%s/public-clouds/read', $current_realm), - ], - ), - array( - 'name' => 'get-public-cloud-datacenters', - 'active' => true, - 'route' => '/api/v1/marketplace/public-clouds/{id}/data-centers', - 'http_method' => 'GET', - 'scopes' => [ - sprintf('%s/public-clouds/read', $current_realm), - ], - ) - ]); - } - - private function seedPrivateCloudsEndpoints() - { - - $current_realm = Config::get('app.url'); - // endpoints scopes - - $this->seedApiEndpoints('private-clouds', [ - array( - 'name' => 'get-private-clouds', - 'route' => '/api/v1/marketplace/private-clouds', - 'http_method' => 'GET', - 'scopes' => [sprintf('%s/private-clouds/read', $current_realm)], - ), - array( - 'name' => 'get-private-cloud', - 'route' => '/api/v1/marketplace/private-clouds/{id}', - 'http_method' => 'GET', - 'scopes' => [sprintf('%s/private-clouds/read', $current_realm)], - ), - array( - 'name' => 'get-private-cloud-datacenters', - 'route' => '/api/v1/marketplace/private-clouds/{id}/data-centers', - 'http_method' => 'GET', - 'scopes' => [sprintf('%s/private-clouds/read', $current_realm)], - ) - ]); - - } - - private function seedConsultantsEndpoints() - { - - $current_realm = Config::get('app.url'); - - $this->seedApiEndpoints('consultants', [ - array( - 'name' => 'get-consultants', - 'route' => '/api/v1/marketplace/consultants', - 'http_method' => 'GET', - 'scopes' => [sprintf('%s/consultants/read', $current_realm)], - ), - array( - 'name' => 'get-consultant', - 'route' => '/api/v1/marketplace/consultants/{id}', - 'http_method' => 'GET', - 'scopes' => [sprintf('%s/consultants/read', $current_realm)], - ), - array( - 'name' => 'get-consultant-offices', - 'route' => '/api/v1/marketplace/consultants/{id}/offices', - 'http_method' => 'GET', - 'scopes' => [sprintf('%s/consultants/read', $current_realm)], - ) - ]); - } - private function seedSummitEndpoints() { $current_realm = Config::get('app.url'); diff --git a/database/seeds/ApiScopesSeeder.php b/database/seeds/ApiScopesSeeder.php index a8cef6dd..2ff598c5 100644 --- a/database/seeds/ApiScopesSeeder.php +++ b/database/seeds/ApiScopesSeeder.php @@ -29,68 +29,11 @@ final class ApiScopesSeeder extends Seeder DB::table('endpoint_api_scopes')->delete(); DB::table('api_scopes')->delete(); - $this->seedPublicCloudScopes(); - $this->seedPrivateCloudScopes(); - $this->seedConsultantScopes(); $this->seedSummitScopes(); $this->seedMembersScopes(); $this->seedTeamsScopes(); } - private function seedPublicCloudScopes() - { - - $current_realm = Config::get('app.url'); - $api = EntityManager::getRepository(\App\Models\ResourceServer\Api::class)->findOneBy(['name' => 'public-clouds']); - - $scope = new ApiScope(); - $scope->setName(sprintf('%s/public-clouds/read', $current_realm)); - $scope->setShortDescription('Read Public Clouds Data'); - $scope->setDescription('Grants read only access for Public Clouds'); - $scope->setActive(true); - $scope->setDefault(false); - $scope->setApi($api); - - EntityManager::persist($scope); - EntityManager::flush(); - } - - private function seedPrivateCloudScopes() - { - - $current_realm = Config::get('app.url'); - $api = EntityManager::getRepository(\App\Models\ResourceServer\Api::class)->findOneBy(['name' => 'private-clouds']); - - $scope = new ApiScope(); - $scope->setName(sprintf('%s/private-clouds/read', $current_realm)); - $scope->setShortDescription('Read Private Clouds Data'); - $scope->setDescription('Grants read only access for Private Clouds'); - $scope->setActive(true); - $scope->setDefault(false); - $scope->setApi($api); - - EntityManager::persist($scope); - EntityManager::flush(); - } - - private function seedConsultantScopes() - { - - $current_realm = Config::get('app.url'); - $api = EntityManager::getRepository(\App\Models\ResourceServer\Api::class)->findOneBy(['name' => 'consultants']); - - $scope = new ApiScope(); - $scope->setName(sprintf('%s/consultants/read', $current_realm)); - $scope->setShortDescription('Read Consultants Data'); - $scope->setDescription('Grants read only access for Consultants'); - $scope->setActive(true); - $scope->setDefault(false); - $scope->setApi($api); - - EntityManager::persist($scope); - EntityManager::flush(); - } - private function seedSummitScopes() { diff --git a/database/seeds/ApiSeeder.php b/database/seeds/ApiSeeder.php index 3cca34c8..61fec342 100644 --- a/database/seeds/ApiSeeder.php +++ b/database/seeds/ApiSeeder.php @@ -31,32 +31,6 @@ final class ApiSeeder extends Seeder DB::table('api_endpoints')->delete(); DB::table('apis')->delete(); - // public clouds - $api = new Api(); - $api->setName('public-clouds'); - $api->setActive(true); - $api->setDescription('Marketplace Public Clouds API'); - - EntityManager::persist($api); - - // private clouds - - $api = new Api(); - $api->setName('private-clouds'); - $api->setActive(true); - $api->setDescription('Marketplace Private Clouds API'); - - EntityManager::persist($api); - - // consultants - - $api = new Api(); - $api->setName('consultants'); - $api->setActive(true); - $api->setDescription('Marketplace Consultants API'); - - EntityManager::persist($api); - // summit $api = new Api(); diff --git a/tests/MarketplaceApiTest.php b/tests/MarketplaceApiTest.php new file mode 100644 index 00000000..4650ffec --- /dev/null +++ b/tests/MarketplaceApiTest.php @@ -0,0 +1,184 @@ + 1, + 'per_page' => 100, + 'expand' => 'company,reviews', + ]; + + $response = $this->action( + "GET", + "AppliancesApiController@getAll", + $params, + [], + [], + [], + [] + ); + + $content = $response->getContent(); + $appliances = json_decode($content); + $this->assertTrue(!is_null($appliances)); + $this->assertResponseStatus(200); + } + + public function testGetAppliancesFilter(){ + + $params = [ + 'filter' => 'company=@Breqwa', + 'order' => '+name', + 'expand' => 'company,reviews' + ]; + + $response = $this->action( + "GET", + "AppliancesApiController@getAll", + $params, + [], + [], + [], + [] + ); + + $content = $response->getContent(); + $appliances = json_decode($content); + $this->assertTrue(!is_null($appliances)); + $this->assertResponseStatus(200); + } + + public function testGetAllDistros(){ + + $params = [ + 'page' => 1, + 'per_page' => 100, + 'expand' => '', + ]; + + $response = $this->action( + "GET", + "DistributionsApiController@getAll", + $params, + [], + [], + [], + [] + ); + + $content = $response->getContent(); + $distros = json_decode($content); + $this->assertTrue(!is_null($distros)); + $this->assertResponseStatus(200); + } + + public function testGetAllConsultants(){ + $params = [ + 'page' => 1, + 'per_page' => 100, + 'expand' => 'offices,clients,spoken_languages,configuration_management_expertise,expertise_areas,services_offered', + ]; + + $response = $this->action( + "GET", + "ConsultantsApiController@getAll", + $params, + [], + [], + [], + [] + ); + + $content = $response->getContent(); + $consultants = json_decode($content); + $this->assertTrue(!is_null($consultants)); + $this->assertResponseStatus(200); + } + + public function testGetAllPrivateClouds(){ + $params = [ + 'page' => 1, + 'per_page' => 100, + 'expand' => '', + ]; + + $response = $this->action( + "GET", + "PrivateCloudsApiController@getAll", + $params, + [], + [], + [], + [] + ); + + $content = $response->getContent(); + $clouds = json_decode($content); + $this->assertTrue(!is_null($clouds)); + $this->assertResponseStatus(200); + } + + public function testGetAllPublicClouds(){ + $params = [ + 'page' => 1, + 'per_page' => 100, + 'expand' => '', + ]; + + $response = $this->action( + "GET", + "PublicCloudsApiController@getAll", + $params, + [], + [], + [], + [] + ); + + $content = $response->getContent(); + $clouds = json_decode($content); + $this->assertTrue(!is_null($clouds)); + $this->assertResponseStatus(200); + } + + public function testGetAllRemoteClouds(){ + $params = [ + 'page' => 1, + 'per_page' => 100, + 'expand' => '', + ]; + + $response = $this->action( + "GET", + "RemoteCloudsApiController@getAll", + $params, + [], + [], + [], + [] + ); + + $content = $response->getContent(); + $clouds = json_decode($content); + $this->assertTrue(!is_null($clouds)); + $this->assertResponseStatus(200); + } +} \ No newline at end of file