Refactoring/Update of logic for SummitEvent Update
Change-Id: I2edb79f9acfd0683cce624b9e6825d3ac5d367b4
This commit is contained in:
parent
ddc0a955e2
commit
3d0455ee38
|
@ -17,7 +17,7 @@ use Doctrine\ORM\Mapping AS ORM;
|
|||
use models\utils\SilverstripeBaseModel;
|
||||
|
||||
/**
|
||||
* @ORM\Entity
|
||||
* @ORM\Entity(repositoryClass="repositories\main\DoctrineCompanyRepository")
|
||||
* @ORM\Table(name="Company")
|
||||
* @ORM\Cache(usage="NONSTRICT_READ_WRITE", region="sponsors_region")
|
||||
* Class Company
|
||||
|
|
|
@ -12,12 +12,12 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
**/
|
||||
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
use Doctrine\ORM\Mapping AS ORM;
|
||||
use models\utils\SilverstripeBaseModel;
|
||||
|
||||
/**
|
||||
* @ORM\Entity
|
||||
* @ORM\Entity(repositoryClass="repositories\main\DoctrineGroupRepository")
|
||||
* @ORM\Table(name="`Group`")
|
||||
* Class Group
|
||||
* @package models\main
|
||||
|
|
|
@ -757,13 +757,13 @@ SQL;
|
|||
|
||||
/**
|
||||
* @param CalendarSyncInfo $calendar_sync_info
|
||||
* @param SummitEvent $event
|
||||
* @param int $event_id
|
||||
* @return bool
|
||||
*/
|
||||
public function isEventSynchronized(CalendarSyncInfo $calendar_sync_info, SummitEvent $event){
|
||||
public function isEventSynchronized(CalendarSyncInfo $calendar_sync_info, $event_id){
|
||||
|
||||
$criteria = Criteria::create();
|
||||
$criteria->where(Criteria::expr()->eq('summit_event', $event));
|
||||
$criteria->where(Criteria::expr()->eq('summit_event_id', $event_id));
|
||||
$criteria->andWhere(Criteria::expr()->eq('calendar_sync_info', $calendar_sync_info));
|
||||
return $this->schedule_sync_info->matching($criteria)->count() > 0;
|
||||
}
|
||||
|
@ -806,14 +806,14 @@ SQL;
|
|||
}
|
||||
|
||||
/**
|
||||
* @param SummitEvent $event
|
||||
* @param int $summit_event_id
|
||||
* @param CalendarSyncInfo $calendar_sync_info
|
||||
* @return ScheduleCalendarSyncInfo|null
|
||||
*/
|
||||
public function getScheduleSyncInfoByEvent(SummitEvent $event, CalendarSyncInfo $calendar_sync_info){
|
||||
public function getScheduleSyncInfoByEvent($summit_event_id, CalendarSyncInfo $calendar_sync_info){
|
||||
try {
|
||||
$criteria = Criteria::create();
|
||||
$criteria->where(Criteria::expr()->eq('summit_event', $event));
|
||||
$criteria->where(Criteria::expr()->eq('summit_event_id', $summit_event_id));
|
||||
$criteria->andWhere(Criteria::expr()->eq('calendar_sync_info', $calendar_sync_info));
|
||||
$res = $this->schedule_sync_info->matching($criteria)->first();
|
||||
return $res === false ? null : $res;
|
||||
|
|
|
@ -0,0 +1,23 @@
|
|||
<?php namespace models\main;
|
||||
/**
|
||||
* 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 models\utils\IBaseRepository;
|
||||
|
||||
/**
|
||||
* Interface ICompanyRepository
|
||||
* @package models\main
|
||||
*/
|
||||
interface ICompanyRepository extends IBaseRepository
|
||||
{
|
||||
|
||||
}
|
|
@ -0,0 +1,23 @@
|
|||
<?php namespace models\main;
|
||||
/**
|
||||
* 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 models\utils\IBaseRepository;
|
||||
|
||||
/**
|
||||
* Interface IGroupRepository
|
||||
* @package models\main
|
||||
*/
|
||||
interface IGroupRepository extends IBaseRepository
|
||||
{
|
||||
|
||||
}
|
|
@ -34,11 +34,49 @@ class ScheduleCalendarSyncInfo extends SilverstripeBaseModel
|
|||
private $member;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity="models\summit\SummitEvent")
|
||||
* @ORM\JoinColumn(name="SummitEventID", referencedColumnName="ID")
|
||||
* @var SummitEvent
|
||||
* @ORM\Column(name="SummitEventID", type="integer")
|
||||
* @var int
|
||||
*/
|
||||
private $summit_event;
|
||||
private $summit_event_id;
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getSummitEventId()
|
||||
{
|
||||
return $this->summit_event_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $summit_event_id
|
||||
*/
|
||||
public function setSummitEventId($summit_event_id)
|
||||
{
|
||||
$this->summit_event_id = $summit_event_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return SummitEvent
|
||||
*/
|
||||
public function getSummitEvent()
|
||||
{
|
||||
$id = $this->summit_event_id;
|
||||
try {
|
||||
$event = $this->getEM()->find(SummitEvent::class, $id);
|
||||
}
|
||||
catch(\Exception $ex){
|
||||
return null;
|
||||
}
|
||||
return $event;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param SummitEvent $summit_event
|
||||
*/
|
||||
public function setSummitEvent($summit_event)
|
||||
{
|
||||
$this->summit_event_id = $summit_event->getId();
|
||||
}
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity="models\summit\SummitAbstractLocation")
|
||||
|
@ -108,22 +146,6 @@ class ScheduleCalendarSyncInfo extends SilverstripeBaseModel
|
|||
$this->event = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return SummitEvent
|
||||
*/
|
||||
public function getSummitEvent()
|
||||
{
|
||||
return $this->summit_event;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param SummitEvent $event
|
||||
*/
|
||||
public function setSummitEvent($event)
|
||||
{
|
||||
$this->summit_event = $event;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \DateTime
|
||||
*/
|
||||
|
|
|
@ -26,19 +26,42 @@ class AdminSummitEventActionSyncWorkRequest
|
|||
{
|
||||
|
||||
const SubType = 'ADMIN_EVENT';
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity="models\summit\SummitEvent", cascade={"persist"})
|
||||
* @ORM\JoinColumn(name="SummitEventID", referencedColumnName="ID")
|
||||
* @var SummitEvent
|
||||
* @ORM\Column(name="SummitEventID", type="integer")
|
||||
* @var int
|
||||
*/
|
||||
private $summit_event;
|
||||
private $summit_event_id;
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getSummitEventId()
|
||||
{
|
||||
return $this->summit_event_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $summit_event_id
|
||||
*/
|
||||
public function setSummitEventId($summit_event_id)
|
||||
{
|
||||
$this->summit_event_id = $summit_event_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return SummitEvent
|
||||
*/
|
||||
public function getSummitEvent()
|
||||
{
|
||||
return $this->summit_event;
|
||||
$id = $this->summit_event_id;
|
||||
try {
|
||||
$event = $this->getEM()->find(SummitEvent::class, $id);
|
||||
}
|
||||
catch(\Exception $ex){
|
||||
return null;
|
||||
}
|
||||
return $event;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -46,7 +69,7 @@ class AdminSummitEventActionSyncWorkRequest
|
|||
*/
|
||||
public function setSummitEvent($summit_event)
|
||||
{
|
||||
$this->summit_event = $summit_event;
|
||||
$this->summit_event_id = $summit_event->getId();
|
||||
}
|
||||
|
||||
}
|
|
@ -24,19 +24,42 @@ class MemberEventScheduleSummitActionSyncWorkRequest
|
|||
extends MemberScheduleSummitActionSyncWorkRequest
|
||||
{
|
||||
const SubType = 'EVENT';
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity="models\summit\SummitEvent", cascade={"persist"})
|
||||
* @ORM\JoinColumn(name="SummitEventID", referencedColumnName="ID")
|
||||
* @var SummitEvent
|
||||
* @ORM\Column(name="SummitEventID", type="integer")
|
||||
* @var int
|
||||
*/
|
||||
protected $summit_event;
|
||||
private $summit_event_id;
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getSummitEventId()
|
||||
{
|
||||
return $this->summit_event_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $summit_event_id
|
||||
*/
|
||||
public function setSummitEventId($summit_event_id)
|
||||
{
|
||||
$this->summit_event_id = $summit_event_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return SummitEvent
|
||||
*/
|
||||
public function getSummitEvent()
|
||||
{
|
||||
return $this->summit_event;
|
||||
$id = $this->summit_event_id;
|
||||
try {
|
||||
$event = $this->getEM()->find(SummitEvent::class, $id);
|
||||
}
|
||||
catch(\Exception $ex){
|
||||
return null;
|
||||
}
|
||||
return $event;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -44,9 +67,8 @@ extends MemberScheduleSummitActionSyncWorkRequest
|
|||
*/
|
||||
public function setSummitEvent($summit_event)
|
||||
{
|
||||
$this->summit_event = $summit_event;
|
||||
$this->summit_event_id = $summit_event->getId();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
|
|
|
@ -96,6 +96,12 @@ class Presentation extends SummitEvent
|
|||
*/
|
||||
protected $to_record;
|
||||
|
||||
/**
|
||||
* @ORM\Column(name="FeatureCloud", type="boolean")
|
||||
* @var bool
|
||||
*/
|
||||
protected $feature_cloud;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity="PresentationSpeaker", inversedBy="moderated_presentations")
|
||||
* @ORM\JoinColumn(name="ModeratorID", referencedColumnName="ID")
|
||||
|
@ -435,4 +441,19 @@ class Presentation extends SummitEvent
|
|||
$this->selected_presentations = $selected_presentations;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getFeatureCloud()
|
||||
{
|
||||
return $this->feature_cloud;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $feature_cloud
|
||||
*/
|
||||
public function setFeatureCloud($feature_cloud)
|
||||
{
|
||||
$this->feature_cloud = $feature_cloud;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -352,4 +352,16 @@ class PresentationSpeaker extends SilverstripeBaseModel
|
|||
{
|
||||
$this->registration_request = $registration_request;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getFullName(){
|
||||
$fullname = $this->first_name;
|
||||
if(!empty($this->last_name)){
|
||||
if(!empty($fullname)) $fullname .= ', ';
|
||||
$fullname .= $this->last_name;
|
||||
}
|
||||
return $fullname;
|
||||
}
|
||||
}
|
|
@ -96,7 +96,7 @@ class PresentationType extends SummitEventType
|
|||
FROM PresentationType
|
||||
INNER JOIN SummitEventType ON SummitEventType.ID = PresentationType.ID
|
||||
WHERE SummitEventType.SummitID = :summit_id
|
||||
AND PresentationType.Type = :type
|
||||
AND SummitEventType.Type = :type
|
||||
SQL;
|
||||
$stmt = self::prepareRawSQLStatic($sql);
|
||||
$stmt->execute(['summit_id' => $summit->getId(), 'type' => $type]);
|
||||
|
|
|
@ -19,6 +19,7 @@ use Doctrine\Common\Collections\Criteria;
|
|||
use Doctrine\ORM\Event\PreUpdateEventArgs;
|
||||
use models\exceptions\ValidationException;
|
||||
use models\main\Company;
|
||||
use models\main\Member;
|
||||
use models\main\Tag;
|
||||
use models\utils\PreRemoveEventArgs;
|
||||
use models\utils\SilverstripeBaseModel;
|
||||
|
@ -136,6 +137,7 @@ class SummitEvent extends SilverstripeBaseModel
|
|||
/**
|
||||
* @ORM\ManyToOne(targetEntity="SummitAbstractLocation", fetch="EXTRA_LAZY")
|
||||
* @ORM\JoinColumn(name="LocationID", referencedColumnName="ID")
|
||||
* @var SummitAbstractLocation
|
||||
*/
|
||||
protected $location = null;
|
||||
|
||||
|
@ -148,15 +150,6 @@ class SummitEvent extends SilverstripeBaseModel
|
|||
*/
|
||||
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")
|
||||
|
@ -211,7 +204,6 @@ class SummitEvent extends SilverstripeBaseModel
|
|||
$this->head_count = 0;
|
||||
$this->tags = new ArrayCollection();
|
||||
$this->feedback = new ArrayCollection();
|
||||
$this->attendees = new ArrayCollection();
|
||||
$this->sponsors = new ArrayCollection();
|
||||
$this->rsvp = new ArrayCollection();
|
||||
}
|
||||
|
@ -576,15 +568,18 @@ class SummitEvent extends SilverstripeBaseModel
|
|||
}
|
||||
|
||||
/**
|
||||
* @return SummitAttendee[]
|
||||
* @param Company $sponsor
|
||||
*/
|
||||
public function getAttendees()
|
||||
{
|
||||
$criteria = Criteria::create();
|
||||
$criteria->where(Criteria::expr()->eq('IsCheckedIn', 1));
|
||||
return $this->attendees->matching($criteria);
|
||||
public function addSponsor(Company $sponsor){
|
||||
$this->sponsors->add($sponsor);
|
||||
}
|
||||
|
||||
|
||||
public function clearSponsors(){
|
||||
$this->sponsors->clear();
|
||||
}
|
||||
|
||||
|
||||
public function addFeedBack(SummitEventFeedback $feedback)
|
||||
{
|
||||
$this->feedback->add($feedback);
|
||||
|
@ -699,13 +694,22 @@ class SummitEvent extends SilverstripeBaseModel
|
|||
* @ORM\PreRemove:
|
||||
*/
|
||||
public function deleting($args){
|
||||
$this->pre_remove_events = new PreRemoveEventArgs(['id' => $this->id, 'class_name' => $this->getClassName(), 'summit' => $this->summit ]);
|
||||
$this->pre_remove_events = new PreRemoveEventArgs
|
||||
(
|
||||
[
|
||||
'id' => $this->id,
|
||||
'class_name' => $this->getClassName(),
|
||||
'summit' => $this->summit,
|
||||
'published' => $this->isPublished(),
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @ORM\PostRemove:
|
||||
*/
|
||||
public function deleted($args){
|
||||
|
||||
Event::fire(new SummitEventDeleted($this, $this->pre_remove_events ));
|
||||
$this->pre_remove_events = null;
|
||||
}
|
||||
|
@ -812,4 +816,10 @@ class SummitEvent extends SilverstripeBaseModel
|
|||
$this->rsvp = $rsvp;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getLocationName(){
|
||||
return $this->hasLocation() ? $this->location->getName() : 'TBD';
|
||||
}
|
||||
}
|
|
@ -76,4 +76,15 @@ class SummitGroupEvent extends SummitEvent
|
|||
return $ids;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Group $group
|
||||
*/
|
||||
public function addGroup(Group $group){
|
||||
$this->groups->add($group);
|
||||
}
|
||||
|
||||
public function clearGroups(){
|
||||
$this->groups->clear();
|
||||
}
|
||||
|
||||
}
|
|
@ -21,15 +21,14 @@ namespace models\summit;
|
|||
final class SummitEventFactory
|
||||
{
|
||||
/**
|
||||
* @param Summit $summit
|
||||
* @param SummitEventType $type
|
||||
* @return SummitEvent
|
||||
*/
|
||||
static public function build(Summit $summit, SummitEventType $type)
|
||||
static public function build(SummitEventType $type)
|
||||
{
|
||||
$event = new SummitEvent();
|
||||
|
||||
if(PresentationType::IsPresentationEventType($summit, $type->getType()))
|
||||
if($type instanceof PresentationType)
|
||||
$event = new Presentation();
|
||||
|
||||
if(SummitEventType::isPrivate($type->getType()))
|
||||
|
|
|
@ -142,5 +142,11 @@ class SummitAbstractLocation extends SilverstripeBaseModel
|
|||
*/
|
||||
protected $order;
|
||||
|
||||
|
||||
/**
|
||||
* @return boolean
|
||||
*/
|
||||
public function isOverrideBlackouts()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
|
@ -23,11 +23,11 @@ use utils\PagingResponse;
|
|||
interface IScheduleCalendarSyncInfoRepository extends IBaseRepository
|
||||
{
|
||||
/**
|
||||
* @param SummitEvent $summit_event
|
||||
* @param int $summit_event_id
|
||||
* @param PagingInfo $paging_info
|
||||
* @return PagingResponse
|
||||
*/
|
||||
public function getAllBySummitEvent(SummitEvent $summit_event, PagingInfo $paging_info);
|
||||
public function getAllBySummitEvent($summit_event_id, PagingInfo $paging_info);
|
||||
|
||||
/**
|
||||
* @param SummitAbstractLocation $location
|
||||
|
|
|
@ -41,5 +41,5 @@ interface ISummitEventRepository extends IBaseRepository
|
|||
/**
|
||||
* @param int $event_id
|
||||
*/
|
||||
public function cleanupAttendeesScheduleForEvent($event_id);
|
||||
public function cleanupScheduleAndFavoritesForEvent($event_id);
|
||||
}
|
|
@ -22,6 +22,8 @@ use Illuminate\Support\Facades\Config;
|
|||
use Illuminate\Support\Facades\Event;
|
||||
use LaravelDoctrine\ORM\Facades\Registry;
|
||||
use models\main\AssetsSyncRequest;
|
||||
use models\summit\CalendarSync\WorkQueue\AbstractCalendarSyncWorkRequest;
|
||||
use models\summit\CalendarSync\WorkQueue\AdminSummitEventActionSyncWorkRequest;
|
||||
use models\summit\SummitEntityEvent;
|
||||
use App\Events\MyScheduleAdd;
|
||||
use App\Events\MyScheduleRemove;
|
||||
|
@ -168,15 +170,30 @@ class EventServiceProvider extends ServiceProvider
|
|||
}
|
||||
|
||||
$entity_event->setSummit($event->getSummitEvent()->getSummit());
|
||||
// sync request from admin
|
||||
$request = new AdminSummitEventActionSyncWorkRequest();
|
||||
$request->setSummitEvent($event->getSummitEvent()) ;
|
||||
$request->setType(AbstractCalendarSyncWorkRequest::TypeUpdate);
|
||||
if($owner_id > 0){
|
||||
$member = $member_repository->getById($owner_id);
|
||||
$request->setCreatedBy($member);
|
||||
}
|
||||
|
||||
// check if there was a change on publishing state
|
||||
|
||||
if($args->hasChangedField('published')){
|
||||
$entity_event->setMetadata(json_encode([ 'pub_old'=> intval($args->getOldValue('published')), 'pub_new' => intval($args->getNewValue('published'))]));
|
||||
$pub_old = intval($args->getOldValue('published'));
|
||||
$pub_new = intval($args->getNewValue('published'));
|
||||
$entity_event->setMetadata(json_encode([ 'pub_old'=> $pub_old, 'pub_new' => $pub_new]));
|
||||
if($pub_old == 1 && $pub_new == 0)
|
||||
$request->setType(AbstractCalendarSyncWorkRequest::TypeRemove);
|
||||
}
|
||||
else
|
||||
$entity_event->setMetadata(json_encode([ 'pub_new' => intval($event->getSummitEvent()->getPublished())]));
|
||||
|
||||
$em = Registry::getManager('ss');
|
||||
$em->persist($entity_event);
|
||||
$em->persist($request);
|
||||
$em->flush();
|
||||
});
|
||||
|
||||
|
@ -191,6 +208,7 @@ class EventServiceProvider extends ServiceProvider
|
|||
$owner_id = $resource_server_context->getCurrentUserExternalId();
|
||||
if(is_null($owner_id)) $owner_id = 0;
|
||||
$params = $args->getParams();
|
||||
$em = Registry::getManager('ss');
|
||||
|
||||
$entity_event = new SummitEntityEvent;
|
||||
$entity_event->setEntityClassName($params['class_name']);
|
||||
|
@ -205,7 +223,24 @@ class EventServiceProvider extends ServiceProvider
|
|||
$entity_event->setSummit($params['summit']);
|
||||
$entity_event->setMetadata('');
|
||||
|
||||
$em = Registry::getManager('ss');
|
||||
if(isset($params['published']) && $params['published']){
|
||||
// just record the published state at the moment of the update
|
||||
|
||||
$entity_event->setMetadata( json_encode([
|
||||
'pub_old' => intval($params['published']),
|
||||
'pub_new' => intval($params['published'])
|
||||
]));
|
||||
|
||||
$request = new AdminSummitEventActionSyncWorkRequest();
|
||||
$request->setSummitEventId ($params['id']);
|
||||
$request->setType(AbstractCalendarSyncWorkRequest::TypeRemove);
|
||||
if($owner_id > 0){
|
||||
$member = $member_repository->getById($owner_id);
|
||||
$request->setCreatedBy($member);
|
||||
}
|
||||
$em->persist($request);
|
||||
}
|
||||
|
||||
$em->persist($entity_event);
|
||||
$em->flush();
|
||||
});
|
||||
|
|
|
@ -0,0 +1,34 @@
|
|||
<?php namespace repositories\main;
|
||||
/**
|
||||
* 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 App\Repositories\SilverStripeDoctrineRepository;
|
||||
use models\main\Company;
|
||||
use models\main\ICompanyRepository;
|
||||
|
||||
/**
|
||||
* Class DoctrineCompanyRepository
|
||||
* @package repositories\main
|
||||
*/
|
||||
final class DoctrineCompanyRepository
|
||||
extends SilverStripeDoctrineRepository
|
||||
implements ICompanyRepository
|
||||
{
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
protected function getBaseEntity()
|
||||
{
|
||||
return Company::class;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,34 @@
|
|||
<?php namespace repositories\main;
|
||||
/**
|
||||
* 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 App\Repositories\SilverStripeDoctrineRepository;
|
||||
use models\main\Group;
|
||||
use models\main\IGroupRepository;
|
||||
|
||||
/**
|
||||
* Class DoctrineGroupRepository
|
||||
* @package repositories\main
|
||||
*/
|
||||
final class DoctrineGroupRepository
|
||||
extends SilverStripeDoctrineRepository
|
||||
implements IGroupRepository
|
||||
{
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
protected function getBaseEntity()
|
||||
{
|
||||
return Group::class;
|
||||
}
|
||||
}
|
|
@ -15,7 +15,9 @@ use Illuminate\Support\Facades\App;
|
|||
use Illuminate\Support\ServiceProvider;
|
||||
use LaravelDoctrine\ORM\Facades\EntityManager;
|
||||
use models\main\AssetsSyncRequest;
|
||||
use models\main\Company;
|
||||
use models\main\File;
|
||||
use models\main\Group;
|
||||
|
||||
/**
|
||||
* Class RepositoriesProvider
|
||||
|
@ -196,5 +198,17 @@ final class RepositoriesProvider extends ServiceProvider
|
|||
function(){
|
||||
return EntityManager::getRepository(AssetsSyncRequest::class);
|
||||
});
|
||||
|
||||
App::singleton(
|
||||
'models\main\ICompanyRepository',
|
||||
function(){
|
||||
return EntityManager::getRepository(Company::class);
|
||||
});
|
||||
|
||||
App::singleton(
|
||||
'models\main\IGroupRepository',
|
||||
function(){
|
||||
return EntityManager::getRepository(Group::class);
|
||||
});
|
||||
}
|
||||
}
|
|
@ -34,20 +34,20 @@ final class DoctrineScheduleCalendarSyncInfoRepository
|
|||
{
|
||||
|
||||
/**
|
||||
* @param SummitEvent $summit_event
|
||||
* @param int $summit_event_id
|
||||
* @param PagingInfo $paging_info
|
||||
* @return PagingResponse
|
||||
*/
|
||||
public function getAllBySummitEvent(SummitEvent $summit_event, PagingInfo $paging_info)
|
||||
public function getAllBySummitEvent($summit_event_id, PagingInfo $paging_info)
|
||||
{
|
||||
$query = $this->getEntityManager()
|
||||
->createQueryBuilder()
|
||||
->select("si")
|
||||
->from(ScheduleCalendarSyncInfo::class, "si")
|
||||
->join('si.summit_event', 'e', Join::WITH, " e.id = :event_id")
|
||||
->join('si.calendar_sync_info', 'ci', Join::WITH, " ci.revoked = :credential_status")
|
||||
->where("si.summit_event_id = :event_id")
|
||||
->orderBy('si.id', 'ASC')
|
||||
->setParameter('event_id', $summit_event->getId())
|
||||
->setParameter('event_id', $summit_event_id)
|
||||
->setParameter('credential_status',false);
|
||||
|
||||
$query= $query
|
||||
|
|
|
@ -225,9 +225,12 @@ final class DoctrineSummitEventRepository
|
|||
/**
|
||||
* @param int $event_id
|
||||
*/
|
||||
public function cleanupAttendeesScheduleForEvent($event_id){
|
||||
public function cleanupScheduleAndFavoritesForEvent($event_id){
|
||||
|
||||
$query = "DELETE SummitAttendee_Schedule FROM SummitAttendee_Schedule WHERE SummitEventID = {$event_id};";
|
||||
$query = "DELETE Member_Schedule FROM Member_Schedule WHERE SummitEventID = {$event_id};";
|
||||
$this->_em->getConnection()->executeUpdate($query);
|
||||
|
||||
$query = "DELETE `Member_FavoriteSummitEvents` FROM `Member_FavoriteSummitEvents` WHERE SummitEventID = {$event_id};";
|
||||
$this->_em->getConnection()->executeUpdate($query);
|
||||
}
|
||||
|
||||
|
|
|
@ -103,7 +103,7 @@ final class GoogleCalendarSyncRemoteFacade
|
|||
$sync_info->setExternalId($created_event->getId());
|
||||
$sync_info->setExternalUrl($created_event->getHtmlLink());
|
||||
// relationships
|
||||
$sync_info->setSummitEvent($summit_event);
|
||||
$sync_info->setSummitEventId($summit_event->getId());
|
||||
$sync_info->setCalendarSyncInfo($this->sync_calendar_info);
|
||||
$sync_info->setLocation($summit_event->getLocation());
|
||||
return $sync_info;
|
||||
|
|
|
@ -161,7 +161,7 @@ final class ICloudCalendarSyncRemoteFacade
|
|||
$sync_info->setExternalUrl($res->getResourceUrl());
|
||||
$sync_info->setVCard($vcard);
|
||||
// relationships
|
||||
$sync_info->setSummitEvent($summit_event);
|
||||
$sync_info->setSummitEventId($summit_event->getId());
|
||||
$sync_info->setCalendarSyncInfo($this->sync_calendar_info);
|
||||
$sync_info->setLocation($summit_event->getLocation());
|
||||
|
||||
|
|
|
@ -162,7 +162,7 @@ final class OutlookCalendarSyncRemoteFacade
|
|||
$sync_info->setExternalId($created_event->getId());
|
||||
$sync_info->setExternalUrl($created_event->getDataId());
|
||||
// relationships
|
||||
$sync_info->setSummitEvent($summit_event);
|
||||
$sync_info->setSummitEventId($summit_event->getId());
|
||||
$sync_info->setCalendarSyncInfo($this->sync_calendar_info);
|
||||
$sync_info->setLocation($summit_event->getLocation());
|
||||
return $sync_info;
|
||||
|
|
|
@ -104,11 +104,11 @@ final class AdminActionsCalendarSyncProcessingService
|
|||
|
||||
if($request instanceof AdminSummitEventActionSyncWorkRequest){
|
||||
|
||||
$page = 1;
|
||||
$summit_event = $request->getSummitEvent();
|
||||
$page = 1;
|
||||
$summit_event_id = $request->getSummitEventId();
|
||||
|
||||
do{
|
||||
$page_response = $this->schedule_sync_repository->getAllBySummitEvent($summit_event, new PagingInfo($page, 1000));
|
||||
$page_response = $this->schedule_sync_repository->getAllBySummitEvent($summit_event_id, new PagingInfo($page, 1000));
|
||||
$has_more = count($page_response->getItems()) > 0;
|
||||
if(!$has_more) continue;
|
||||
foreach ($page_response->getItems() as $schedule_event){
|
||||
|
@ -117,7 +117,7 @@ final class AdminActionsCalendarSyncProcessingService
|
|||
$work_request->setType($request->getType());
|
||||
$work_request->setCalendarSyncInfo($schedule_event->getCalendarSyncInfo());
|
||||
$work_request->setOwner($schedule_event->getMember());
|
||||
$work_request->setSummitEvent($summit_event);
|
||||
$work_request->setSummitEventId($summit_event_id);
|
||||
$this->work_request_repository->add($work_request);
|
||||
}
|
||||
$page++;
|
||||
|
@ -140,7 +140,7 @@ final class AdminActionsCalendarSyncProcessingService
|
|||
$work_request->setType(AbstractCalendarSyncWorkRequest::TypeUpdate);
|
||||
$work_request->setCalendarSyncInfo($schedule_event->getCalendarSyncInfo());
|
||||
$work_request->setOwner($schedule_event->getMember());
|
||||
$work_request->setSummitEvent($schedule_event->getSummitEvent());
|
||||
$work_request->setSummitEventId($schedule_event->getSummitEvent()->getId());
|
||||
$this->work_request_repository->add($work_request);
|
||||
}
|
||||
$page++;
|
||||
|
|
|
@ -36,7 +36,7 @@ implements ICalendarSyncWorkRequestQueueManager
|
|||
$event_id = null;
|
||||
$location_id = null;
|
||||
if($request instanceof AdminSummitEventActionSyncWorkRequest){
|
||||
$event_id = $request->getSummitEvent()->getId();
|
||||
$event_id = $request->getSummitEventId();
|
||||
}
|
||||
if($request instanceof AdminSummitLocationActionSyncWorkRequest){
|
||||
$location_id = $request->getLocation()->getId();
|
||||
|
|
|
@ -123,7 +123,10 @@ implements IMemberActionsCalendarSyncProcessingService
|
|||
switch ($request_sub_type) {
|
||||
|
||||
case MemberEventScheduleSummitActionSyncWorkRequest::SubType: {
|
||||
$summit_event = $request->getSummitEvent();
|
||||
|
||||
$summit_event_id = $request->getSummitEventId();
|
||||
$summit_event = $request->getSummitEvent();
|
||||
|
||||
log::info(sprintf
|
||||
(
|
||||
"%s - processing work request %s - sub type %s - type %s - event id %s - member %s - credential id %s -revoked credentials %s",
|
||||
|
@ -131,7 +134,7 @@ implements IMemberActionsCalendarSyncProcessingService
|
|||
$request->getIdentifier(),
|
||||
$request_sub_type,
|
||||
$request_type,
|
||||
$summit_event->getIdentifier(),
|
||||
$summit_event_id,
|
||||
$member->getIdentifier(),
|
||||
$calendar_sync_info->getId(),
|
||||
$calendar_sync_info->isRevoked()? 1:0
|
||||
|
@ -139,24 +142,32 @@ implements IMemberActionsCalendarSyncProcessingService
|
|||
|
||||
switch ($request_type) {
|
||||
case AbstractCalendarSyncWorkRequest::TypeAdd:
|
||||
if ($calendar_sync_info->isRevoked()){
|
||||
Log::warning(sprintf("EVENT ADD : event id %s - member id %s could not be added on external calendar bc credential are revoked!", $summit_event->getId(), $member->getId()));
|
||||
if(is_null($summit_event)){
|
||||
Log::warning(sprintf("EVENT ADD : event id %s does not exists!", $summit_event_id, $member->getId()));
|
||||
continue;
|
||||
}
|
||||
if($member->isEventSynchronized($calendar_sync_info, $summit_event)){
|
||||
Log::warning(sprintf("EVENT ADD : event id %s - member id %s already synchronized", $summit_event->getId(), $member->getId()));
|
||||
if ($calendar_sync_info->isRevoked()){
|
||||
Log::warning(sprintf("EVENT ADD : event id %s - member id %s could not be added on external calendar bc credential are revoked!", $summit_event_id, $member->getId()));
|
||||
continue;
|
||||
}
|
||||
if($member->isEventSynchronized($calendar_sync_info, $summit_event_id)){
|
||||
Log::warning(sprintf("EVENT ADD : event id %s - member id %s already synchronized", $summit_event_id, $member->getId()));
|
||||
continue;
|
||||
}
|
||||
$schedule_sync_info = $remote_facade->addEvent($request);
|
||||
if(is_null($schedule_sync_info)){
|
||||
Log::warning(sprintf("EVENT ADD : event id %s - member id %s could not be added on external calendar", $summit_event->getId(), $member->getId()));
|
||||
Log::warning(sprintf("EVENT ADD : event id %s - member id %s could not be added on external calendar", $summit_event_id, $member->getId()));
|
||||
continue;
|
||||
}
|
||||
$member->add2ScheduleSyncInfo($schedule_sync_info);
|
||||
break;
|
||||
case AbstractCalendarSyncWorkRequest::TypeUpdate:
|
||||
if(is_null($summit_event)){
|
||||
Log::warning(sprintf("EVENT UPDATE : event id %s does not exists!", $summit_event_id, $member->getId()));
|
||||
continue;
|
||||
}
|
||||
if($calendar_sync_info->isRevoked()) continue;
|
||||
$sync_info = $member->getScheduleSyncInfoByEvent($summit_event, $calendar_sync_info);
|
||||
$sync_info = $member->getScheduleSyncInfoByEvent($summit_event_id, $calendar_sync_info);
|
||||
$is_scheduled = $member->isOnSchedule($summit_event);
|
||||
if(is_null($sync_info)) continue;
|
||||
if(!$is_scheduled) {
|
||||
|
@ -167,9 +178,9 @@ implements IMemberActionsCalendarSyncProcessingService
|
|||
break;
|
||||
case AbstractCalendarSyncWorkRequest::TypeRemove:
|
||||
if($calendar_sync_info->isRevoked()) continue;
|
||||
$schedule_sync_info = $member->getScheduleSyncInfoByEvent($summit_event, $calendar_sync_info);
|
||||
$schedule_sync_info = $member->getScheduleSyncInfoByEvent($summit_event_id, $calendar_sync_info);
|
||||
if(is_null($schedule_sync_info)){
|
||||
Log::warning(sprintf("EVENT REMOVE : event id %s - member id %s could not be removed, schedule synch info is null", $summit_event->getId(), $member->getId()));
|
||||
Log::warning(sprintf("EVENT REMOVE : event id %s - member id %s could not be removed, schedule synch info is null", $summit_event_id, $member->getId()));
|
||||
continue;
|
||||
}
|
||||
$remote_facade->deleteEvent($request, $schedule_sync_info);
|
||||
|
|
|
@ -44,7 +44,7 @@ implements ICalendarSyncWorkRequestQueueManager
|
|||
private function getKey(AbstractCalendarSyncWorkRequest $request, $type = null){
|
||||
$event_id = null;
|
||||
if($request instanceof MemberEventScheduleSummitActionSyncWorkRequest){
|
||||
$event_id = $request->getSummitEvent()->getId();
|
||||
$event_id = $request->getSummitEventId();
|
||||
}
|
||||
if(empty($type)) $type = $request->getType();
|
||||
return $this->generateKey($type, $request->getCalendarSyncInfo()->getId(), $event_id);
|
||||
|
|
|
@ -57,8 +57,8 @@ final class AdminSummitEventActionSyncWorkRequestDeleteStrategy
|
|||
public function process(AbstractCalendarSyncWorkRequest $request)
|
||||
{
|
||||
if(!$request instanceof AdminSummitEventActionSyncWorkRequest) return null;
|
||||
$summit_event = $request->getSummitEvent();
|
||||
$pending_requests = $this->queue_manager->getSummitEventRequestFor($summit_event->getId());
|
||||
$summit_event_id = $request->getSummitEventId();
|
||||
$pending_requests = $this->queue_manager->getSummitEventRequestFor($summit_event_id);
|
||||
if(count($pending_requests) > 0 ){
|
||||
// delete all former and pending ...
|
||||
foreach ($pending_requests as $pending_request) {
|
||||
|
|
|
@ -57,8 +57,9 @@ final class AdminSummitEventActionSyncWorkRequestUpdateStrategy
|
|||
public function process(AbstractCalendarSyncWorkRequest $request)
|
||||
{
|
||||
if(!$request instanceof AdminSummitEventActionSyncWorkRequest) return null;
|
||||
$summit_event = $request->getSummitEvent();
|
||||
$pending_requests = $this->queue_manager->getSummitEventRequestFor($summit_event->getId());
|
||||
$summit_event_id = $request->getSummitEventId();
|
||||
$pending_requests = $this->queue_manager->getSummitEventRequestFor($summit_event_id);
|
||||
|
||||
if(count($pending_requests) > 0 ){
|
||||
// delete all former and pending ...
|
||||
foreach ($pending_requests as $pending_request) {
|
||||
|
|
|
@ -58,10 +58,10 @@ implements ICalendarSyncWorkRequestPreProcessorStrategy
|
|||
public function process(AbstractCalendarSyncWorkRequest $request)
|
||||
{
|
||||
if(!$request instanceof MemberEventScheduleSummitActionSyncWorkRequest) return null;
|
||||
$summit_event = $request->getSummitEvent();
|
||||
$summit_event_id = $request->getSummitEventId();
|
||||
$calendar_sync_info = $request->getCalendarSyncInfo();
|
||||
// check if there is a former add, disregard and omit
|
||||
$pending_requests = $this->work_queue_manager->getSummitEventRequestFor($calendar_sync_info->getId(), $summit_event->getId());
|
||||
$pending_requests = $this->work_queue_manager->getSummitEventRequestFor($calendar_sync_info->getId(), $summit_event_id);
|
||||
if(count($pending_requests) > 0 ) {
|
||||
foreach ($pending_requests as $pending_request) {
|
||||
if($request->getType() == AbstractCalendarSyncWorkRequest::TypeUpdate)
|
||||
|
@ -73,7 +73,7 @@ implements ICalendarSyncWorkRequestPreProcessorStrategy
|
|||
$this->work_request_repository->delete($pending_request);
|
||||
}
|
||||
// if the event is not already synchronized disregard add
|
||||
if($request->getOwner()->isEventSynchronized($calendar_sync_info, $summit_event)) {
|
||||
if($request->getOwner()->isEventSynchronized($calendar_sync_info, $summit_event_id)) {
|
||||
$this->work_queue_manager->unRegisterRequestForDelete($request, AbstractCalendarSyncWorkRequest::TypeUpdate);
|
||||
$this->work_request_repository->delete($request);
|
||||
return null;
|
||||
|
|
|
@ -58,10 +58,10 @@ implements ICalendarSyncWorkRequestPreProcessorStrategy
|
|||
public function process(AbstractCalendarSyncWorkRequest $request)
|
||||
{
|
||||
if(!$request instanceof MemberEventScheduleSummitActionSyncWorkRequest) return null;
|
||||
$summit_event = $request->getSummitEvent();
|
||||
$summit_event_id = $request->getSummitEventId();
|
||||
$calendar_sync_info = $request->getCalendarSyncInfo();
|
||||
// check if there is a former add, disregard and omit
|
||||
$pending_requests = $this->queue_manager->getSummitEventRequestFor($calendar_sync_info->getId(), $summit_event->getId());
|
||||
$pending_requests = $this->queue_manager->getSummitEventRequestFor($calendar_sync_info->getId(), $summit_event_id);
|
||||
if(count($pending_requests) > 0 ) {
|
||||
foreach ($pending_requests as $pending_request) {
|
||||
if($request->getType() == AbstractCalendarSyncWorkRequest::TypeUpdate)
|
||||
|
@ -73,7 +73,7 @@ implements ICalendarSyncWorkRequestPreProcessorStrategy
|
|||
$this->work_request_repository->delete($pending_request);
|
||||
}
|
||||
// if the event is not already synchronized disregard delete
|
||||
if(!$request->getOwner()->isEventSynchronized($calendar_sync_info, $summit_event)) {
|
||||
if(!$request->getOwner()->isEventSynchronized($calendar_sync_info, $summit_event_id)) {
|
||||
$this->work_request_repository->delete($request);
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -60,11 +60,11 @@ final class MemberEventScheduleSummitActionSyncWorkRequestUpdateStrategy
|
|||
public function process(AbstractCalendarSyncWorkRequest $request)
|
||||
{
|
||||
if(!$request instanceof MemberEventScheduleSummitActionSyncWorkRequest) return null;
|
||||
$summit_event = $request->getSummitEvent();
|
||||
$summit_event_id = $request->getSummitEventId();
|
||||
$calendar_sync_info = $request->getCalendarSyncInfo();
|
||||
// check if there is a former ones, disregard and omit
|
||||
$pending_requests = $this->queue_manager->getSummitEventRequestFor($calendar_sync_info->getId(), $summit_event->getId());
|
||||
if(count($pending_requests) > 0 || !$request->getOwner()->isEventSynchronized($calendar_sync_info, $summit_event)) {
|
||||
$pending_requests = $this->queue_manager->getSummitEventRequestFor($calendar_sync_info->getId(), $summit_event_id);
|
||||
if(count($pending_requests) > 0 || !$request->getOwner()->isEventSynchronized($calendar_sync_info, $summit_event_id)) {
|
||||
//$this->work_request_repository->delete($request);
|
||||
$this->queue_manager->registerRequestForDelete($request);
|
||||
return null;
|
||||
|
|
|
@ -24,7 +24,9 @@ use Illuminate\Support\Facades\Storage;
|
|||
use models\exceptions\EntityNotFoundException;
|
||||
use models\exceptions\ValidationException;
|
||||
use models\main\File;
|
||||
use models\main\ICompanyRepository;
|
||||
use models\main\IFolderRepository;
|
||||
use models\main\IGroupRepository;
|
||||
use models\main\IMemberRepository;
|
||||
use models\main\ITagRepository;
|
||||
use Models\foundation\summit\EntityEvents\EntityEventTypeFactory;
|
||||
|
@ -41,6 +43,7 @@ use models\summit\ISummitAttendeeRepository;
|
|||
use models\summit\ISummitAttendeeTicketRepository;
|
||||
use models\summit\ISummitEntityEventRepository;
|
||||
use models\summit\ISummitEventRepository;
|
||||
use models\summit\ISummitEventType;
|
||||
use models\summit\Presentation;
|
||||
use models\summit\PresentationType;
|
||||
use models\summit\Summit;
|
||||
|
@ -49,7 +52,9 @@ use models\summit\SummitAttendeeTicket;
|
|||
use models\summit\SummitEvent;
|
||||
use models\summit\SummitEventFactory;
|
||||
use models\summit\SummitEventFeedback;
|
||||
use models\summit\SummitEventType;
|
||||
use models\summit\SummitEventWithFile;
|
||||
use models\summit\SummitGroupEvent;
|
||||
use services\apis\IEventbriteAPI;
|
||||
use libs\utils\ITransactionService;
|
||||
use Exception;
|
||||
|
@ -126,6 +131,17 @@ final class SummitService implements ISummitService
|
|||
*/
|
||||
private $folder_repository;
|
||||
|
||||
/**
|
||||
* @var ICompanyRepository
|
||||
*/
|
||||
private $company_repository;
|
||||
|
||||
|
||||
/**
|
||||
* @var IGroupRepository
|
||||
*/
|
||||
private $group_repository;
|
||||
|
||||
/**
|
||||
* SummitService constructor.
|
||||
* @param ISummitEventRepository $event_repository
|
||||
|
@ -139,6 +155,8 @@ final class SummitService implements ISummitService
|
|||
* @param IAbstractCalendarSyncWorkRequestRepository $calendar_sync_work_request_repository
|
||||
* @param IEventbriteAPI $eventbrite_api
|
||||
* @param IFolderRepository $folder_repository
|
||||
* @param ICompanyRepository $company_repository
|
||||
* @param IGroupRepository $group_repository,
|
||||
* @param ITransactionService $tx_service
|
||||
*/
|
||||
public function __construct
|
||||
|
@ -154,6 +172,8 @@ final class SummitService implements ISummitService
|
|||
IAbstractCalendarSyncWorkRequestRepository $calendar_sync_work_request_repository,
|
||||
IEventbriteAPI $eventbrite_api,
|
||||
IFolderRepository $folder_repository,
|
||||
ICompanyRepository $company_repository,
|
||||
IGroupRepository $group_repository,
|
||||
ITransactionService $tx_service
|
||||
)
|
||||
{
|
||||
|
@ -168,6 +188,8 @@ final class SummitService implements ISummitService
|
|||
$this->calendar_sync_work_request_repository = $calendar_sync_work_request_repository;
|
||||
$this->eventbrite_api = $eventbrite_api;
|
||||
$this->folder_repository = $folder_repository;
|
||||
$this->company_repository = $company_repository;
|
||||
$this->group_repository = $group_repository;
|
||||
$this->tx_service = $tx_service;
|
||||
}
|
||||
|
||||
|
@ -578,7 +600,7 @@ final class SummitService implements ISummitService
|
|||
}
|
||||
|
||||
if (is_null($event_id)) {
|
||||
$event = SummitEventFactory::build($summit, $event_type);
|
||||
$event = SummitEventFactory::build($event_type);
|
||||
} else {
|
||||
$event = $this->event_repository->getById($event_id);
|
||||
if (is_null($event))
|
||||
|
@ -586,14 +608,22 @@ final class SummitService implements ISummitService
|
|||
$event_type = $event->getType();
|
||||
}
|
||||
|
||||
if (isset($data['title']))
|
||||
$event->setTitle(trim($data['title']));
|
||||
// main data
|
||||
|
||||
if (isset($data['description']))
|
||||
$event->setAbstract(trim($data['description']));
|
||||
if (isset($data['title']))
|
||||
$event->setTitle(html_entity_decode(trim($data['title'])));
|
||||
|
||||
if (isset($data['abstract']))
|
||||
$event->setAbstract(html_entity_decode(trim($data['abstract'])));
|
||||
|
||||
if (isset($data['rsvp_link']))
|
||||
$event->setRsvpLink(html_entity_decode(trim($data['rsvp_link'])));
|
||||
|
||||
if (isset($data['head_count']))
|
||||
$event->setHeadCount(intval(data['head_count']));
|
||||
|
||||
if (isset($data['social_summary']))
|
||||
$event->setSocialSummary(trim($data['social_summary']));
|
||||
$event->setSocialSummary(strip_tags(trim($data['social_summary'])));
|
||||
|
||||
if (isset($data['allow_feedback']))
|
||||
$event->setAllowFeedBack($data['allow_feedback']);
|
||||
|
@ -611,11 +641,6 @@ final class SummitService implements ISummitService
|
|||
$event->setCategory($track);
|
||||
}
|
||||
|
||||
// is event is new and we dont provide speakers ...
|
||||
if(is_null($event_id) && !is_null($event_type) && $event_type instanceof PresentationType
|
||||
&& $event_type->isAreSpeakersMandatory() && !isset($data['speakers']))
|
||||
throw new ValidationException('speakers data is required for presentations!');
|
||||
|
||||
$event->setSummit($summit);
|
||||
|
||||
if (!is_null($location))
|
||||
|
@ -632,25 +657,32 @@ final class SummitService implements ISummitService
|
|||
}
|
||||
}
|
||||
|
||||
if (isset($data['speakers']) && !is_null($event_type) && $event_type->isPresentationType()) {
|
||||
$event->clearSpeakers();
|
||||
foreach ($data['speakers'] as $speaker_id) {
|
||||
$speaker = $this->speaker_repository->getById(intval($speaker_id));
|
||||
if(is_null($speaker)) throw new EntityNotFoundException(sprintf('speaker id %s', $speaker_id));
|
||||
$event->addSpeaker($speaker);
|
||||
// sponsors
|
||||
|
||||
$sponsors = ($event_type->isUseSponsors() && isset($data['sponsors'])) ?
|
||||
$data['sponsors'] : [];
|
||||
|
||||
if($event_type->isAreSponsorsMandatory() && count($sponsors) == 0){
|
||||
throw new ValidationException('sponsors are mandatory!');
|
||||
}
|
||||
|
||||
if (count($sponsors) > 0) {
|
||||
$event->clearSponsors();
|
||||
foreach ($sponsors as $sponsor_id) {
|
||||
$sponsor = $this->company_repository->getById(intval($sponsor_id));
|
||||
if(is_null($sponsor)) throw new EntityNotFoundException(sprintf('sponsor id %s', $sponsor_id));
|
||||
$event->addSponsor($sponsor);
|
||||
}
|
||||
}
|
||||
|
||||
if(isset($data['moderator_speaker_id']) && !is_null($event_type)
|
||||
&& $event_type instanceof PresentationType && $event instanceof Presentation){
|
||||
$speaker_id = intval($data['moderator_speaker_id']);
|
||||
if($speaker_id === 0) $event->unsetModerator();
|
||||
else
|
||||
{
|
||||
$moderator = $this->speaker_repository->getById($speaker_id);
|
||||
if (is_null($moderator)) throw new EntityNotFoundException(sprintf('speaker id %s', $speaker_id));
|
||||
$event->setModerator($speaker);
|
||||
}
|
||||
$this->saveOrUpdatePresentationData($event, $event_type, $data);
|
||||
$this->saveOrUpdateSummitGroupEventData($event, $event_type, $data);
|
||||
|
||||
if($event->isPublished())
|
||||
{
|
||||
$this->validateBlackOutTimesAndTimes($event);
|
||||
$event->unPublish();
|
||||
$event->publish();
|
||||
}
|
||||
|
||||
$this->event_repository->add($event);
|
||||
|
@ -659,6 +691,77 @@ final class SummitService implements ISummitService
|
|||
});
|
||||
}
|
||||
|
||||
private function saveOrUpdateSummitGroupEventData(SummitEvent $event, SummitEventType $event_type, array $data ){
|
||||
if(!$event instanceof SummitGroupEvent) return;
|
||||
|
||||
if(!isset($data['groups']) || count($data['groups']) == 0)
|
||||
throw new ValidationException('groups is required');
|
||||
$event->clearGroups();
|
||||
|
||||
foreach ($data['groups'] as $group_id) {
|
||||
$group = $this->group_repository->getById(intval($group_id));
|
||||
if(is_null($group)) throw new EntityNotFoundException(sprintf('group id %s', $group_id));
|
||||
$event->addGroup($group);
|
||||
}
|
||||
}
|
||||
|
||||
private function saveOrUpdatePresentationData(SummitEvent $event, SummitEventType $event_type, array $data ){
|
||||
if(!$event instanceof Presentation) return;
|
||||
|
||||
// main data
|
||||
if(isset($data['expect_learn']))
|
||||
$event->setAttendeesExpectedLearnt(html_entity_decode($data['expect_learn']));
|
||||
if(isset($data['level']))
|
||||
$event->setLevel($data['level']);
|
||||
|
||||
// if we are creating the presentation from admin, then
|
||||
// we should mark it as received and complete
|
||||
$event->setStatus(Presentation::STATUS_RECEIVED);
|
||||
$event->setProgress(Presentation::PHASE_COMPLETE);
|
||||
|
||||
$event->setToRecord(isset($data['to_record'])? $data['to_record'] : 0);
|
||||
|
||||
// speakers
|
||||
|
||||
if($event_type instanceof PresentationType && $event_type->isUseSponsors()) {
|
||||
$speakers = isset($data['speakers']) ?
|
||||
$data['speakers'] : [];
|
||||
|
||||
if ($event_type->isAreSpeakersMandatory() && count($speakers) == 0) {
|
||||
throw new ValidationException('speakers are mandatory!');
|
||||
}
|
||||
|
||||
if (count($speakers) > 0 && $event instanceof Presentation) {
|
||||
$event->clearSpeakers();
|
||||
foreach ($speakers as $speaker_id) {
|
||||
$speaker = $this->speaker_repository->getById(intval($speaker_id));
|
||||
if (is_null($speaker)) throw new EntityNotFoundException(sprintf('speaker id %s', $speaker_id));
|
||||
$event->addSpeaker($speaker);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// moderator
|
||||
|
||||
if($event_type instanceof PresentationType && $event_type->isUseModerator()) {
|
||||
$moderator_id = isset($data['moderator_speaker_id']) ? intval($data['moderator_speaker_id']) : 0;
|
||||
|
||||
if ($event_type->isModeratorMandatory() && $moderator_id == 0) {
|
||||
throw new ValidationException('moderator_speaker_id is mandatory!');
|
||||
}
|
||||
|
||||
if ($moderator_id > 0) {
|
||||
$speaker_id = intval($data['moderator_speaker_id']);
|
||||
if ($speaker_id === 0) $event->unsetModerator();
|
||||
else {
|
||||
$moderator = $this->speaker_repository->getById($speaker_id);
|
||||
if (is_null($moderator)) throw new EntityNotFoundException(sprintf('speaker id %s', $speaker_id));
|
||||
$event->setModerator($speaker);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
/**
|
||||
* @param Summit $summit
|
||||
* @param int $event_id
|
||||
|
@ -702,57 +805,7 @@ final class SummitService implements ISummitService
|
|||
$event->setLocation($location);
|
||||
}
|
||||
|
||||
$current_event_location = $event->getLocation();
|
||||
|
||||
// validate blackout times
|
||||
$conflict_events = $this->event_repository->getPublishedOnSameTimeFrame($event);
|
||||
if (!is_null($conflict_events)) {
|
||||
foreach ($conflict_events as $c_event) {
|
||||
// if the published event is BlackoutTime or if there is a BlackoutTime event in this timeframe
|
||||
if (($event->getType()->isBlackoutTimes() || $c_event->getType()->isBlackoutTimes()) && $event->getId() != $c_event->getId()) {
|
||||
throw new ValidationException
|
||||
(
|
||||
sprintf
|
||||
(
|
||||
"You can't publish on this time frame, it conflicts with event id %s",
|
||||
$c_event->getId()
|
||||
)
|
||||
);
|
||||
}
|
||||
// if trying to publish an event on a slot occupied by another event
|
||||
if (!is_null($current_event_location) && !is_null($c_event->getLocation()) && $current_event_location->getId() == $c_event->getLocation()->getId() && $event->getId() != $c_event->getId()) {
|
||||
throw new ValidationException
|
||||
(
|
||||
sprintf
|
||||
(
|
||||
"You can't publish on this time frame, it conflicts with event id %s",
|
||||
$c_event->getId()
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
// check speakers collisions
|
||||
if ($event->getClassName() == 'Presentation' && $c_event->getClassName() == 'Presentation' && $event->getId() != $c_event->getId()) {
|
||||
foreach ($event->getSpeakers() as $current_speaker) {
|
||||
foreach ($c_event->getSpeakers() as $c_speaker) {
|
||||
if (intval($c_speaker->getId()) === intval($current_speaker->getId())) {
|
||||
throw new ValidationException
|
||||
(
|
||||
sprintf
|
||||
(
|
||||
'speaker id % belongs already to another event ( %s) on that time frame',
|
||||
$c_speaker->getId(),
|
||||
$c_event->getId()
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
$this->validateBlackOutTimesAndTimes($event);
|
||||
$event->unPublish();
|
||||
$event->publish();
|
||||
|
||||
|
@ -761,6 +814,60 @@ final class SummitService implements ISummitService
|
|||
});
|
||||
}
|
||||
|
||||
private function validateBlackOutTimesAndTimes(SummitEvent $event){
|
||||
$current_event_location = $event->getLocation();
|
||||
|
||||
// validate blackout times
|
||||
$conflict_events = $this->event_repository->getPublishedOnSameTimeFrame($event);
|
||||
if (!is_null($conflict_events)) {
|
||||
foreach ($conflict_events as $c_event) {
|
||||
// if the published event is BlackoutTime or if there is a BlackoutTime event in this timeframe
|
||||
if ((!is_null($current_event_location) && !$current_event_location->isOverrideBlackouts()) && ($event->getType()->isBlackoutTimes() || $c_event->getType()->isBlackoutTimes()) && $event->getId() != $c_event->getId()) {
|
||||
throw new ValidationException
|
||||
(
|
||||
sprintf
|
||||
(
|
||||
"You can't publish on this time frame, it conflicts with event id %s",
|
||||
$c_event->getId()
|
||||
)
|
||||
);
|
||||
}
|
||||
// if trying to publish an event on a slot occupied by another event
|
||||
if (!is_null($current_event_location) && !is_null($c_event->getLocation()) && $current_event_location->getId() == $c_event->getLocation()->getId() && $event->getId() != $c_event->getId()) {
|
||||
throw new ValidationException
|
||||
(
|
||||
sprintf
|
||||
(
|
||||
"You can't publish on this time frame, it conflicts with event id %s",
|
||||
$c_event->getId()
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
// check speakers collisions
|
||||
if ($event instanceof Presentation && $c_event instanceof Presentation && $event->getId() != $c_event->getId()) {
|
||||
foreach ($event->getSpeakers() as $current_speaker) {
|
||||
foreach ($c_event->getSpeakers() as $c_speaker) {
|
||||
if (intval($c_speaker->getId()) === intval($current_speaker->getId())) {
|
||||
throw new ValidationException
|
||||
(
|
||||
sprintf
|
||||
(
|
||||
"You can't publish Event %s (%s) on this timeframe, speaker %s its presention in room %s at this time.",
|
||||
$event->getTitle(),
|
||||
$event->getId(),
|
||||
$current_speaker->getFullName(),
|
||||
$c_event->getLocationName()
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* @param Summit $summit
|
||||
* @param int $event_id
|
||||
|
@ -781,7 +888,7 @@ final class SummitService implements ISummitService
|
|||
|
||||
$event->unPublish();
|
||||
$this->event_repository->add($event);
|
||||
$this->event_repository->cleanupAttendeesScheduleForEvent($event_id);
|
||||
$this->event_repository->cleanupScheduleAndFavoritesForEvent($event_id);
|
||||
return $event;
|
||||
});
|
||||
}
|
||||
|
@ -806,7 +913,8 @@ final class SummitService implements ISummitService
|
|||
|
||||
$this->event_repository->delete($event);
|
||||
// clean up summit attendees schedule
|
||||
$this->event_repository->cleanupAttendeesScheduleForEvent($event_id);
|
||||
$this->event_repository->cleanupScheduleAndFavoritesForEvent($event_id);
|
||||
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
|
|
@ -1099,13 +1099,13 @@ final class OAuth2SummitApiTest extends ProtectedApiTest
|
|||
unset($event->tags);*/
|
||||
$params = array
|
||||
(
|
||||
'id' => 6,
|
||||
'event_id' => 15303,
|
||||
'id' => 23,
|
||||
'event_id' => 20619,
|
||||
);
|
||||
|
||||
$data = array
|
||||
(
|
||||
'tags' => ['keystone'],
|
||||
'title' => 'OpenStack Public Cloud Update TEST!',
|
||||
);
|
||||
|
||||
|
||||
|
@ -1137,7 +1137,7 @@ final class OAuth2SummitApiTest extends ProtectedApiTest
|
|||
|
||||
public function testPublishEvent($start_date = 1509789600, $end_date = 1509791400)
|
||||
{
|
||||
$event = $this->testPostEvent($summit_id = 23,$location_id = 0, $type_id = 124, $track_id = 206, $start_date, $end_date);
|
||||
$event = $this->testPostEvent($summit_id = 23, $location_id = 0, $type_id = 124, $track_id = 206, $start_date, $end_date);
|
||||
unset($event->tags);
|
||||
|
||||
$params = array
|
||||
|
@ -1202,14 +1202,14 @@ final class OAuth2SummitApiTest extends ProtectedApiTest
|
|||
return $event;
|
||||
}
|
||||
|
||||
public function testDeleteEvent()
|
||||
public function testDeleteEvent($summit_id = 23)
|
||||
{
|
||||
$event = $this->testPostEvent();
|
||||
//$event = $this->testPublishEvent();
|
||||
|
||||
$params = array
|
||||
(
|
||||
'id' => 6,
|
||||
'event_id' => $event->getId(),
|
||||
'id' => $summit_id,
|
||||
'event_id' => 20617,
|
||||
);
|
||||
|
||||
$headers = array
|
||||
|
@ -1231,7 +1231,7 @@ final class OAuth2SummitApiTest extends ProtectedApiTest
|
|||
|
||||
$this->assertResponseStatus(204);
|
||||
|
||||
return $event;
|
||||
//return $event;
|
||||
}
|
||||
|
||||
public function testAddFeedback2Event()
|
||||
|
|
Loading…
Reference in New Issue