External Calendar Sync
Allows to synchronize member summit schedule with an enternal calendar provider: * Outlook * iCloud * Google the solution is composed of 2 services * member actions processor ( process actions like: create calendar, add event, remove event, remove calendar) * admin actions processsor ( process actions like: update event, delete event, update location, delete location) Change-Id: Ib8681bd2ea3b66b114fb676b4fa25fc15c65b46c
This commit is contained in:
parent
32c377a0c2
commit
8e67f5ae90
@ -55,4 +55,10 @@ LOG_EMAIL_TO=smarcet@gmail.com
|
||||
LOG_EMAIL_FROM=smarcet@gmail.com
|
||||
LOG_LEVEL=info
|
||||
|
||||
EVENTBRITE_OAUTH2_PERSONAL_TOKEN=
|
||||
EVENTBRITE_OAUTH2_PERSONAL_TOKEN=
|
||||
SS_ENCRYPT_KEY=
|
||||
SS_ENCRYPT_CYPHER=AES-256-CBC
|
||||
|
||||
GOOGLE_CLIENT_ID=""
|
||||
GOOGLE_CLIENT_SECRET=""
|
||||
GOOGLE_SCOPES=""
|
||||
|
21
Libs/Utils/IEncryptionService.php
Normal file
21
Libs/Utils/IEncryptionService.php
Normal file
@ -0,0 +1,21 @@
|
||||
<?php namespace libs\utils;
|
||||
|
||||
/**
|
||||
* 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.
|
||||
**/
|
||||
|
||||
interface IEncryptionService
|
||||
{
|
||||
public function encrypt($value);
|
||||
|
||||
public function decrypt($payload);
|
||||
}
|
@ -0,0 +1,77 @@
|
||||
<?php namespace App\Console\Commands;
|
||||
/**
|
||||
* 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 Illuminate\Console\Command;
|
||||
use App\Services\Model\IAdminActionsCalendarSyncProcessingService;
|
||||
|
||||
/**
|
||||
* Class AdminActionsCalendarSyncProcessingCommand
|
||||
* @package App\Console\Commands
|
||||
*/
|
||||
final class AdminActionsCalendarSyncProcessingCommand extends Command
|
||||
{
|
||||
/**
|
||||
* @var IAdminActionsCalendarSyncProcessingService
|
||||
*/
|
||||
private $service;
|
||||
|
||||
/**
|
||||
* MemberActionsCalendarSyncProcessingCommand constructor.
|
||||
* @param IAdminActionsCalendarSyncProcessingService $service
|
||||
*/
|
||||
public function __construct(IAdminActionsCalendarSyncProcessingService $service)
|
||||
{
|
||||
parent::__construct();
|
||||
$this->service = $service;
|
||||
}
|
||||
|
||||
/**
|
||||
* The console command name.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $name = 'summit:admin-schedule-action-process';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Process Admin External Schedule Sync Actions';
|
||||
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'summit:admin-schedule-action-process {batch_size?}';
|
||||
|
||||
public function handle()
|
||||
{
|
||||
$batch_size = $this->argument('batch_size');
|
||||
if(empty($batch_size))
|
||||
$batch_size = PHP_INT_MAX;
|
||||
|
||||
$start = time();
|
||||
|
||||
$this->info(sprintf("processing batch size of %s", $batch_size));
|
||||
|
||||
|
||||
$res = $this->service->processActions($batch_size);
|
||||
|
||||
$end = time();
|
||||
$delta = $end - $start;
|
||||
$this->info(sprintf("execution call %s seconds - processed entries %s", $delta, $res));
|
||||
|
||||
}
|
||||
}
|
@ -1,33 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Foundation\Inspiring;
|
||||
|
||||
class Inspire extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'inspire';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Display an inspiring quote';
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$this->comment(PHP_EOL.Inspiring::quote().PHP_EOL);
|
||||
}
|
||||
}
|
@ -0,0 +1,83 @@
|
||||
<?php namespace App\Console\Commands;
|
||||
/**
|
||||
* 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 Illuminate\Console\Command;
|
||||
use App\Services\Model\IMemberActionsCalendarSyncProcessingService;
|
||||
use models\summit\CalendarSync\CalendarSyncInfo;
|
||||
|
||||
/**
|
||||
* Class MemberActionsCalendarSyncProcessingCommand
|
||||
* @package App\Console\Commands
|
||||
*/
|
||||
final class MemberActionsCalendarSyncProcessingCommand extends Command
|
||||
{
|
||||
/**
|
||||
* @var IMemberActionsCalendarSyncProcessingService
|
||||
*/
|
||||
private $service;
|
||||
|
||||
/**
|
||||
* MemberActionsCalendarSyncProcessingCommand constructor.
|
||||
* @param IMemberActionsCalendarSyncProcessingService $service
|
||||
*/
|
||||
public function __construct(IMemberActionsCalendarSyncProcessingService $service)
|
||||
{
|
||||
parent::__construct();
|
||||
$this->service = $service;
|
||||
}
|
||||
|
||||
/**
|
||||
* The console command name.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $name = 'summit:member-schedule-action-process';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Process Member External Schedule Sync Actions';
|
||||
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'summit:member-schedule-action-process {provider} {batch_size?}';
|
||||
|
||||
public function handle()
|
||||
{
|
||||
$batch_size = $this->argument('batch_size');
|
||||
$provider = $this->argument('provider');
|
||||
if(!CalendarSyncInfo::isValidProvider($provider)){
|
||||
$this->error("provider param is not valid , valid values are [Google, Outlook, iCloud]");
|
||||
return false;
|
||||
}
|
||||
if(empty($batch_size))
|
||||
$batch_size = 1000;
|
||||
|
||||
$start = time();
|
||||
|
||||
$this->info(sprintf("processing provider %s - batch size of %s", $provider, $batch_size));
|
||||
|
||||
|
||||
$res = $this->service->processActions($provider, $batch_size);
|
||||
|
||||
$end = time();
|
||||
$delta = $end - $start;
|
||||
$this->info(sprintf("execution call %s seconds - processed entries %s", $delta, $res));
|
||||
}
|
||||
}
|
@ -4,6 +4,7 @@ namespace App\Console;
|
||||
|
||||
use Illuminate\Console\Scheduling\Schedule;
|
||||
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
|
||||
use models\summit\CalendarSync\CalendarSyncInfo;
|
||||
|
||||
class Kernel extends ConsoleKernel
|
||||
{
|
||||
@ -14,6 +15,8 @@ class Kernel extends ConsoleKernel
|
||||
*/
|
||||
protected $commands = [
|
||||
\App\Console\Commands\SummitJsonGenerator::class,
|
||||
\App\Console\Commands\MemberActionsCalendarSyncProcessingCommand::class,
|
||||
\App\Console\Commands\AdminActionsCalendarSyncProcessingCommand::class,
|
||||
\App\Console\Commands\ChatTeamMessagesSender::class,
|
||||
];
|
||||
|
||||
@ -28,12 +31,23 @@ class Kernel extends ConsoleKernel
|
||||
//Current
|
||||
$schedule->command('summit:json-generator')->everyTenMinutes()->withoutOverlapping();
|
||||
//Austin
|
||||
$schedule->command('summit:json-generator 6')->everyTenMinutes()->withoutOverlapping();
|
||||
$schedule->command('summit:json-generator',[6])->everyTenMinutes()->withoutOverlapping();
|
||||
//BCN
|
||||
$schedule->command('summit:json-generator 7')->everyTenMinutes()->withoutOverlapping();
|
||||
$schedule->command('summit:json-generator', [7])->everyTenMinutes()->withoutOverlapping();
|
||||
//Boston
|
||||
$schedule->command('summit:json-generator 22')->everyTenMinutes()->withoutOverlapping();
|
||||
// teams messages
|
||||
$schedule->command('teams:message-sender 100')->everyMinute()->withoutOverlapping();
|
||||
$schedule->command('summit:json-generator', [22])->everyTenMinutes()->withoutOverlapping();
|
||||
|
||||
// Calendar Sync Jobs
|
||||
|
||||
// Admin Actions
|
||||
$schedule->command('summit:admin-schedule-action-process')->withoutOverlapping();
|
||||
// Member Actions
|
||||
// Google Calendar
|
||||
$schedule->command('summit:member-schedule-action-process', [CalendarSyncInfo::ProviderGoogle, 1000])->withoutOverlapping();
|
||||
// Outlook
|
||||
$schedule->command('summit:member-schedule-action-process', [CalendarSyncInfo::ProviderOutlook, 1000])->withoutOverlapping();
|
||||
// iCloud
|
||||
$schedule->command('summit:member-schedule-action-process', [CalendarSyncInfo::ProvideriCloud, 1000])->withoutOverlapping();
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -91,7 +91,6 @@ final class OwnMemberSerializer extends AbstractMemberSerializer
|
||||
$values['favorite_summit_events'] = $res;
|
||||
}
|
||||
|
||||
|
||||
if(in_array('schedule_summit_events', $relations) && !is_null($summit)){
|
||||
$schedule = [];
|
||||
|
||||
|
@ -36,7 +36,7 @@ class SummitEventSerializer extends SilverStripeSerializer
|
||||
'Published' => 'is_published:json_boolean',
|
||||
'HeadCount' => 'head_count:json_int',
|
||||
'RSVPLink' => 'rsvp_link:json_string',
|
||||
'IssExternalRSVP' => 'rsvp_external:json_boolean',
|
||||
'IsExternalRSVP' => 'rsvp_external:json_boolean',
|
||||
'CategoryId' => 'track_id:json_int',
|
||||
);
|
||||
|
||||
|
@ -42,7 +42,7 @@ class Affiliation extends SilverstripeBaseModel
|
||||
private $is_current;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity="models\main\Member")
|
||||
* @ORM\ManyToOne(targetEntity="models\main\Member", inversedBy="affiliations")
|
||||
* @ORM\JoinColumn(name="MemberID", referencedColumnName="ID")
|
||||
* @var Member
|
||||
*/
|
||||
|
@ -195,7 +195,7 @@ class ChatTeamInvitation extends SilverstripeBaseModel
|
||||
}
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity="models\main\ChatTeam")
|
||||
* @ORM\ManyToOne(targetEntity="models\main\ChatTeam", inversedBy="invitations")
|
||||
* @ORM\JoinColumn(name="TeamID", referencedColumnName="ID")
|
||||
* @var ChatTeam
|
||||
*/
|
||||
|
@ -123,14 +123,14 @@ class ChatTeamMember
|
||||
}
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity="models\main\Member")
|
||||
* @ORM\ManyToOne(targetEntity="models\main\Member", inversedBy="team_memberships")
|
||||
* @ORM\JoinColumn(name="MemberID", referencedColumnName="ID")
|
||||
* @var Member
|
||||
*/
|
||||
private $member;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity="models\main\ChatTeam")
|
||||
* @ORM\ManyToOne(targetEntity="models\main\ChatTeam", inversedBy="members")
|
||||
* @ORM\JoinColumn(name="ChatTeamID", referencedColumnName="ID")
|
||||
* @var ChatTeam
|
||||
*/
|
||||
|
@ -51,7 +51,7 @@ class ChatTeamPushNotificationMessage extends PushNotificationMessage
|
||||
$this->team = $team;
|
||||
}
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity="models\main\ChatTeam")
|
||||
* @ORM\ManyToOne(targetEntity="models\main\ChatTeam", inversedBy="messages")
|
||||
* @ORM\JoinColumn(name="ChatTeamID", referencedColumnName="ID")
|
||||
* @var ChatTeam
|
||||
*/
|
||||
|
@ -19,6 +19,8 @@ use Doctrine\ORM\NonUniqueResultException;
|
||||
use Doctrine\ORM\NoResultException;
|
||||
use Doctrine\ORM\Query\ResultSetMappingBuilder;
|
||||
use models\exceptions\ValidationException;
|
||||
use models\summit\CalendarSync\CalendarSyncInfo;
|
||||
use models\summit\CalendarSync\ScheduleCalendarSyncInfo;
|
||||
use models\summit\RSVP;
|
||||
use models\summit\Summit;
|
||||
use models\summit\SummitEvent;
|
||||
@ -35,20 +37,114 @@ use Doctrine\ORM\Mapping AS ORM;
|
||||
*/
|
||||
class Member extends SilverstripeBaseModel
|
||||
{
|
||||
|
||||
/**
|
||||
* Member constructor.
|
||||
* @ORM\Column(name="FirstName", type="string")
|
||||
* @var string
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->feedback = new ArrayCollection();
|
||||
$this->groups = new ArrayCollection();
|
||||
$this->affiliations = new ArrayCollection();
|
||||
$this->team_memberships = new ArrayCollection();
|
||||
$this->favorites = new ArrayCollection();
|
||||
$this->schedule = new ArrayCollection();
|
||||
$this->rsvp = new ArrayCollection();
|
||||
}
|
||||
private $first_name;
|
||||
|
||||
/**
|
||||
* @ORM\Column(name="Bio", type="string")
|
||||
* @var string
|
||||
*/
|
||||
private $bio;
|
||||
|
||||
/**
|
||||
* @ORM\Column(name="Surname", type="string")
|
||||
* @var string
|
||||
*/
|
||||
private $last_name;
|
||||
|
||||
/**
|
||||
* @ORM\OneToMany(targetEntity="models\summit\SummitEventFeedback", mappedBy="owner", cascade={"persist"})
|
||||
* @var SummitEventFeedback[]
|
||||
*/
|
||||
private $feedback;
|
||||
|
||||
/**
|
||||
* @ORM\OneToMany(targetEntity="Affiliation", mappedBy="owner", cascade={"persist"})
|
||||
*/
|
||||
private $affiliations;
|
||||
|
||||
/**
|
||||
* @ORM\Column(name="Active", type="boolean")
|
||||
* @var bool
|
||||
*/
|
||||
private $active;
|
||||
|
||||
/**
|
||||
* @ORM\Column(name="LinkedInProfile", type="string")
|
||||
* @var string
|
||||
*/
|
||||
private $linked_in_profile;
|
||||
|
||||
/**
|
||||
* @ORM\Column(name="IRCHandle", type="string")
|
||||
* @var string
|
||||
*/
|
||||
private $irc_handle;
|
||||
|
||||
/**
|
||||
* @ORM\Column(name="TwitterName", type="string")
|
||||
* @var string
|
||||
*/
|
||||
private $twitter_handle;
|
||||
|
||||
/**
|
||||
* @ORM\Column(name="Gender", type="string")
|
||||
* @var string
|
||||
*/
|
||||
private $gender;
|
||||
|
||||
/**
|
||||
* @ORM\Column(name="Country", type="string")
|
||||
* @var string
|
||||
*/
|
||||
private $country;
|
||||
|
||||
/**
|
||||
* @ORM\Column(name="Email", type="string")
|
||||
* @var string
|
||||
*/
|
||||
private $email;
|
||||
|
||||
/**
|
||||
* @ORM\Column(name="SecondEmail", type="string")
|
||||
* @var string
|
||||
*/
|
||||
private $second_email;
|
||||
|
||||
/**
|
||||
* @ORM\Column(name="ThirdEmail", type="string")
|
||||
* @var string
|
||||
*/
|
||||
private $third_email;
|
||||
|
||||
/**
|
||||
* @ORM\Column(name="EmailVerified", type="boolean")
|
||||
* @var bool
|
||||
*/
|
||||
private $email_verified;
|
||||
|
||||
/**
|
||||
* @ORM\Column(name="EmailVerifiedDate", type="datetime")
|
||||
* @var \DateTime
|
||||
*/
|
||||
private $email_verified_date;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity="models\main\File")
|
||||
* @ORM\JoinColumn(name="PhotoID", referencedColumnName="ID")
|
||||
* @var File
|
||||
*/
|
||||
private $photo;
|
||||
|
||||
/**
|
||||
* @ORM\Column(name="State", type="string")
|
||||
* @var string
|
||||
*/
|
||||
private $state;
|
||||
|
||||
/**
|
||||
* @ORM\OneToMany(targetEntity="SummitMemberSchedule", mappedBy="member", cascade={"persist"}, orphanRemoval=true)
|
||||
@ -56,11 +152,62 @@ class Member extends SilverstripeBaseModel
|
||||
*/
|
||||
private $schedule;
|
||||
|
||||
/**
|
||||
* @ORM\OneToMany(targetEntity="models\summit\CalendarSync\ScheduleCalendarSyncInfo", mappedBy="member", cascade={"persist"}, orphanRemoval=true)
|
||||
* @var ScheduleCalendarSyncInfo[]
|
||||
*/
|
||||
private $schedule_sync_info;
|
||||
|
||||
/**
|
||||
* @ORM\OneToMany(targetEntity="models\summit\CalendarSync\CalendarSyncInfo", mappedBy="owner", cascade={"persist"}, orphanRemoval=true)
|
||||
* @var CalendarSyncInfo[]
|
||||
*/
|
||||
private $calendars_sync;
|
||||
|
||||
/**
|
||||
* @ORM\OneToMany(targetEntity="models\summit\RSVP", mappedBy="owner", cascade={"persist"})
|
||||
* @var RSVP[]
|
||||
*/
|
||||
protected $rsvp;
|
||||
private $rsvp;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToMany(targetEntity="models\main\Group", inversedBy="members")
|
||||
* @ORM\JoinTable(name="Group_Members",
|
||||
* joinColumns={@ORM\JoinColumn(name="MemberID", referencedColumnName="ID")},
|
||||
* inverseJoinColumns={@ORM\JoinColumn(name="GroupID", referencedColumnName="ID")}
|
||||
* )
|
||||
* @var Group[]
|
||||
*/
|
||||
private $groups;
|
||||
|
||||
/**
|
||||
* @ORM\OneToMany(targetEntity="ChatTeamMember", mappedBy="member", cascade={"persist"}, orphanRemoval=true)
|
||||
* @var ChatTeamMember[]
|
||||
*/
|
||||
private $team_memberships;
|
||||
|
||||
/**
|
||||
* @ORM\OneToMany(targetEntity="SummitMemberFavorite", mappedBy="member", cascade={"persist"}, orphanRemoval=true)
|
||||
* @var SummitMemberFavorite[]
|
||||
*/
|
||||
private $favorites;
|
||||
|
||||
/**
|
||||
* Member constructor.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->feedback = new ArrayCollection();
|
||||
$this->groups = new ArrayCollection();
|
||||
$this->affiliations = new ArrayCollection();
|
||||
$this->team_memberships = new ArrayCollection();
|
||||
$this->favorites = new ArrayCollection();
|
||||
$this->schedule = new ArrayCollection();
|
||||
$this->rsvp = new ArrayCollection();
|
||||
$this->calendars_sync = new ArrayCollection();
|
||||
$this->schedule_sync_info = new ArrayCollection();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Affiliation[]
|
||||
@ -130,23 +277,6 @@ class Member extends SilverstripeBaseModel
|
||||
$this->groups = $groups;
|
||||
}
|
||||
|
||||
/**
|
||||
* @ORM\ManyToMany(targetEntity="models\main\Group", inversedBy="members")
|
||||
* @ORM\JoinTable(name="Group_Members",
|
||||
* joinColumns={@ORM\JoinColumn(name="MemberID", referencedColumnName="ID")},
|
||||
* inverseJoinColumns={@ORM\JoinColumn(name="GroupID", referencedColumnName="ID")}
|
||||
* )
|
||||
* @var Group[]
|
||||
*/
|
||||
private $groups;
|
||||
|
||||
|
||||
/**
|
||||
* @ORM\OneToMany(targetEntity="ChatTeamMember", mappedBy="member", cascade={"persist"}, orphanRemoval=true)
|
||||
* @var ChatTeamMember[]
|
||||
*/
|
||||
private $team_memberships;
|
||||
|
||||
/**
|
||||
* @return SummitEvent[]
|
||||
*/
|
||||
@ -155,7 +285,6 @@ class Member extends SilverstripeBaseModel
|
||||
return $this->favorites;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param SummitMemberFavorite[] $favorites
|
||||
*/
|
||||
@ -164,12 +293,6 @@ class Member extends SilverstripeBaseModel
|
||||
$this->favorites = $favorites;
|
||||
}
|
||||
|
||||
/**
|
||||
* @ORM\OneToMany(targetEntity="SummitMemberFavorite", mappedBy="member", cascade={"persist"}, orphanRemoval=true)
|
||||
* @var SummitMemberFavorite[]
|
||||
*/
|
||||
private $favorites;
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
@ -202,31 +325,6 @@ class Member extends SilverstripeBaseModel
|
||||
return $this->twitter_handle;
|
||||
}
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity="models\main\File")
|
||||
* @ORM\JoinColumn(name="PhotoID", referencedColumnName="ID")
|
||||
* @var File
|
||||
*/
|
||||
private $photo;
|
||||
|
||||
/**
|
||||
* @ORM\Column(name="FirstName", type="string")
|
||||
* @var string
|
||||
*/
|
||||
private $first_name;
|
||||
|
||||
/**
|
||||
* @ORM\Column(name="Bio", type="string")
|
||||
* @var string
|
||||
*/
|
||||
private $bio;
|
||||
|
||||
/**
|
||||
* @ORM\Column(name="State", type="string")
|
||||
* @var string
|
||||
*/
|
||||
private $state;
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
@ -291,42 +389,6 @@ class Member extends SilverstripeBaseModel
|
||||
$this->third_email = $third_email;
|
||||
}
|
||||
|
||||
/**
|
||||
* @ORM\Column(name="Country", type="string")
|
||||
* @var string
|
||||
*/
|
||||
private $country;
|
||||
|
||||
/**
|
||||
* @ORM\Column(name="Email", type="string")
|
||||
* @var string
|
||||
*/
|
||||
private $email;
|
||||
|
||||
/**
|
||||
* @ORM\Column(name="SecondEmail", type="string")
|
||||
* @var string
|
||||
*/
|
||||
private $second_email;
|
||||
|
||||
/**
|
||||
* @ORM\Column(name="ThirdEmail", type="string")
|
||||
* @var string
|
||||
*/
|
||||
private $third_email;
|
||||
|
||||
/**
|
||||
* @ORM\Column(name="EmailVerified", type="boolean")
|
||||
* @var bool
|
||||
*/
|
||||
private $email_verified;
|
||||
|
||||
/**
|
||||
* @ORM\Column(name="EmailVerifiedDate", type="datetime")
|
||||
* @var \DateTime
|
||||
*/
|
||||
private $email_verified_date;
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
@ -407,36 +469,6 @@ class Member extends SilverstripeBaseModel
|
||||
$this->active = $active;
|
||||
}
|
||||
|
||||
/**
|
||||
* @ORM\Column(name="Active", type="boolean")
|
||||
* @var bool
|
||||
*/
|
||||
private $active;
|
||||
|
||||
/**
|
||||
* @ORM\Column(name="LinkedInProfile", type="string")
|
||||
* @var string
|
||||
*/
|
||||
private $linked_in_profile;
|
||||
|
||||
/**
|
||||
* @ORM\Column(name="IRCHandle", type="string")
|
||||
* @var string
|
||||
*/
|
||||
private $irc_handle;
|
||||
|
||||
/**
|
||||
* @ORM\Column(name="TwitterName", type="string")
|
||||
* @var string
|
||||
*/
|
||||
private $twitter_handle;
|
||||
|
||||
/**
|
||||
* @ORM\Column(name="Gender", type="string")
|
||||
* @var string
|
||||
*/
|
||||
private $gender;
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
@ -461,24 +493,6 @@ class Member extends SilverstripeBaseModel
|
||||
return $this->first_name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @ORM\Column(name="Surname", type="string")
|
||||
* @var string
|
||||
*/
|
||||
private $last_name;
|
||||
|
||||
/**
|
||||
* @ORM\OneToMany(targetEntity="models\summit\SummitEventFeedback", mappedBy="owner", cascade={"persist"})
|
||||
* @var SummitEventFeedback[]
|
||||
*/
|
||||
private $feedback;
|
||||
|
||||
|
||||
/**
|
||||
* @ORM\OneToMany(targetEntity="Affiliation", mappedBy="owner", cascade={"persist"})
|
||||
*/
|
||||
private $affiliations;
|
||||
|
||||
/**
|
||||
* @return File
|
||||
*/
|
||||
@ -606,19 +620,9 @@ class Member extends SilverstripeBaseModel
|
||||
*/
|
||||
public function isOnFavorite(SummitEvent $event)
|
||||
{
|
||||
$sql = <<<SQL
|
||||
SELECT COUNT(SummitEventID) AS QTY
|
||||
FROM Member_FavoriteSummitEvents
|
||||
WHERE MemberID = :member_id AND SummitEventID = :event_id
|
||||
SQL;
|
||||
|
||||
$stmt = $this->prepareRawSQL($sql);
|
||||
$stmt->execute([
|
||||
'member_id' => $this->getId(),
|
||||
'event_id' => $event->getId()
|
||||
]);
|
||||
$res = $stmt->fetchAll(\PDO::FETCH_COLUMN);
|
||||
return count($res) > 0 ? intval($res[0]) > 0 : false;
|
||||
$criteria = Criteria::create();
|
||||
$criteria->where(Criteria::expr()->eq('event', $event));
|
||||
return $this->favorites->matching($criteria)->count() > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -634,7 +638,7 @@ SQL;
|
||||
(
|
||||
sprintf('Event %s does not belongs to member %s favorite.', $event->getId(), $this->getId())
|
||||
);
|
||||
$this->schedule->removeElement($favorite);
|
||||
$this->favorites->removeElement($favorite);
|
||||
$favorite->clearOwner();
|
||||
}
|
||||
|
||||
@ -686,6 +690,14 @@ SQL;
|
||||
$this->schedule->add($schedule);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ScheduleCalendarSyncInfo $sync_info
|
||||
*/
|
||||
public function add2ScheduleSyncInfo(ScheduleCalendarSyncInfo $sync_info){
|
||||
$sync_info->setMember($this);
|
||||
$this->schedule_sync_info->add($sync_info);
|
||||
}
|
||||
|
||||
public function removeFromSchedule(SummitEvent $event)
|
||||
{
|
||||
$schedule = $this->getScheduleByEvent($event);
|
||||
@ -699,25 +711,33 @@ SQL;
|
||||
$schedule->clearOwner();
|
||||
}
|
||||
|
||||
public function removeFromScheduleSyncInfo(ScheduleCalendarSyncInfo $sync_info){
|
||||
$this->schedule_sync_info->removeElement($sync_info);
|
||||
$sync_info->clearOwner();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param CalendarSyncInfo $calendar_sync_info
|
||||
* @param SummitEvent $event
|
||||
* @return bool
|
||||
*/
|
||||
public function isEventSynchronized(CalendarSyncInfo $calendar_sync_info, SummitEvent $event){
|
||||
|
||||
$criteria = Criteria::create();
|
||||
$criteria->where(Criteria::expr()->eq('summit_event', $event));
|
||||
$criteria->andWhere(Criteria::expr()->eq('calendar_sync_info', $calendar_sync_info));
|
||||
return $this->schedule_sync_info->matching($criteria)->count() > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param SummitEvent $event
|
||||
* @return bool
|
||||
*/
|
||||
public function isOnSchedule(SummitEvent $event)
|
||||
{
|
||||
$sql = <<<SQL
|
||||
SELECT COUNT(SummitEventID) AS QTY
|
||||
FROM Member_Schedule
|
||||
WHERE MemberID = :member_id AND SummitEventID = :event_id
|
||||
SQL;
|
||||
|
||||
$stmt = $this->prepareRawSQL($sql);
|
||||
$stmt->execute([
|
||||
'member_id' => $this->getId(),
|
||||
'event_id' => $event->getId()
|
||||
]);
|
||||
$res = $stmt->fetchAll(\PDO::FETCH_COLUMN);
|
||||
return count($res) > 0 ? intval($res[0]) > 0 : false;
|
||||
$criteria = Criteria::create();
|
||||
$criteria->where(Criteria::expr()->eq('event', $event));
|
||||
return $this->schedule->matching($criteria)->count() > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -746,6 +766,27 @@ SQL;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param SummitEvent $event
|
||||
* @param CalendarSyncInfo $calendar_sync_info
|
||||
* @return ScheduleCalendarSyncInfo|null
|
||||
*/
|
||||
public function getScheduleSyncInfoByEvent(SummitEvent $event, CalendarSyncInfo $calendar_sync_info){
|
||||
try {
|
||||
$criteria = Criteria::create();
|
||||
$criteria->where(Criteria::expr()->eq('summit_event', $event));
|
||||
$criteria->andWhere(Criteria::expr()->eq('calendar_sync_info', $calendar_sync_info));
|
||||
return $this->schedule_sync_info->matching($criteria)->first();
|
||||
}
|
||||
catch(NoResultException $ex1){
|
||||
return null;
|
||||
}
|
||||
catch(NonUniqueResultException $ex2){
|
||||
// should never happen
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param SummitEvent $event
|
||||
* @return SummitMemberFavorite|null
|
||||
@ -771,12 +812,6 @@ SQL;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return SummitMemberSchedule[]
|
||||
*/
|
||||
public function getSchedule(){
|
||||
return $this->schedule;
|
||||
}
|
||||
/**
|
||||
* @param Summit $summit
|
||||
* @return int[]
|
||||
@ -851,4 +886,31 @@ SQL;
|
||||
->setParameter('summit_id', $summit->getId())
|
||||
->getResult();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Summit $summit
|
||||
* @return CalendarSyncInfo[]
|
||||
*/
|
||||
public function getSyncInfoBy(Summit $summit){
|
||||
$res = $this->calendars_sync->filter(function($entity) use($summit){
|
||||
return $entity->getSummit()->getIdentifier() == $summit->getIdentifier() && !$entity->isRevoked();
|
||||
});
|
||||
return count($res) > 0 ? $res[0] : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Summit $summit
|
||||
* @return bool
|
||||
*/
|
||||
public function hasSyncInfoFor(Summit $summit){
|
||||
return !is_null($this->getSyncInfoBy($summit));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param CalendarSyncInfo $calendar_sync_info
|
||||
*/
|
||||
public function removeFromCalendarSyncInfo(CalendarSyncInfo $calendar_sync_info){
|
||||
$this->calendars_sync->removeElement($calendar_sync_info);
|
||||
$calendar_sync_info->clearOwner();
|
||||
}
|
||||
}
|
@ -26,6 +26,9 @@ use models\utils\SilverstripeBaseModel;
|
||||
*/
|
||||
class PushNotificationMessage extends SilverstripeBaseModel
|
||||
{
|
||||
const PlatformMobile = 'MOBILE';
|
||||
const PlatformWeb = 'WEB';
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
@ -38,22 +41,6 @@ class PushNotificationMessage extends SilverstripeBaseModel
|
||||
*/
|
||||
protected $message;
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getPriority()
|
||||
{
|
||||
return $this->priority;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $priority
|
||||
*/
|
||||
public function setPriority($priority)
|
||||
{
|
||||
$this->priority = $priority;
|
||||
}
|
||||
|
||||
/**
|
||||
* @ORM\Column(name="Priority", type="string")
|
||||
* @var string
|
||||
@ -72,6 +59,18 @@ class PushNotificationMessage extends SilverstripeBaseModel
|
||||
*/
|
||||
protected $is_sent;
|
||||
|
||||
/**
|
||||
* @ORM\Column(name="Approved", type="boolean")
|
||||
* @var bool
|
||||
*/
|
||||
protected $approved;
|
||||
|
||||
/**
|
||||
* @ORM\Column(name="Platform", type="string")
|
||||
* @var bool
|
||||
*/
|
||||
protected $platform;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity="models\main\Member")
|
||||
* @ORM\JoinColumn(name="OwnerID", referencedColumnName="ID")
|
||||
@ -79,6 +78,13 @@ class PushNotificationMessage extends SilverstripeBaseModel
|
||||
*/
|
||||
protected $owner;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity="models\main\Member")
|
||||
* @ORM\JoinColumn(name="ApprovedByID", referencedColumnName="ID")
|
||||
* @var Member
|
||||
*/
|
||||
protected $approved_by;
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
@ -180,4 +186,68 @@ class PushNotificationMessage extends SilverstripeBaseModel
|
||||
$this->owner = $owner;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getPriority()
|
||||
{
|
||||
return $this->priority;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $priority
|
||||
*/
|
||||
public function setPriority($priority)
|
||||
{
|
||||
$this->priority = $priority;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function isApproved()
|
||||
{
|
||||
return $this->approved;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bool $approved
|
||||
*/
|
||||
public function setApproved($approved)
|
||||
{
|
||||
$this->approved = $approved;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function isPlatform()
|
||||
{
|
||||
return $this->platform;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bool $platform
|
||||
*/
|
||||
public function setPlatform($platform)
|
||||
{
|
||||
$this->platform = $platform;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Member
|
||||
*/
|
||||
public function getApprovedBy()
|
||||
{
|
||||
return $this->approved_by;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Member $approved_by
|
||||
*/
|
||||
public function setApprovedBy($approved_by)
|
||||
{
|
||||
$this->approved_by = $approved_by;
|
||||
}
|
||||
|
||||
}
|
@ -22,7 +22,7 @@ use models\utils\IEntity;
|
||||
* Class SummitMemberSchedule
|
||||
* @package models\main
|
||||
*/
|
||||
class SummitMemberFavorite
|
||||
final class SummitMemberFavorite
|
||||
{
|
||||
/**
|
||||
* @ORM\Id
|
||||
@ -86,7 +86,7 @@ class SummitMemberFavorite
|
||||
}
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity="Member", inversedBy="schedule")
|
||||
* @ORM\ManyToOne(targetEntity="Member", inversedBy="favorites")
|
||||
* @ORM\JoinColumn(name="MemberID", referencedColumnName="ID", nullable=true )
|
||||
* @var Member
|
||||
*/
|
||||
|
@ -22,8 +22,12 @@ use models\utils\IEntity;
|
||||
* Class SummitMemberSchedule
|
||||
* @package models\main
|
||||
*/
|
||||
class SummitMemberSchedule implements IEntity
|
||||
final class SummitMemberSchedule implements IEntity
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* @ORM\Id
|
||||
* @ORM\GeneratedValue
|
||||
@ -31,6 +35,28 @@ class SummitMemberSchedule implements IEntity
|
||||
*/
|
||||
private $id;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity="Member", inversedBy="schedule")
|
||||
* @ORM\JoinColumn(name="MemberID", referencedColumnName="ID", nullable=true )
|
||||
* @var Member
|
||||
*/
|
||||
private $member;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity="models\summit\SummitEvent")
|
||||
* @ORM\JoinColumn(name="SummitEventID", referencedColumnName="ID")
|
||||
* @var SummitEvent
|
||||
*/
|
||||
private $event;
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getIdentifier()
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
@ -76,27 +102,4 @@ class SummitMemberSchedule implements IEntity
|
||||
{
|
||||
$this->event = $event;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getIdentifier()
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity="Member", inversedBy="schedule")
|
||||
* @ORM\JoinColumn(name="MemberID", referencedColumnName="ID", nullable=true )
|
||||
* @var Member
|
||||
*/
|
||||
private $member;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity="models\summit\SummitEvent")
|
||||
* @ORM\JoinColumn(name="SummitEventID", referencedColumnName="ID")
|
||||
* @var SummitEvent
|
||||
*/
|
||||
private $event;
|
||||
|
||||
}
|
@ -49,6 +49,13 @@ class SummitAttendee extends SilverstripeBaseModel
|
||||
*/
|
||||
private $summit_hall_checked_in_date;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity="models\main\Member")
|
||||
* @ORM\JoinColumn(name="MemberID", referencedColumnName="ID")
|
||||
* @var Member
|
||||
*/
|
||||
private $member;
|
||||
|
||||
/**
|
||||
* @return \DateTime
|
||||
*/
|
||||
@ -79,13 +86,6 @@ class SummitAttendee extends SilverstripeBaseModel
|
||||
$this->share_contact_info = $share_contact_info;
|
||||
}
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity="models\main\Member")
|
||||
* @ORM\JoinColumn(name="MemberID", referencedColumnName="ID")
|
||||
* @var Member
|
||||
*/
|
||||
private $member;
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
@ -106,7 +106,7 @@ class SummitAttendee extends SilverstripeBaseModel
|
||||
}
|
||||
|
||||
/**
|
||||
* @ORM\OneToMany(targetEntity="SummitAttendeeTicket", mappedBy="owner", cascade={"persist"})
|
||||
* @ORM\OneToMany(targetEntity="SummitAttendeeTicket", mappedBy="owner", cascade={"persist"}, orphanRemoval=true)
|
||||
* @var SummitAttendeeTicket[]
|
||||
*/
|
||||
private $tickets;
|
||||
|
@ -170,7 +170,7 @@ class SummitAttendeeTicket extends SilverstripeBaseModel
|
||||
private $ticket_type;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity="SummitAttendee")
|
||||
* @ORM\ManyToOne(targetEntity="SummitAttendee", inversedBy="tickets")
|
||||
* @ORM\JoinColumn(name="OwnerID", referencedColumnName="ID")
|
||||
* @var SummitAttendee
|
||||
*/
|
||||
|
186
app/Models/Foundation/Summit/CalendarSync/CalendarSyncInfo.php
Normal file
186
app/Models/Foundation/Summit/CalendarSync/CalendarSyncInfo.php
Normal file
@ -0,0 +1,186 @@
|
||||
<?php namespace models\summit\CalendarSync;
|
||||
/**
|
||||
* 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\Common\Collections\ArrayCollection;
|
||||
use Doctrine\ORM\Mapping AS ORM;
|
||||
use models\main\Member;
|
||||
use models\main\SummitMemberSchedule;
|
||||
use models\summit\SummitOwned;
|
||||
use models\utils\SilverstripeBaseModel;
|
||||
|
||||
/**
|
||||
* @ORM\Entity(repositoryClass="repositories\summit\DoctrineCalendarSyncInfoRepository")
|
||||
* @ORM\Table(name="CalendarSyncInfo")
|
||||
* @ORM\InheritanceType("JOINED")
|
||||
* @ORM\DiscriminatorColumn(name="ClassName", type="string")
|
||||
* @ORM\DiscriminatorMap({"CalendarSyncInfo" = "CalendarSyncInfo", "CalendarSyncInfoCalDav" = "CalendarSyncInfoCalDav", "CalendarSyncInfoOAuth2" = "CalendarSyncInfoOAuth2"})
|
||||
* Class CalendarSyncInfo
|
||||
* @package models\summit\CalendarSync
|
||||
*/
|
||||
class CalendarSyncInfo extends SilverstripeBaseModel
|
||||
{
|
||||
const ProviderGoogle = 'Google';
|
||||
const ProviderOutlook = 'Outlook';
|
||||
const ProvideriCloud = 'iCloud';
|
||||
|
||||
private static $valid_providers = [self::ProviderGoogle, self::ProviderOutlook, self::ProvideriCloud];
|
||||
|
||||
/**
|
||||
* @param string $provider
|
||||
* @return bool
|
||||
*/
|
||||
public static function isValidProvider($provider){
|
||||
if(empty($provider)) return false;
|
||||
return in_array($provider, self::$valid_providers);
|
||||
}
|
||||
|
||||
/**
|
||||
* CalendarSyncInfo constructor.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->synchronized_events = new ArrayCollection();
|
||||
}
|
||||
|
||||
/**
|
||||
* @ORM\Column(name="Provider", type="string")
|
||||
* @var string
|
||||
*/
|
||||
protected $provider;
|
||||
|
||||
/**
|
||||
* @ORM\Column(name="CalendarExternalId", type="string")
|
||||
* @var string
|
||||
*/
|
||||
protected $external_id;
|
||||
|
||||
/**
|
||||
* @ORM\Column(name="ETag", type="string")
|
||||
* @var string
|
||||
*/
|
||||
protected $etag;
|
||||
|
||||
/**
|
||||
* @ORM\Column(name="Revoked", type="boolean")
|
||||
* @var bool
|
||||
*/
|
||||
protected $revoked;
|
||||
|
||||
use SummitOwned;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity="models\main\Member", inversedBy="calendars_sync")
|
||||
* @ORM\JoinColumn(name="OwnerID", referencedColumnName="ID")
|
||||
* @var Member
|
||||
*/
|
||||
protected $owner;
|
||||
|
||||
/**
|
||||
* @ORM\OneToMany(targetEntity="ScheduleCalendarSyncInfo", mappedBy="calendar_sync_info", cascade={"persist"}, orphanRemoval=true)
|
||||
* @var ScheduleCalendarSyncInfo[]
|
||||
*/
|
||||
protected $synchronized_events;
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getProvider()
|
||||
{
|
||||
return $this->provider;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $provider
|
||||
*/
|
||||
public function setProvider($provider)
|
||||
{
|
||||
$this->provider = $provider;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getExternalId()
|
||||
{
|
||||
return $this->external_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $external_id
|
||||
*/
|
||||
public function setExternalId($external_id)
|
||||
{
|
||||
$this->external_id = $external_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getEtag()
|
||||
{
|
||||
return $this->etag;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $etag
|
||||
*/
|
||||
public function setEtag($etag)
|
||||
{
|
||||
$this->etag = $etag;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Member
|
||||
*/
|
||||
public function getOwner()
|
||||
{
|
||||
return $this->owner;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Member $owner
|
||||
*/
|
||||
public function setOwner($owner)
|
||||
{
|
||||
$this->owner = $owner;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return ScheduleCalendarSyncInfo[]
|
||||
*/
|
||||
public function getSynchronizedEvents()
|
||||
{
|
||||
return $this->synchronized_events;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function isRevoked()
|
||||
{
|
||||
return $this->revoked;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bool $revoked
|
||||
*/
|
||||
public function setRevoked($revoked)
|
||||
{
|
||||
$this->revoked = $revoked;
|
||||
}
|
||||
|
||||
public function clearOwner(){
|
||||
$this->owner = null;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,150 @@
|
||||
<?php namespace models\summit\CalendarSync;
|
||||
/**
|
||||
* 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\Mapping AS ORM;
|
||||
use services\utils\Facades\Encryption;
|
||||
|
||||
/**
|
||||
* Class CalendarSyncInfoCalDav
|
||||
* @ORM\Entity
|
||||
* @ORM\Table(name="CalendarSyncInfoCalDav")
|
||||
* @package models\summit\CalendarSync
|
||||
*/
|
||||
final class CalendarSyncInfoCalDav extends CalendarSyncInfo
|
||||
{
|
||||
/**
|
||||
* @ORM\Column(name="UserName", type="string")
|
||||
* @var string
|
||||
*/
|
||||
protected $user_name;
|
||||
|
||||
/**
|
||||
* @ORM\Column(name="UserPassword", type="string")
|
||||
* @var string
|
||||
*/
|
||||
protected $user_password;
|
||||
|
||||
/**
|
||||
* @ORM\Column(name="UserPrincipalURL", type="string")
|
||||
* @var string
|
||||
*/
|
||||
protected $user_principal_url;
|
||||
|
||||
/**
|
||||
* @ORM\Column(name="CalendarDisplayName", type="string")
|
||||
* @var string
|
||||
*/
|
||||
protected $calendar_display_name;
|
||||
|
||||
/**
|
||||
* @ORM\Column(name="CalendarSyncToken", type="string")
|
||||
* @var string
|
||||
*/
|
||||
protected $calendar_sync_token;
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getUserName()
|
||||
{
|
||||
return $this->user_name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $user_name
|
||||
*/
|
||||
public function setUserName($user_name)
|
||||
{
|
||||
$this->user_name = $user_name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getUserPassword()
|
||||
{
|
||||
return Encryption::decrypt($this->user_password);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $user_password
|
||||
*/
|
||||
public function setUserPassword($user_password)
|
||||
{
|
||||
$this->user_password = Encryption::encrypt($user_password);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getUserPrincipalUrl()
|
||||
{
|
||||
return $this->user_principal_url;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $user_principal_url
|
||||
*/
|
||||
public function setUserPrincipalUrl($user_principal_url)
|
||||
{
|
||||
$this->user_principal_url = $user_principal_url;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getServer(){
|
||||
$result = parse_url($this->user_principal_url);
|
||||
return $result['scheme']."://".$result['host'];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getCalendarUrl(){
|
||||
return $this->external_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getCalendarDisplayName()
|
||||
{
|
||||
return $this->calendar_display_name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $calendar_display_name
|
||||
*/
|
||||
public function setCalendarDisplayName($calendar_display_name)
|
||||
{
|
||||
$this->calendar_display_name = $calendar_display_name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getCalendarSyncToken()
|
||||
{
|
||||
return $this->calendar_sync_token;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $calendar_sync_token
|
||||
*/
|
||||
public function setCalendarSyncToken($calendar_sync_token)
|
||||
{
|
||||
$this->calendar_sync_token = $calendar_sync_token;
|
||||
}
|
||||
}
|
@ -0,0 +1,74 @@
|
||||
<?php namespace models\summit\CalendarSync;
|
||||
/**
|
||||
* 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\Mapping AS ORM;
|
||||
use services\utils\Facades\Encryption;
|
||||
|
||||
/**
|
||||
* Class CalendarSyncInfoOAuth2
|
||||
* @ORM\Entity
|
||||
* @ORM\Table(name="CalendarSyncInfoOAuth2")
|
||||
* @package models\summit\CalendarSync
|
||||
*/
|
||||
final class CalendarSyncInfoOAuth2 extends CalendarSyncInfo
|
||||
{
|
||||
/**
|
||||
* @ORM\Column(name="AccessToken", type="string")
|
||||
* @var string
|
||||
*/
|
||||
protected $access_token;
|
||||
|
||||
/**
|
||||
* @ORM\Column(name="RefreshToken", type="string")
|
||||
* @var string
|
||||
*/
|
||||
protected $refresh_token;
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getAccessToken()
|
||||
{
|
||||
$access_token = Encryption::decrypt($this->access_token);
|
||||
return json_decode($access_token, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $access_token
|
||||
*/
|
||||
public function setAccessToken($access_token)
|
||||
{
|
||||
$this->access_token = Encryption::encrypt
|
||||
(
|
||||
json_encode($access_token)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getRefreshToken()
|
||||
{
|
||||
return Encryption::decrypt($this->refresh_token);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $refresh_token
|
||||
*/
|
||||
public function setRefreshToken($refresh_token)
|
||||
{
|
||||
$this->refresh_token = Encryption::encrypt($refresh_token);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,280 @@
|
||||
<?php namespace models\summit\CalendarSync;
|
||||
/**
|
||||
* 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\Mapping AS ORM;
|
||||
use models\main\Member;
|
||||
use models\summit\SummitAbstractLocation;
|
||||
use models\summit\SummitEvent;
|
||||
use models\utils\SilverstripeBaseModel;
|
||||
|
||||
/**
|
||||
* @ORM\Entity(repositoryClass="repositories\summit\DoctrineScheduleCalendarSyncInfoRepository")
|
||||
* @ORM\Table(name="ScheduleCalendarSyncInfo")
|
||||
* @package models\summit\CalendarSync
|
||||
*/
|
||||
class ScheduleCalendarSyncInfo extends SilverstripeBaseModel
|
||||
{
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity="models\main\Member", inversedBy="schedule_sync_info")
|
||||
* @ORM\JoinColumn(name="OwnerID", referencedColumnName="ID", nullable=true )
|
||||
* @var Member
|
||||
*/
|
||||
private $member;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity="models\summit\SummitEvent")
|
||||
* @ORM\JoinColumn(name="SummitEventID", referencedColumnName="ID")
|
||||
* @var SummitEvent
|
||||
*/
|
||||
private $summit_event;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity="models\summit\SummitAbstractLocation")
|
||||
* @ORM\JoinColumn(name="LocationID", referencedColumnName="ID")
|
||||
* @var SummitAbstractLocation
|
||||
*/
|
||||
private $location;
|
||||
|
||||
/**
|
||||
* @ORM\Column(name="ExternalId", type="string")
|
||||
* @var string
|
||||
*/
|
||||
private $external_id;
|
||||
|
||||
/**
|
||||
* @ORM\Column(name="ETag", type="string")
|
||||
* @var string
|
||||
*/
|
||||
private $etag;
|
||||
|
||||
/**
|
||||
* @ORM\Column(name="VCard", type="string")
|
||||
* @var string
|
||||
*/
|
||||
private $vcard;
|
||||
|
||||
/**
|
||||
* @ORM\Column(name="CalendarEventExternalUrl", type="string")
|
||||
* @var string
|
||||
*/
|
||||
private $external_url;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity="models\summit\CalendarSync\CalendarSyncInfo", inversedBy="synchronized_events")
|
||||
* @ORM\JoinColumn(name="CalendarSyncInfoID", referencedColumnName="ID", nullable=true )
|
||||
* @var CalendarSyncInfo
|
||||
*/
|
||||
private $calendar_sync_info;
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getId()
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Member
|
||||
*/
|
||||
public function getMember()
|
||||
{
|
||||
return $this->member;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Member $member
|
||||
*/
|
||||
public function setMember($member)
|
||||
{
|
||||
$this->member = $member;
|
||||
}
|
||||
|
||||
|
||||
public function clearOwner(){
|
||||
$this->member = null;
|
||||
$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
|
||||
*/
|
||||
public function getCreated()
|
||||
{
|
||||
return $this->created;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \DateTime $created
|
||||
*/
|
||||
public function setCreated($created)
|
||||
{
|
||||
$this->created = $created;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \DateTime
|
||||
*/
|
||||
public function getLastEdited()
|
||||
{
|
||||
return $this->last_edited;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \DateTime $last_edited
|
||||
*/
|
||||
public function setLastEdited($last_edited)
|
||||
{
|
||||
$this->last_edited = $last_edited;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getExternalId()
|
||||
{
|
||||
return $this->external_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $external_id
|
||||
*/
|
||||
public function setExternalId($external_id)
|
||||
{
|
||||
$this->external_id = $external_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getEtag()
|
||||
{
|
||||
return $this->etag;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $etag
|
||||
*/
|
||||
public function setEtag($etag)
|
||||
{
|
||||
$this->etag = $etag;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getExternalUrl()
|
||||
{
|
||||
return $this->external_url;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $external_url
|
||||
*/
|
||||
public function setExternalUrl($external_url)
|
||||
{
|
||||
$this->external_url = $external_url;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return CalendarSyncInfo
|
||||
*/
|
||||
public function getCalendarSyncInfo()
|
||||
{
|
||||
return $this->calendar_sync_info;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param CalendarSyncInfo $calendar_sync_info
|
||||
*/
|
||||
public function setCalendarSyncInfo($calendar_sync_info)
|
||||
{
|
||||
$this->calendar_sync_info = $calendar_sync_info;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getLocation()
|
||||
{
|
||||
return $this->location;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $location
|
||||
*/
|
||||
public function setLocation($location)
|
||||
{
|
||||
$this->location = $location;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getVCard()
|
||||
{
|
||||
return $this->vcard;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $vcard
|
||||
*/
|
||||
public function setVCard($vcard)
|
||||
{
|
||||
$this->vcard = $vcard;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function toJson(){
|
||||
return json_encode([
|
||||
'external_id' => $this->external_id,
|
||||
'etag' => $this->etag,
|
||||
'external_url' => $this->external_url,
|
||||
'vcard' => $this->vcard,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $str_json
|
||||
* @return ScheduleCalendarSyncInfo
|
||||
*/
|
||||
public static function buildFromJson($str_json){
|
||||
$res = json_decode($str_json, true);
|
||||
$o = new ScheduleCalendarSyncInfo();
|
||||
$o->setExternalId($res['external_id']);
|
||||
$o->setEtag($res['etag']);
|
||||
$o->setExternalUrl($res['external_url']);
|
||||
$o->setVCard($res['vcard']);
|
||||
return $o;
|
||||
}
|
||||
}
|
@ -0,0 +1,110 @@
|
||||
<?php namespace models\summit\CalendarSync\WorkQueue;
|
||||
/**
|
||||
* 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\Mapping AS ORM;
|
||||
use models\utils\SilverstripeBaseModel;
|
||||
/**
|
||||
* @ORM\Entity(repositoryClass="repositories\summit\DoctrineAbstractCalendarSyncWorkRequestRepository")
|
||||
* @ORM\Table(name="AbstractCalendarSyncWorkRequest")
|
||||
* @ORM\InheritanceType("JOINED")
|
||||
* @ORM\DiscriminatorColumn(name="ClassName", type="string")
|
||||
* @ORM\DiscriminatorMap({"AbstractCalendarSyncWorkRequest" = "AbstractCalendarSyncWorkRequest", "AdminScheduleSummitActionSyncWorkRequest" = "AdminScheduleSummitActionSyncWorkRequest", "AdminSummitEventActionSyncWorkRequest" = "AdminSummitEventActionSyncWorkRequest", "AdminSummitLocationActionSyncWorkRequest" = "AdminSummitLocationActionSyncWorkRequest", "MemberCalendarScheduleSummitActionSyncWorkRequest" = "MemberCalendarScheduleSummitActionSyncWorkRequest", "MemberEventScheduleSummitActionSyncWorkRequest" = "MemberEventScheduleSummitActionSyncWorkRequest", "MemberScheduleSummitActionSyncWorkRequest" = "MemberScheduleSummitActionSyncWorkRequest"})
|
||||
* Class AbstractCalendarSyncWorkRequest
|
||||
* @package models\summit\CalendarSync\WorkQueue
|
||||
*/
|
||||
class AbstractCalendarSyncWorkRequest extends SilverstripeBaseModel
|
||||
{
|
||||
|
||||
const TypeAdd = 'ADD';
|
||||
const TypeRemove = 'REMOVE';
|
||||
const TypeUpdate = 'UPDATE';
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->is_processed = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @ORM\Column(name="Type", type="string")
|
||||
* @var string
|
||||
*/
|
||||
protected $type;
|
||||
|
||||
/**
|
||||
* @ORM\Column(name="IsProcessed", type="boolean", options={"default":"0"})
|
||||
* @var bool
|
||||
*/
|
||||
protected $is_processed;
|
||||
|
||||
/**
|
||||
* @ORM\Column(name="ProcessedDate", type="datetime")
|
||||
* @var \DateTime
|
||||
*/
|
||||
protected $processed_date;
|
||||
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getType()
|
||||
{
|
||||
return $this->type;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $type
|
||||
*/
|
||||
public function setType($type)
|
||||
{
|
||||
$this->type = $type;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function IsProcessed()
|
||||
{
|
||||
return $this->is_processed;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bool $is_processed
|
||||
*/
|
||||
public function setIsProcessed($is_processed)
|
||||
{
|
||||
$this->is_processed = $is_processed;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \DateTime
|
||||
*/
|
||||
public function getProcessedDate()
|
||||
{
|
||||
return $this->processed_date;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \DateTime $processed_date
|
||||
*/
|
||||
public function setProcessedDate($processed_date)
|
||||
{
|
||||
$this->processed_date = $processed_date;
|
||||
}
|
||||
|
||||
|
||||
public function markProcessed(){
|
||||
$this->is_processed = true;
|
||||
$this->processed_date = new \DateTime('now', new \DateTimeZone(SilverstripeBaseModel::DefaultTimeZone));
|
||||
}
|
||||
}
|
@ -0,0 +1,49 @@
|
||||
<?php namespace models\summit\CalendarSync\WorkQueue;
|
||||
/**
|
||||
* 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\main\Member;
|
||||
use Doctrine\ORM\Mapping AS ORM;
|
||||
|
||||
/**
|
||||
* Class AdminScheduleSummitActionSyncWorkRequest
|
||||
* @ORM\Entity
|
||||
* @ORM\Table(name="AdminScheduleSummitActionSyncWorkRequest")
|
||||
* @package models\summit\CalendarSync\WorkQueue
|
||||
*/
|
||||
class AdminScheduleSummitActionSyncWorkRequest
|
||||
extends AbstractCalendarSyncWorkRequest
|
||||
{
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity="models\main\Member", cascade={"persist"})
|
||||
* @ORM\JoinColumn(name="CreatedByID", referencedColumnName="ID")
|
||||
* @var Member
|
||||
*/
|
||||
protected $created_by;
|
||||
|
||||
/**
|
||||
* @return Member
|
||||
*/
|
||||
public function getCreatedBy()
|
||||
{
|
||||
return $this->created_by;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Member $created_by
|
||||
*/
|
||||
public function setCreatedBy($created_by)
|
||||
{
|
||||
$this->created_by = $created_by;
|
||||
}
|
||||
}
|
@ -0,0 +1,52 @@
|
||||
<?php namespace models\summit\CalendarSync\WorkQueue;
|
||||
/**
|
||||
* 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\summit\SummitEvent;
|
||||
use Doctrine\ORM\Mapping AS ORM;
|
||||
|
||||
/**
|
||||
* Class AdminSummitEventActionSyncWorkRequest
|
||||
* @ORM\Entity
|
||||
* @ORM\Table(name="AdminSummitEventActionSyncWorkRequest")
|
||||
* @package models\summit\CalendarSync\WorkQueue
|
||||
*/
|
||||
class AdminSummitEventActionSyncWorkRequest
|
||||
extends AdminScheduleSummitActionSyncWorkRequest
|
||||
{
|
||||
|
||||
const SubType = 'ADMIN_EVENT';
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity="models\summit\SummitEvent", cascade={"persist"})
|
||||
* @ORM\JoinColumn(name="SummitEventID", referencedColumnName="ID")
|
||||
* @var SummitEvent
|
||||
*/
|
||||
private $summit_event;
|
||||
|
||||
/**
|
||||
* @return SummitEvent
|
||||
*/
|
||||
public function getSummitEvent()
|
||||
{
|
||||
return $this->summit_event;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param SummitEvent $summit_event
|
||||
*/
|
||||
public function setSummitEvent($summit_event)
|
||||
{
|
||||
$this->summit_event = $summit_event;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,48 @@
|
||||
<?php namespace models\summit\CalendarSync\WorkQueue;
|
||||
/**
|
||||
* 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\Mapping AS ORM;
|
||||
use models\summit\SummitAbstractLocation;
|
||||
/**
|
||||
* Class AdminSummitLocationActionSyncWorkRequest
|
||||
* @ORM\Entity
|
||||
* @ORM\Table(name="AdminSummitLocationActionSyncWorkRequest")
|
||||
* @package models\summit\CalendarSync\WorkQueue
|
||||
*/
|
||||
final class AdminSummitLocationActionSyncWorkRequest
|
||||
extends AdminScheduleSummitActionSyncWorkRequest
|
||||
{
|
||||
const SubType = 'ADMIN_LOCATION';
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity="models\summit\SummitAbstractLocation", cascade={"persist"})
|
||||
* @ORM\JoinColumn(name="LocationID", referencedColumnName="ID")
|
||||
* @var SummitAbstractLocation
|
||||
*/
|
||||
private $location;
|
||||
|
||||
/**
|
||||
* @return SummitAbstractLocation
|
||||
*/
|
||||
public function getLocation()
|
||||
{
|
||||
return $this->location;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param SummitAbstractLocation $location
|
||||
*/
|
||||
public function setLocation($location)
|
||||
{
|
||||
$this->location = $location;
|
||||
}
|
||||
}
|
@ -0,0 +1,99 @@
|
||||
<?php namespace models\summit\CalendarSync\WorkQueue;
|
||||
/**
|
||||
* 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\Mapping AS ORM;
|
||||
/**
|
||||
* Class MemberCalendarScheduleSummitActionSyncWorkRequest
|
||||
* @ORM\Entity
|
||||
* @ORM\Table(name="MemberCalendarScheduleSummitActionSyncWorkRequest")
|
||||
* @package models\summit\CalendarSync\WorkQueue
|
||||
*/
|
||||
class MemberCalendarScheduleSummitActionSyncWorkRequest
|
||||
extends MemberScheduleSummitActionSyncWorkRequest
|
||||
{
|
||||
const SubType = 'CALENDAR';
|
||||
|
||||
/**
|
||||
* @ORM\Column(name="CalendarId", type="string")
|
||||
* @var string
|
||||
*/
|
||||
private $calendar_id;
|
||||
|
||||
/**
|
||||
* @ORM\Column(name="CalendarName", type="string")
|
||||
* @var string
|
||||
*/
|
||||
private $calendar_name;
|
||||
|
||||
/**
|
||||
* @ORM\Column(name="CalendarDescription", type="string")
|
||||
* @var string
|
||||
*/
|
||||
private $calendar_description;
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getCalendarId()
|
||||
{
|
||||
return $this->calendar_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $calendar_id
|
||||
*/
|
||||
public function setCalendarId($calendar_id)
|
||||
{
|
||||
$this->calendar_id = $calendar_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getCalendarName()
|
||||
{
|
||||
return $this->calendar_name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $calendar_name
|
||||
*/
|
||||
public function setCalendarName($calendar_name)
|
||||
{
|
||||
$this->calendar_name = $calendar_name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getCalendarDescription()
|
||||
{
|
||||
return $this->calendar_description;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $calendar_description
|
||||
*/
|
||||
public function setCalendarDescription($calendar_description)
|
||||
{
|
||||
$this->calendar_description = $calendar_description;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getSubType(){
|
||||
return self::SubType;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,56 @@
|
||||
<?php namespace models\summit\CalendarSync\WorkQueue;
|
||||
/**
|
||||
* 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\summit\SummitEvent;
|
||||
use Doctrine\ORM\Mapping AS ORM;
|
||||
/**
|
||||
* Class MemberEventScheduleSummitActionSyncWorkRequest
|
||||
* @ORM\Entity
|
||||
* @ORM\Table(name="MemberEventScheduleSummitActionSyncWorkRequest")
|
||||
* @package models\summit\CalendarSync\WorkQueue
|
||||
*/
|
||||
class MemberEventScheduleSummitActionSyncWorkRequest
|
||||
extends MemberScheduleSummitActionSyncWorkRequest
|
||||
{
|
||||
const SubType = 'EVENT';
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity="models\summit\SummitEvent", cascade={"persist"})
|
||||
* @ORM\JoinColumn(name="SummitEventID", referencedColumnName="ID")
|
||||
* @var SummitEvent
|
||||
*/
|
||||
protected $summit_event;
|
||||
|
||||
/**
|
||||
* @return SummitEvent
|
||||
*/
|
||||
public function getSummitEvent()
|
||||
{
|
||||
return $this->summit_event;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param SummitEvent $summit_event
|
||||
*/
|
||||
public function setSummitEvent($summit_event)
|
||||
{
|
||||
$this->summit_event = $summit_event;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getSubType(){
|
||||
return self::SubType;
|
||||
}
|
||||
}
|
@ -0,0 +1,77 @@
|
||||
<?php namespace models\summit\CalendarSync\WorkQueue;
|
||||
/**
|
||||
* 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\main\Member;
|
||||
use models\summit\CalendarSync\CalendarSyncInfo;
|
||||
use Doctrine\ORM\Mapping AS ORM;
|
||||
|
||||
/**
|
||||
* Class MemberScheduleSummitActionSyncWorkRequest
|
||||
* @ORM\Entity
|
||||
* @ORM\Table(name="MemberScheduleSummitActionSyncWorkRequest")
|
||||
* @package models\summit\CalendarSync\WorkQueue
|
||||
*/
|
||||
class MemberScheduleSummitActionSyncWorkRequest
|
||||
extends AbstractCalendarSyncWorkRequest
|
||||
{
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity="models\main\Member", cascade={"persist"})
|
||||
* @ORM\JoinColumn(name="OwnerID", referencedColumnName="ID")
|
||||
* @var Member
|
||||
*/
|
||||
protected $owner;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity="models\summit\CalendarSync\CalendarSyncInfo", cascade={"persist"})
|
||||
* @ORM\JoinColumn(name="CalendarSyncInfoID", referencedColumnName="ID")
|
||||
* @var CalendarSyncInfo
|
||||
*/
|
||||
protected $calendar_sync_info;
|
||||
|
||||
/**
|
||||
* @return Member
|
||||
*/
|
||||
public function getOwner()
|
||||
{
|
||||
return $this->owner;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Member $owner
|
||||
*/
|
||||
public function setOwner($owner)
|
||||
{
|
||||
$this->owner = $owner;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return CalendarSyncInfo
|
||||
*/
|
||||
public function getCalendarSyncInfo()
|
||||
{
|
||||
return $this->calendar_sync_info;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param CalendarSyncInfo $calendar_sync_info
|
||||
*/
|
||||
public function setCalendarSyncInfo($calendar_sync_info)
|
||||
{
|
||||
$this->calendar_sync_info = $calendar_sync_info;
|
||||
}
|
||||
|
||||
public function getSubType(){
|
||||
return null;
|
||||
}
|
||||
}
|
@ -38,7 +38,7 @@ abstract class PresentationMaterial extends SilverstripeBaseModel
|
||||
}
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity="models\summit\Presentation", inversedBy="materil")
|
||||
* @ORM\ManyToOne(targetEntity="models\summit\Presentation", inversedBy="materials")
|
||||
* @ORM\JoinColumn(name="PresentationID", referencedColumnName="ID")
|
||||
* @var Presentation
|
||||
*/
|
||||
|
@ -26,7 +26,7 @@ class Presentation extends SummitEvent
|
||||
{
|
||||
|
||||
/**
|
||||
* @ORM\OneToMany(targetEntity="models\summit\PresentationMaterial", mappedBy="presentation", cascade={"persist"})
|
||||
* @ORM\OneToMany(targetEntity="models\summit\PresentationMaterial", mappedBy="presentation", cascade={"persist"}, orphanRemoval=true)
|
||||
* @var PresentationMaterial[]
|
||||
*/
|
||||
private $materials;
|
||||
@ -293,7 +293,7 @@ class Presentation extends SummitEvent
|
||||
}
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity="PresentationSpeaker")
|
||||
* @ORM\ManyToOne(targetEntity="PresentationSpeaker", inversedBy="moderated_presentations")
|
||||
* @ORM\JoinColumn(name="ModeratorID", referencedColumnName="ID")
|
||||
* @var PresentationSpeaker
|
||||
*/
|
||||
|
@ -170,6 +170,7 @@ class PresentationSpeaker extends SilverstripeBaseModel
|
||||
|
||||
/**
|
||||
* @ORM\OneToMany(targetEntity="Presentation", mappedBy="moderator", cascade={"persist"})
|
||||
* @var Presentation[]
|
||||
*/
|
||||
private $moderated_presentations;
|
||||
|
||||
|
@ -265,10 +265,17 @@ class SummitEvent extends SilverstripeBaseModel
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function getIssExternalRSVP(){
|
||||
public function isExternalRSVP(){
|
||||
return !empty($this->rsvp_link) && $this->rsvp_template_id == 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function getIsExternalRSVP(){
|
||||
return $this->isExternalRSVP();
|
||||
}
|
||||
|
||||
public function getSlug(){
|
||||
$slugify = new Slugify();
|
||||
return $slugify->slugify($this->title);
|
||||
|
@ -37,6 +37,95 @@ class SummitGeoLocatedLocation extends SummitAbstractLocation
|
||||
*/
|
||||
protected $address1;
|
||||
|
||||
/**
|
||||
* @ORM\Column(name="Address2", type="string")
|
||||
*/
|
||||
protected $address2;
|
||||
|
||||
/**
|
||||
* @ORM\Column(name="ZipCode", type="string")
|
||||
*/
|
||||
protected $zip_code;
|
||||
|
||||
/**
|
||||
* @ORM\Column(name="City", type="string")
|
||||
*/
|
||||
protected $city;
|
||||
|
||||
/**
|
||||
* @ORM\Column(name="State", type="string")
|
||||
*/
|
||||
protected $state;
|
||||
|
||||
/**
|
||||
* @ORM\Column(name="Country", type="string")
|
||||
*/
|
||||
protected $country;
|
||||
|
||||
/**
|
||||
* @ORM\Column(name="WebSiteUrl", type="string")
|
||||
*/
|
||||
protected $website_url;
|
||||
|
||||
/**
|
||||
* @ORM\Column(name="Lng", type="string")
|
||||
*/
|
||||
protected $lng;
|
||||
|
||||
/**
|
||||
* @ORM\Column(name="Lat", type="string")
|
||||
*/
|
||||
protected $lat;
|
||||
|
||||
/**
|
||||
* @ORM\Column(name="DisplayOnSite", type="boolean")
|
||||
*/
|
||||
protected $display_on_site;
|
||||
|
||||
/**
|
||||
* @ORM\Column(name="DetailsPage", type="boolean")
|
||||
*/
|
||||
protected $details_page;
|
||||
|
||||
/**
|
||||
* @ORM\Column(name="LocationMessage", type="string")
|
||||
*/
|
||||
protected $location_message;
|
||||
|
||||
/**
|
||||
* @ORM\OneToMany(targetEntity="models\summit\SummitLocationImage", mappedBy="location", cascade={"persist"}, orphanRemoval=true)
|
||||
* @var SummitLocationImage[]
|
||||
*/
|
||||
protected $images;
|
||||
|
||||
|
||||
/**
|
||||
* @param SummitVenueRoom|null $room
|
||||
* @return string
|
||||
*/
|
||||
public function getFullAddress(SummitVenueRoom $room = null){
|
||||
$full_location = $this->getName().', ';
|
||||
if(!is_null($room)){
|
||||
$floor = $room->getFloor();
|
||||
if(!is_null($floor)){
|
||||
$full_location .= $floor->getName().', ';
|
||||
}
|
||||
$full_location .= $room->getName().', ';
|
||||
}
|
||||
if(!empty($this->getAddress1()))
|
||||
$full_location .= $this->getAddress1().', ';
|
||||
if(!empty($this->getAddress2()))
|
||||
$full_location .= $this->getAddress2().', ';
|
||||
if(!empty($this->getCity()))
|
||||
$full_location .= $this->getCity().', ';
|
||||
if(!empty($this->getState()))
|
||||
$full_location .= $this->getState().', ';
|
||||
if(!empty($this->getZipCode()))
|
||||
$full_location .= $this->getZipCode().', ';
|
||||
if(!empty($this->getCountry))
|
||||
$full_location .= $this->getCountry().', ';
|
||||
return rtrim($full_location, ', ');
|
||||
}
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
@ -229,66 +318,6 @@ class SummitGeoLocatedLocation extends SummitAbstractLocation
|
||||
$this->location_message = $location_message;
|
||||
}
|
||||
|
||||
/**
|
||||
* @ORM\Column(name="Address2", type="string")
|
||||
*/
|
||||
protected $address2;
|
||||
|
||||
/**
|
||||
* @ORM\Column(name="ZipCode", type="string")
|
||||
*/
|
||||
protected $zip_code;
|
||||
|
||||
/**
|
||||
* @ORM\Column(name="City", type="string")
|
||||
*/
|
||||
protected $city;
|
||||
|
||||
/**
|
||||
* @ORM\Column(name="State", type="string")
|
||||
*/
|
||||
protected $state;
|
||||
|
||||
/**
|
||||
* @ORM\Column(name="Country", type="string")
|
||||
*/
|
||||
protected $country;
|
||||
|
||||
/**
|
||||
* @ORM\Column(name="WebSiteUrl", type="string")
|
||||
*/
|
||||
protected $website_url;
|
||||
|
||||
/**
|
||||
* @ORM\Column(name="Lng", type="string")
|
||||
*/
|
||||
protected $lng;
|
||||
|
||||
/**
|
||||
* @ORM\Column(name="Lat", type="string")
|
||||
*/
|
||||
protected $lat;
|
||||
|
||||
/**
|
||||
* @ORM\Column(name="DisplayOnSite", type="boolean")
|
||||
*/
|
||||
protected $display_on_site;
|
||||
|
||||
/**
|
||||
* @ORM\Column(name="DetailsPage", type="boolean")
|
||||
*/
|
||||
protected $details_page;
|
||||
|
||||
/**
|
||||
* @ORM\Column(name="LocationMessage", type="string")
|
||||
*/
|
||||
protected $location_message;
|
||||
|
||||
/**
|
||||
* @ORM\OneToMany(targetEntity="models\summit\SummitLocationImage", mappedBy="location", cascade={"persist"})
|
||||
* @var SummitLocationImage[]
|
||||
*/
|
||||
protected $images;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
|
@ -159,9 +159,9 @@ class SummitLocationImage extends SilverstripeBaseModel
|
||||
protected $picture;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity="models\summit\SummitAbstractLocation")
|
||||
* @ORM\ManyToOne(targetEntity="models\summit\SummitGeoLocatedLocation", inversedBy="images")
|
||||
* @ORM\JoinColumn(name="LocationID", referencedColumnName="ID")
|
||||
* @var SummitAbstractLocation
|
||||
* @var SummitGeoLocatedLocation
|
||||
*/
|
||||
protected $location;
|
||||
|
||||
|
@ -0,0 +1,49 @@
|
||||
<?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 models\main\Member;
|
||||
use models\summit\CalendarSync\CalendarSyncInfo;
|
||||
use models\summit\CalendarSync\WorkQueue\AbstractCalendarSyncWorkRequest;
|
||||
use models\utils\IBaseRepository;
|
||||
use utils\PagingInfo;
|
||||
use utils\PagingResponse;
|
||||
|
||||
/**
|
||||
* Interface IAbstractCalendarSyncWorkRequestRepository
|
||||
* @package models\summit
|
||||
*/
|
||||
interface IAbstractCalendarSyncWorkRequestRepository extends IBaseRepository
|
||||
{
|
||||
/**
|
||||
* @param Member $member
|
||||
* @param SummitEvent $event
|
||||
* @param CalendarSyncInfo $calendar_sync_info
|
||||
* @param null|string $type
|
||||
* @return AbstractCalendarSyncWorkRequest
|
||||
*/
|
||||
public function getUnprocessedMemberScheduleWorkRequest($member, $event, $calendar_sync_info, $type = null);
|
||||
|
||||
/**
|
||||
* @param string $provider
|
||||
* @param PagingInfo $paging_info
|
||||
* @return PagingResponse
|
||||
*/
|
||||
public function getUnprocessedMemberScheduleWorkRequestActionByPage($provider = 'ALL', PagingInfo $paging_info);
|
||||
|
||||
/**
|
||||
* @param PagingInfo $paging_info
|
||||
* @return PagingResponse
|
||||
*/
|
||||
public function getUnprocessedAdminScheduleWorkRequestActionByPage(PagingInfo $paging_info);
|
||||
}
|
@ -0,0 +1,24 @@
|
||||
<?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 models\utils\IBaseRepository;
|
||||
|
||||
/**
|
||||
* Interface ICalendarSyncInfoRepository
|
||||
* @package models\summit
|
||||
*/
|
||||
interface ICalendarSyncInfoRepository extends IBaseRepository
|
||||
{
|
||||
|
||||
}
|
@ -0,0 +1,39 @@
|
||||
<?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 models\utils\IBaseRepository;
|
||||
use utils\PagingInfo;
|
||||
use utils\PagingResponse;
|
||||
|
||||
/**
|
||||
* Interface IScheduleCalendarSyncInfoRepository
|
||||
* @package models\summit
|
||||
*/
|
||||
interface IScheduleCalendarSyncInfoRepository extends IBaseRepository
|
||||
{
|
||||
/**
|
||||
* @param SummitEvent $summit_event
|
||||
* @param PagingInfo $paging_info
|
||||
* @return PagingResponse
|
||||
*/
|
||||
public function getAllBySummitEvent(SummitEvent $summit_event, PagingInfo $paging_info);
|
||||
|
||||
/**
|
||||
* @param SummitAbstractLocation $location
|
||||
* @param PagingInfo $paging_info
|
||||
* @return PagingResponse
|
||||
*/
|
||||
public function getAllBySummitLocation(SummitAbstractLocation $location, PagingInfo $paging_info);
|
||||
|
||||
}
|
@ -337,7 +337,8 @@ class Summit extends SilverstripeBaseModel
|
||||
private $events;
|
||||
|
||||
/**
|
||||
* @ORM\OneToMany(targetEntity="SummitWIFIConnection", mappedBy="summit", cascade={"persist"})
|
||||
* @ORM\OneToMany(targetEntity="SummitWIFIConnection", mappedBy="summit", cascade={"persist"}, orphanRemoval=true)
|
||||
* @var SummitWIFIConnection[]
|
||||
*/
|
||||
private $wifi_connections;
|
||||
|
||||
@ -364,15 +365,11 @@ class Summit extends SilverstripeBaseModel
|
||||
*/
|
||||
public function convertDateFromTimeZone2UTC(DateTime $value)
|
||||
{
|
||||
$time_zone_id = $this->time_zone_id;
|
||||
if(empty($time_zone_id)) return $value;
|
||||
$time_zone_list = timezone_identifiers_list();
|
||||
$summit_time_zone = $this->getTimeZone();
|
||||
|
||||
if(isset($time_zone_list[$time_zone_id]) && !empty($value))
|
||||
if(!is_null($summit_time_zone) && !empty($value))
|
||||
{
|
||||
$utc_timezone = new DateTimeZone("UTC");
|
||||
$time_zone_name = $time_zone_list[$time_zone_id];
|
||||
$summit_time_zone = new DateTimeZone($time_zone_name);
|
||||
$timestamp = $value->format('Y-m-d H:i:s');
|
||||
$local_date = new DateTime($timestamp, $summit_time_zone);
|
||||
return $local_date->setTimezone($utc_timezone);
|
||||
@ -380,6 +377,19 @@ class Summit extends SilverstripeBaseModel
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return DateTimeZone|null
|
||||
*/
|
||||
public function getTimeZone(){
|
||||
$time_zone_id = $this->time_zone_id;
|
||||
if(empty($time_zone_id)) return null;
|
||||
$time_zone_list = timezone_identifiers_list();
|
||||
if(isset($time_zone_list[$time_zone_id])){
|
||||
$time_zone_name = $time_zone_list[$time_zone_id];
|
||||
return new DateTimeZone($time_zone_name);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
/**
|
||||
* @param DateTime $value
|
||||
* @return null|DateTime
|
||||
@ -992,4 +1002,13 @@ SQL;
|
||||
return $builder->getQuery()->getResult();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getSlug(){
|
||||
$res = "openstack-".$this->name.'-';
|
||||
$res .= $this->begin_date->format('Y').'-summit';
|
||||
$res = strtolower( preg_replace('/[^a-zA-Z0-9\-]/', '',$res));
|
||||
return $res;
|
||||
}
|
||||
}
|
@ -21,7 +21,7 @@ use Doctrine\ORM\Mapping AS ORM;
|
||||
trait SummitOwned
|
||||
{
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity="Summit", cascade={"persist"})
|
||||
* @ORM\ManyToOne(targetEntity="models\summit\Summit")
|
||||
* @ORM\JoinColumn(name="SummitID", referencedColumnName="ID")
|
||||
* @var Summit
|
||||
*/
|
||||
|
@ -181,38 +181,42 @@ final class AccessTokenService implements IAccessTokenService
|
||||
if (empty($auth_server_url)) {
|
||||
throw new ConfigurationException('app.openstackid_base_url param is missing!');
|
||||
}
|
||||
|
||||
$response = $client->post(
|
||||
$auth_server_url . '/oauth2/token/introspection',
|
||||
// http://docs.guzzlephp.org/en/stable/request-options.html
|
||||
$response = $client->request('POST',
|
||||
"{$auth_server_url}/oauth2/token/introspection",
|
||||
[
|
||||
'body' => ['token' => $token_value],
|
||||
'headers' => ['Authorization' => " Basic " . base64_encode($client_id . ':' . $client_secret)]
|
||||
'form_params' => ['token' => $token_value],
|
||||
'auth' => [$client_id, $client_secret],
|
||||
'timeout' => 120,
|
||||
'http_errors' => true
|
||||
]
|
||||
);
|
||||
|
||||
$content_type = $response->getHeader('content-type');
|
||||
$content_type = $response->getHeaderLine('content-type');
|
||||
if(!str_contains($content_type, 'application/json'))
|
||||
{
|
||||
// invalid content type
|
||||
throw new \Exception($response->getBody());
|
||||
}
|
||||
$token_info = $response->json();
|
||||
$token_info = json_decode($response->getBody()->getContents(), true);
|
||||
|
||||
return $token_info;
|
||||
|
||||
}
|
||||
catch (RequestException $ex)
|
||||
{
|
||||
catch (RequestException $ex) {
|
||||
|
||||
Log::warning($ex->getMessage());
|
||||
$response = $ex->getResponse();
|
||||
$response = $ex->getResponse();
|
||||
|
||||
if(is_null($response))
|
||||
throw new OAuth2InvalidIntrospectionResponse(sprintf('http code %s', $ex->getCode()));
|
||||
|
||||
$content_type = $response->getHeader('content-type');
|
||||
$content_type = $response->getHeaderLine('content-type');
|
||||
$is_json = str_contains($content_type, 'application/json');
|
||||
$body = ($is_json) ? $response->json(): $response->getBody();
|
||||
$body = $response->getBody()->getContents();
|
||||
$body = $is_json ? json_decode($body, true): $body;
|
||||
$code = $response->getStatusCode();
|
||||
|
||||
$code = $response->getStatusCode();
|
||||
if ($code === 400 && $is_json && isset($body['error'])
|
||||
&& (
|
||||
$body['error'] === OAuth2Protocol::OAuth2Protocol_Error_InvalidToken ||
|
||||
@ -227,7 +231,7 @@ final class AccessTokenService implements IAccessTokenService
|
||||
$this->cache_service->setSingleValue(md5($token_value).'.revoked', md5($token_value));
|
||||
throw new InvalidGrantTypeException(OAuth2Protocol::OAuth2Protocol_Error_InvalidToken);
|
||||
}
|
||||
throw new OAuth2InvalidIntrospectionResponse(sprintf('http code %s - body %s', $ex->getCode(), $response->getBody()));
|
||||
throw new OAuth2InvalidIntrospectionResponse(sprintf('http code %s - body %s', $ex->getCode(), $body));
|
||||
}
|
||||
}
|
||||
}
|
@ -26,7 +26,7 @@ class Api extends ResourceServerEntity implements IApi
|
||||
{
|
||||
|
||||
/**
|
||||
* @ORM\OneToMany(targetEntity="ApiScope", mappedBy="api", cascade={"persist"})
|
||||
* @ORM\OneToMany(targetEntity="ApiScope", mappedBy="api", cascade={"persist"}, orphanRemoval=true)
|
||||
*/
|
||||
private $scopes;
|
||||
|
||||
|
@ -171,7 +171,7 @@ class ApiEndpoint extends ResourceServerEntity implements IApiEndpoint
|
||||
$this->http_method = $http_method;
|
||||
}
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity="Api", cascade={"persist"})
|
||||
* @ORM\ManyToOne(targetEntity="Api", cascade={"persist"}, inversedBy="endpoints")
|
||||
* @ORM\JoinColumn(name="api_id", referencedColumnName="id")
|
||||
* @var Api
|
||||
*/
|
||||
|
@ -40,7 +40,7 @@ class ApiScope extends ResourceServerEntity implements IApiScope
|
||||
}
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity="Api", cascade={"persist"})
|
||||
* @ORM\ManyToOne(targetEntity="Api", inversedBy="scopes")
|
||||
* @ORM\JoinColumn(name="api_id", referencedColumnName="id")
|
||||
* @var Api
|
||||
*/
|
||||
|
@ -139,5 +139,22 @@ final class RepositoriesProvider extends ServiceProvider
|
||||
return EntityManager::getRepository(\models\summit\RSVP::class);
|
||||
});
|
||||
|
||||
App::singleton(
|
||||
'models\summit\IAbstractCalendarSyncWorkRequestRepository',
|
||||
function(){
|
||||
return EntityManager::getRepository(\models\summit\CalendarSync\WorkQueue\AbstractCalendarSyncWorkRequest::class);
|
||||
});
|
||||
|
||||
App::singleton(
|
||||
'models\summit\ICalendarSyncInfoRepository',
|
||||
function(){
|
||||
return EntityManager::getRepository(\models\summit\CalendarSync\CalendarSyncInfo::class);
|
||||
});
|
||||
|
||||
App::singleton(
|
||||
'models\summit\IScheduleCalendarSyncInfoRepository',
|
||||
function(){
|
||||
return EntityManager::getRepository(\models\summit\CalendarSync\ScheduleCalendarSyncInfo::class);
|
||||
});
|
||||
}
|
||||
}
|
@ -0,0 +1,149 @@
|
||||
<?php namespace repositories\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\Query\Expr\Join;
|
||||
use Doctrine\ORM\Tools\Pagination\Paginator;
|
||||
use models\main\Member;
|
||||
use models\summit\CalendarSync\CalendarSyncInfo;
|
||||
use models\summit\CalendarSync\WorkQueue\AbstractCalendarSyncWorkRequest;
|
||||
use models\summit\CalendarSync\WorkQueue\AdminScheduleSummitActionSyncWorkRequest;
|
||||
use models\summit\IAbstractCalendarSyncWorkRequestRepository;
|
||||
use models\summit\CalendarSync\WorkQueue\MemberEventScheduleSummitActionSyncWorkRequest;
|
||||
use models\summit\SummitEvent;
|
||||
use repositories\SilverStripeDoctrineRepository;
|
||||
use utils\PagingInfo;
|
||||
use utils\PagingResponse;
|
||||
use models\summit\CalendarSync\WorkQueue\MemberScheduleSummitActionSyncWorkRequest;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
/**
|
||||
* Class DoctrineAbstractCalendarSyncWorkRequestRepository
|
||||
* @package repositories\summit
|
||||
*/
|
||||
final class DoctrineAbstractCalendarSyncWorkRequestRepository
|
||||
extends SilverStripeDoctrineRepository
|
||||
implements IAbstractCalendarSyncWorkRequestRepository
|
||||
{
|
||||
|
||||
/**
|
||||
* @param Member $member
|
||||
* @param SummitEvent $event
|
||||
* @param CalendarSyncInfo $calendar_sync_info
|
||||
* @param string|null $type
|
||||
* @return AbstractCalendarSyncWorkRequest
|
||||
*/
|
||||
public function getUnprocessedMemberScheduleWorkRequest($member, $event, $calendar_sync_info, $type = null)
|
||||
{
|
||||
$query = $this->getEntityManager()
|
||||
->createQueryBuilder()
|
||||
->select("r")
|
||||
->from(MemberEventScheduleSummitActionSyncWorkRequest::class, "r")
|
||||
->join('r.summit_event', 'e', Join::WITH, " e.id = :event_id")
|
||||
->join('r.owner', 'o', Join::WITH, " o.id = :member_id")
|
||||
->join('r.calendar_sync_info', 'si', Join::WITH, " si.id = :calendar_sync_info_id");
|
||||
if(!empty($type)){
|
||||
$query = $query
|
||||
->where('r.type = :type')
|
||||
->setParameter('type', $type)->getQuery();
|
||||
}
|
||||
|
||||
$query
|
||||
->setParameter('event_id', $event->getId())
|
||||
->setParameter('member_id', $member->getId())
|
||||
->setParameter('calendar_sync_info_id', $calendar_sync_info->getId());
|
||||
|
||||
return $query->getSingleResult();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $provider
|
||||
* @param PagingInfo $paging_info
|
||||
* @return PagingResponse
|
||||
*/
|
||||
public function getUnprocessedMemberScheduleWorkRequestActionByPage($provider = 'ALL', PagingInfo $paging_info){
|
||||
|
||||
log::debug(sprintf("DoctrineAbstractCalendarSyncWorkRequestRepository::getUnprocessedMemberScheduleWorkRequestActionByPage: provider %s",$provider));
|
||||
$query = $this->getEntityManager()
|
||||
->createQueryBuilder()
|
||||
->select("r")
|
||||
->from(MemberScheduleSummitActionSyncWorkRequest::class, "r")
|
||||
->where('(r.type = :type_add or r.type = :type_remove or r.type = :type_update) and r.is_processed = 0')
|
||||
->orderBy('r.id', 'ASC')
|
||||
->setParameter('type_add',AbstractCalendarSyncWorkRequest::TypeAdd )
|
||||
->setParameter('type_update',AbstractCalendarSyncWorkRequest::TypeUpdate )
|
||||
->setParameter('type_remove',AbstractCalendarSyncWorkRequest::TypeRemove);
|
||||
|
||||
if(CalendarSyncInfo::isValidProvider($provider)){
|
||||
log::debug(sprintf("provider %s is valid",$provider));
|
||||
$query = $query
|
||||
->join('r.calendar_sync_info', 'si', Join::WITH, " si.provider = :provider")
|
||||
->setParameter('provider', $provider);
|
||||
}
|
||||
$query = $query
|
||||
->setFirstResult($paging_info->getOffset())
|
||||
->setMaxResults($paging_info->getPerPage());
|
||||
|
||||
$paginator = new Paginator($query, $fetchJoinCollection = true);
|
||||
$total = $paginator->count();
|
||||
$data = [];
|
||||
|
||||
foreach($paginator as $entity)
|
||||
$data[] = $entity;
|
||||
|
||||
return new PagingResponse
|
||||
(
|
||||
$total,
|
||||
$paging_info->getPerPage(),
|
||||
$paging_info->getCurrentPage(),
|
||||
$paging_info->getLastPage($total),
|
||||
$data
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param PagingInfo $paging_info
|
||||
* @return PagingResponse
|
||||
*/
|
||||
public function getUnprocessedAdminScheduleWorkRequestActionByPage(PagingInfo $paging_info){
|
||||
$query = $this->getEntityManager()
|
||||
->createQueryBuilder()
|
||||
->select("r")
|
||||
->from(AdminScheduleSummitActionSyncWorkRequest::class, "r")
|
||||
->where('(r.type = :type_add or r.type = :type_remove or r.type = :type_update) and r.is_processed = 0')
|
||||
->orderBy('r.id', 'ASC')
|
||||
->setParameter('type_add',AbstractCalendarSyncWorkRequest::TypeAdd )
|
||||
->setParameter('type_update',AbstractCalendarSyncWorkRequest::TypeUpdate )
|
||||
->setParameter('type_remove',AbstractCalendarSyncWorkRequest::TypeRemove);
|
||||
|
||||
$query= $query
|
||||
->setFirstResult($paging_info->getOffset())
|
||||
->setMaxResults($paging_info->getPerPage());
|
||||
|
||||
$paginator = new Paginator($query, $fetchJoinCollection = true);
|
||||
$total = $paginator->count();
|
||||
$data = [];
|
||||
|
||||
foreach($paginator as $entity)
|
||||
$data[] = $entity;
|
||||
|
||||
return new PagingResponse
|
||||
(
|
||||
$total,
|
||||
$paging_info->getPerPage(),
|
||||
$paging_info->getCurrentPage(),
|
||||
$paging_info->getLastPage($total),
|
||||
$data
|
||||
);
|
||||
}
|
||||
}
|
@ -0,0 +1,27 @@
|
||||
<?php namespace repositories\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 models\summit\ICalendarSyncInfoRepository;
|
||||
use repositories\SilverStripeDoctrineRepository;
|
||||
|
||||
/**
|
||||
* Class DoctrineCalendarSyncInfoRepository
|
||||
* @package repositories\summit
|
||||
*/
|
||||
final class DoctrineCalendarSyncInfoRepository
|
||||
extends SilverStripeDoctrineRepository
|
||||
implements ICalendarSyncInfoRepository
|
||||
{
|
||||
|
||||
}
|
@ -0,0 +1,110 @@
|
||||
<?php namespace repositories\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\Query\Expr\Join;
|
||||
use Doctrine\ORM\Tools\Pagination\Paginator;
|
||||
use models\summit\IScheduleCalendarSyncInfoRepository;
|
||||
use models\summit\SummitAbstractLocation;
|
||||
use models\summit\SummitEvent;
|
||||
use models\summit\CalendarSync\ScheduleCalendarSyncInfo;
|
||||
use repositories\SilverStripeDoctrineRepository;
|
||||
use utils\PagingInfo;
|
||||
use utils\PagingResponse;
|
||||
|
||||
/**
|
||||
* Class DoctrineScheduleCalendarSyncInfoRepository
|
||||
* @package repositories\summit
|
||||
*/
|
||||
final class DoctrineScheduleCalendarSyncInfoRepository extends SilverStripeDoctrineRepository
|
||||
implements IScheduleCalendarSyncInfoRepository
|
||||
{
|
||||
|
||||
/**
|
||||
* @param SummitEvent $summit_event
|
||||
* @param PagingInfo $paging_info
|
||||
* @return PagingResponse
|
||||
*/
|
||||
public function getAllBySummitEvent(SummitEvent $summit_event, 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")
|
||||
->orderBy('si.id', 'ASC')
|
||||
->setParameter('event_id', $summit_event->getId())
|
||||
->setParameter('credential_status',false);
|
||||
|
||||
$query= $query
|
||||
->setFirstResult($paging_info->getOffset())
|
||||
->setMaxResults($paging_info->getPerPage());
|
||||
|
||||
$paginator = new Paginator($query, $fetchJoinCollection = true);
|
||||
$total = $paginator->count();
|
||||
$data = [];
|
||||
|
||||
foreach($paginator as $entity)
|
||||
$data[] = $entity;
|
||||
|
||||
return new PagingResponse
|
||||
(
|
||||
$total,
|
||||
$paging_info->getPerPage(),
|
||||
$paging_info->getCurrentPage(),
|
||||
$paging_info->getLastPage($total),
|
||||
$data
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param SummitAbstractLocation $location
|
||||
* @param PagingInfo $paging_info
|
||||
* @return PagingResponse
|
||||
*/
|
||||
public function getAllBySummitLocation(SummitAbstractLocation $location, PagingInfo $paging_info)
|
||||
{
|
||||
$query = $this->getEntityManager()
|
||||
->createQueryBuilder()
|
||||
->select("si")
|
||||
->from(ScheduleCalendarSyncInfo::class, "si")
|
||||
->join('si.location', 'l', Join::WITH, " l.id = :location_id")
|
||||
->join('si.calendar_sync_info', 'ci', Join::WITH, " ci.revoked = :crendential_status")
|
||||
->orderBy('si.id', 'ASC')
|
||||
->setParameter('location_id', $location->getId())
|
||||
->setParameter('crendential_status',false);
|
||||
|
||||
$query= $query
|
||||
->setFirstResult($paging_info->getOffset())
|
||||
->setMaxResults($paging_info->getPerPage());
|
||||
|
||||
$paginator = new Paginator($query, $fetchJoinCollection = true);
|
||||
$total = $paginator->count();
|
||||
$data = [];
|
||||
|
||||
foreach($paginator as $entity)
|
||||
$data[] = $entity;
|
||||
|
||||
return new PagingResponse
|
||||
(
|
||||
$total,
|
||||
$paging_info->getPerPage(),
|
||||
$paging_info->getCurrentPage(),
|
||||
$paging_info->getLastPage($total),
|
||||
$data
|
||||
);
|
||||
}
|
||||
|
||||
}
|
@ -17,6 +17,7 @@ use Doctrine\ORM\Query\Expr\Join;
|
||||
use Doctrine\ORM\Tools\Pagination\Paginator;
|
||||
use models\summit\ISummitNotificationRepository;
|
||||
use models\summit\Summit;
|
||||
use models\summit\SummitPushNotification;
|
||||
use repositories\SilverStripeDoctrineRepository;
|
||||
use utils\Filter;
|
||||
use utils\Order;
|
||||
@ -44,7 +45,7 @@ final class DoctrineSummitNotificationRepository
|
||||
{
|
||||
$query = $this->getEntityManager()->createQueryBuilder()
|
||||
->select("n")
|
||||
->from(\models\summit\SummitPushNotification::class, "n")
|
||||
->from(SummitPushNotification::class, "n")
|
||||
->leftJoin('n.summit_event', 'e')
|
||||
->join('n.summit', 's', Join::WITH, " s.id = :summit_id")
|
||||
->setParameter('summit_id', $summit->getId());
|
||||
|
@ -0,0 +1,42 @@
|
||||
<?php namespace services\apis\CalendarSync;
|
||||
/**
|
||||
* 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\summit\CalendarSync\CalendarSyncInfo;
|
||||
|
||||
/**
|
||||
* Class AbstractCalendarSyncRemoteFacade
|
||||
* @package services\apis\CalendarSync
|
||||
*/
|
||||
abstract class AbstractCalendarSyncRemoteFacade
|
||||
implements ICalendarSyncRemoteFacade
|
||||
{
|
||||
/**
|
||||
* @var CalendarSyncInfo
|
||||
*/
|
||||
protected $sync_calendar_info;
|
||||
|
||||
/**
|
||||
* AbstractCalendarSyncRemoteFacade constructor.
|
||||
* @param CalendarSyncInfo $sync_calendar_info
|
||||
*/
|
||||
public function __construct(CalendarSyncInfo $sync_calendar_info)
|
||||
{
|
||||
$this->sync_calendar_info = $sync_calendar_info;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
abstract public function getSleepInterval();
|
||||
}
|
@ -0,0 +1,56 @@
|
||||
<?php namespace services\apis\CalendarSync;
|
||||
/**
|
||||
* 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\summit\CalendarSync\CalendarSyncInfo;
|
||||
|
||||
/**
|
||||
* Class CalendarSyncRemoteFacadeFactory
|
||||
* @package services\apis\CalendarSync
|
||||
*/
|
||||
final class CalendarSyncRemoteFacadeFactory
|
||||
{
|
||||
private function __construct(){}
|
||||
|
||||
private function __clone(){}
|
||||
|
||||
private static $instance = null;
|
||||
|
||||
/**
|
||||
* @return CalendarSyncRemoteFacadeFactory
|
||||
*/
|
||||
public static function getInstance(){
|
||||
if(self::$instance == null)
|
||||
self::$instance = new CalendarSyncRemoteFacadeFactory();
|
||||
return self::$instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param CalendarSyncInfo $sync_calendar_info
|
||||
* @return ICalendarSyncRemoteFacade|null
|
||||
*/
|
||||
public function build(CalendarSyncInfo $sync_calendar_info){
|
||||
switch($sync_calendar_info->getProvider()){
|
||||
case CalendarSyncInfo::ProviderGoogle:
|
||||
return new GoogleCalendarSyncRemoteFacade($sync_calendar_info);
|
||||
break;
|
||||
case CalendarSyncInfo::ProvideriCloud:
|
||||
return new ICloudCalendarSyncRemoteFacade($sync_calendar_info);
|
||||
break;
|
||||
case CalendarSyncInfo::ProviderOutlook:
|
||||
return new OutlookCalendarSyncRemoteFacade($sync_calendar_info);
|
||||
break;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
@ -0,0 +1,23 @@
|
||||
<?php namespace App\Services\Apis\CalendarSync\Exceptions;
|
||||
/**
|
||||
* 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 Exception;
|
||||
|
||||
/**
|
||||
* Class RateLimitExceededException
|
||||
* @package App\Services\Apis\CalendarSync\Exceptions
|
||||
*/
|
||||
final class RateLimitExceededException extends Exception
|
||||
{
|
||||
|
||||
}
|
@ -0,0 +1,322 @@
|
||||
<?php namespace services\apis\CalendarSync;
|
||||
/**
|
||||
* 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\Services\Apis\CalendarSync\Exceptions\RateLimitExceededException;
|
||||
use models\summit\CalendarSync\CalendarSyncInfo;
|
||||
use models\summit\CalendarSync\CalendarSyncInfoOAuth2;
|
||||
use models\summit\CalendarSync\ScheduleCalendarSyncInfo;
|
||||
use models\summit\CalendarSync\WorkQueue\MemberCalendarScheduleSummitActionSyncWorkRequest;
|
||||
use models\summit\CalendarSync\WorkQueue\MemberEventScheduleSummitActionSyncWorkRequest;
|
||||
use models\summit\SummitEvent;
|
||||
use models\summit\SummitGeoLocatedLocation;
|
||||
use models\summit\SummitVenueRoom;
|
||||
use Illuminate\Support\Facades\Config;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Google_Service_Calendar;
|
||||
use Google_Service_Calendar_Calendar;
|
||||
use Google_Service_Calendar_Event;
|
||||
use Google_Service_Calendar_EventDateTime;
|
||||
use DateTime;
|
||||
use Google_Service_Exception;
|
||||
use Exception;
|
||||
use GuzzleHttp\Psr7\Response;
|
||||
/**
|
||||
* Class GoogleCalendarSyncRemoteFacade
|
||||
* The Google Calendar API has a courtesy limit of 1,000,000 queries per day.
|
||||
* @see https://developers.google.com/google-apps/calendar/pricing
|
||||
* @package services\apis\CalendarSync
|
||||
*/
|
||||
final class GoogleCalendarSyncRemoteFacade
|
||||
extends AbstractCalendarSyncRemoteFacade
|
||||
{
|
||||
|
||||
/**
|
||||
* @var \Google_Client
|
||||
*/
|
||||
private $client;
|
||||
|
||||
/**
|
||||
* GoogleCalendarSyncRemoteFacade constructor.
|
||||
* @param CalendarSyncInfoOAuth2 $sync_calendar_info
|
||||
*/
|
||||
public function __construct(CalendarSyncInfoOAuth2 $sync_calendar_info)
|
||||
{
|
||||
parent::__construct($sync_calendar_info);
|
||||
|
||||
$this->client = new \Google_Client();
|
||||
$this->client->setClientId(Config::get("google_api.google_client_id"));
|
||||
$this->client->setClientSecret(Config::get("google_api.google_client_secret"));
|
||||
//$this->client->setRedirectUri(Config::get("google_api.google_redirect_url"));
|
||||
$this->client->setScopes(explode(',', Config::get("google_api.google_scopes")));
|
||||
$this->client->setApprovalPrompt('force');
|
||||
$this->client->setAccessType('offline');
|
||||
$this->client->setAccessToken($sync_calendar_info->getAccessToken());
|
||||
$this->checkAccessToken();
|
||||
}
|
||||
|
||||
private function checkAccessToken(){
|
||||
if($this->client->isAccessTokenExpired())
|
||||
{
|
||||
$creds = $this->client->fetchAccessTokenWithRefreshToken($this->sync_calendar_info->getRefreshToken());
|
||||
$access_token = isset($creds['access_token']) ? $creds['access_token'] : null;
|
||||
$refresh_token = isset($creds['refresh_token']) ? $creds['refresh_token'] : null;
|
||||
|
||||
if(!empty($access_token)) {
|
||||
$this->sync_calendar_info->setAccessToken($creds);
|
||||
}
|
||||
|
||||
if(!empty($refresh_token))
|
||||
$this->sync_calendar_info->setRefreshToken($refresh_token);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param MemberEventScheduleSummitActionSyncWorkRequest $request
|
||||
* @throws RateLimitExceededException
|
||||
* @throws Google_Service_Exception
|
||||
* @return ScheduleCalendarSyncInfo
|
||||
*/
|
||||
public function addEvent(MemberEventScheduleSummitActionSyncWorkRequest $request)
|
||||
{
|
||||
try {
|
||||
$this->checkAccessToken();
|
||||
$service = new Google_Service_Calendar($this->client);
|
||||
$summit_event = $request->getSummitEvent();
|
||||
$vo = $this->buildEventVO($summit_event);
|
||||
$calendar_id = $this->sync_calendar_info->getExternalId();
|
||||
$created_event = $service->events->insert($calendar_id, $vo);
|
||||
|
||||
// new schedule sync info
|
||||
$sync_info = new ScheduleCalendarSyncInfo();
|
||||
// primitives
|
||||
$sync_info->setEtag($created_event->getEtag());
|
||||
$sync_info->setExternalId($created_event->getId());
|
||||
$sync_info->setExternalUrl($created_event->getHtmlLink());
|
||||
// relationships
|
||||
$sync_info->setSummitEvent($summit_event);
|
||||
$sync_info->setCalendarSyncInfo($this->sync_calendar_info);
|
||||
$sync_info->setLocation($summit_event->getLocation());
|
||||
return $sync_info;
|
||||
}
|
||||
catch(Google_Service_Exception $ex1){
|
||||
Log::warning($ex1);
|
||||
if($ex1->getCode() == 403)
|
||||
throw new RateLimitExceededException($ex1->getMessage(), $ex1->getCode());
|
||||
throw $ex1;
|
||||
}
|
||||
catch (Exception $ex){
|
||||
Log::error($ex);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param SummitEvent $summit_event
|
||||
* @param bool $update
|
||||
* @return Google_Service_Calendar_Event
|
||||
*/
|
||||
private function buildEventVO(SummitEvent $summit_event, $update = false){
|
||||
$vo = new Google_Service_Calendar_Event();
|
||||
$title = $summit_event->getTitle();
|
||||
if($update) $title = "{$title} [UPDATED]";
|
||||
$vo->setSummary($title);
|
||||
$vo->setDescription($summit_event->getAbstract());
|
||||
|
||||
$location = null;
|
||||
|
||||
if($summit_event->hasLocation()){
|
||||
$venue = $summit_event->getLocation();
|
||||
$room = null;
|
||||
if($venue instanceof SummitVenueRoom){
|
||||
$room = $venue;
|
||||
$venue = $venue->getVenue();
|
||||
}
|
||||
if($venue instanceof SummitGeoLocatedLocation) {
|
||||
$location = $venue->getFullAddress($room);
|
||||
}
|
||||
}
|
||||
|
||||
if(!empty($location))
|
||||
$vo->setLocation($location);
|
||||
|
||||
// dates
|
||||
|
||||
$time_zone = $summit_event->getSummit()->getTimeZone()->getName();
|
||||
$start = new Google_Service_Calendar_EventDateTime();
|
||||
$start->setDateTime($summit_event->getLocalStartDate()->format(DateTime::RFC3339));
|
||||
$start->setTimeZone($time_zone);
|
||||
$vo->setStart($start);
|
||||
|
||||
$end = new Google_Service_Calendar_EventDateTime();
|
||||
$end->setDateTime($summit_event->getLocalEndDate()->format(DateTime::RFC3339));
|
||||
$end->setTimeZone($time_zone);
|
||||
$vo->setEnd($end);
|
||||
|
||||
return $vo;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param MemberEventScheduleSummitActionSyncWorkRequest $request
|
||||
* @param ScheduleCalendarSyncInfo $schedule_sync_info
|
||||
* @throws RateLimitExceededException
|
||||
* @throws Google_Service_Exception
|
||||
* @return bool
|
||||
*/
|
||||
public function deleteEvent
|
||||
(
|
||||
MemberEventScheduleSummitActionSyncWorkRequest $request,
|
||||
ScheduleCalendarSyncInfo $schedule_sync_info
|
||||
)
|
||||
{
|
||||
try{
|
||||
$this->checkAccessToken();
|
||||
$service = new Google_Service_Calendar($this->client);
|
||||
$calendar_id = $this->sync_calendar_info->getExternalId();
|
||||
$res = $service->events->delete($calendar_id, $schedule_sync_info->getExternalId());
|
||||
if(!$res instanceof Response) return false;
|
||||
return $res->getStatusCode() == 204;
|
||||
}
|
||||
catch(Google_Service_Exception $ex1){
|
||||
Log::warning($ex1);
|
||||
if($ex1->getCode() == 404) return false;
|
||||
if($ex1->getCode() == 403)
|
||||
throw new RateLimitExceededException($ex1->getMessage(), $ex1->getCode());
|
||||
throw $ex1;
|
||||
}
|
||||
catch (Exception $ex){
|
||||
Log::error($ex);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param MemberEventScheduleSummitActionSyncWorkRequest $request
|
||||
* @param ScheduleCalendarSyncInfo $schedule_sync_info
|
||||
* @throws RateLimitExceededException
|
||||
* @throws Google_Service_Exception
|
||||
* @return bool
|
||||
*/
|
||||
public function updateEvent
|
||||
(
|
||||
MemberEventScheduleSummitActionSyncWorkRequest $request,
|
||||
ScheduleCalendarSyncInfo $schedule_sync_info
|
||||
)
|
||||
{
|
||||
try{
|
||||
$this->checkAccessToken();
|
||||
$service = new Google_Service_Calendar($this->client);
|
||||
$summit_event = $request->getSummitEvent();
|
||||
$vo = $this->buildEventVO($summit_event, true);
|
||||
$calendar_id = $this->sync_calendar_info->getExternalId();
|
||||
|
||||
$updated_event = $service->events->update($calendar_id, $schedule_sync_info->getExternalId(), $vo);
|
||||
// primitives
|
||||
$schedule_sync_info->setEtag($updated_event->getEtag());
|
||||
// relationships
|
||||
$schedule_sync_info->setLocation($summit_event->getLocation());
|
||||
|
||||
return true;
|
||||
}
|
||||
catch(Google_Service_Exception $ex1){
|
||||
Log::warning($ex1);
|
||||
if($ex1->getCode() == 403)
|
||||
throw new RateLimitExceededException($ex1->getMessage(), $ex1->getCode());
|
||||
throw $ex1;
|
||||
}
|
||||
catch (Exception $ex){
|
||||
Log::error($ex);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param MemberCalendarScheduleSummitActionSyncWorkRequest $request
|
||||
* @param CalendarSyncInfo $calendar_sync_info
|
||||
* @throws RateLimitExceededException
|
||||
* @throws Google_Service_Exception
|
||||
* @return bool
|
||||
*/
|
||||
public function createCalendar
|
||||
(
|
||||
MemberCalendarScheduleSummitActionSyncWorkRequest $request,
|
||||
CalendarSyncInfo $calendar_sync_info
|
||||
)
|
||||
{
|
||||
try {
|
||||
$this->checkAccessToken();
|
||||
$service = new Google_Service_Calendar($this->client);
|
||||
$google_calendar = new Google_Service_Calendar_Calendar($this->client);
|
||||
$google_calendar->setSummary($request->getCalendarName());
|
||||
$google_calendar->setDescription($request->getCalendarDescription());
|
||||
$google_calendar->setTimeZone($calendar_sync_info->getSummit()->getTimeZone()->getName());
|
||||
$created_calendar = $service->calendars->insert($google_calendar);
|
||||
$calendar_id = $created_calendar->getId();
|
||||
Log::info(sprintf("GoogleCalendarSyncRemoteFacade::createCalendar: calendarId %s", $calendar_id));
|
||||
$this->sync_calendar_info->setExternalId($calendar_id);
|
||||
$this->sync_calendar_info->setEtag($created_calendar->getEtag());
|
||||
return true;
|
||||
}
|
||||
catch(Google_Service_Exception $ex1){
|
||||
Log::warning($ex1);
|
||||
if($ex1->getCode() == 403)
|
||||
throw new RateLimitExceededException($ex1->getMessage(), $ex1->getCode());
|
||||
throw $ex1;
|
||||
}
|
||||
catch (Exception $ex){
|
||||
Log::error($ex);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param MemberCalendarScheduleSummitActionSyncWorkRequest $request
|
||||
* @param CalendarSyncInfo $calendar_sync_info
|
||||
* @throws RateLimitExceededException
|
||||
* @throws Google_Service_Exception
|
||||
* @return bool
|
||||
*/
|
||||
public function deleteCalendar
|
||||
(
|
||||
MemberCalendarScheduleSummitActionSyncWorkRequest $request,
|
||||
CalendarSyncInfo $calendar_sync_info
|
||||
)
|
||||
{
|
||||
try {
|
||||
$this->checkAccessToken();
|
||||
$service = new Google_Service_Calendar($this->client);
|
||||
Log::info(sprintf("GoogleCalendarSyncRemoteFacade::deleteCalendar: calendarId %s", $calendar_sync_info->getExternalId()));
|
||||
$res = $service->calendars->delete($calendar_sync_info->getExternalId());
|
||||
if(!$res instanceof Response) return false;
|
||||
return $res->getStatusCode() == 204;
|
||||
}
|
||||
catch(Google_Service_Exception $ex1){
|
||||
Log::warning($ex1);
|
||||
if($ex1->getCode() == 404) return false;
|
||||
if($ex1->getCode() == 403)
|
||||
throw new RateLimitExceededException($ex1->getMessage(), $ex1->getCode());
|
||||
throw $ex1;
|
||||
}
|
||||
catch (Exception $ex){
|
||||
Log::error($ex);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getSleepInterval()
|
||||
{
|
||||
return 500;
|
||||
}
|
||||
}
|
60
app/Services/Apis/CalendarSync/ICalendarSyncRemoteFacade.php
Normal file
60
app/Services/Apis/CalendarSync/ICalendarSyncRemoteFacade.php
Normal file
@ -0,0 +1,60 @@
|
||||
<?php namespace services\apis\CalendarSync;
|
||||
/**
|
||||
* 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\summit\CalendarSync\CalendarSyncInfo;
|
||||
use models\summit\CalendarSync\ScheduleCalendarSyncInfo;
|
||||
use models\summit\CalendarSync\WorkQueue\MemberCalendarScheduleSummitActionSyncWorkRequest;
|
||||
use models\summit\CalendarSync\WorkQueue\MemberEventScheduleSummitActionSyncWorkRequest;
|
||||
|
||||
/**
|
||||
* Interface ICalendarSyncRemoteFacade
|
||||
* @package services\apis\CalendarSync
|
||||
*/
|
||||
interface ICalendarSyncRemoteFacade
|
||||
{
|
||||
|
||||
/**
|
||||
* @param MemberEventScheduleSummitActionSyncWorkRequest $request
|
||||
* @return ScheduleCalendarSyncInfo
|
||||
*/
|
||||
public function addEvent(MemberEventScheduleSummitActionSyncWorkRequest $request);
|
||||
|
||||
/**
|
||||
* @param MemberEventScheduleSummitActionSyncWorkRequest $request
|
||||
* @param ScheduleCalendarSyncInfo $schedule_sync_info
|
||||
* @return bool
|
||||
*/
|
||||
public function deleteEvent(MemberEventScheduleSummitActionSyncWorkRequest $request, ScheduleCalendarSyncInfo $schedule_sync_info);
|
||||
|
||||
/**
|
||||
* @param MemberEventScheduleSummitActionSyncWorkRequest $request
|
||||
* @param ScheduleCalendarSyncInfo $schedule_sync_info
|
||||
* @return bool
|
||||
*/
|
||||
public function updateEvent(MemberEventScheduleSummitActionSyncWorkRequest $request, ScheduleCalendarSyncInfo $schedule_sync_info);
|
||||
|
||||
/**
|
||||
* @param MemberCalendarScheduleSummitActionSyncWorkRequest $request
|
||||
* @param CalendarSyncInfo $calendar_sync_info
|
||||
* @return bool
|
||||
*/
|
||||
public function createCalendar(MemberCalendarScheduleSummitActionSyncWorkRequest $request, CalendarSyncInfo $calendar_sync_info);
|
||||
|
||||
/**
|
||||
* @param MemberCalendarScheduleSummitActionSyncWorkRequest $request
|
||||
* @param CalendarSyncInfo $calendar_sync_info
|
||||
* @return bool
|
||||
*/
|
||||
public function deleteCalendar(MemberCalendarScheduleSummitActionSyncWorkRequest $request, CalendarSyncInfo $calendar_sync_info);
|
||||
}
|
@ -0,0 +1,325 @@
|
||||
<?php namespace services\apis\CalendarSync;
|
||||
/**
|
||||
* 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 CalDAVClient\Facade\CalDavClient;
|
||||
use CalDAVClient\Facade\Exceptions\ForbiddenException;
|
||||
use CalDAVClient\Facade\Requests\EventRequestVO;
|
||||
use CalDAVClient\Facade\Requests\MakeCalendarRequestVO;
|
||||
use CalDAVClient\ICalDavClient;
|
||||
use models\summit\CalendarSync\CalendarSyncInfo;
|
||||
use models\summit\CalendarSync\CalendarSyncInfoCalDav;
|
||||
use models\summit\CalendarSync\ScheduleCalendarSyncInfo;
|
||||
use models\summit\CalendarSync\WorkQueue\MemberCalendarScheduleSummitActionSyncWorkRequest;
|
||||
use models\summit\CalendarSync\WorkQueue\MemberEventScheduleSummitActionSyncWorkRequest;
|
||||
use models\summit\SummitEvent;
|
||||
use models\summit\SummitGeoLocatedLocation;
|
||||
use models\summit\SummitVenueRoom;
|
||||
use Illuminate\Support\Facades\Config;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Exception;
|
||||
|
||||
/**
|
||||
* Class ICloudCalendarSyncRemoteFacade
|
||||
* @package services\apis\CalendarSync
|
||||
*/
|
||||
final class ICloudCalendarSyncRemoteFacade
|
||||
extends AbstractCalendarSyncRemoteFacade
|
||||
{
|
||||
/**
|
||||
* @var ICalDavClient
|
||||
*/
|
||||
private $client;
|
||||
|
||||
public function __construct(CalendarSyncInfoCalDav $sync_calendar_info)
|
||||
{
|
||||
parent::__construct($sync_calendar_info);
|
||||
|
||||
$this->client = new CalDavClient(
|
||||
$this->sync_calendar_info->getServer(),
|
||||
$this->sync_calendar_info->getUserName(),
|
||||
$this->sync_calendar_info->getUserPassword()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $prod_id
|
||||
* @param SummitEvent $summit_event
|
||||
* @param bool $update
|
||||
* @return EventRequestVO
|
||||
*/
|
||||
private function buildEventVO($prod_id, SummitEvent $summit_event, $update = false){
|
||||
$location_name = null;
|
||||
$location_title = null;
|
||||
$location_lat = null;
|
||||
$location_lng = null;
|
||||
|
||||
if($summit_event->hasLocation()){
|
||||
$venue = $summit_event->getLocation();
|
||||
$room = null;
|
||||
if($venue instanceof SummitVenueRoom){
|
||||
$room = $venue;
|
||||
$venue = $venue->getVenue();
|
||||
}
|
||||
$location_full_name = $venue->getName();
|
||||
if(!is_null($room)){
|
||||
if($room->hasFloor()){
|
||||
$location_full_name .= ' - '.$room->getFloor()->getName();
|
||||
}
|
||||
$location_full_name .= ' - '.$room->getName();
|
||||
}
|
||||
|
||||
$location_name = $location_full_name;
|
||||
$location_title = $location_full_name;
|
||||
if($venue instanceof SummitGeoLocatedLocation) {
|
||||
$location_lat = $venue->getLat();
|
||||
$location_lng = $venue->getLng();
|
||||
}
|
||||
}
|
||||
|
||||
$title = $summit_event->getTitle();
|
||||
if($update) $title = "{$title} [UPDATED]";
|
||||
return new EventRequestVO(
|
||||
$prod_id,
|
||||
$title,
|
||||
$summit_event->getAbstract(),
|
||||
$summit_event->getSocialSummary(),
|
||||
$summit_event->getLocalStartDate(),
|
||||
$summit_event->getLocalEndDate(),
|
||||
$summit_event->getSummit()->getTimeZone(),
|
||||
$location_name,
|
||||
$location_title,
|
||||
$location_lat,
|
||||
$location_lng
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $calendar_url
|
||||
* @param string $event_url
|
||||
* @return array
|
||||
*/
|
||||
private function getEventInfo($calendar_url, $event_url){
|
||||
$etag = null;
|
||||
$vcard = null;
|
||||
|
||||
try {
|
||||
|
||||
$relative_resource_url = parse_url($event_url, PHP_URL_PATH);
|
||||
|
||||
$events_response = $this->client->getEventsBy
|
||||
(
|
||||
$calendar_url, [
|
||||
$relative_resource_url
|
||||
]);
|
||||
|
||||
if ($events_response->isSuccessFull() && count($events_response->getResponses()) > 0) {
|
||||
$etag = $events_response->getResponses()[0]->getETag();
|
||||
$vcard = $events_response->getResponses()[0]->getVCard();
|
||||
}
|
||||
}
|
||||
catch (\Exception $ex){
|
||||
|
||||
}
|
||||
return [$etag, $vcard];
|
||||
}
|
||||
/**
|
||||
* @param MemberEventScheduleSummitActionSyncWorkRequest $request
|
||||
* @return ScheduleCalendarSyncInfo
|
||||
*/
|
||||
public function addEvent(MemberEventScheduleSummitActionSyncWorkRequest $request)
|
||||
{
|
||||
try {
|
||||
$summit_event = $request->getSummitEvent();
|
||||
$calendar_url = $this->sync_calendar_info->getCalendarUrl();
|
||||
$vo = $this->buildEventVO($this->sync_calendar_info->getCalendarDisplayName(), $summit_event);
|
||||
$res = $this->client->createEvent(
|
||||
$calendar_url,
|
||||
$vo
|
||||
);
|
||||
|
||||
$etag = $res->getETag();
|
||||
$vcard = "";
|
||||
|
||||
if (empty($etag)) {
|
||||
list($etag, $vcard) = $this->getEventInfo($calendar_url, $res->getResourceUrl());
|
||||
}
|
||||
|
||||
$sync_info = new ScheduleCalendarSyncInfo();
|
||||
// primitives
|
||||
$sync_info->setEtag($etag);
|
||||
$sync_info->setExternalId($res->getUid());
|
||||
$sync_info->setExternalUrl($res->getResourceUrl());
|
||||
$sync_info->setVCard($vcard);
|
||||
// relationships
|
||||
$sync_info->setSummitEvent($summit_event);
|
||||
$sync_info->setCalendarSyncInfo($this->sync_calendar_info);
|
||||
$sync_info->setLocation($summit_event->getLocation());
|
||||
|
||||
return $sync_info;
|
||||
}
|
||||
catch (Exception $ex){
|
||||
Log::error($ex);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param MemberEventScheduleSummitActionSyncWorkRequest $request
|
||||
* @param ScheduleCalendarSyncInfo $schedule_sync_info
|
||||
* @return bool
|
||||
*/
|
||||
public function updateEvent
|
||||
(
|
||||
MemberEventScheduleSummitActionSyncWorkRequest $request,
|
||||
ScheduleCalendarSyncInfo $schedule_sync_info
|
||||
)
|
||||
{
|
||||
try {
|
||||
$summit_event = $request->getSummitEvent();
|
||||
$calendar_url = $this->sync_calendar_info->getCalendarUrl();
|
||||
$vo = $this->buildEventVO($this->sync_calendar_info->getCalendarDisplayName(), $summit_event, true);
|
||||
$vo->setUID($schedule_sync_info->getExternalId());
|
||||
$res = $this->client->updateEvent(
|
||||
$calendar_url,
|
||||
$vo,
|
||||
$schedule_sync_info->getEtag()
|
||||
);
|
||||
|
||||
$etag = $res->getETag();
|
||||
$vcard = "";
|
||||
|
||||
if (empty($etag)) {
|
||||
list($etag, $vcard) = $this->getEventInfo($calendar_url, $res->getResourceUrl());
|
||||
}
|
||||
|
||||
// primitives
|
||||
$schedule_sync_info->setEtag($etag);
|
||||
$schedule_sync_info->setVCard($vcard);
|
||||
// relationships
|
||||
$schedule_sync_info->setLocation($summit_event->getLocation());
|
||||
return true;
|
||||
}
|
||||
catch (Exception $ex){
|
||||
Log::error($ex);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param MemberEventScheduleSummitActionSyncWorkRequest $request
|
||||
* @param ScheduleCalendarSyncInfo $schedule_sync_info
|
||||
* @return bool
|
||||
*/
|
||||
public function deleteEvent(MemberEventScheduleSummitActionSyncWorkRequest $request, ScheduleCalendarSyncInfo $schedule_sync_info)
|
||||
{
|
||||
try{
|
||||
if(empty($schedule_sync_info->getEtag())) return false;
|
||||
$res = $this->client->deleteEvent
|
||||
(
|
||||
$this->sync_calendar_info->getCalendarUrl(),
|
||||
$schedule_sync_info->getExternalId(),
|
||||
$schedule_sync_info->getEtag()
|
||||
);
|
||||
|
||||
return $res->isSuccessFull();
|
||||
return true;
|
||||
}
|
||||
catch (Exception $ex){
|
||||
Log::error($ex);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param MemberCalendarScheduleSummitActionSyncWorkRequest $request
|
||||
* @param CalendarSyncInfo $calendar_sync_info
|
||||
* @return bool
|
||||
*/
|
||||
public function createCalendar(MemberCalendarScheduleSummitActionSyncWorkRequest $request, CalendarSyncInfo $calendar_sync_info)
|
||||
{
|
||||
try{
|
||||
try {
|
||||
// get calendar home url
|
||||
$user_ppal_url = $this->sync_calendar_info->getUserPrincipalUrl();
|
||||
$res = $this->client->getCalendarHome
|
||||
(
|
||||
$user_ppal_url
|
||||
);
|
||||
$calendar_home = $res->getCalendarHomeSetUrl();
|
||||
$real_server = $res->getRealCalDAVHost();
|
||||
|
||||
// make calendar
|
||||
$summit = $this->sync_calendar_info->getSummit();
|
||||
$calendar_url = $this->client->createCalendar($calendar_home,
|
||||
new MakeCalendarRequestVO(
|
||||
$request->getCalendarId(),
|
||||
$request->getCalendarName(),
|
||||
$request->getCalendarDescription(),
|
||||
$summit->getTimeZone()
|
||||
)
|
||||
);
|
||||
$calendar_url = rtrim($calendar_url, '/') . '/';
|
||||
}
|
||||
catch(ForbiddenException $ex){
|
||||
// calendar already exists
|
||||
$calendar_url = $calendar_home.'/'.$request->getCalendarId().'/';
|
||||
}
|
||||
|
||||
$this->sync_calendar_info->setUserPrincipalUrl
|
||||
(
|
||||
str_replace
|
||||
(
|
||||
Config::get("apple_api.base_caldav_server"),
|
||||
$real_server,
|
||||
$user_ppal_url
|
||||
)
|
||||
);
|
||||
|
||||
$this->sync_calendar_info->setCalendarDisplayName($request->getCalendarName());
|
||||
$this->sync_calendar_info->setExternalId($calendar_url);
|
||||
|
||||
$res = $this->client->getCalendar($calendar_url);
|
||||
$this->sync_calendar_info->setCalendarSyncToken($res->getSyncToken());
|
||||
return true;
|
||||
}
|
||||
catch (Exception $ex){
|
||||
Log::error($ex);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param MemberCalendarScheduleSummitActionSyncWorkRequest $request
|
||||
* @param CalendarSyncInfo $calendar_sync_info
|
||||
* @return bool
|
||||
*/
|
||||
public function deleteCalendar(MemberCalendarScheduleSummitActionSyncWorkRequest $request, CalendarSyncInfo $calendar_sync_info)
|
||||
{
|
||||
try {
|
||||
$this->client->deleteCalendar($this->sync_calendar_info->getExternalId());
|
||||
return true;
|
||||
}
|
||||
catch (Exception $ex){
|
||||
Log::error($ex);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getSleepInterval()
|
||||
{
|
||||
return 500;
|
||||
}
|
||||
}
|
@ -0,0 +1,299 @@
|
||||
<?php namespace services\apis\CalendarSync;
|
||||
/**
|
||||
* 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\summit\CalendarSync\CalendarSyncInfo;
|
||||
use models\summit\CalendarSync\CalendarSyncInfoOAuth2;
|
||||
use models\summit\CalendarSync\ScheduleCalendarSyncInfo;
|
||||
use models\summit\CalendarSync\WorkQueue\MemberCalendarScheduleSummitActionSyncWorkRequest;
|
||||
use models\summit\CalendarSync\WorkQueue\MemberEventScheduleSummitActionSyncWorkRequest;
|
||||
use models\summit\SummitEvent;
|
||||
use models\summit\SummitGeoLocatedLocation;
|
||||
use models\summit\SummitVenueRoom;
|
||||
use OutlookRestClient\Facade\OutlookRestClient;
|
||||
use OutlookRestClient\Facade\Requests\AddressVO;
|
||||
use OutlookRestClient\Facade\Requests\CalendarVO;
|
||||
use OutlookRestClient\Facade\Requests\EventVO;
|
||||
use OutlookRestClient\Facade\Requests\LocationVO;
|
||||
use OutlookRestClient\Facade\Responses\CalendarResponse;
|
||||
use OutlookRestClient\Facade\Responses\ErrorResponse;
|
||||
use OutlookRestClient\IOutlookRestClient;
|
||||
use Exception;
|
||||
use LogicException;
|
||||
use RuntimeException;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
/**
|
||||
* Class OutlookCalendarSyncRemoteFacade
|
||||
* @package services\apis\CalendarSync
|
||||
*/
|
||||
final class OutlookCalendarSyncRemoteFacade
|
||||
extends AbstractCalendarSyncRemoteFacade
|
||||
{
|
||||
|
||||
/**
|
||||
* @var IOutlookRestClient
|
||||
*/
|
||||
private $client;
|
||||
|
||||
|
||||
/**
|
||||
* OutlookCalendarSyncRemoteFacade constructor.
|
||||
* @param CalendarSyncInfoOAuth2 $sync_calendar_info
|
||||
*/
|
||||
public function __construct(CalendarSyncInfoOAuth2 $sync_calendar_info)
|
||||
{
|
||||
parent::__construct($sync_calendar_info);
|
||||
|
||||
$this->client = new OutlookRestClient();
|
||||
$this->client->setAccessToken($sync_calendar_info->getAccessToken());
|
||||
$this->client->setTokenCallback(function($access_token){
|
||||
|
||||
$this->sync_calendar_info->setAccessToken($access_token);
|
||||
|
||||
if(isset($access_token['refresh_token']))
|
||||
$this->sync_calendar_info->setRefreshToken($access_token['refresh_token']);
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param SummitEvent $summit_event
|
||||
* @param bool $update
|
||||
* @return EventVO
|
||||
*/
|
||||
private function buildEventVO(SummitEvent $summit_event, $update = false){
|
||||
|
||||
try {
|
||||
$location_name = null;
|
||||
$location_title = null;
|
||||
$location_lat = null;
|
||||
$location_lng = null;
|
||||
$location_street = null;
|
||||
$location_city = null;
|
||||
$location_state = null;
|
||||
$location_country = null;
|
||||
$location_postal_code = null;
|
||||
|
||||
if ($summit_event->hasLocation()) {
|
||||
$venue = $summit_event->getLocation();
|
||||
$room = null;
|
||||
if ($venue instanceof SummitVenueRoom) {
|
||||
$room = $venue;
|
||||
$venue = $venue->getVenue();
|
||||
}
|
||||
$location_full_name = $venue->getName();
|
||||
if (!is_null($room)) {
|
||||
if ($room->hasFloor()) {
|
||||
$location_full_name .= ', ' . $room->getFloor()->getName();
|
||||
}
|
||||
$location_full_name .= ', ' . $room->getName();
|
||||
}
|
||||
|
||||
$location_name = $location_full_name;
|
||||
$location_title = $location_full_name;
|
||||
if ($venue instanceof SummitGeoLocatedLocation) {
|
||||
$location_lat = $venue->getLat();
|
||||
$location_lng = $venue->getLng();
|
||||
$location_street = $venue->getAddress1();
|
||||
$location_city = $venue->getCity();
|
||||
$location_state = $venue->getState();
|
||||
$location_country = $venue->getCountry();
|
||||
$location_postal_code = $venue->getZipCode();
|
||||
}
|
||||
}
|
||||
$title = $summit_event->getTitle();
|
||||
if($update) $title = "{$title} [UPDATED]";
|
||||
return new EventVO(
|
||||
$title,
|
||||
$summit_event->getAbstract(),
|
||||
$summit_event->getLocalStartDate(),
|
||||
$summit_event->getLocalEndDate(),
|
||||
$summit_event->getSummit()->getTimeZone(),
|
||||
new LocationVO
|
||||
(
|
||||
$location_name,
|
||||
new AddressVO
|
||||
(
|
||||
$location_street,
|
||||
$location_city,
|
||||
$location_state,
|
||||
$location_country,
|
||||
$location_postal_code
|
||||
),
|
||||
$location_lat,
|
||||
$location_lng
|
||||
)
|
||||
);
|
||||
}
|
||||
catch (Exception $ex){
|
||||
Log::error($ex);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param MemberEventScheduleSummitActionSyncWorkRequest $request
|
||||
* @return ScheduleCalendarSyncInfo
|
||||
*/
|
||||
public function addEvent(MemberEventScheduleSummitActionSyncWorkRequest $request)
|
||||
{
|
||||
try {
|
||||
$summit_event = $request->getSummitEvent();
|
||||
$vo = $this->buildEventVO($summit_event);
|
||||
if(is_null($vo)) throw new LogicException();
|
||||
$calendar_id = $this->sync_calendar_info->getExternalId();
|
||||
$created_event = $this->client->createEvent($calendar_id, $vo);
|
||||
// new schedule sync info
|
||||
$sync_info = new ScheduleCalendarSyncInfo();
|
||||
// primitives
|
||||
$sync_info->setEtag($created_event->getEtag());
|
||||
$sync_info->setExternalId($created_event->getId());
|
||||
$sync_info->setExternalUrl($created_event->getDataId());
|
||||
// relationships
|
||||
$sync_info->setSummitEvent($summit_event);
|
||||
$sync_info->setCalendarSyncInfo($this->sync_calendar_info);
|
||||
$sync_info->setLocation($summit_event->getLocation());
|
||||
return $sync_info;
|
||||
}
|
||||
catch (Exception $ex){
|
||||
Log::error($ex);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param MemberEventScheduleSummitActionSyncWorkRequest $request
|
||||
* @param ScheduleCalendarSyncInfo $schedule_sync_info
|
||||
* @return bool
|
||||
*/
|
||||
public function deleteEvent
|
||||
(
|
||||
MemberEventScheduleSummitActionSyncWorkRequest $request,
|
||||
ScheduleCalendarSyncInfo $schedule_sync_info
|
||||
)
|
||||
{
|
||||
try {
|
||||
$res = $this->client->deleteEvent($schedule_sync_info->getExternalId());
|
||||
return !($res instanceof ErrorResponse);
|
||||
}
|
||||
catch (Exception $ex){
|
||||
Log::error($ex);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param MemberEventScheduleSummitActionSyncWorkRequest $request
|
||||
* @param ScheduleCalendarSyncInfo $schedule_sync_info
|
||||
* @return bool
|
||||
*/
|
||||
public function updateEvent
|
||||
(
|
||||
MemberEventScheduleSummitActionSyncWorkRequest $request,
|
||||
ScheduleCalendarSyncInfo $schedule_sync_info
|
||||
)
|
||||
{
|
||||
try {
|
||||
$summit_event = $request->getSummitEvent();
|
||||
$vo = $this->buildEventVO($summit_event, true);
|
||||
if(is_null($vo)) throw new LogicException();
|
||||
$event_id = $schedule_sync_info->getExternalId();
|
||||
$updated_event = $this->client->updateEvent($event_id, $vo);
|
||||
// primitives
|
||||
$schedule_sync_info->setEtag($updated_event->getEtag());
|
||||
// relationships
|
||||
$schedule_sync_info->setLocation($summit_event->getLocation());
|
||||
return true;
|
||||
}
|
||||
catch (Exception $ex){
|
||||
Log::error($ex);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param MemberCalendarScheduleSummitActionSyncWorkRequest $request
|
||||
* @param CalendarSyncInfo $calendar_sync_info
|
||||
* @return bool
|
||||
*/
|
||||
public function createCalendar
|
||||
(
|
||||
MemberCalendarScheduleSummitActionSyncWorkRequest $request,
|
||||
CalendarSyncInfo $calendar_sync_info
|
||||
)
|
||||
{
|
||||
try {
|
||||
$res = $this->client->createCalendar(new CalendarVO
|
||||
(
|
||||
$request->getCalendarName()
|
||||
));
|
||||
|
||||
if ($res instanceof CalendarResponse) {
|
||||
|
||||
$this->sync_calendar_info->setExternalId($res->getId());
|
||||
$this->sync_calendar_info->setEtag($res->getChangeKey());
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
catch (Exception $ex){
|
||||
Log::error($ex);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param MemberCalendarScheduleSummitActionSyncWorkRequest $request
|
||||
* @param CalendarSyncInfo $calendar_sync_info
|
||||
* @return bool
|
||||
*/
|
||||
public function deleteCalendar
|
||||
(
|
||||
MemberCalendarScheduleSummitActionSyncWorkRequest $request,
|
||||
CalendarSyncInfo $calendar_sync_info
|
||||
)
|
||||
{
|
||||
try {
|
||||
do {
|
||||
$res = $this->client->deleteCalendar($calendar_sync_info->getExternalId());
|
||||
$deleted = is_bool($res) ? $res : false;
|
||||
if ($res instanceof ErrorResponse) {
|
||||
if($res->getErrorCode() == "ErrorItemNotFound"){$delete = true; break;}
|
||||
// @see https://stackoverflow.com/questions/31923669/office-365-unified-api-error-when-deleting-a-calendar
|
||||
// @see https://stackoverflow.com/questions/44597230/office365-calendar-rest-api-cannot-delete-calendars
|
||||
// change name ...
|
||||
$this->client->updateCalendar($calendar_sync_info->getExternalId(), new CalendarVO(
|
||||
md5(uniqid(mt_rand(), true))
|
||||
));
|
||||
}
|
||||
|
||||
} while (!$deleted);
|
||||
return $deleted;
|
||||
}
|
||||
catch (Exception $ex){
|
||||
Log::error($ex);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getSleepInterval()
|
||||
{
|
||||
return 500;
|
||||
}
|
||||
}
|
@ -1,7 +1,4 @@
|
||||
<?php
|
||||
namespace services\apis;
|
||||
use GuzzleHttp\Client;
|
||||
|
||||
<?php namespace services\apis;
|
||||
/**
|
||||
* Copyright 2016 OpenStack Foundation
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
@ -14,6 +11,15 @@ use GuzzleHttp\Client;
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
**/
|
||||
use GuzzleHttp\Client;
|
||||
use Exception;
|
||||
use GuzzleHttp\Exception\RequestException;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
/**
|
||||
* Class EventbriteAPI
|
||||
* @package services\apis
|
||||
*/
|
||||
final class EventbriteAPI implements IEventbriteAPI
|
||||
{
|
||||
|
||||
@ -37,33 +43,42 @@ final class EventbriteAPI implements IEventbriteAPI
|
||||
*/
|
||||
public function getEntity($api_url, array $params)
|
||||
{
|
||||
if(strstr($api_url, self::BaseUrl) === false) throw new Exception('invalid base url!');
|
||||
$client = new Client();
|
||||
try {
|
||||
if (strstr($api_url, self::BaseUrl) === false)
|
||||
throw new Exception('invalid base url!');
|
||||
|
||||
$query = array
|
||||
(
|
||||
'token' => $this->auth_info['token']
|
||||
);
|
||||
$client = new Client();
|
||||
|
||||
foreach($params as $param => $value)
|
||||
{
|
||||
$query[$param] = $value;
|
||||
}
|
||||
|
||||
$response = $client->get($api_url, array
|
||||
$query = array
|
||||
(
|
||||
'query' => $query
|
||||
)
|
||||
);
|
||||
'token' => $this->auth_info['token']
|
||||
);
|
||||
|
||||
if($response->getStatusCode() !== 200) throw new Exception('invalid status code!');
|
||||
$content_type = $response->getHeader('content-type');
|
||||
if(empty($content_type)) throw new Exception('invalid content type!');
|
||||
if($content_type !== 'application/json') throw new Exception('invalid content type!');
|
||||
foreach ($params as $param => $value) {
|
||||
$query[$param] = $value;
|
||||
}
|
||||
|
||||
$json = $response->getBody()->getContents();
|
||||
return json_decode($json, true);
|
||||
$response = $client->get($api_url, array
|
||||
(
|
||||
'query' => $query
|
||||
)
|
||||
);
|
||||
|
||||
if ($response->getStatusCode() !== 200)
|
||||
throw new Exception('invalid status code!');
|
||||
$content_type = $response->getHeaderLine('content-type');
|
||||
if (empty($content_type))
|
||||
throw new Exception('invalid content type!');
|
||||
if ($content_type !== 'application/json')
|
||||
throw new Exception('invalid content type!');
|
||||
|
||||
$json = $response->getBody()->getContents();
|
||||
return json_decode($json, true);
|
||||
}
|
||||
catch(RequestException $ex){
|
||||
Log::warning($ex->getMessage());
|
||||
throw $ex;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -73,7 +88,7 @@ final class EventbriteAPI implements IEventbriteAPI
|
||||
public function getOrder($order_id)
|
||||
{
|
||||
$order_id = intval($order_id);
|
||||
$url = sprintf('%s/orders/%s', self::BaseUrl, $order_id);
|
||||
$url = sprintf('%s/orders/%s', self::BaseUrl, $order_id);
|
||||
return $this->getEntity($url, array('expand' => 'attendees'));
|
||||
}
|
||||
}
|
@ -12,8 +12,11 @@
|
||||
* limitations under the License.
|
||||
**/
|
||||
use GuzzleHttp\Client;
|
||||
use GuzzleHttp\Exception\ClientException;
|
||||
use models\main\PushNotificationMessagePriority;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Exception;
|
||||
|
||||
/**
|
||||
* Class FireBaseGCMApi
|
||||
* @package services\apis
|
||||
@ -56,20 +59,19 @@ final class FireBaseGCMApi implements IPushNotificationApi
|
||||
$response = $client->post($endpoint, [
|
||||
'headers' => [
|
||||
'Authorization' => sprintf('key=%s', $this->api_server_key),
|
||||
'Content-Type' => 'application/json'
|
||||
],
|
||||
'body' => json_encode($message)
|
||||
'json' => $message
|
||||
]);
|
||||
|
||||
if ($response->getStatusCode() !== 200) $res = $res && false;
|
||||
}
|
||||
return $res;
|
||||
}
|
||||
catch (\GuzzleHttp\Exception\ClientException $ex1){
|
||||
catch (ClientException $ex1){
|
||||
Log::error($ex1->getMessage());
|
||||
return false;
|
||||
}
|
||||
catch(\Exception $ex){
|
||||
catch(Exception $ex){
|
||||
Log::error($ex->getMessage());
|
||||
return false;
|
||||
}
|
||||
|
67
app/Services/Model/AdminActionsCalendarSyncPreProcessor.php
Normal file
67
app/Services/Model/AdminActionsCalendarSyncPreProcessor.php
Normal file
@ -0,0 +1,67 @@
|
||||
<?php namespace App\Services\Model;
|
||||
/**
|
||||
* 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\Services\Model\Strategies\ICalendarSyncWorkRequestPreProcessorStrategyFactory;
|
||||
|
||||
/**
|
||||
* Class AdminActionsCalendarSyncPreProcessor
|
||||
* @package App\Services\Model
|
||||
*/
|
||||
final class AdminActionsCalendarSyncPreProcessor
|
||||
implements ICalendarSyncWorkRequestPreProcessor
|
||||
{
|
||||
|
||||
/**
|
||||
* @var ICalendarSyncWorkRequestQueueManager
|
||||
*/
|
||||
private $queue_manager;
|
||||
|
||||
|
||||
/**
|
||||
* @var ICalendarSyncWorkRequestPreProcessorStrategyFactory
|
||||
*/
|
||||
private $strategy_factory;
|
||||
|
||||
/**
|
||||
* AdminActionsCalendarSyncPreProcessor constructor.
|
||||
* @param ICalendarSyncWorkRequestQueueManager $queue_manager
|
||||
* @param ICalendarSyncWorkRequestPreProcessorStrategyFactory $strategy_factory
|
||||
*/
|
||||
public function __construct
|
||||
(
|
||||
ICalendarSyncWorkRequestQueueManager $queue_manager,
|
||||
ICalendarSyncWorkRequestPreProcessorStrategyFactory $strategy_factory
|
||||
)
|
||||
{
|
||||
$this->queue_manager = $queue_manager;
|
||||
$this->strategy_factory = $strategy_factory;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $requests
|
||||
* @return array
|
||||
*/
|
||||
public function preProcessActions(array $requests)
|
||||
{
|
||||
foreach ($requests as $request){
|
||||
$strategy = $this->strategy_factory->build($this->queue_manager, $request);
|
||||
if(is_null($strategy)) continue;
|
||||
$request = $strategy->process($request);
|
||||
if(!is_null($request))
|
||||
$this->queue_manager->registerRequest($request);
|
||||
}
|
||||
|
||||
return $this->queue_manager->getPurgedRequests();
|
||||
}
|
||||
}
|
166
app/Services/Model/AdminActionsCalendarSyncProcessingService.php
Normal file
166
app/Services/Model/AdminActionsCalendarSyncProcessingService.php
Normal file
@ -0,0 +1,166 @@
|
||||
<?php namespace App\Services\Model;
|
||||
/**
|
||||
* 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 libs\utils\ITransactionService;
|
||||
use models\summit\CalendarSync\ScheduleCalendarSyncInfo;
|
||||
use models\summit\CalendarSync\WorkQueue\AbstractCalendarSyncWorkRequest;
|
||||
use models\summit\CalendarSync\WorkQueue\AdminScheduleSummitActionSyncWorkRequest;
|
||||
use models\summit\CalendarSync\WorkQueue\AdminSummitEventActionSyncWorkRequest;
|
||||
use models\summit\CalendarSync\WorkQueue\AdminSummitLocationActionSyncWorkRequest;
|
||||
use models\summit\CalendarSync\WorkQueue\MemberEventScheduleSummitActionSyncWorkRequest;
|
||||
use models\summit\IAbstractCalendarSyncWorkRequestRepository;
|
||||
use models\summit\ICalendarSyncInfoRepository;
|
||||
use models\summit\IScheduleCalendarSyncInfoRepository;
|
||||
use utils\PagingInfo;
|
||||
use Doctrine\DBAL\DBALException;
|
||||
use Exception;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
/**
|
||||
* Class AdminActionsCalendarSyncProcessingService
|
||||
* @package App\Services\Model
|
||||
*/
|
||||
final class AdminActionsCalendarSyncProcessingService
|
||||
implements IAdminActionsCalendarSyncProcessingService
|
||||
{
|
||||
|
||||
/**
|
||||
* @var IAbstractCalendarSyncWorkRequestRepository
|
||||
*/
|
||||
private $work_request_repository;
|
||||
|
||||
/**
|
||||
* @var ICalendarSyncInfoRepository
|
||||
*/
|
||||
private $calendar_sync_repository;
|
||||
|
||||
/**
|
||||
* @var IScheduleCalendarSyncInfoRepository
|
||||
*/
|
||||
private $schedule_sync_repository;
|
||||
|
||||
/**
|
||||
* @var ITransactionService
|
||||
*/
|
||||
private $tx_manager;
|
||||
|
||||
/**
|
||||
* @var ICalendarSyncWorkRequestPreProcessor
|
||||
*/
|
||||
private $preprocessor_requests;
|
||||
|
||||
/**
|
||||
* AdminActionsCalendarSyncProcessingService constructor.
|
||||
* @param IAbstractCalendarSyncWorkRequestRepository $work_request_repository
|
||||
* @param ICalendarSyncInfoRepository $calendar_sync_repository
|
||||
* @param IScheduleCalendarSyncInfoRepository $schedule_sync_repository
|
||||
* @param ICalendarSyncWorkRequestPreProcessor $preprocessor_requests
|
||||
* @param ITransactionService $tx_manager
|
||||
*/
|
||||
public function __construct
|
||||
(
|
||||
IAbstractCalendarSyncWorkRequestRepository $work_request_repository,
|
||||
ICalendarSyncInfoRepository $calendar_sync_repository,
|
||||
IScheduleCalendarSyncInfoRepository $schedule_sync_repository,
|
||||
ICalendarSyncWorkRequestPreProcessor $preprocessor_requests,
|
||||
ITransactionService $tx_manager
|
||||
)
|
||||
{
|
||||
$this->work_request_repository = $work_request_repository;
|
||||
$this->calendar_sync_repository = $calendar_sync_repository;
|
||||
$this->schedule_sync_repository = $schedule_sync_repository;
|
||||
$this->preprocessor_requests = $preprocessor_requests;
|
||||
$this->tx_manager = $tx_manager;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $batch_size
|
||||
* @return int
|
||||
*/
|
||||
public function processActions($batch_size = PHP_INT_MAX)
|
||||
{
|
||||
return $this->tx_manager->transaction(function() use($batch_size){
|
||||
$count = 0;
|
||||
|
||||
$res = $this->work_request_repository->getUnprocessedAdminScheduleWorkRequestActionByPage
|
||||
(
|
||||
new PagingInfo(1, $batch_size)
|
||||
);
|
||||
|
||||
foreach ($this->preprocessor_requests->preProcessActions($res->getItems()) as $request){
|
||||
|
||||
try {
|
||||
if (!$request instanceof AdminScheduleSummitActionSyncWorkRequest) continue;
|
||||
|
||||
if($request instanceof AdminSummitEventActionSyncWorkRequest){
|
||||
|
||||
$page = 1;
|
||||
$summit_event = $request->getSummitEvent();
|
||||
|
||||
do{
|
||||
$page_response = $this->schedule_sync_repository->getAllBySummitEvent($summit_event, new PagingInfo($page, 1000));
|
||||
$has_more = count($page_response->getItems()) > 0;
|
||||
if(!$has_more) continue;
|
||||
foreach ($page_response->getItems() as $schedule_event){
|
||||
if(!$schedule_event instanceof ScheduleCalendarSyncInfo) continue;
|
||||
$work_request = new MemberEventScheduleSummitActionSyncWorkRequest();
|
||||
$work_request->setType($request->getType());
|
||||
$work_request->setCalendarSyncInfo($schedule_event->getCalendarSyncInfo());
|
||||
$work_request->setOwner($schedule_event->getMember());
|
||||
$work_request->setSummitEvent($summit_event);
|
||||
$this->work_request_repository->add($work_request);
|
||||
}
|
||||
$page++;
|
||||
|
||||
}while($has_more);
|
||||
}
|
||||
|
||||
if($request instanceof AdminSummitLocationActionSyncWorkRequest){
|
||||
$location = $request->getLocation();
|
||||
$page = 1;
|
||||
|
||||
do{
|
||||
$page_response = $this->schedule_sync_repository->getAllBySummitLocation($location, new PagingInfo($page, 1000));
|
||||
$has_more = count($page_response->getItems()) > 0;
|
||||
if(!$has_more) continue;
|
||||
foreach ($page_response->getItems() as $schedule_event){
|
||||
if(!$schedule_event instanceof ScheduleCalendarSyncInfo) continue;
|
||||
$work_request = new MemberEventScheduleSummitActionSyncWorkRequest();
|
||||
// always is update no matter what
|
||||
$work_request->setType(AbstractCalendarSyncWorkRequest::TypeUpdate);
|
||||
$work_request->setCalendarSyncInfo($schedule_event->getCalendarSyncInfo());
|
||||
$work_request->setOwner($schedule_event->getMember());
|
||||
$work_request->setSummitEvent($summit_event);
|
||||
$this->work_request_repository->add($work_request);
|
||||
}
|
||||
$page++;
|
||||
|
||||
}while($has_more);
|
||||
}
|
||||
|
||||
$request->markProcessed();
|
||||
$count++;
|
||||
}
|
||||
catch(DBALException $ex1){
|
||||
echo 'DBALException !!'.PHP_EOL;
|
||||
Log::error($ex1);
|
||||
}
|
||||
catch(Exception $ex6){
|
||||
echo 'Exception !!'.PHP_EOL;
|
||||
Log::error($ex6);
|
||||
}
|
||||
}
|
||||
return $count;
|
||||
});
|
||||
}
|
||||
}
|
152
app/Services/Model/AdminScheduleWorkQueueManager.php
Normal file
152
app/Services/Model/AdminScheduleWorkQueueManager.php
Normal file
@ -0,0 +1,152 @@
|
||||
<?php namespace App\Services\Model;
|
||||
/**
|
||||
* 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\summit\CalendarSync\WorkQueue\AbstractCalendarSyncWorkRequest;
|
||||
use models\summit\CalendarSync\WorkQueue\AdminSummitEventActionSyncWorkRequest;
|
||||
use models\summit\CalendarSync\WorkQueue\AdminSummitLocationActionSyncWorkRequest;
|
||||
|
||||
/**
|
||||
* Class AdminScheduleWorkQueueManager
|
||||
* @package App\Services\Model
|
||||
*/
|
||||
final class AdminScheduleWorkQueueManager
|
||||
implements ICalendarSyncWorkRequestQueueManager
|
||||
{
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
private $registered_requests = [];
|
||||
|
||||
/**
|
||||
* @param AbstractCalendarSyncWorkRequest $request
|
||||
* @return string
|
||||
*/
|
||||
private function getKey(AbstractCalendarSyncWorkRequest $request){
|
||||
$event_id = null;
|
||||
$location_id = null;
|
||||
if($request instanceof AdminSummitEventActionSyncWorkRequest){
|
||||
$event_id = $request->getSummitEvent()->getId();
|
||||
}
|
||||
if($request instanceof AdminSummitLocationActionSyncWorkRequest){
|
||||
$location_id = $request->getLocation()->getId();
|
||||
}
|
||||
return $this->generateKey($request->getType(), $event_id, $location_id);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $type
|
||||
* @param int $event_id
|
||||
* @param int $location_id
|
||||
* @return string
|
||||
*/
|
||||
private function generateKey($type, $event_id = null, $location_id = null){
|
||||
$sub_type = !is_null($event_id) ? AdminSummitEventActionSyncWorkRequest::SubType : AdminSummitLocationActionSyncWorkRequest::SubType;
|
||||
$id = !is_null($event_id) ? $event_id : $location_id;
|
||||
$key = "{$sub_type}_{$type}_{$id}";
|
||||
return $key;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param AbstractCalendarSyncWorkRequest $request
|
||||
* @return bool
|
||||
*/
|
||||
public function registerRequest(AbstractCalendarSyncWorkRequest $request){
|
||||
$key = $this->getKey($request);
|
||||
if(isset($this->registered_requests[$key])) return false;
|
||||
$this->registered_requests[$key] = $request;
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param AbstractCalendarSyncWorkRequest $request
|
||||
* @return bool
|
||||
*/
|
||||
public function removeRequest(AbstractCalendarSyncWorkRequest $request){
|
||||
$key = $this->getKey($request);
|
||||
if(isset($this->registered_requests[$key])){
|
||||
unset($this->registered_requests[$key]);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $event_id
|
||||
* @param string $type
|
||||
* @return AdminSummitEventActionSyncWorkRequest[]
|
||||
*/
|
||||
public function getSummitEventRequestFor($event_id, $type = null){
|
||||
$types = [
|
||||
AbstractCalendarSyncWorkRequest::TypeAdd,
|
||||
AbstractCalendarSyncWorkRequest::TypeRemove,
|
||||
AbstractCalendarSyncWorkRequest::TypeUpdate,
|
||||
];
|
||||
|
||||
if(!empty($type)) $types = [$type];
|
||||
$list = [];
|
||||
foreach ($types as $t){
|
||||
$key = $this->generateKey($t, $event_id);
|
||||
if(isset($this->registered_requests[$key])){
|
||||
$list[] = $this->registered_requests[$key];
|
||||
}
|
||||
}
|
||||
return $list;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $location_id
|
||||
* @param string $type
|
||||
* @return AdminSummitLocationActionSyncWorkRequest[]
|
||||
*/
|
||||
public function getSummitLocationRequestFor($location_id, $type = null){
|
||||
$types = [
|
||||
AbstractCalendarSyncWorkRequest::TypeAdd,
|
||||
AbstractCalendarSyncWorkRequest::TypeRemove,
|
||||
AbstractCalendarSyncWorkRequest::TypeUpdate,
|
||||
];
|
||||
|
||||
if(!empty($type)) $types = [$type];
|
||||
$list = [];
|
||||
foreach ($types as $t){
|
||||
$key = $this->generateKey($t, null, $location_id);
|
||||
if(isset($this->registered_requests[$key])){
|
||||
$list[] = $this->registered_requests[$key];
|
||||
}
|
||||
}
|
||||
return $list;
|
||||
}
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getPurgedRequests(){
|
||||
return array_values($this->registered_requests);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param AbstractCalendarSyncWorkRequest $request
|
||||
* @return bool
|
||||
*/
|
||||
public function registerRequestForDelete(AbstractCalendarSyncWorkRequest $request)
|
||||
{
|
||||
// TODO: Implement registerRequestForDelete() method.
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getRequestsToDelete()
|
||||
{
|
||||
// TODO: Implement getRequestsToDelete() method.
|
||||
}
|
||||
}
|
@ -0,0 +1,26 @@
|
||||
<?php namespace App\Services\Model;
|
||||
/**
|
||||
* 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.
|
||||
**/
|
||||
|
||||
/**
|
||||
* Interface IAdminActionsCalendarSyncProcessingService
|
||||
* @package App\Services\Model
|
||||
*/
|
||||
interface IAdminActionsCalendarSyncProcessingService
|
||||
{
|
||||
/**
|
||||
* @param int $batch_size
|
||||
* @return int
|
||||
*/
|
||||
public function processActions($batch_size = 100);
|
||||
}
|
25
app/Services/Model/ICalendarSyncWorkRequestPreProcessor.php
Normal file
25
app/Services/Model/ICalendarSyncWorkRequestPreProcessor.php
Normal file
@ -0,0 +1,25 @@
|
||||
<?php namespace App\Services\Model;
|
||||
/**
|
||||
* 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.
|
||||
**/
|
||||
/**
|
||||
* Interface ICalendarSyncWorkRequestPreProcessor
|
||||
* @package services\model
|
||||
*/
|
||||
interface ICalendarSyncWorkRequestPreProcessor
|
||||
{
|
||||
/**
|
||||
* @param array $requests
|
||||
* @return array
|
||||
*/
|
||||
public function preProcessActions(array $requests);
|
||||
}
|
49
app/Services/Model/ICalendarSyncWorkRequestQueueManager.php
Normal file
49
app/Services/Model/ICalendarSyncWorkRequestQueueManager.php
Normal file
@ -0,0 +1,49 @@
|
||||
<?php namespace App\Services\Model;
|
||||
/**
|
||||
* 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\summit\CalendarSync\WorkQueue\AbstractCalendarSyncWorkRequest;
|
||||
|
||||
/**
|
||||
* Interface ICalendarSyncWorkRequestQueueManager
|
||||
* @package App\Services\Model
|
||||
*/
|
||||
interface ICalendarSyncWorkRequestQueueManager
|
||||
{
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getPurgedRequests();
|
||||
|
||||
/**
|
||||
* @param AbstractCalendarSyncWorkRequest $request
|
||||
* @return bool
|
||||
*/
|
||||
public function registerRequest(AbstractCalendarSyncWorkRequest $request);
|
||||
|
||||
/**
|
||||
* @param AbstractCalendarSyncWorkRequest $request
|
||||
* @return bool
|
||||
*/
|
||||
public function removeRequest(AbstractCalendarSyncWorkRequest $request);
|
||||
|
||||
/**
|
||||
* @param AbstractCalendarSyncWorkRequest $request
|
||||
* @return bool
|
||||
*/
|
||||
public function registerRequestForDelete(AbstractCalendarSyncWorkRequest $request);
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getRequestsToDelete();
|
||||
}
|
@ -0,0 +1,27 @@
|
||||
<?php namespace App\Services\Model;
|
||||
/**
|
||||
* 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.
|
||||
**/
|
||||
|
||||
/**
|
||||
* Interface IMemberActionsCalendarSyncProcessingService
|
||||
* @package App\Services\Model
|
||||
*/
|
||||
interface IMemberActionsCalendarSyncProcessingService
|
||||
{
|
||||
/**
|
||||
* @param string $provider
|
||||
* @param int $batch_size
|
||||
* @return int
|
||||
*/
|
||||
public function processActions($provider = 'ALL', $batch_size = 1000);
|
||||
}
|
79
app/Services/Model/MemberActionsCalendarSyncPreProcessor.php
Normal file
79
app/Services/Model/MemberActionsCalendarSyncPreProcessor.php
Normal file
@ -0,0 +1,79 @@
|
||||
<?php namespace App\Services\Model;
|
||||
/**
|
||||
* 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\Services\Model\ICalendarSyncWorkRequestQueueManager;
|
||||
use App\Services\Model\Strategies\ICalendarSyncWorkRequestPreProcessorStrategyFactory;
|
||||
use models\summit\CalendarSync\WorkQueue\MemberScheduleSummitActionSyncWorkRequest;
|
||||
use models\summit\IAbstractCalendarSyncWorkRequestRepository;
|
||||
|
||||
/**
|
||||
* Class MemberActionsCalendarSyncPreProcessor
|
||||
* @package services\model
|
||||
*/
|
||||
final class MemberActionsCalendarSyncPreProcessor
|
||||
implements ICalendarSyncWorkRequestPreProcessor
|
||||
{
|
||||
/**
|
||||
* @var ICalendarSyncWorkRequestQueueManager
|
||||
*/
|
||||
private $queue_manager;
|
||||
|
||||
/**
|
||||
* @var IAbstractCalendarSyncWorkRequestRepository
|
||||
*/
|
||||
private $work_request_repository;
|
||||
|
||||
/**
|
||||
* @var ICalendarSyncWorkRequestPreProcessorStrategyFactory
|
||||
*/
|
||||
private $strategy_factory;
|
||||
|
||||
/**
|
||||
* MemberActionsCalendarSyncPreProcessor constructor.
|
||||
* @param ICalendarSyncWorkRequestQueueManager $queue_manager
|
||||
* @param IAbstractCalendarSyncWorkRequestRepository $work_request_repository
|
||||
* @param ICalendarSyncWorkRequestPreProcessorStrategyFactory $strategy_factory
|
||||
*/
|
||||
public function __construct
|
||||
(
|
||||
ICalendarSyncWorkRequestQueueManager $queue_manager,
|
||||
IAbstractCalendarSyncWorkRequestRepository $work_request_repository,
|
||||
ICalendarSyncWorkRequestPreProcessorStrategyFactory $strategy_factory
|
||||
)
|
||||
{
|
||||
$this->queue_manager = $queue_manager;
|
||||
$this->work_request_repository = $work_request_repository;
|
||||
$this->strategy_factory = $strategy_factory;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param MemberScheduleSummitActionSyncWorkRequest[] $requests
|
||||
* @return MemberScheduleSummitActionSyncWorkRequest[]
|
||||
*/
|
||||
function preProcessActions(array $requests){
|
||||
|
||||
foreach ($requests as $request){
|
||||
$strategy = $this->strategy_factory->build($this->queue_manager, $request);
|
||||
if(is_null($strategy)) continue;
|
||||
$request = $strategy->process($request);
|
||||
if(!is_null($request))
|
||||
$this->queue_manager->registerRequest($request);
|
||||
}
|
||||
|
||||
foreach($this->queue_manager->getRequestsToDelete() as $request_2_delete){
|
||||
$this->work_request_repository->delete($request_2_delete);
|
||||
}
|
||||
return $this->queue_manager->getPurgedRequests();
|
||||
}
|
||||
}
|
@ -0,0 +1,236 @@
|
||||
<?php namespace App\Services\Model;
|
||||
/**
|
||||
* 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\Services\Apis\CalendarSync\Exceptions\RateLimitExceededException;
|
||||
use CalDAVClient\Facade\Exceptions\ForbiddenException;
|
||||
use CalDAVClient\Facade\Exceptions\NotFoundResourceException;
|
||||
use CalDAVClient\Facade\Exceptions\ServerErrorException;
|
||||
use CalDAVClient\Facade\Exceptions\UserUnAuthorizedException;
|
||||
use models\summit\CalendarSync\ScheduleCalendarSyncInfo;
|
||||
use models\summit\CalendarSync\WorkQueue\AbstractCalendarSyncWorkRequest;
|
||||
use models\summit\CalendarSync\WorkQueue\MemberCalendarScheduleSummitActionSyncWorkRequest;
|
||||
use models\summit\CalendarSync\WorkQueue\MemberEventScheduleSummitActionSyncWorkRequest;
|
||||
use models\summit\CalendarSync\WorkQueue\MemberScheduleSummitActionSyncWorkRequest;
|
||||
use models\summit\IAbstractCalendarSyncWorkRequestRepository;
|
||||
use models\summit\ICalendarSyncInfoRepository;
|
||||
use services\apis\CalendarSync\CalendarSyncRemoteFacadeFactory;
|
||||
use utils\PagingInfo;
|
||||
use libs\utils\ITransactionService;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Doctrine\DBAL\DBALException;
|
||||
use Exception;
|
||||
|
||||
/**
|
||||
* Class MemberActionsCalendarSyncProcessingService
|
||||
* @package App\Services\Model
|
||||
*/
|
||||
final class MemberActionsCalendarSyncProcessingService
|
||||
implements IMemberActionsCalendarSyncProcessingService
|
||||
{
|
||||
|
||||
const FailedAddSummitEventTxFileFormatName = '/tmp/failed_insert_member_%s_calendar_%s_summit_event_%s.json';
|
||||
/**
|
||||
* @var IAbstractCalendarSyncWorkRequestRepository
|
||||
*/
|
||||
private $work_request_repository;
|
||||
|
||||
/**
|
||||
* @var ICalendarSyncInfoRepository
|
||||
*/
|
||||
private $calendar_sync_repository;
|
||||
|
||||
/**
|
||||
* @var ITransactionService
|
||||
*/
|
||||
private $tx_manager;
|
||||
|
||||
/**
|
||||
* @var ICalendarSyncWorkRequestPreProcessor
|
||||
*/
|
||||
private $preprocessor_requests;
|
||||
|
||||
/**
|
||||
* MemberActionsCalendarSyncProcessingService constructor.
|
||||
* @param IAbstractCalendarSyncWorkRequestRepository $work_request_repository
|
||||
* @param ICalendarSyncInfoRepository $calendar_sync_repository
|
||||
* @param ICalendarSyncWorkRequestPreProcessor $preprocessor_requests
|
||||
* @param ITransactionService $tx_manager
|
||||
*/
|
||||
public function __construct
|
||||
(
|
||||
IAbstractCalendarSyncWorkRequestRepository $work_request_repository,
|
||||
ICalendarSyncInfoRepository $calendar_sync_repository,
|
||||
ICalendarSyncWorkRequestPreProcessor $preprocessor_requests,
|
||||
ITransactionService $tx_manager
|
||||
)
|
||||
{
|
||||
$this->work_request_repository = $work_request_repository;
|
||||
$this->calendar_sync_repository = $calendar_sync_repository;
|
||||
$this->preprocessor_requests = $preprocessor_requests;
|
||||
$this->tx_manager = $tx_manager;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param string $provider
|
||||
* @param int $batch_size
|
||||
* @return int
|
||||
*/
|
||||
public function processActions($provider = 'ALL', $batch_size = 1000)
|
||||
{
|
||||
return $this->tx_manager->transaction(function() use($provider, $batch_size){
|
||||
$count = 0;
|
||||
|
||||
$res = $this->work_request_repository->getUnprocessedMemberScheduleWorkRequestActionByPage
|
||||
(
|
||||
$provider,
|
||||
new PagingInfo(1, $batch_size)
|
||||
);
|
||||
$requests = $this->preprocessor_requests->preProcessActions($res->getItems());
|
||||
log::info(sprintf("provider %s got %s request to process ...", $provider, count($requests)));
|
||||
|
||||
foreach ($requests as $request){
|
||||
try {
|
||||
log::debug(sprintf("iteration # %s", $count+1));
|
||||
if (!$request instanceof MemberScheduleSummitActionSyncWorkRequest) continue;
|
||||
$calendar_sync_info = $request->getCalendarSyncInfo();
|
||||
$remote_facade = CalendarSyncRemoteFacadeFactory::getInstance()->build($calendar_sync_info);
|
||||
if (is_null($remote_facade)) continue;
|
||||
$member = $request->getOwner();
|
||||
$request_type = $request->getType();
|
||||
$request_sub_type = $request->getSubType();
|
||||
|
||||
log::info(sprintf
|
||||
(
|
||||
"%s - processing work request %s - sub type %s - type %s - member %s - credential id %s -revoked credentials %s",
|
||||
$provider,
|
||||
$request->getIdentifier(),
|
||||
$request_sub_type,
|
||||
$request_type,
|
||||
$member->getIdentifier(),
|
||||
$calendar_sync_info->getId(),
|
||||
$calendar_sync_info->isRevoked()? 1:0
|
||||
));
|
||||
|
||||
switch ($request_sub_type) {
|
||||
|
||||
case MemberEventScheduleSummitActionSyncWorkRequest::SubType: {
|
||||
$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",
|
||||
$provider,
|
||||
$request->getIdentifier(),
|
||||
$request_sub_type,
|
||||
$request_type,
|
||||
$summit_event->getIdentifier(),
|
||||
$member->getIdentifier(),
|
||||
$calendar_sync_info->getId(),
|
||||
$calendar_sync_info->isRevoked()? 1:0
|
||||
));
|
||||
|
||||
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()));
|
||||
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()));
|
||||
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()));
|
||||
continue;
|
||||
}
|
||||
$member->add2ScheduleSyncInfo($schedule_sync_info);
|
||||
break;
|
||||
case AbstractCalendarSyncWorkRequest::TypeUpdate:
|
||||
if($calendar_sync_info->isRevoked()) continue;
|
||||
$sync_info = $member->getScheduleSyncInfoByEvent($summit_event, $calendar_sync_info);
|
||||
$is_scheduled = $member->isOnSchedule($summit_event);
|
||||
if(is_null($sync_info)) continue;
|
||||
if(!$is_scheduled) {
|
||||
$member->removeFromScheduleSyncInfo($sync_info);
|
||||
continue;
|
||||
}
|
||||
$remote_facade->updateEvent($request, $sync_info);
|
||||
break;
|
||||
case AbstractCalendarSyncWorkRequest::TypeRemove:
|
||||
if($calendar_sync_info->isRevoked()) continue;
|
||||
$schedule_sync_info = $member->getScheduleSyncInfoByEvent($summit_event, $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()));
|
||||
continue;
|
||||
}
|
||||
$remote_facade->deleteEvent($request, $schedule_sync_info);
|
||||
$member->removeFromScheduleSyncInfo($schedule_sync_info);
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case MemberCalendarScheduleSummitActionSyncWorkRequest::SubType: {
|
||||
switch ($request_type) {
|
||||
case AbstractCalendarSyncWorkRequest::TypeAdd:
|
||||
if($calendar_sync_info->isRevoked()){
|
||||
Log::warning(sprintf("CALENDAR ADD : calendar sync info id %s, member id %s is revoked!", $calendar_sync_info->getId(), $member->getId()));
|
||||
continue;
|
||||
}
|
||||
$remote_facade->createCalendar($request, $calendar_sync_info);
|
||||
break;
|
||||
case AbstractCalendarSyncWorkRequest::TypeRemove:
|
||||
$remote_facade->deleteCalendar($request, $calendar_sync_info);
|
||||
$member->removeFromCalendarSyncInfo($calendar_sync_info);
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
$request->markProcessed();
|
||||
$count++;
|
||||
usleep($remote_facade->getSleepInterval());
|
||||
}
|
||||
catch(ForbiddenException $ex1){
|
||||
// cant create calendar (CAL DAV)...
|
||||
echo 'ForbiddenException !!'.PHP_EOL;
|
||||
Log::warning($ex1);
|
||||
}
|
||||
catch(UserUnAuthorizedException $ex2){
|
||||
echo 'UserUnAuthorizedException !!'.PHP_EOL;
|
||||
Log::warning($ex2);
|
||||
}
|
||||
catch(NotFoundResourceException $ex3){
|
||||
echo 'NotFoundResourceException !!'.PHP_EOL;
|
||||
Log::error($ex3);
|
||||
}
|
||||
catch(ServerErrorException $ex4){
|
||||
echo 'ServerErrorException !!'.PHP_EOL;
|
||||
Log::error($ex4);
|
||||
}
|
||||
catch (RateLimitExceededException $ex5){
|
||||
Log::critical($ex5);
|
||||
break;
|
||||
}
|
||||
catch(Exception $ex6){
|
||||
echo 'Exception !!'.PHP_EOL;
|
||||
Log::error($ex6);
|
||||
}
|
||||
}
|
||||
|
||||
return $count;
|
||||
});
|
||||
}
|
||||
}
|
212
app/Services/Model/MemberScheduleWorkQueueManager.php
Normal file
212
app/Services/Model/MemberScheduleWorkQueueManager.php
Normal file
@ -0,0 +1,212 @@
|
||||
<?php namespace App\Services\Model;
|
||||
/**
|
||||
* 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\summit\CalendarSync\WorkQueue\AbstractCalendarSyncWorkRequest;
|
||||
use models\summit\CalendarSync\WorkQueue\MemberCalendarScheduleSummitActionSyncWorkRequest;
|
||||
use models\summit\CalendarSync\WorkQueue\MemberEventScheduleSummitActionSyncWorkRequest;
|
||||
use models\summit\CalendarSync\WorkQueue\MemberScheduleSummitActionSyncWorkRequest;
|
||||
/**
|
||||
* Class MemberScheduleWorkQueueManager
|
||||
* @package services\model
|
||||
*/
|
||||
final class MemberScheduleWorkQueueManager
|
||||
implements ICalendarSyncWorkRequestQueueManager
|
||||
{
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
private $registered_requests = [];
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
private $registered_requests_2_delete = [];
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
private $calendars_events = [];
|
||||
|
||||
/**
|
||||
* @param AbstractCalendarSyncWorkRequest $request
|
||||
* @param string|null $type
|
||||
* @return string
|
||||
*/
|
||||
private function getKey(AbstractCalendarSyncWorkRequest $request, $type = null){
|
||||
$event_id = null;
|
||||
if($request instanceof MemberEventScheduleSummitActionSyncWorkRequest){
|
||||
$event_id = $request->getSummitEvent()->getId();
|
||||
}
|
||||
if(empty($type)) $type = $request->getType();
|
||||
return $this->generateKey($type, $request->getCalendarSyncInfo()->getId(), $event_id);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $type
|
||||
* @param int $calendar_id
|
||||
* @param null|int $event_id
|
||||
* @return string
|
||||
*/
|
||||
private function generateKey($type, $calendar_id, $event_id = null){
|
||||
$sub_type = is_null($event_id) ? MemberCalendarScheduleSummitActionSyncWorkRequest::SubType : MemberEventScheduleSummitActionSyncWorkRequest::SubType;
|
||||
$key = "{$sub_type}_{$type}_{$calendar_id}";
|
||||
if(!is_null($event_id)){
|
||||
$key .= "_{$event_id}";
|
||||
}
|
||||
return $key;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param AbstractCalendarSyncWorkRequest $request
|
||||
* @return bool
|
||||
*/
|
||||
public function registerRequest(AbstractCalendarSyncWorkRequest $request){
|
||||
$key = $this->getKey($request);
|
||||
if(isset($this->registered_requests[$key])) return false;
|
||||
$this->registered_requests[$key] = $request;
|
||||
// register request per member calendar
|
||||
if($request instanceof MemberEventScheduleSummitActionSyncWorkRequest) {
|
||||
$calendar_info_id = $request->getCalendarSyncInfo()->getId();
|
||||
if (!isset($this->calendars_events[$calendar_info_id]))
|
||||
$this->calendars_events[$calendar_info_id] = [];
|
||||
$this->calendars_events[$calendar_info_id][] = $request;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $calendar_info_id
|
||||
* @return MemberEventScheduleSummitActionSyncWorkRequest[]
|
||||
*/
|
||||
public function getPendingEventsForCalendar($calendar_info_id){
|
||||
if (isset($this->calendars_events[$calendar_info_id])){
|
||||
return $this->calendars_events[$calendar_info_id];
|
||||
}
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $calendar_info_id
|
||||
* @return bool
|
||||
*/
|
||||
public function clearPendingEventsForCalendar($calendar_info_id){
|
||||
if (isset($this->calendars_events[$calendar_info_id])){
|
||||
unset($this->calendars_events[$calendar_info_id]);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $calendar_id
|
||||
* @param int $event_id
|
||||
* @param string $type
|
||||
* @return MemberEventScheduleSummitActionSyncWorkRequest[]
|
||||
*/
|
||||
public function getSummitEventRequestFor($calendar_id, $event_id, $type = null){
|
||||
$types = [
|
||||
AbstractCalendarSyncWorkRequest::TypeAdd,
|
||||
AbstractCalendarSyncWorkRequest::TypeRemove,
|
||||
AbstractCalendarSyncWorkRequest::TypeUpdate,
|
||||
];
|
||||
|
||||
if(!empty($type)) $types = [$type];
|
||||
$list = [];
|
||||
foreach ($types as $t){
|
||||
$key = $this->generateKey($t, $calendar_id, $event_id);
|
||||
if(isset($this->registered_requests[$key]) && !isset($this->registered_requests_2_delete[$key]) ){
|
||||
$list[] = $this->registered_requests[$key];
|
||||
}
|
||||
}
|
||||
return $list;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $calendar_id
|
||||
* @param string $type
|
||||
* @return MemberCalendarScheduleSummitActionSyncWorkRequest|null
|
||||
*/
|
||||
public function getCalendarRequestFor($calendar_id, $type){
|
||||
$key = $this->generateKey($type, $calendar_id);
|
||||
return isset($this->registered_requests[$key]) ? $this->registered_requests[$key] : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param AbstractCalendarSyncWorkRequest $request
|
||||
* @return bool
|
||||
*/
|
||||
public function removeRequest(AbstractCalendarSyncWorkRequest $request){
|
||||
$key = $this->getKey($request);
|
||||
if(isset($this->registered_requests[$key])){
|
||||
unset($this->registered_requests[$key]);
|
||||
if($request instanceof MemberEventScheduleSummitActionSyncWorkRequest) {
|
||||
$calendar_info_id = $request->getCalendarSyncInfo()->getId();
|
||||
if (isset($this->calendars_events[$calendar_info_id])) {
|
||||
// remove from calendar events
|
||||
$key = array_search($request, $this->calendars_events[$calendar_info_id]);
|
||||
if($key!==false){
|
||||
unset($this->calendars_events[$calendar_info_id][$key]);
|
||||
if(isset($this->calendars_events[$calendar_info_id])){
|
||||
unset($this->calendars_events[$calendar_info_id]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param AbstractCalendarSyncWorkRequest $request
|
||||
* @return bool
|
||||
*/
|
||||
public function registerRequestForDelete(AbstractCalendarSyncWorkRequest $request){
|
||||
$key = $this->getKey($request);
|
||||
if(isset($this->registered_requests_2_delete[$key])) return false;
|
||||
$this->registerRequest($request);
|
||||
$this->registered_requests_2_delete[$key] = $request;
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getPurgedRequests(){
|
||||
$list = [];
|
||||
foreach($this->registered_requests as $key => $request){
|
||||
if(isset($this->registered_requests_2_delete[$key])) continue;
|
||||
$list[] = $request;
|
||||
};
|
||||
return $list;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getRequestsToDelete(){
|
||||
return array_values($this->registered_requests_2_delete);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param MemberScheduleSummitActionSyncWorkRequest $request
|
||||
* @param string|null $type
|
||||
* @return bool
|
||||
*/
|
||||
public function unRegisterRequestForDelete(MemberScheduleSummitActionSyncWorkRequest $request , $type = null){
|
||||
$key = $this->getKey($request, $type);
|
||||
if(!isset($this->registered_requests_2_delete[$key])) return false;
|
||||
unset($this->registered_requests_2_delete[$key]);
|
||||
return true;
|
||||
}
|
||||
}
|
@ -0,0 +1,71 @@
|
||||
<?php namespace App\Services\Model\Strategies\AdminActions;
|
||||
/**
|
||||
* 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\Services\Model\AdminScheduleWorkQueueManager;
|
||||
use App\Services\Model\Strategies\ICalendarSyncWorkRequestPreProcessorStrategy;
|
||||
use models\summit\CalendarSync\WorkQueue\AbstractCalendarSyncWorkRequest;
|
||||
use models\summit\CalendarSync\WorkQueue\AdminSummitEventActionSyncWorkRequest;
|
||||
use models\summit\IAbstractCalendarSyncWorkRequestRepository;
|
||||
|
||||
/**
|
||||
* Class AdminSummitEventActionSyncWorkRequestDeleteStrategy
|
||||
* @package App\Services\Model\Strategies\AdminActions
|
||||
*/
|
||||
final class AdminSummitEventActionSyncWorkRequestDeleteStrategy
|
||||
implements ICalendarSyncWorkRequestPreProcessorStrategy
|
||||
{
|
||||
|
||||
/**
|
||||
* @var AdminScheduleWorkQueueManager
|
||||
*/
|
||||
private $queue_manager;
|
||||
|
||||
/**
|
||||
* @var IAbstractCalendarSyncWorkRequestRepository
|
||||
*/
|
||||
private $work_request_repository;
|
||||
|
||||
/**
|
||||
* AdminSummitEventActionSyncWorkRequestDeleteStrategy constructor.
|
||||
* @param AdminScheduleWorkQueueManager $queue_manager
|
||||
* @param IAbstractCalendarSyncWorkRequestRepository $work_request_repository
|
||||
*/
|
||||
public function __construct
|
||||
(
|
||||
AdminScheduleWorkQueueManager $queue_manager,
|
||||
IAbstractCalendarSyncWorkRequestRepository $work_request_repository
|
||||
)
|
||||
{
|
||||
$this->queue_manager = $queue_manager;
|
||||
$this->work_request_repository = $work_request_repository;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param AbstractCalendarSyncWorkRequest $request
|
||||
* @return AbstractCalendarSyncWorkRequest|null
|
||||
*/
|
||||
public function process(AbstractCalendarSyncWorkRequest $request)
|
||||
{
|
||||
if(!$request instanceof AdminSummitEventActionSyncWorkRequest) return null;
|
||||
$summit_event = $request->getSummitEvent();
|
||||
$pending_requests = $this->queue_manager->getSummitEventRequestFor($summit_event->getId());
|
||||
if(count($pending_requests) > 0 ){
|
||||
// delete all former and pending ...
|
||||
foreach ($pending_requests as $pending_request) {
|
||||
if($this->queue_manager->removeRequest($pending_request))
|
||||
$this->work_request_repository->delete($pending_request);
|
||||
}
|
||||
}
|
||||
return $request;
|
||||
}
|
||||
}
|
@ -0,0 +1,71 @@
|
||||
<?php namespace App\Services\Model\Strategies\AdminActions;
|
||||
/**
|
||||
* 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\Services\Model\AdminScheduleWorkQueueManager;
|
||||
use App\Services\Model\Strategies\ICalendarSyncWorkRequestPreProcessorStrategy;
|
||||
use models\summit\CalendarSync\WorkQueue\AbstractCalendarSyncWorkRequest;
|
||||
use models\summit\CalendarSync\WorkQueue\AdminSummitEventActionSyncWorkRequest;
|
||||
use models\summit\IAbstractCalendarSyncWorkRequestRepository;
|
||||
|
||||
/**
|
||||
* Class AdminSummitEventActionSyncWorkRequestUpdateStrategy
|
||||
* @package App\Services\Model\Strategies\AdminActions
|
||||
*/
|
||||
final class AdminSummitEventActionSyncWorkRequestUpdateStrategy
|
||||
implements ICalendarSyncWorkRequestPreProcessorStrategy
|
||||
{
|
||||
|
||||
/**
|
||||
* @var AdminScheduleWorkQueueManager
|
||||
*/
|
||||
private $queue_manager;
|
||||
|
||||
/**
|
||||
* @var IAbstractCalendarSyncWorkRequestRepository
|
||||
*/
|
||||
private $work_request_repository;
|
||||
|
||||
/**
|
||||
* AdminSummitEventActionSyncWorkRequestUpdateStrategy constructor.
|
||||
* @param AdminScheduleWorkQueueManager $queue_manager
|
||||
* @param IAbstractCalendarSyncWorkRequestRepository $work_request_repository
|
||||
*/
|
||||
public function __construct
|
||||
(
|
||||
AdminScheduleWorkQueueManager $queue_manager,
|
||||
IAbstractCalendarSyncWorkRequestRepository $work_request_repository
|
||||
)
|
||||
{
|
||||
$this->queue_manager = $queue_manager;
|
||||
$this->work_request_repository = $work_request_repository;
|
||||
}
|
||||
/**
|
||||
* @param AbstractCalendarSyncWorkRequest $request
|
||||
* @return AbstractCalendarSyncWorkRequest|null
|
||||
*/
|
||||
public function process(AbstractCalendarSyncWorkRequest $request)
|
||||
{
|
||||
if(!$request instanceof AdminSummitEventActionSyncWorkRequest) return null;
|
||||
$summit_event = $request->getSummitEvent();
|
||||
$pending_requests = $this->queue_manager->getSummitEventRequestFor($summit_event->getId());
|
||||
if(count($pending_requests) > 0 ){
|
||||
// delete all former and pending ...
|
||||
foreach ($pending_requests as $pending_request) {
|
||||
if( $this->queue_manager->removeRequest($pending_request))
|
||||
$this->work_request_repository->delete($pending_request);
|
||||
}
|
||||
}
|
||||
return $request;
|
||||
}
|
||||
}
|
@ -0,0 +1,71 @@
|
||||
<?php namespace App\Services\Model\Strategies\AdminActions;
|
||||
/**
|
||||
* 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\Services\Model\AdminScheduleWorkQueueManager;
|
||||
use App\Services\Model\Strategies\ICalendarSyncWorkRequestPreProcessorStrategy;
|
||||
use models\summit\CalendarSync\WorkQueue\AbstractCalendarSyncWorkRequest;
|
||||
use models\summit\CalendarSync\WorkQueue\AdminSummitLocationActionSyncWorkRequest;
|
||||
use models\summit\IAbstractCalendarSyncWorkRequestRepository;
|
||||
|
||||
/**
|
||||
* Class AdminSummitLocationActionSyncWorkRequestDeleteStrategy
|
||||
* @package App\Services\Model\Strategies\AdminActions
|
||||
*/
|
||||
final class AdminSummitLocationActionSyncWorkRequestDeleteStrategy
|
||||
implements ICalendarSyncWorkRequestPreProcessorStrategy
|
||||
{
|
||||
/**
|
||||
* @var AdminScheduleWorkQueueManager
|
||||
*/
|
||||
private $queue_manager;
|
||||
|
||||
/**
|
||||
* @var IAbstractCalendarSyncWorkRequestRepository
|
||||
*/
|
||||
private $work_request_repository;
|
||||
|
||||
/**
|
||||
* AdminSummitLocationActionSyncWorkRequestDeleteStrategy constructor.
|
||||
* @param AdminScheduleWorkQueueManager $queue_manager
|
||||
* @param IAbstractCalendarSyncWorkRequestRepository $work_request_repository
|
||||
*/
|
||||
public function __construct
|
||||
(
|
||||
AdminScheduleWorkQueueManager $queue_manager,
|
||||
IAbstractCalendarSyncWorkRequestRepository $work_request_repository
|
||||
)
|
||||
{
|
||||
$this->queue_manager = $queue_manager;
|
||||
$this->work_request_repository = $work_request_repository;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param AbstractCalendarSyncWorkRequest $request
|
||||
* @return AbstractCalendarSyncWorkRequest|null
|
||||
*/
|
||||
public function process(AbstractCalendarSyncWorkRequest $request)
|
||||
{
|
||||
if(!$request instanceof AdminSummitLocationActionSyncWorkRequest) return null;
|
||||
$location = $request->getLocation();
|
||||
$pending_requests = $this->queue_manager->getSummitLocationRequestFor($location->getId());
|
||||
if(count($pending_requests) > 0 ){
|
||||
// delete all former and pending ...
|
||||
foreach ($pending_requests as $pending_request) {
|
||||
if($this->queue_manager->removeRequest($pending_request))
|
||||
$this->work_request_repository->delete($pending_request);
|
||||
}
|
||||
}
|
||||
return $request;
|
||||
}
|
||||
}
|
@ -0,0 +1,72 @@
|
||||
<?php namespace App\Services\Model\Strategies\AdminActions;
|
||||
/**
|
||||
* 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\Services\Model\AdminScheduleWorkQueueManager;
|
||||
use App\Services\Model\Strategies\ICalendarSyncWorkRequestPreProcessorStrategy;
|
||||
use models\summit\CalendarSync\WorkQueue\AbstractCalendarSyncWorkRequest;
|
||||
use models\summit\CalendarSync\WorkQueue\AdminSummitLocationActionSyncWorkRequest;
|
||||
use models\summit\IAbstractCalendarSyncWorkRequestRepository;
|
||||
|
||||
/**
|
||||
* Class AdminSummitLocationActionSyncWorkRequestUpdateStrategy
|
||||
* @package App\Services\Model\Strategies\AdminActions
|
||||
*/
|
||||
final class AdminSummitLocationActionSyncWorkRequestUpdateStrategy
|
||||
implements ICalendarSyncWorkRequestPreProcessorStrategy
|
||||
{
|
||||
|
||||
/**
|
||||
* @var AdminScheduleWorkQueueManager
|
||||
*/
|
||||
private $queue_manager;
|
||||
|
||||
/**
|
||||
* @var IAbstractCalendarSyncWorkRequestRepository
|
||||
*/
|
||||
private $work_request_repository;
|
||||
|
||||
/**
|
||||
* AdminSummitLocationActionSyncWorkRequestUpdateStrategy constructor.
|
||||
* @param AdminScheduleWorkQueueManager $queue_manager
|
||||
* @param IAbstractCalendarSyncWorkRequestRepository $work_request_repository
|
||||
*/
|
||||
public function __construct
|
||||
(
|
||||
AdminScheduleWorkQueueManager $queue_manager,
|
||||
IAbstractCalendarSyncWorkRequestRepository $work_request_repository
|
||||
)
|
||||
{
|
||||
$this->queue_manager = $queue_manager;
|
||||
$this->work_request_repository = $work_request_repository;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param AbstractCalendarSyncWorkRequest $request
|
||||
* @return AbstractCalendarSyncWorkRequest|null
|
||||
*/
|
||||
public function process(AbstractCalendarSyncWorkRequest $request)
|
||||
{
|
||||
if(!$request instanceof AdminSummitLocationActionSyncWorkRequest) return null;
|
||||
$location = $request->getLocation();
|
||||
$pending_requests = $this->queue_manager->getSummitLocationRequestFor($location->getId());
|
||||
if(count($pending_requests) > 0 ){
|
||||
// delete all former and pending ...
|
||||
foreach ($pending_requests as $pending_request) {
|
||||
if($this->queue_manager->removeRequest($pending_request))
|
||||
$this->work_request_repository->delete($pending_request);
|
||||
}
|
||||
}
|
||||
return $request;
|
||||
}
|
||||
}
|
@ -0,0 +1,126 @@
|
||||
<?php namespace App\Services\Model\Strategies;
|
||||
/**
|
||||
* 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\Services\Model\ICalendarSyncWorkRequestQueueManager;
|
||||
use App\Services\Model\Strategies\AdminActions\AdminSummitEventActionSyncWorkRequestDeleteStrategy;
|
||||
use App\Services\Model\Strategies\AdminActions\AdminSummitEventActionSyncWorkRequestUpdateStrategy;
|
||||
use App\Services\Model\Strategies\AdminActions\AdminSummitLocationActionSyncWorkRequestDeleteStrategy;
|
||||
use App\Services\Model\Strategies\AdminActions\AdminSummitLocationActionSyncWorkRequestUpdateStrategy;
|
||||
use App\Services\Model\Strategies\MemberActions\MemberCalendarScheduleSummitActionSyncWorkRequestAddStrategy;
|
||||
use App\Services\Model\Strategies\MemberActions\MemberCalendarScheduleSummitActionSyncWorkRequestDeleteStrategy;
|
||||
use App\Services\Model\Strategies\MemberActions\MemberEventScheduleSummitActionSyncWorkRequestAddStrategy;
|
||||
use App\Services\Model\Strategies\MemberActions\MemberEventScheduleSummitActionSyncWorkRequestDeleteStrategy;
|
||||
use App\Services\Model\Strategies\MemberActions\MemberEventScheduleSummitActionSyncWorkRequestUpdateStrategy;
|
||||
use models\summit\CalendarSync\WorkQueue\AbstractCalendarSyncWorkRequest;
|
||||
use models\summit\CalendarSync\WorkQueue\AdminSummitEventActionSyncWorkRequest;
|
||||
use models\summit\CalendarSync\WorkQueue\AdminSummitLocationActionSyncWorkRequest;
|
||||
use models\summit\CalendarSync\WorkQueue\MemberCalendarScheduleSummitActionSyncWorkRequest;
|
||||
use models\summit\CalendarSync\WorkQueue\MemberEventScheduleSummitActionSyncWorkRequest;
|
||||
use models\summit\IAbstractCalendarSyncWorkRequestRepository;
|
||||
use models\summit\ICalendarSyncInfoRepository;
|
||||
/**
|
||||
* Class CalendarSyncWorkRequestPreProcessorStrategyFactory
|
||||
* @package App\Services\Model\Strategies
|
||||
*/
|
||||
final class CalendarSyncWorkRequestPreProcessorStrategyFactory
|
||||
implements ICalendarSyncWorkRequestPreProcessorStrategyFactory
|
||||
{
|
||||
|
||||
/**
|
||||
* @var IAbstractCalendarSyncWorkRequestRepository
|
||||
*/
|
||||
private $work_request_repository;
|
||||
|
||||
/**
|
||||
* @var ICalendarSyncInfoRepository
|
||||
*/
|
||||
private $calendar_sync_repository;
|
||||
|
||||
/**
|
||||
* CalendarSyncWorkRequestPreProcessorStrategyFactory constructor.
|
||||
* @param IAbstractCalendarSyncWorkRequestRepository $work_request_repository
|
||||
* @param ICalendarSyncInfoRepository $calendar_sync_repository
|
||||
*/
|
||||
public function __construct
|
||||
(
|
||||
IAbstractCalendarSyncWorkRequestRepository $work_request_repository,
|
||||
ICalendarSyncInfoRepository $calendar_sync_repository
|
||||
)
|
||||
{
|
||||
$this->work_request_repository = $work_request_repository;
|
||||
$this->calendar_sync_repository = $calendar_sync_repository;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ICalendarSyncWorkRequestQueueManager $queue_manager
|
||||
* @param AbstractCalendarSyncWorkRequest $request
|
||||
* @return ICalendarSyncWorkRequestPreProcessorStrategy|null
|
||||
*/
|
||||
public function build(ICalendarSyncWorkRequestQueueManager $queue_manager, AbstractCalendarSyncWorkRequest $request){
|
||||
if($request instanceof MemberEventScheduleSummitActionSyncWorkRequest) {
|
||||
switch ($request->getType()) {
|
||||
case AbstractCalendarSyncWorkRequest::TypeRemove:
|
||||
return new MemberEventScheduleSummitActionSyncWorkRequestDeleteStrategy($queue_manager, $this->work_request_repository);
|
||||
case AbstractCalendarSyncWorkRequest::TypeAdd:
|
||||
return new MemberEventScheduleSummitActionSyncWorkRequestAddStrategy($queue_manager, $this->work_request_repository);
|
||||
|
||||
case AbstractCalendarSyncWorkRequest::TypeUpdate:
|
||||
return new MemberEventScheduleSummitActionSyncWorkRequestUpdateStrategy($queue_manager, $this->work_request_repository);
|
||||
}
|
||||
}
|
||||
if($request instanceof MemberCalendarScheduleSummitActionSyncWorkRequest){
|
||||
switch ($request->getType()) {
|
||||
case AbstractCalendarSyncWorkRequest::TypeRemove:
|
||||
return new MemberCalendarScheduleSummitActionSyncWorkRequestDeleteStrategy
|
||||
(
|
||||
$queue_manager,
|
||||
$this->work_request_repository,
|
||||
$this->calendar_sync_repository
|
||||
);
|
||||
|
||||
case AbstractCalendarSyncWorkRequest::TypeAdd:
|
||||
return new MemberCalendarScheduleSummitActionSyncWorkRequestAddStrategy();
|
||||
}
|
||||
}
|
||||
if($request instanceof AdminSummitEventActionSyncWorkRequest){
|
||||
switch ($request->getType()) {
|
||||
case AbstractCalendarSyncWorkRequest::TypeRemove:
|
||||
return new AdminSummitEventActionSyncWorkRequestDeleteStrategy(
|
||||
$queue_manager,
|
||||
$this->work_request_repository
|
||||
);
|
||||
case AbstractCalendarSyncWorkRequest::TypeUpdate:
|
||||
return new AdminSummitEventActionSyncWorkRequestUpdateStrategy(
|
||||
$queue_manager,
|
||||
$this->work_request_repository
|
||||
);
|
||||
}
|
||||
}
|
||||
if($request instanceof AdminSummitLocationActionSyncWorkRequest){
|
||||
switch ($request->getType()) {
|
||||
case AbstractCalendarSyncWorkRequest::TypeRemove:
|
||||
return new AdminSummitLocationActionSyncWorkRequestDeleteStrategy(
|
||||
$queue_manager,
|
||||
$this->work_request_repository
|
||||
);
|
||||
case AbstractCalendarSyncWorkRequest::TypeUpdate:
|
||||
return new AdminSummitLocationActionSyncWorkRequestUpdateStrategy(
|
||||
$queue_manager,
|
||||
$this->work_request_repository
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
@ -0,0 +1,28 @@
|
||||
<?php namespace App\Services\Model\Strategies;;
|
||||
/**
|
||||
* 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\summit\CalendarSync\WorkQueue\AbstractCalendarSyncWorkRequest;
|
||||
|
||||
/**
|
||||
* Interface ICalendarSyncWorkRequestPreProcessorStrategy
|
||||
* @package App\Services\Model\Strategies
|
||||
*/
|
||||
interface ICalendarSyncWorkRequestPreProcessorStrategy
|
||||
{
|
||||
/**
|
||||
* @param AbstractCalendarSyncWorkRequest $request
|
||||
* @return AbstractCalendarSyncWorkRequest|null
|
||||
*/
|
||||
public function process(AbstractCalendarSyncWorkRequest $request);
|
||||
}
|
@ -0,0 +1,30 @@
|
||||
<?php namespace App\Services\Model\Strategies;
|
||||
/**
|
||||
* 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\Services\Model\ICalendarSyncWorkRequestQueueManager;
|
||||
use models\summit\CalendarSync\WorkQueue\AbstractCalendarSyncWorkRequest;
|
||||
|
||||
/**
|
||||
* Interface ICalendarSyncWorkRequestPreProcessorStrategyFactory
|
||||
* @package App\Services\Model\Strategies
|
||||
*/
|
||||
interface ICalendarSyncWorkRequestPreProcessorStrategyFactory
|
||||
{
|
||||
/**
|
||||
* @param ICalendarSyncWorkRequestQueueManager $queue_manager
|
||||
* @param AbstractCalendarSyncWorkRequest $request
|
||||
* @return ICalendarSyncWorkRequestPreProcessorStrategy|null
|
||||
*/
|
||||
public function build(ICalendarSyncWorkRequestQueueManager $queue_manager, AbstractCalendarSyncWorkRequest $request);
|
||||
}
|
@ -0,0 +1,36 @@
|
||||
<?php namespace App\Services\Model\Strategies\MemberActions;
|
||||
/**
|
||||
* 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\Services\Model\Strategies\ICalendarSyncWorkRequestPreProcessorStrategy;
|
||||
use models\summit\CalendarSync\WorkQueue\AbstractCalendarSyncWorkRequest;
|
||||
use models\summit\CalendarSync\WorkQueue\MemberCalendarScheduleSummitActionSyncWorkRequest;
|
||||
|
||||
/**
|
||||
* Class MemberCalendarScheduleSummitActionSyncWorkRequestAddStrategy
|
||||
* @package App\Services\Model\Strategies\MemberActions
|
||||
*/
|
||||
final class MemberCalendarScheduleSummitActionSyncWorkRequestAddStrategy
|
||||
implements ICalendarSyncWorkRequestPreProcessorStrategy
|
||||
{
|
||||
|
||||
/**
|
||||
* @param AbstractCalendarSyncWorkRequest $request
|
||||
* @return AbstractCalendarSyncWorkRequest|null
|
||||
*/
|
||||
public function process(AbstractCalendarSyncWorkRequest $request)
|
||||
{
|
||||
if(!$request instanceof MemberCalendarScheduleSummitActionSyncWorkRequest) return null;
|
||||
return $request;
|
||||
}
|
||||
}
|
@ -0,0 +1,99 @@
|
||||
<?php namespace App\Services\Model\Strategies\MemberActions;
|
||||
|
||||
/**
|
||||
* 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\Services\Model\Strategies\ICalendarSyncWorkRequestPreProcessorStrategy;
|
||||
use models\summit\CalendarSync\WorkQueue\AbstractCalendarSyncWorkRequest;
|
||||
use models\summit\CalendarSync\WorkQueue\MemberCalendarScheduleSummitActionSyncWorkRequest;
|
||||
use models\summit\IAbstractCalendarSyncWorkRequestRepository;
|
||||
use models\summit\ICalendarSyncInfoRepository;
|
||||
use App\Services\Model\MemberScheduleWorkQueueManager;
|
||||
|
||||
/**
|
||||
* Class MemberCalendarScheduleSummitActionSyncWorkRequestDeleteStrategy
|
||||
* @package App\Services\Model\Strategies\MemberActions
|
||||
*/
|
||||
final class MemberCalendarScheduleSummitActionSyncWorkRequestDeleteStrategy
|
||||
implements ICalendarSyncWorkRequestPreProcessorStrategy
|
||||
{
|
||||
/**
|
||||
* @var MemberScheduleWorkQueueManager
|
||||
*/
|
||||
private $queue_manager;
|
||||
|
||||
/**
|
||||
* @var IAbstractCalendarSyncWorkRequestRepository
|
||||
*/
|
||||
private $work_request_repository;
|
||||
|
||||
/**
|
||||
* @var ICalendarSyncInfoRepository
|
||||
*/
|
||||
private $calendar_sync_repository;
|
||||
|
||||
/**
|
||||
* MemberCalendarScheduleSummitActionSyncWorkRequestDeleteStrategy constructor.
|
||||
* @param MemberScheduleWorkQueueManager $queue_manager
|
||||
* @param IAbstractCalendarSyncWorkRequestRepository $work_request_repository
|
||||
* @param ICalendarSyncInfoRepository $calendar_sync_repository
|
||||
*/
|
||||
public function __construct
|
||||
(
|
||||
MemberScheduleWorkQueueManager $queue_manager,
|
||||
IAbstractCalendarSyncWorkRequestRepository $work_request_repository,
|
||||
ICalendarSyncInfoRepository $calendar_sync_repository
|
||||
)
|
||||
{
|
||||
$this->queue_manager = $queue_manager;
|
||||
$this->work_request_repository = $work_request_repository;
|
||||
$this->calendar_sync_repository = $calendar_sync_repository;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param AbstractCalendarSyncWorkRequest $request
|
||||
* @return AbstractCalendarSyncWorkRequest|null
|
||||
*/
|
||||
public function process(AbstractCalendarSyncWorkRequest $request)
|
||||
{
|
||||
if(! $request instanceof MemberCalendarScheduleSummitActionSyncWorkRequest) return null;
|
||||
$calendar_sync_info = $request->getCalendarSyncInfo();
|
||||
//check if we have pending make calendar on this round ...
|
||||
$pending_calendar_create_request = $this->queue_manager->getCalendarRequestFor($calendar_sync_info->getId(), AbstractCalendarSyncWorkRequest::TypeAdd);
|
||||
$calendar_created = true;
|
||||
if(!is_null($pending_calendar_create_request)){
|
||||
if($this->queue_manager->removeRequest($pending_calendar_create_request))
|
||||
$this->work_request_repository->delete($pending_calendar_create_request);
|
||||
$calendar_created = false;
|
||||
}
|
||||
// delete all pending work ( calendar and events)
|
||||
$pending_requests = $this->queue_manager->getPendingEventsForCalendar($calendar_sync_info->getId());
|
||||
if(count($pending_requests) > 0 ) {
|
||||
foreach($pending_requests as $pending_request) {
|
||||
if($this->queue_manager->removeRequest($pending_request))
|
||||
$this->work_request_repository->delete($pending_request);
|
||||
}
|
||||
}
|
||||
|
||||
if(!$calendar_created){
|
||||
// delete the current request ( delete calendar, we never created it )
|
||||
$this->work_request_repository->delete($request);
|
||||
$this->queue_manager->clearPendingEventsForCalendar($calendar_sync_info->getId());
|
||||
// delete revoked credentials;
|
||||
$this->calendar_sync_repository->delete($calendar_sync_info);
|
||||
return null;
|
||||
}
|
||||
|
||||
return $request;
|
||||
}
|
||||
}
|
@ -0,0 +1,84 @@
|
||||
<?php namespace App\Services\Model\Strategies\MemberActions;
|
||||
/**
|
||||
* 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\Services\Model\Strategies\ICalendarSyncWorkRequestPreProcessorStrategy;
|
||||
use models\summit\CalendarSync\WorkQueue\AbstractCalendarSyncWorkRequest;
|
||||
use models\summit\CalendarSync\WorkQueue\MemberEventScheduleSummitActionSyncWorkRequest;
|
||||
use models\summit\IAbstractCalendarSyncWorkRequestRepository;
|
||||
use App\Services\Model\MemberScheduleWorkQueueManager;
|
||||
|
||||
/**
|
||||
* Class MemberEventScheduleSummitActionSyncWorkRequestAddStrategy
|
||||
* @package App\Services\Model\Strategies\MemberActions
|
||||
*/
|
||||
final class MemberEventScheduleSummitActionSyncWorkRequestAddStrategy
|
||||
implements ICalendarSyncWorkRequestPreProcessorStrategy
|
||||
{
|
||||
|
||||
/**
|
||||
* @var MemberScheduleWorkQueueManager
|
||||
*/
|
||||
private $work_queue_manager;
|
||||
|
||||
/**
|
||||
* @var IAbstractCalendarSyncWorkRequestRepository
|
||||
*/
|
||||
private $work_request_repository;
|
||||
|
||||
/**
|
||||
* MemberEventScheduleSummitActionSyncWorkRequestAddStrategy constructor.
|
||||
* @param MemberScheduleWorkQueueManager $work_queue_manager
|
||||
* @param IAbstractCalendarSyncWorkRequestRepository $work_request_repository
|
||||
*/
|
||||
public function __construct
|
||||
(
|
||||
MemberScheduleWorkQueueManager $work_queue_manager,
|
||||
IAbstractCalendarSyncWorkRequestRepository $work_request_repository
|
||||
)
|
||||
{
|
||||
$this->work_queue_manager = $work_queue_manager;
|
||||
$this->work_request_repository = $work_request_repository;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param AbstractCalendarSyncWorkRequest $request
|
||||
* @return AbstractCalendarSyncWorkRequest|null
|
||||
*/
|
||||
public function process(AbstractCalendarSyncWorkRequest $request)
|
||||
{
|
||||
if(!$request instanceof MemberEventScheduleSummitActionSyncWorkRequest) return null;
|
||||
$summit_event = $request->getSummitEvent();
|
||||
$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());
|
||||
if(count($pending_requests) > 0 ) {
|
||||
foreach ($pending_requests as $pending_request) {
|
||||
if($request->getType() == AbstractCalendarSyncWorkRequest::TypeUpdate)
|
||||
{
|
||||
$this->work_queue_manager->registerRequestForDelete($request);
|
||||
continue;
|
||||
}
|
||||
if($this->work_queue_manager->removeRequest($pending_request))
|
||||
$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)) {
|
||||
$this->work_queue_manager->unRegisterRequestForDelete($request, AbstractCalendarSyncWorkRequest::TypeUpdate);
|
||||
$this->work_request_repository->delete($request);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
return $request;
|
||||
}
|
||||
}
|
@ -0,0 +1,83 @@
|
||||
<?php namespace App\Services\Model\Strategies\MemberActions;
|
||||
|
||||
/**
|
||||
* 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\Services\Model\Strategies\ICalendarSyncWorkRequestPreProcessorStrategy;
|
||||
use models\summit\CalendarSync\WorkQueue\AbstractCalendarSyncWorkRequest;
|
||||
use models\summit\CalendarSync\WorkQueue\MemberEventScheduleSummitActionSyncWorkRequest;
|
||||
use models\summit\IAbstractCalendarSyncWorkRequestRepository;
|
||||
use App\Services\Model\MemberScheduleWorkQueueManager;
|
||||
|
||||
/**
|
||||
* Class MemberEventScheduleSummitActionSyncWorkRequestDeleteStrategy
|
||||
* @package App\Services\Model\Strategies\MemberActions
|
||||
*/
|
||||
final class MemberEventScheduleSummitActionSyncWorkRequestDeleteStrategy
|
||||
implements ICalendarSyncWorkRequestPreProcessorStrategy
|
||||
{
|
||||
|
||||
/**
|
||||
* @var MemberScheduleWorkQueueManager
|
||||
*/
|
||||
private $queue_manager;
|
||||
|
||||
/**
|
||||
* @var IAbstractCalendarSyncWorkRequestRepository
|
||||
*/
|
||||
private $work_request_repository;
|
||||
|
||||
/**
|
||||
* MemberEventScheduleSummitActionSyncWorkRequestDeleteStrategy constructor.
|
||||
* @param MemberScheduleWorkQueueManager $queue_manager
|
||||
* @param IAbstractCalendarSyncWorkRequestRepository $work_request_repository
|
||||
*/
|
||||
public function __construct
|
||||
(
|
||||
MemberScheduleWorkQueueManager $queue_manager,
|
||||
IAbstractCalendarSyncWorkRequestRepository $work_request_repository
|
||||
)
|
||||
{
|
||||
$this->queue_manager = $queue_manager;
|
||||
$this->work_request_repository = $work_request_repository;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param AbstractCalendarSyncWorkRequest $request
|
||||
* @return AbstractCalendarSyncWorkRequest|null
|
||||
*/
|
||||
public function process(AbstractCalendarSyncWorkRequest $request)
|
||||
{
|
||||
if(!$request instanceof MemberEventScheduleSummitActionSyncWorkRequest) return null;
|
||||
$summit_event = $request->getSummitEvent();
|
||||
$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());
|
||||
if(count($pending_requests) > 0 ) {
|
||||
foreach ($pending_requests as $pending_request) {
|
||||
if($request->getType() == AbstractCalendarSyncWorkRequest::TypeUpdate)
|
||||
{
|
||||
$this->queue_manager->registerRequestForDelete($request);
|
||||
continue;
|
||||
}
|
||||
if($this->queue_manager->removeRequest($pending_request))
|
||||
$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)) {
|
||||
$this->work_request_repository->delete($request);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
return $request;
|
||||
}
|
||||
}
|
@ -0,0 +1,74 @@
|
||||
<?php namespace App\Services\Model\Strategies\MemberActions;
|
||||
/**
|
||||
* 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\Services\Model\Strategies\ICalendarSyncWorkRequestPreProcessorStrategy;
|
||||
use models\summit\CalendarSync\WorkQueue\AbstractCalendarSyncWorkRequest;
|
||||
use models\summit\CalendarSync\WorkQueue\MemberEventScheduleSummitActionSyncWorkRequest;
|
||||
use models\summit\IAbstractCalendarSyncWorkRequestRepository;
|
||||
use App\Services\Model\MemberScheduleWorkQueueManager;
|
||||
|
||||
/**
|
||||
* Class MemberEventScheduleSummitActionSyncWorkRequestUpdateStrategy
|
||||
* @package App\Services\Model\Strategies\MemberActions
|
||||
*/
|
||||
final class MemberEventScheduleSummitActionSyncWorkRequestUpdateStrategy
|
||||
implements ICalendarSyncWorkRequestPreProcessorStrategy
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @var MemberScheduleWorkQueueManager
|
||||
*/
|
||||
private $queue_manager;
|
||||
|
||||
/**
|
||||
* @var IAbstractCalendarSyncWorkRequestRepository
|
||||
*/
|
||||
private $work_request_repository;
|
||||
|
||||
/**
|
||||
* MemberEventScheduleSummitActionSyncWorkRequestUpdateStrategy constructor.
|
||||
* @param MemberScheduleWorkQueueManager $queue_manager
|
||||
* @param IAbstractCalendarSyncWorkRequestRepository $work_request_repository
|
||||
*/
|
||||
public function __construct
|
||||
(
|
||||
MemberScheduleWorkQueueManager $queue_manager,
|
||||
IAbstractCalendarSyncWorkRequestRepository $work_request_repository
|
||||
)
|
||||
{
|
||||
$this->queue_manager = $queue_manager;
|
||||
$this->work_request_repository = $work_request_repository;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param AbstractCalendarSyncWorkRequest $request
|
||||
* @return AbstractCalendarSyncWorkRequest|null
|
||||
*/
|
||||
public function process(AbstractCalendarSyncWorkRequest $request)
|
||||
{
|
||||
if(!$request instanceof MemberEventScheduleSummitActionSyncWorkRequest) return null;
|
||||
$summit_event = $request->getSummitEvent();
|
||||
$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)) {
|
||||
//$this->work_request_repository->delete($request);
|
||||
$this->queue_manager->registerRequestForDelete($request);
|
||||
return null;
|
||||
}
|
||||
return $request;
|
||||
}
|
||||
}
|
@ -28,7 +28,11 @@ use Models\foundation\summit\EntityEvents\EntityEventTypeFactory;
|
||||
use Models\foundation\summit\EntityEvents\SummitEntityEventProcessContext;
|
||||
use models\main\Member;
|
||||
use models\main\Tag;
|
||||
use models\summit\CalendarSync\WorkQueue\AbstractCalendarSyncWorkRequest;
|
||||
use models\summit\CalendarSync\WorkQueue\MemberEventScheduleSummitActionSyncWorkRequest;
|
||||
use models\summit\CalendarSync\WorkQueue\MemberScheduleSummitEventCalendarSyncWorkRequest;
|
||||
use models\summit\ConfirmationExternalOrderRequest;
|
||||
use models\summit\IAbstractCalendarSyncWorkRequestRepository;
|
||||
use models\summit\IRSVPRepository;
|
||||
use models\summit\ISpeakerRepository;
|
||||
use models\summit\ISummitAttendeeRepository;
|
||||
@ -108,6 +112,11 @@ final class SummitService implements ISummitService
|
||||
*/
|
||||
private $rsvp_repository;
|
||||
|
||||
/**
|
||||
* @var IAbstractCalendarSyncWorkRequestRepository
|
||||
*/
|
||||
private $calendar_sync_work_request_repository;
|
||||
|
||||
/**
|
||||
* SummitService constructor.
|
||||
* @param ISummitEventRepository $event_repository
|
||||
@ -118,6 +127,7 @@ final class SummitService implements ISummitService
|
||||
* @param IMemberRepository $member_repository
|
||||
* @param ITagRepository $tag_repository
|
||||
* @param IRSVPRepository $rsvp_repository,
|
||||
* @param IAbstractCalendarSyncWorkRequestRepository $calendar_sync_work_request_repository
|
||||
* @param IEventbriteAPI $eventbrite_api
|
||||
* @param ITransactionService $tx_service
|
||||
*/
|
||||
@ -131,20 +141,22 @@ final class SummitService implements ISummitService
|
||||
IMemberRepository $member_repository,
|
||||
ITagRepository $tag_repository,
|
||||
IRSVPRepository $rsvp_repository,
|
||||
IAbstractCalendarSyncWorkRequestRepository $calendar_sync_work_request_repository,
|
||||
IEventbriteAPI $eventbrite_api,
|
||||
ITransactionService $tx_service
|
||||
)
|
||||
{
|
||||
$this->event_repository = $event_repository;
|
||||
$this->speaker_repository = $speaker_repository;
|
||||
$this->entity_events_repository = $entity_events_repository;
|
||||
$this->ticket_repository = $ticket_repository;
|
||||
$this->member_repository = $member_repository;
|
||||
$this->attendee_repository = $attendee_repository;
|
||||
$this->tag_repository = $tag_repository;
|
||||
$this->rsvp_repository = $rsvp_repository;
|
||||
$this->eventbrite_api = $eventbrite_api;
|
||||
$this->tx_service = $tx_service;
|
||||
$this->event_repository = $event_repository;
|
||||
$this->speaker_repository = $speaker_repository;
|
||||
$this->entity_events_repository = $entity_events_repository;
|
||||
$this->ticket_repository = $ticket_repository;
|
||||
$this->member_repository = $member_repository;
|
||||
$this->attendee_repository = $attendee_repository;
|
||||
$this->tag_repository = $tag_repository;
|
||||
$this->rsvp_repository = $rsvp_repository;
|
||||
$this->calendar_sync_work_request_repository = $calendar_sync_work_request_repository;
|
||||
$this->eventbrite_api = $eventbrite_api;
|
||||
$this->tx_service = $tx_service;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -160,6 +172,7 @@ final class SummitService implements ISummitService
|
||||
{
|
||||
try {
|
||||
$this->tx_service->transaction(function () use ($summit, $member, $event_id, $check_rsvp) {
|
||||
|
||||
$event = $summit->getScheduleEvent($event_id);
|
||||
if (is_null($event)) {
|
||||
throw new EntityNotFoundException('event not found on summit!');
|
||||
@ -167,10 +180,21 @@ final class SummitService implements ISummitService
|
||||
if(!Summit::allowToSee($event, $member))
|
||||
throw new EntityNotFoundException('event not found on summit!');
|
||||
|
||||
if($check_rsvp && $event->hasRSVP() && !$event->getIssExternalRSVP())
|
||||
if($check_rsvp && $event->hasRSVP() && !$event->isExternalRSVP())
|
||||
throw new ValidationException("event has rsvp set on it!");
|
||||
|
||||
$member->add2Schedule($event);
|
||||
|
||||
if($member->hasSyncInfoFor($summit)) {
|
||||
$sync_info = $member->getSyncInfoBy($summit);
|
||||
$request = new MemberEventScheduleSummitActionSyncWorkRequest();
|
||||
$request->setType(AbstractCalendarSyncWorkRequest::TypeAdd);
|
||||
$request->setSummitEvent($event);
|
||||
$request->setOwner($member);
|
||||
$request->setCalendarSyncInfo($sync_info);
|
||||
$this->calendar_sync_work_request_repository->add($request);
|
||||
}
|
||||
|
||||
});
|
||||
Event::fire(new MyScheduleAdd($member ,$summit, $event_id));
|
||||
}
|
||||
@ -182,6 +206,40 @@ final class SummitService implements ISummitService
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Summit $summit
|
||||
* @param Member $member
|
||||
* @param int $event_id
|
||||
* @param boolean $check_rsvp
|
||||
* @return void
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function removeEventFromMemberSchedule(Summit $summit, Member $member, $event_id, $check_rsvp = true)
|
||||
{
|
||||
$this->tx_service->transaction(function () use ($summit, $member, $event_id, $check_rsvp) {
|
||||
$event = $summit->getScheduleEvent($event_id);
|
||||
if (is_null($event))
|
||||
throw new EntityNotFoundException('event not found on summit!');
|
||||
|
||||
if($check_rsvp && $event->hasRSVP() && !$event->isExternalRSVP())
|
||||
throw new ValidationException("event has rsvp set on it!");
|
||||
|
||||
$member->removeFromSchedule($event);
|
||||
|
||||
if($member->hasSyncInfoFor($summit)) {
|
||||
$sync_info = $member->getSyncInfoBy($summit);
|
||||
$request = new MemberEventScheduleSummitActionSyncWorkRequest();
|
||||
$request->setType(AbstractCalendarSyncWorkRequest::TypeRemove);
|
||||
$request->setSummitEvent($event);
|
||||
$request->setOwner($member);
|
||||
$request->setCalendarSyncInfo($sync_info);
|
||||
$this->calendar_sync_work_request_repository->add($request);
|
||||
}
|
||||
});
|
||||
|
||||
Event::fire(new MyScheduleRemove($member,$summit, $event_id));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Summit $summit
|
||||
* @param Member $member
|
||||
@ -200,6 +258,7 @@ final class SummitService implements ISummitService
|
||||
throw new EntityNotFoundException('event not found on summit!');
|
||||
$member->addFavoriteSummitEvent($event);
|
||||
});
|
||||
|
||||
Event::fire(new MyFavoritesAdd($member, $summit, $event_id));
|
||||
}
|
||||
catch (UniqueConstraintViolationException $ex){
|
||||
@ -210,31 +269,6 @@ final class SummitService implements ISummitService
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param Summit $summit
|
||||
* @param Member $member
|
||||
* @param int $event_id
|
||||
* @param boolean $check_rsvp
|
||||
* @return void
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function removeEventFromMemberSchedule(Summit $summit, Member $member, $event_id, $check_rsvp = true)
|
||||
{
|
||||
$this->tx_service->transaction(function () use ($summit, $member, $event_id, $check_rsvp) {
|
||||
$event = $summit->getScheduleEvent($event_id);
|
||||
if (is_null($event))
|
||||
throw new EntityNotFoundException('event not found on summit!');
|
||||
|
||||
if($check_rsvp && $event->hasRSVP() && !$event->getIssExternalRSVP())
|
||||
throw new ValidationException("event has rsvp set on it!");
|
||||
|
||||
$member->removeFromSchedule($event);
|
||||
});
|
||||
|
||||
Event::fire(new MyScheduleRemove($member,$summit, $event_id));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Summit $summit
|
||||
* @param Member $member
|
||||
|
@ -31,20 +31,80 @@ class ServicesProvider extends ServiceProvider
|
||||
public function register()
|
||||
{
|
||||
App::singleton('libs\utils\ICacheService', 'services\utils\RedisCacheService');
|
||||
|
||||
App::singleton(\libs\utils\ITransactionService::class, function(){
|
||||
return new \services\utils\DoctrineTransactionService('ss');
|
||||
});
|
||||
|
||||
App::singleton(\libs\utils\IEncryptionService::class, function(){
|
||||
return new \services\utils\EncryptionService(
|
||||
Config::get("server.ss_encrypt_key", ''),
|
||||
Config::get("server.ss_encrypt_cypher", '')
|
||||
);
|
||||
});
|
||||
|
||||
// setting facade
|
||||
$this->app['encryption'] = App::share(function ($app) {
|
||||
return new \services\utils\EncryptionService(
|
||||
Config::get("server.ss_encrypt_key", ''),
|
||||
Config::get("server.ss_encrypt_cypher", '')
|
||||
);
|
||||
});
|
||||
|
||||
App::singleton('services\model\ISummitService', 'services\model\SummitService');
|
||||
|
||||
App::singleton('services\model\IPresentationService', 'services\model\PresentationService');
|
||||
|
||||
App::singleton('services\model\IChatTeamService', 'services\model\ChatTeamService');
|
||||
|
||||
App::singleton('services\apis\IEventbriteAPI', function(){
|
||||
$api = new EventbriteAPI();
|
||||
$api->setCredentials(array('token' => Config::get("server.eventbrite_oauth2_personal_token", null)));
|
||||
return $api;
|
||||
});
|
||||
|
||||
App::singleton('services\apis\IPushNotificationApi', function(){
|
||||
$api = new FireBaseGCMApi(Config::get("server.firebase_gcm_server_key", null));
|
||||
return $api;
|
||||
});
|
||||
|
||||
// work request pre processors
|
||||
|
||||
App::singleton
|
||||
(
|
||||
'App\Services\Model\Strategies\ICalendarSyncWorkRequestPreProcessorStrategyFactory',
|
||||
'App\Services\Model\Strategies\CalendarSyncWorkRequestPreProcessorStrategyFactory'
|
||||
);
|
||||
|
||||
App::when('App\Services\Model\MemberActionsCalendarSyncPreProcessor')
|
||||
->needs('App\Services\Model\ICalendarSyncWorkRequestQueueManager')
|
||||
->give('App\Services\Model\MemberScheduleWorkQueueManager');
|
||||
|
||||
App::when('App\Services\Model\AdminActionsCalendarSyncPreProcessor')
|
||||
->needs('App\Services\Model\ICalendarSyncWorkRequestQueueManager')
|
||||
->give('App\Services\Model\AdminScheduleWorkQueueManager');
|
||||
|
||||
|
||||
// work request process services
|
||||
|
||||
App::when('App\Services\Model\MemberActionsCalendarSyncProcessingService')
|
||||
->needs('App\Services\Model\ICalendarSyncWorkRequestPreProcessor')
|
||||
->give('App\Services\Model\MemberActionsCalendarSyncPreProcessor');
|
||||
|
||||
App::singleton
|
||||
(
|
||||
'App\Services\Model\IMemberActionsCalendarSyncProcessingService',
|
||||
'App\Services\Model\MemberActionsCalendarSyncProcessingService'
|
||||
);
|
||||
|
||||
App::when('App\Services\Model\AdminActionsCalendarSyncProcessingService')
|
||||
->needs('App\Services\Model\ICalendarSyncWorkRequestPreProcessor')
|
||||
->give('App\Services\Model\AdminActionsCalendarSyncPreProcessor');
|
||||
|
||||
App::singleton
|
||||
(
|
||||
'App\Services\Model\IAdminActionsCalendarSyncProcessingService',
|
||||
'App\Services\Model\AdminActionsCalendarSyncProcessingService'
|
||||
);
|
||||
}
|
||||
}
|
48
app/Services/Utils/EncryptionService.php
Normal file
48
app/Services/Utils/EncryptionService.php
Normal file
@ -0,0 +1,48 @@
|
||||
<?php namespace services\utils;
|
||||
use libs\utils\IEncryptionService;
|
||||
|
||||
/**
|
||||
* 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 Illuminate\Encryption\Encrypter;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
/**
|
||||
* Class EncryptionService
|
||||
* @package services\utils
|
||||
*/
|
||||
final class EncryptionService implements IEncryptionService
|
||||
{
|
||||
/**
|
||||
* @var Encrypter
|
||||
*/
|
||||
private $enc;
|
||||
|
||||
public function __construct($key, $cipher)
|
||||
{
|
||||
if (Str::startsWith($key = $key, 'base64:')) {
|
||||
$key = base64_decode(substr($key, 7));
|
||||
}
|
||||
$this->enc = new Encrypter($key, $cipher);
|
||||
}
|
||||
|
||||
public function encrypt($value)
|
||||
{
|
||||
return $this->enc->encrypt($value);
|
||||
}
|
||||
|
||||
public function decrypt($payload)
|
||||
{
|
||||
return $this->enc->decrypt($payload);
|
||||
}
|
||||
}
|
27
app/Services/Utils/Facades/Encryption.php
Normal file
27
app/Services/Utils/Facades/Encryption.php
Normal file
@ -0,0 +1,27 @@
|
||||
<?php namespace services\utils\Facades;
|
||||
/**
|
||||
* 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 Illuminate\Support\Facades\Facade;
|
||||
|
||||
/**
|
||||
* Class Encryption
|
||||
* @package services\utils\Facades
|
||||
*/
|
||||
class Encryption extends Facade
|
||||
{
|
||||
protected static function getFacadeAccessor()
|
||||
{
|
||||
return 'encryption';
|
||||
}
|
||||
}
|
@ -11,19 +11,22 @@
|
||||
"php": ">=5.5.9",
|
||||
"laravel/framework": "5.2.*",
|
||||
"predis/predis": "1.0.1",
|
||||
"guzzlehttp/guzzle": "5.3.0",
|
||||
"ezyang/htmlpurifier": "4.7.0",
|
||||
"glenscott/url-normalizer" : "^1.4",
|
||||
"laravel-doctrine/orm":"1.2.*",
|
||||
"laravel-doctrine/extensions": "1.0.*",
|
||||
"cocur/slugify": "^2.3"
|
||||
"cocur/slugify": "^2.3",
|
||||
"guzzlehttp/guzzle": "^6.3",
|
||||
"google/apiclient": "^2.2",
|
||||
"smarcet/caldavclient": "dev-master",
|
||||
"smarcet/outlook-rest-client": "dev-master"
|
||||
},
|
||||
"require-dev": {
|
||||
"fzaninotto/faker": "~1.4",
|
||||
"mockery/mockery": "0.9.*",
|
||||
"phpunit/phpunit": "~4.0",
|
||||
"symfony/css-selector": "2.8.*|3.0.*",
|
||||
"symfony/dom-crawler": "2.8.*|3.0.*"
|
||||
"symfony/dom-crawler": "2.8.*|3.0.*",
|
||||
"mockery/mockery": "^0.9.9"
|
||||
},
|
||||
"autoload": {
|
||||
"classmap": [
|
||||
@ -59,5 +62,6 @@
|
||||
},
|
||||
"config": {
|
||||
"preferred-install": "dist"
|
||||
}
|
||||
},
|
||||
"minimum-stability":"dev"
|
||||
}
|
||||
|
1806
composer.lock
generated
1806
composer.lock
generated
File diff suppressed because it is too large
Load Diff
@ -212,6 +212,7 @@ return [
|
||||
'EntityManager' => LaravelDoctrine\ORM\Facades\EntityManager::class,
|
||||
'Registry' => LaravelDoctrine\ORM\Facades\Registry::class,
|
||||
'Doctrine' => LaravelDoctrine\ORM\Facades\Doctrine::class,
|
||||
'Encryption' => services\utils\Facades\Encryption::class,
|
||||
],
|
||||
|
||||
];
|
||||
|
17
config/apple_api.php
Normal file
17
config/apple_api.php
Normal file
@ -0,0 +1,17 @@
|
||||
<?php
|
||||
/**
|
||||
* 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.
|
||||
**/
|
||||
|
||||
return [
|
||||
'base_caldav_server'=> env('APPLE_CALDAV_BASE_SERVER', "p01-caldav.icloud.com"),
|
||||
];
|
@ -74,7 +74,7 @@ return [
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
'mapping_types' => [
|
||||
//'enum' => 'string'
|
||||
'enum' => 'string'
|
||||
]
|
||||
],
|
||||
'ss' => [
|
||||
@ -130,7 +130,7 @@ return [
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
'mapping_types' => [
|
||||
//'enum' => 'string'
|
||||
'enum' => 'string'
|
||||
]
|
||||
]
|
||||
],
|
||||
|
19
config/google_api.php
Normal file
19
config/google_api.php
Normal file
@ -0,0 +1,19 @@
|
||||
<?php
|
||||
/**
|
||||
* 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.
|
||||
**/
|
||||
|
||||
return [
|
||||
'google_client_id' => env('GOOGLE_CLIENT_ID', null),
|
||||
'google_client_secret' => env('GOOGLE_CLIENT_SECRET', null),
|
||||
'google_scopes' => env('GOOGLE_SCOPES', null),
|
||||
];
|
@ -22,4 +22,6 @@ return array
|
||||
'response_cache_lifetime' => env('API_RESPONSE_CACHE_LIFETIME', 300),
|
||||
'eventbrite_oauth2_personal_token' => env('EVENTBRITE_OAUTH2_PERSONAL_TOKEN', ''),
|
||||
'firebase_gcm_server_key' => env('FIREBASE_GCM_SERVER_KEY', ''),
|
||||
'ss_encrypt_key' => env('SS_ENCRYPT_KEY', ''),
|
||||
'ss_encrypt_cypher' => env('SS_ENCRYPT_CYPHER', ''),
|
||||
);
|
170
tests/AdminActionsCalendarSyncPreProcessorTest.php
Normal file
170
tests/AdminActionsCalendarSyncPreProcessorTest.php
Normal file
@ -0,0 +1,170 @@
|
||||
<?php
|
||||
/**
|
||||
* 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\summit\IAbstractCalendarSyncWorkRequestRepository;
|
||||
use models\summit\ICalendarSyncInfoRepository;
|
||||
use models\summit\SummitEvent;
|
||||
use models\summit\CalendarSync\WorkQueue\AdminSummitEventActionSyncWorkRequest;
|
||||
use models\summit\CalendarSync\WorkQueue\AdminSummitLocationActionSyncWorkRequest;
|
||||
use models\summit\CalendarSync\WorkQueue\AbstractCalendarSyncWorkRequest;
|
||||
/**
|
||||
* Class AdminActionsCalendarSyncPreProcessorTest
|
||||
*/
|
||||
final class AdminActionsCalendarSyncPreProcessorTest extends TestCase
|
||||
{
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
}
|
||||
|
||||
protected function prepareForTests()
|
||||
{
|
||||
parent::prepareForTests();
|
||||
}
|
||||
|
||||
public function tearDown()
|
||||
{
|
||||
Mockery::close();
|
||||
}
|
||||
|
||||
public function createApplication()
|
||||
{
|
||||
$app = parent::createApplication();
|
||||
|
||||
$repo_mock = Mockery::mock(IAbstractCalendarSyncWorkRequestRepository::class)->shouldIgnoreMissing();
|
||||
$app->instance(IAbstractCalendarSyncWorkRequestRepository::class, $repo_mock);
|
||||
|
||||
$repo_mock = Mockery::mock(ICalendarSyncInfoRepository::class)->shouldIgnoreMissing();
|
||||
$app->instance(ICalendarSyncInfoRepository::class, $repo_mock);
|
||||
return $app;
|
||||
}
|
||||
|
||||
public function testUpdateFourthSameEvent(){
|
||||
$preprocessor = App::make('App\Services\Model\AdminActionsCalendarSyncPreProcessor');
|
||||
|
||||
$summit_event = Mockery::mock(SummitEvent::class);
|
||||
$summit_event->shouldReceive('getId')->andReturn(1);
|
||||
|
||||
$mock_update_request = Mockery::mock(AdminSummitEventActionSyncWorkRequest::class);
|
||||
$mock_update_request->shouldReceive('getSummitEvent')->andReturn($summit_event);
|
||||
$mock_update_request->shouldReceive('getType')->andReturn(AbstractCalendarSyncWorkRequest::TypeUpdate);
|
||||
|
||||
$mock_update_request1 = Mockery::mock(AdminSummitEventActionSyncWorkRequest::class);
|
||||
$mock_update_request1->shouldReceive('getSummitEvent')->andReturn($summit_event);
|
||||
$mock_update_request1->shouldReceive('getType')->andReturn(AbstractCalendarSyncWorkRequest::TypeUpdate);
|
||||
|
||||
$mock_update_request2 = Mockery::mock(AdminSummitEventActionSyncWorkRequest::class);
|
||||
$mock_update_request2->shouldReceive('getSummitEvent')->andReturn($summit_event);
|
||||
$mock_update_request2->shouldReceive('getType')->andReturn(AbstractCalendarSyncWorkRequest::TypeUpdate);
|
||||
|
||||
$mock_update_request3 = Mockery::mock(AdminSummitEventActionSyncWorkRequest::class);
|
||||
$mock_update_request3->shouldReceive('getSummitEvent')->andReturn($summit_event);
|
||||
$mock_update_request3->shouldReceive('getType')->andReturn(AbstractCalendarSyncWorkRequest::TypeUpdate);
|
||||
|
||||
$purged_requests = $preprocessor->preProcessActions([
|
||||
$mock_update_request,
|
||||
$mock_update_request1,
|
||||
$mock_update_request2,
|
||||
$mock_update_request3
|
||||
]);
|
||||
|
||||
$this->assertTrue(count($purged_requests) == 1);
|
||||
}
|
||||
|
||||
public function testUpdateFourthTimesDeleteSameEvent(){
|
||||
$preprocessor = App::make('App\Services\Model\AdminActionsCalendarSyncPreProcessor');
|
||||
|
||||
$summit_event = Mockery::mock(SummitEvent::class);
|
||||
$summit_event->shouldReceive('getId')->andReturn(1);
|
||||
|
||||
$mock_update_request = Mockery::mock(AdminSummitEventActionSyncWorkRequest::class);
|
||||
$mock_update_request->shouldReceive('getSummitEvent')->andReturn($summit_event);
|
||||
$mock_update_request->shouldReceive('getType')->andReturn(AbstractCalendarSyncWorkRequest::TypeUpdate);
|
||||
|
||||
$mock_update_request1 = Mockery::mock(AdminSummitEventActionSyncWorkRequest::class);
|
||||
$mock_update_request1->shouldReceive('getSummitEvent')->andReturn($summit_event);
|
||||
$mock_update_request1->shouldReceive('getType')->andReturn(AbstractCalendarSyncWorkRequest::TypeUpdate);
|
||||
|
||||
$mock_update_request2 = Mockery::mock(AdminSummitEventActionSyncWorkRequest::class);
|
||||
$mock_update_request2->shouldReceive('getSummitEvent')->andReturn($summit_event);
|
||||
$mock_update_request2->shouldReceive('getType')->andReturn(AbstractCalendarSyncWorkRequest::TypeUpdate);
|
||||
|
||||
$mock_update_request3 = Mockery::mock(AdminSummitEventActionSyncWorkRequest::class);
|
||||
$mock_update_request3->shouldReceive('getSummitEvent')->andReturn($summit_event);
|
||||
$mock_update_request3->shouldReceive('getType')->andReturn(AbstractCalendarSyncWorkRequest::TypeUpdate);
|
||||
|
||||
$mock_delete_request = Mockery::mock(AdminSummitEventActionSyncWorkRequest::class);
|
||||
$mock_delete_request->shouldReceive('getSummitEvent')->andReturn($summit_event);
|
||||
$mock_delete_request->shouldReceive('getType')->andReturn(AbstractCalendarSyncWorkRequest::TypeRemove);
|
||||
|
||||
$purged_requests = $preprocessor->preProcessActions([
|
||||
$mock_update_request,
|
||||
$mock_update_request1,
|
||||
$mock_delete_request,
|
||||
$mock_update_request2,
|
||||
$mock_update_request3
|
||||
]);
|
||||
|
||||
$this->assertTrue(count($purged_requests) == 1);
|
||||
$this->assertTrue($purged_requests[0]->getType() == AbstractCalendarSyncWorkRequest::TypeUpdate);
|
||||
}
|
||||
|
||||
public function testDeleteUpdateSameEvent(){
|
||||
$preprocessor = App::make('App\Services\Model\AdminActionsCalendarSyncPreProcessor');
|
||||
|
||||
$summit_event = Mockery::mock(SummitEvent::class);
|
||||
$summit_event->shouldReceive('getId')->andReturn(1);
|
||||
|
||||
$mock_delete_request = Mockery::mock(AdminSummitEventActionSyncWorkRequest::class);
|
||||
$mock_delete_request->shouldReceive('getSummitEvent')->andReturn($summit_event);
|
||||
$mock_delete_request->shouldReceive('getType')->andReturn(AbstractCalendarSyncWorkRequest::TypeRemove);
|
||||
|
||||
$mock_update_request = Mockery::mock(AdminSummitEventActionSyncWorkRequest::class);
|
||||
$mock_update_request->shouldReceive('getSummitEvent')->andReturn($summit_event);
|
||||
$mock_update_request->shouldReceive('getType')->andReturn(AbstractCalendarSyncWorkRequest::TypeUpdate);
|
||||
|
||||
$purged_requests = $preprocessor->preProcessActions([
|
||||
$mock_delete_request,
|
||||
$mock_update_request
|
||||
]);
|
||||
|
||||
$this->assertTrue(count($purged_requests) == 1);
|
||||
$this->assertTrue($purged_requests[0]->getType() == AbstractCalendarSyncWorkRequest::TypeUpdate);
|
||||
}
|
||||
|
||||
|
||||
public function testUpdateDeleteSameEvent(){
|
||||
|
||||
$preprocessor = App::make('App\Services\Model\AdminActionsCalendarSyncPreProcessor');
|
||||
|
||||
$summit_event = Mockery::mock(SummitEvent::class);
|
||||
$summit_event->shouldReceive('getId')->andReturn(1);
|
||||
|
||||
$mock_delete_request = Mockery::mock(AdminSummitEventActionSyncWorkRequest::class);
|
||||
$mock_delete_request->shouldReceive('getSummitEvent')->andReturn($summit_event);
|
||||
$mock_delete_request->shouldReceive('getType')->andReturn(AbstractCalendarSyncWorkRequest::TypeRemove);
|
||||
|
||||
$mock_update_request = Mockery::mock(AdminSummitEventActionSyncWorkRequest::class);
|
||||
$mock_update_request->shouldReceive('getSummitEvent')->andReturn($summit_event);
|
||||
$mock_update_request->shouldReceive('getType')->andReturn(AbstractCalendarSyncWorkRequest::TypeUpdate);
|
||||
|
||||
$purged_requests = $preprocessor->preProcessActions([
|
||||
$mock_update_request,
|
||||
$mock_delete_request,
|
||||
]);
|
||||
|
||||
$this->assertTrue(count($purged_requests) == 1);
|
||||
$this->assertTrue($purged_requests[0]->getType() == AbstractCalendarSyncWorkRequest::TypeRemove);
|
||||
}
|
||||
|
||||
}
|
308
tests/MemberActionsCalendarSyncPreProcessorTest.php
Normal file
308
tests/MemberActionsCalendarSyncPreProcessorTest.php
Normal file
@ -0,0 +1,308 @@
|
||||
<?php
|
||||
/**
|
||||
* 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 Illuminate\Support\Facades\App;
|
||||
use models\summit\IAbstractCalendarSyncWorkRequestRepository;
|
||||
use models\summit\ICalendarSyncInfoRepository;
|
||||
use models\summit\CalendarSync\WorkQueue\MemberEventScheduleSummitActionSyncWorkRequest;
|
||||
use models\summit\SummitEvent;
|
||||
use models\summit\CalendarSync\WorkQueue\AbstractCalendarSyncWorkRequest;
|
||||
use models\summit\CalendarSync\CalendarSyncInfo;
|
||||
use models\main\Member;
|
||||
|
||||
/**
|
||||
* Class MemberActionsCalendarSyncPreProcessorTest
|
||||
*/
|
||||
final class MemberActionsCalendarSyncPreProcessorTest extends TestCase
|
||||
{
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
}
|
||||
|
||||
protected function prepareForTests()
|
||||
{
|
||||
parent::prepareForTests();
|
||||
}
|
||||
|
||||
public function tearDown()
|
||||
{
|
||||
Mockery::close();
|
||||
}
|
||||
|
||||
public function createApplication()
|
||||
{
|
||||
$app = parent::createApplication();
|
||||
|
||||
$repo_mock = Mockery::mock(IAbstractCalendarSyncWorkRequestRepository::class)->shouldIgnoreMissing();
|
||||
$app->instance(IAbstractCalendarSyncWorkRequestRepository::class, $repo_mock);
|
||||
|
||||
$repo_mock = Mockery::mock(ICalendarSyncInfoRepository::class)->shouldIgnoreMissing();
|
||||
$app->instance(ICalendarSyncInfoRepository::class, $repo_mock);
|
||||
return $app;
|
||||
}
|
||||
|
||||
public function testSynchronizedRemoveUpdateAdd(){
|
||||
|
||||
$preprocessor = App::make('App\Services\Model\MemberActionsCalendarSyncPreProcessor');
|
||||
|
||||
$summit_event = Mockery::mock(SummitEvent::class);
|
||||
$summit_event->shouldReceive('getId')->andReturn(1);
|
||||
|
||||
$member_mock = Mockery::mock(Member::class);
|
||||
$member_mock->shouldReceive("isEventSynchronized")->andReturn(true);
|
||||
|
||||
$calendar_sync_info = Mockery::mock(CalendarSyncInfo::class);
|
||||
$calendar_sync_info->shouldReceive("getId")->andReturn(1);
|
||||
|
||||
$request_delete_mock = Mockery::mock(MemberEventScheduleSummitActionSyncWorkRequest::class);
|
||||
$request_delete_mock->shouldReceive('getSummitEvent')->andReturn($summit_event);
|
||||
$request_delete_mock->shouldReceive('getType')->andReturn(AbstractCalendarSyncWorkRequest::TypeRemove);
|
||||
$request_delete_mock->shouldReceive("getOwner")->andReturn($member_mock);
|
||||
$request_delete_mock->shouldReceive("getCalendarSyncInfo")->andReturn($calendar_sync_info);
|
||||
|
||||
$request_update_mock = Mockery::mock(MemberEventScheduleSummitActionSyncWorkRequest::class);
|
||||
$request_update_mock->shouldReceive('getSummitEvent')->andReturn($summit_event);
|
||||
$request_update_mock->shouldReceive('getType')->andReturn(AbstractCalendarSyncWorkRequest::TypeUpdate);
|
||||
$request_update_mock->shouldReceive("getOwner")->andReturn($member_mock);
|
||||
$request_update_mock->shouldReceive("getCalendarSyncInfo")->andReturn($calendar_sync_info);
|
||||
|
||||
$request_add_mock = Mockery::mock(MemberEventScheduleSummitActionSyncWorkRequest::class);
|
||||
$request_add_mock->shouldReceive('getSummitEvent')->andReturn($summit_event);
|
||||
$request_add_mock->shouldReceive('getType')->andReturn(AbstractCalendarSyncWorkRequest::TypeAdd);
|
||||
$request_add_mock->shouldReceive("getCalendarSyncInfo")->andReturn($calendar_sync_info);
|
||||
$request_add_mock->shouldReceive("getOwner")->andReturn($member_mock);
|
||||
|
||||
|
||||
// preconditions event id 1 is already synchronized with user external calendar
|
||||
// we pass over the time this work load
|
||||
// delete , update, add
|
||||
// bc event is already synchronized, the purged actions should only emmit an update
|
||||
$purged_requests = $preprocessor->preProcessActions([
|
||||
$request_delete_mock,
|
||||
$request_update_mock,
|
||||
$request_add_mock
|
||||
]);
|
||||
|
||||
$this->assertTrue(count($purged_requests) == 1);
|
||||
|
||||
$this->assertTrue($purged_requests[0]->getType() == AbstractCalendarSyncWorkRequest::TypeUpdate);
|
||||
}
|
||||
|
||||
public function testSynchronizedRemoveAdd(){
|
||||
|
||||
$preprocessor = App::make('App\Services\Model\MemberActionsCalendarSyncPreProcessor');
|
||||
|
||||
$summit_event = Mockery::mock(SummitEvent::class);
|
||||
$summit_event->shouldReceive('getId')->andReturn(1);
|
||||
|
||||
$member_mock = Mockery::mock(Member::class);
|
||||
$member_mock->shouldReceive("isEventSynchronized")->andReturn(true);
|
||||
|
||||
$calendar_sync_info = Mockery::mock(CalendarSyncInfo::class);
|
||||
$calendar_sync_info->shouldReceive("getId")->andReturn(1);
|
||||
|
||||
$request_delete_mock = Mockery::mock(MemberEventScheduleSummitActionSyncWorkRequest::class);
|
||||
$request_delete_mock->shouldReceive('getSummitEvent')->andReturn($summit_event);
|
||||
$request_delete_mock->shouldReceive('getType')->andReturn(AbstractCalendarSyncWorkRequest::TypeRemove);
|
||||
$request_delete_mock->shouldReceive("getOwner")->andReturn($member_mock);
|
||||
$request_delete_mock->shouldReceive("getCalendarSyncInfo")->andReturn($calendar_sync_info);
|
||||
|
||||
$request_add_mock = Mockery::mock(MemberEventScheduleSummitActionSyncWorkRequest::class);
|
||||
$request_add_mock->shouldReceive('getSummitEvent')->andReturn($summit_event);
|
||||
$request_add_mock->shouldReceive('getType')->andReturn(AbstractCalendarSyncWorkRequest::TypeAdd);
|
||||
$request_add_mock->shouldReceive("getCalendarSyncInfo")->andReturn($calendar_sync_info);
|
||||
$request_add_mock->shouldReceive("getOwner")->andReturn($member_mock);
|
||||
|
||||
|
||||
// preconditions event id 1 is already synchronized with user external calendar
|
||||
// we pass over the time this work load
|
||||
// delete , add
|
||||
// bc event is already synchronized, the purged actions should only emmit zero elements ( no action)
|
||||
$purged_requests = $preprocessor->preProcessActions([
|
||||
$request_delete_mock,
|
||||
$request_add_mock
|
||||
]);
|
||||
|
||||
$this->assertTrue(count($purged_requests) == 0);
|
||||
}
|
||||
|
||||
public function testSynchronizedRemoveUpdate(){
|
||||
|
||||
$preprocessor = App::make('App\Services\Model\MemberActionsCalendarSyncPreProcessor');
|
||||
|
||||
$summit_event = Mockery::mock(SummitEvent::class);
|
||||
$summit_event->shouldReceive('getId')->andReturn(1);
|
||||
|
||||
$member_mock = Mockery::mock(Member::class);
|
||||
$member_mock->shouldReceive("isEventSynchronized")->andReturn(true);
|
||||
|
||||
$calendar_sync_info = Mockery::mock(CalendarSyncInfo::class);
|
||||
$calendar_sync_info->shouldReceive("getId")->andReturn(1);
|
||||
|
||||
$request_delete_mock = Mockery::mock(MemberEventScheduleSummitActionSyncWorkRequest::class);
|
||||
$request_delete_mock->shouldReceive('getSummitEvent')->andReturn($summit_event);
|
||||
$request_delete_mock->shouldReceive('getType')->andReturn(AbstractCalendarSyncWorkRequest::TypeRemove);
|
||||
$request_delete_mock->shouldReceive("getOwner")->andReturn($member_mock);
|
||||
$request_delete_mock->shouldReceive("getCalendarSyncInfo")->andReturn($calendar_sync_info);
|
||||
|
||||
$request_update_mock = Mockery::mock(MemberEventScheduleSummitActionSyncWorkRequest::class);
|
||||
$request_update_mock->shouldReceive('getSummitEvent')->andReturn($summit_event);
|
||||
$request_update_mock->shouldReceive('getType')->andReturn(AbstractCalendarSyncWorkRequest::TypeUpdate);
|
||||
$request_update_mock->shouldReceive("getOwner")->andReturn($member_mock);
|
||||
$request_update_mock->shouldReceive("getCalendarSyncInfo")->andReturn($calendar_sync_info);
|
||||
|
||||
|
||||
// preconditions event id 1 is already synchronized with user external calendar
|
||||
// we pass over the time this work load
|
||||
// delete, update
|
||||
// bc event is already synchronized, the purged actions should only emmit an delete
|
||||
$purged_requests = $preprocessor->preProcessActions([
|
||||
$request_delete_mock,
|
||||
$request_update_mock,
|
||||
]);
|
||||
|
||||
$this->assertTrue(count($purged_requests) == 1);
|
||||
|
||||
$this->assertTrue($purged_requests[0]->getType() == AbstractCalendarSyncWorkRequest::TypeRemove);
|
||||
}
|
||||
|
||||
public function testSynchronizedUpdateRemove(){
|
||||
|
||||
$preprocessor = App::make('App\Services\Model\MemberActionsCalendarSyncPreProcessor');
|
||||
|
||||
$summit_event = Mockery::mock(SummitEvent::class);
|
||||
$summit_event->shouldReceive('getId')->andReturn(1);
|
||||
|
||||
$member_mock = Mockery::mock(Member::class);
|
||||
$member_mock->shouldReceive("isEventSynchronized")->andReturn(true);
|
||||
|
||||
$calendar_sync_info = Mockery::mock(CalendarSyncInfo::class);
|
||||
$calendar_sync_info->shouldReceive("getId")->andReturn(1);
|
||||
|
||||
$request_delete_mock = Mockery::mock(MemberEventScheduleSummitActionSyncWorkRequest::class);
|
||||
$request_delete_mock->shouldReceive('getSummitEvent')->andReturn($summit_event);
|
||||
$request_delete_mock->shouldReceive('getType')->andReturn(AbstractCalendarSyncWorkRequest::TypeRemove);
|
||||
$request_delete_mock->shouldReceive("getOwner")->andReturn($member_mock);
|
||||
$request_delete_mock->shouldReceive("getCalendarSyncInfo")->andReturn($calendar_sync_info);
|
||||
|
||||
$request_update_mock = Mockery::mock(MemberEventScheduleSummitActionSyncWorkRequest::class);
|
||||
$request_update_mock->shouldReceive('getSummitEvent')->andReturn($summit_event);
|
||||
$request_update_mock->shouldReceive('getType')->andReturn(AbstractCalendarSyncWorkRequest::TypeUpdate);
|
||||
$request_update_mock->shouldReceive("getOwner")->andReturn($member_mock);
|
||||
$request_update_mock->shouldReceive("getCalendarSyncInfo")->andReturn($calendar_sync_info);
|
||||
|
||||
|
||||
// preconditions event id 1 is already synchronized with user external calendar
|
||||
// we pass over the time this work load
|
||||
// update, delete
|
||||
// bc event is already synchronized, the purged actions should only emmit an delete
|
||||
$purged_requests = $preprocessor->preProcessActions([
|
||||
$request_update_mock,
|
||||
$request_delete_mock,
|
||||
]);
|
||||
|
||||
$this->assertTrue(count($purged_requests) == 1);
|
||||
|
||||
$this->assertTrue($purged_requests[0]->getType() == AbstractCalendarSyncWorkRequest::TypeRemove);
|
||||
}
|
||||
|
||||
public function testUnSynchronizedAddRemoveAdd(){
|
||||
|
||||
$preprocessor = App::make('App\Services\Model\MemberActionsCalendarSyncPreProcessor');
|
||||
|
||||
$summit_event = Mockery::mock(SummitEvent::class);
|
||||
$summit_event->shouldReceive('getId')->andReturn(1);
|
||||
|
||||
$member_mock = Mockery::mock(Member::class);
|
||||
$member_mock->shouldReceive("isEventSynchronized")->andReturn(false);
|
||||
|
||||
$calendar_sync_info = Mockery::mock(CalendarSyncInfo::class);
|
||||
$calendar_sync_info->shouldReceive("getId")->andReturn(1);
|
||||
|
||||
|
||||
$request_add_mock = Mockery::mock(MemberEventScheduleSummitActionSyncWorkRequest::class);
|
||||
$request_add_mock->shouldReceive('getSummitEvent')->andReturn($summit_event);
|
||||
$request_add_mock->shouldReceive('getType')->andReturn(AbstractCalendarSyncWorkRequest::TypeAdd);
|
||||
$request_add_mock->shouldReceive("getCalendarSyncInfo")->andReturn($calendar_sync_info);
|
||||
$request_add_mock->shouldReceive("getOwner")->andReturn($member_mock);
|
||||
|
||||
|
||||
$request_delete_mock = Mockery::mock(MemberEventScheduleSummitActionSyncWorkRequest::class);
|
||||
$request_delete_mock->shouldReceive('getSummitEvent')->andReturn($summit_event);
|
||||
$request_delete_mock->shouldReceive('getType')->andReturn(AbstractCalendarSyncWorkRequest::TypeRemove);
|
||||
$request_delete_mock->shouldReceive("getOwner")->andReturn($member_mock);
|
||||
$request_delete_mock->shouldReceive("getCalendarSyncInfo")->andReturn($calendar_sync_info);
|
||||
|
||||
$request_add_mock2 = Mockery::mock(MemberEventScheduleSummitActionSyncWorkRequest::class);
|
||||
$request_add_mock2->shouldReceive('getSummitEvent')->andReturn($summit_event);
|
||||
$request_add_mock2->shouldReceive('getType')->andReturn(AbstractCalendarSyncWorkRequest::TypeAdd);
|
||||
$request_add_mock2->shouldReceive("getCalendarSyncInfo")->andReturn($calendar_sync_info);
|
||||
$request_add_mock2->shouldReceive("getOwner")->andReturn($member_mock);
|
||||
|
||||
|
||||
// preconditions event id 1 is not synchronized
|
||||
// we pass over the time this work load
|
||||
// add , delete, add
|
||||
// bc event is already synchronized, the purged actions should only emmit 1 element : add
|
||||
$purged_requests = $preprocessor->preProcessActions([
|
||||
$request_add_mock,
|
||||
$request_delete_mock,
|
||||
$request_add_mock2
|
||||
]);
|
||||
|
||||
$this->assertTrue(count($purged_requests) == 1);
|
||||
$this->assertTrue($purged_requests[0]->getType() == AbstractCalendarSyncWorkRequest::TypeAdd);
|
||||
}
|
||||
|
||||
public function testUnSynchronizedAddAdd(){
|
||||
|
||||
$preprocessor = App::make('App\Services\Model\MemberActionsCalendarSyncPreProcessor');
|
||||
|
||||
$summit_event = Mockery::mock(SummitEvent::class);
|
||||
$summit_event->shouldReceive('getId')->andReturn(1);
|
||||
|
||||
$member_mock = Mockery::mock(Member::class);
|
||||
$member_mock->shouldReceive("isEventSynchronized")->andReturn(false);
|
||||
|
||||
$calendar_sync_info = Mockery::mock(CalendarSyncInfo::class);
|
||||
$calendar_sync_info->shouldReceive("getId")->andReturn(1);
|
||||
|
||||
|
||||
$request_add_mock = Mockery::mock(MemberEventScheduleSummitActionSyncWorkRequest::class);
|
||||
$request_add_mock->shouldReceive('getSummitEvent')->andReturn($summit_event);
|
||||
$request_add_mock->shouldReceive('getType')->andReturn(AbstractCalendarSyncWorkRequest::TypeAdd);
|
||||
$request_add_mock->shouldReceive("getCalendarSyncInfo")->andReturn($calendar_sync_info);
|
||||
$request_add_mock->shouldReceive("getOwner")->andReturn($member_mock);
|
||||
|
||||
$request_add_mock2 = Mockery::mock(MemberEventScheduleSummitActionSyncWorkRequest::class);
|
||||
$request_add_mock2->shouldReceive('getSummitEvent')->andReturn($summit_event);
|
||||
$request_add_mock2->shouldReceive('getType')->andReturn(AbstractCalendarSyncWorkRequest::TypeAdd);
|
||||
$request_add_mock2->shouldReceive("getCalendarSyncInfo")->andReturn($calendar_sync_info);
|
||||
$request_add_mock2->shouldReceive("getOwner")->andReturn($member_mock);
|
||||
|
||||
|
||||
// preconditions event id 1 is not synchronized
|
||||
// we pass over the time this work load
|
||||
// add , delete, add
|
||||
// bc event is already synchronized, the purged actions should only emmit 1 element : add
|
||||
$purged_requests = $preprocessor->preProcessActions([
|
||||
$request_add_mock,
|
||||
$request_add_mock2
|
||||
]);
|
||||
|
||||
$this->assertTrue(count($purged_requests) == 1);
|
||||
$this->assertTrue($purged_requests[0]->getType() == AbstractCalendarSyncWorkRequest::TypeAdd);
|
||||
}
|
||||
}
|
@ -266,7 +266,6 @@ final class OAuth2SummitApiTest extends ProtectedApiTest
|
||||
$this->assertTrue(!is_null($attendee));
|
||||
}
|
||||
|
||||
|
||||
public function testCurrentSummitMyAttendeeAddToSchedule($event_id = 18845, $summit_id = 22)
|
||||
{
|
||||
$params = array
|
||||
@ -290,7 +289,6 @@ final class OAuth2SummitApiTest extends ProtectedApiTest
|
||||
$this->assertResponseStatus(201);
|
||||
}
|
||||
|
||||
|
||||
public function testCurrentSummitMyAttendeeScheduleUnset($event_id = 18845, $summit_id = 22)
|
||||
{
|
||||
//$this->testCurrentSummitMyAttendeeAddToSchedule($event_id, $summit_id);
|
||||
@ -2148,7 +2146,7 @@ final class OAuth2SummitApiTest extends ProtectedApiTest
|
||||
$this->assertTrue(!is_null($events));
|
||||
}
|
||||
|
||||
public function testAdd2Favorite($summit_id = 7, $event_id = 14964){
|
||||
public function testAdd2Favorite($summit_id = 22, $event_id = 18719){
|
||||
$params = array
|
||||
(
|
||||
'id' => $summit_id,
|
||||
@ -2170,7 +2168,7 @@ final class OAuth2SummitApiTest extends ProtectedApiTest
|
||||
$this->assertResponseStatus(201);
|
||||
}
|
||||
|
||||
public function testRemoveFromFavorites($summit_id = 7, $event_id = 14964){
|
||||
public function testRemoveFromFavorites($summit_id = 22, $event_id = 18719){
|
||||
|
||||
$params = array
|
||||
(
|
||||
@ -2271,6 +2269,53 @@ final class OAuth2SummitApiTest extends ProtectedApiTest
|
||||
$this->assertTrue(!is_null($favorites));
|
||||
}
|
||||
|
||||
public function testCurrentSummitMemberAddToSchedule($event_id = 18845, $summit_id = 22)
|
||||
{
|
||||
$params = array
|
||||
(
|
||||
'id' => $summit_id,
|
||||
'member_id' => 'me',
|
||||
'event_id' => $event_id
|
||||
);
|
||||
|
||||
$headers = array("HTTP_Authorization" => " Bearer " . $this->access_token);
|
||||
$response = $this->action(
|
||||
"POST",
|
||||
"OAuth2SummitMembersApiController@addEventToMemberSchedule",
|
||||
$params,
|
||||
array(),
|
||||
array(),
|
||||
array(),
|
||||
$headers
|
||||
);
|
||||
$content = $response->getContent();
|
||||
$this->assertResponseStatus(201);
|
||||
}
|
||||
|
||||
public function testCurrentSummitMemberScheduleUnset($event_id = 18845, $summit_id = 22)
|
||||
{
|
||||
$this->testCurrentSummitMemberAddToSchedule($event_id, $summit_id);
|
||||
$params = array
|
||||
(
|
||||
'id' => $summit_id,
|
||||
'member_id' => 'me',
|
||||
'event_id' => $event_id
|
||||
);
|
||||
|
||||
$headers = array("HTTP_Authorization" => " Bearer " . $this->access_token);
|
||||
$response = $this->action(
|
||||
"DELETE",
|
||||
"OAuth2SummitMembersApiController@removeEventFromMemberSchedule",
|
||||
$params,
|
||||
array(),
|
||||
array(),
|
||||
array(),
|
||||
$headers
|
||||
);
|
||||
$content = $response->getContent();
|
||||
$this->assertResponseStatus(204);
|
||||
}
|
||||
|
||||
public function testCurrentSummitMyMemberScheduleUnRSVP($event_id = 18639, $summit_id = 22)
|
||||
{
|
||||
//$this->testCurrentSummitMyAttendeeAddToSchedule($event_id, $summit_id);
|
||||
|
@ -57,7 +57,7 @@ class AccessTokenServiceStub implements IAccessTokenService
|
||||
$url . '/me/summits/events/favorites/delete',
|
||||
);
|
||||
|
||||
return AccessToken::createFromParams('123456789', implode(' ', $scopes), '1', $realm, '1','13867', 3600, 'WEB_APPLICATION', '', '');
|
||||
return AccessToken::createFromParams('123456789', implode(' ', $scopes), '1', $realm, '1','11624', 3600, 'WEB_APPLICATION', '', '');
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user