Summit Wifi Connections

Added summit wifi connection entity to summit json

Change-Id: Ic9aff92729cec7f28b064250787196c587c1e1d6
This commit is contained in:
Sebastian Marcet 2017-02-02 11:49:29 -03:00
parent 079b7a59ca
commit f4be12644d
7 changed files with 225 additions and 4 deletions

View File

@ -56,6 +56,7 @@ final class SerializerRegistry
private function __construct()
{
$this->registry['Summit'] = SummitSerializer::class;
$this->registry['SummitWIFIConnection'] = SummitWIFIConnectionSerializer::class;
$this->registry['SummitType'] = SummitTypeSerializer::class;
$this->registry['SummitEventType'] = SummitEventTypeSerializer::class;
$this->registry['SummitTicketType'] = SummitTicketTypeSerializer::class;

View File

@ -14,6 +14,7 @@
**/
use Illuminate\Support\Facades\Config;
use models\summit\Summit;
/**
* Class SummitSerializer
@ -42,6 +43,7 @@ final class SummitSerializer extends SilverStripeSerializer
public function serialize($expand = null, array $fields = array(), array $relations = array(), array $params = array())
{
$summit = $this->object;
if(!$summit instanceof Summit) return [];
$values = parent::serialize($expand, $fields, $relations, $params);
$time_zone_list = timezone_identifiers_list();
$time_zone_id = $summit->getTimeZoneId();
@ -70,18 +72,26 @@ final class SummitSerializer extends SilverStripeSerializer
$values['schedule_event_detail_url'] = sprintf("%ssummit/%s/%s/%s", Config::get("server.assets_base_url", 'https://www.openstack.org/'), $main_page, $schedule_page, 'events/:event_id/:event_title');
// tickets
$ticket_types = array();
$ticket_types = [];
foreach ($summit->getTicketTypes() as $ticket) {
$ticket_types[] = SerializerRegistry::getInstance()->getSerializer($ticket)->serialize();
}
$values['ticket_types'] = $ticket_types;
//locations
$locations = array();
$locations = [];
foreach ($summit->getLocations() as $location) {
$locations[] = SerializerRegistry::getInstance()->getSerializer($location)->serialize();
}
$values['locations'] = $locations;
// wifi connections
$wifi_connections = [];
foreach ($summit->getWifiConnections() as $wifi_connection) {
$wifi_connections[] = SerializerRegistry::getInstance()->getSerializer($wifi_connection)->serialize();
}
$values['wifi_connections'] = $wifi_connections;
if (!empty($expand)) {
$expand = explode(',', $expand);
foreach ($expand as $relation) {

View File

@ -0,0 +1,44 @@
<?php namespace ModelSerializers;
/**
* Copyright 2017 OpenStack Foundation
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
**/
/**
* Class SummitWIFIConnectionSerializer
* @package ModelSerializers
*/
class SummitWIFIConnectionSerializer extends SilverStripeSerializer
{
protected static $array_mappings = array
(
'SSID' => 'ssid:json_string',
'Password' => 'password:json_string',
'Description' => 'description:json_string',
'SummitId' => 'summit_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() )
{
$values = parent::serialize($expand, $fields, $relations, $params);
$wifi_connection = $this->object;
return $values;
}
}

View File

@ -63,7 +63,7 @@ final class EntityEventTypeFactory
if ($e->getType() === 'UPDATE' || $e->getType() === "INSERT")
return new SummitGroupEventEntityEventInsertOrUpdateType($e, $ctx);
return new SummitEventEntityEventDeleteType($e, $ctx);;
return new SummitEventEntityEventDeleteType($e, $ctx);
}
break;
case 'MySchedule':
@ -86,6 +86,10 @@ final class EntityEventTypeFactory
return new SummitEventTypeEntityEventType($e, $ctx);
}
break;
case 'SummitWIFIConnection': {
return new SummitWIFIConnectionEntityEventType($e, $ctx);
}
break;
case 'SummitVenue':
case 'SummitVenueRoom':
case 'SummitAirport':

View File

@ -0,0 +1,34 @@
<?php namespace Models\foundation\summit\EntityEvents;
use models\utils\IEntity;
/**
* Copyright 2017 OpenStack Foundation
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
**/
/**
* Class SummitWIFIConnectionEntityEventType
* @package Models\foundation\summit\EntityEvents
*/
class SummitWIFIConnectionEntityEventType extends GenericSummitEntityEventType
{
/**
* @return IEntity|null
*/
protected function registerEntity()
{
$entity = $this->entity_event->getSummit()->getWifiConnection($this->entity_event->getEntityId());
if(!is_null($entity))
$this->entity_event->registerEntity($entity);
return $entity;
}
}

View File

@ -49,6 +49,22 @@ class Summit extends SilverstripeBaseModel
$this->name = $name;
}
/**
* @return mixed
*/
public function getWifiConnections()
{
return $this->wifi_connections;
}
/**
* @param mixed $wifi_connections
*/
public function setWifiConnections($wifi_connections)
{
$this->wifi_connections = $wifi_connections;
}
/**
* @return string
*/
@ -300,6 +316,11 @@ class Summit extends SilverstripeBaseModel
*/
private $events;
/**
* @ORM\OneToMany(targetEntity="SummitWIFIConnection", mappedBy="summit", cascade={"persist"})
*/
private $wifi_connections;
/**
* Summit constructor.
*/
@ -314,6 +335,7 @@ class Summit extends SilverstripeBaseModel
$this->category_groups = new ArrayCollection();
$this->attendees = new ArrayCollection();
$this->entity_events = new ArrayCollection();
$this->wifi_connections = new ArrayCollection();
}
/**
@ -355,6 +377,7 @@ class Summit extends SilverstripeBaseModel
$summit_time_zone = new DateTimeZone($time_zone_name);
$timestamp = $value->format('Y-m-d H:i:s');
$utc_date = new DateTime($timestamp, $utc_timezone);
return $utc_date->setTimezone($summit_time_zone);
}
return null;
@ -503,7 +526,7 @@ class Summit extends SilverstripeBaseModel
/**
* @param int $event_type_id
* @return SummitEventType
* @return SummitEventType|null
*/
public function getEventType($event_type_id)
{
@ -513,6 +536,16 @@ class Summit extends SilverstripeBaseModel
return $event_type === false ? null:$event_type;
}
/**
* @param int $wifi_connection_id
* @return SummitWIFIConnection|null
*/
public function getWifiConnection($wifi_connection_id){
$criteria = Criteria::create();
$criteria->where(Criteria::expr()->eq('id', intval($wifi_connection_id)));
$wifi_conn = $this->wifi_connections->matching($criteria)->first();
return $wifi_conn === false ? null:$wifi_conn;
}
/**
* @ORM\OneToMany(targetEntity="models\summit\SummitTicketType", mappedBy="summit", cascade={"persist"})

View File

@ -0,0 +1,95 @@
<?php namespace models\summit;
/**
* Copyright 2017 OpenStack Foundation
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
**/
use Doctrine\ORM\Cache;
use models\utils\SilverstripeBaseModel;
use Doctrine\ORM\Mapping AS ORM;
/**
* @ORM\Entity
* @ORM\Table(name="SummitWIFIConnection")
* @ORM\Cache(usage="NONSTRICT_READ_WRITE", region="summit_region")
* Class SummitWIFIConnection
* @package models\summit\SummitWIFIConnection
*/
class SummitWIFIConnection extends SilverstripeBaseModel
{
use SummitOwned;
/**
* @ORM\Column(name="SSID", type="string")
* @var string
*/
private $ssid;
/**
* @ORM\Column(name="Password", type="string")
* @var string
*/
private $password;
/**
* @ORM\Column(name="Description", type="string")
* @var string
*/
private $description;
/**
* @return string
*/
public function getSsid()
{
return $this->ssid;
}
/**
* @param string $ssid
*/
public function setSsid($ssid)
{
$this->ssid = $ssid;
}
/**
* @return string
*/
public function getPassword()
{
return $this->password;
}
/**
* @param string $password
*/
public function setPassword($password)
{
$this->password = $password;
}
/**
* @return string
*/
public function getDescription()
{
return $this->description;
}
/**
* @param string $description
*/
public function setDescription($description)
{
$this->description = $description;
}
}