|
|
@ -55,10 +55,10 @@ class UpdateCalendarResourcesRoomsBackgroundJob extends TimedJob {
|
|
|
|
private $calDavBackend;
|
|
|
|
private $calDavBackend;
|
|
|
|
|
|
|
|
|
|
|
|
public function __construct(ITimeFactory $time,
|
|
|
|
public function __construct(ITimeFactory $time,
|
|
|
|
IResourceManager $resourceManager,
|
|
|
|
IResourceManager $resourceManager,
|
|
|
|
IRoomManager $roomManager,
|
|
|
|
IRoomManager $roomManager,
|
|
|
|
IDBConnection $dbConnection,
|
|
|
|
IDBConnection $dbConnection,
|
|
|
|
CalDavBackend $calDavBackend) {
|
|
|
|
CalDavBackend $calDavBackend) {
|
|
|
|
parent::__construct($time);
|
|
|
|
parent::__construct($time);
|
|
|
|
$this->resourceManager = $resourceManager;
|
|
|
|
$this->resourceManager = $resourceManager;
|
|
|
|
$this->roomManager = $roomManager;
|
|
|
|
$this->roomManager = $roomManager;
|
|
|
@ -101,10 +101,10 @@ class UpdateCalendarResourcesRoomsBackgroundJob extends TimedJob {
|
|
|
|
* @param string $principalPrefix
|
|
|
|
* @param string $principalPrefix
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
private function runForBackend($backendManager,
|
|
|
|
private function runForBackend($backendManager,
|
|
|
|
string $dbTable,
|
|
|
|
string $dbTable,
|
|
|
|
string $dbTableMetadata,
|
|
|
|
string $dbTableMetadata,
|
|
|
|
string $foreignKey,
|
|
|
|
string $foreignKey,
|
|
|
|
string $principalPrefix): void {
|
|
|
|
string $principalPrefix): void {
|
|
|
|
$backends = $backendManager->getBackends();
|
|
|
|
$backends = $backendManager->getBackends();
|
|
|
|
|
|
|
|
|
|
|
|
foreach ($backends as $backend) {
|
|
|
|
foreach ($backends as $backend) {
|
|
|
@ -194,8 +194,8 @@ class UpdateCalendarResourcesRoomsBackgroundJob extends TimedJob {
|
|
|
|
* @return int Insert id
|
|
|
|
* @return int Insert id
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
private function addToCache(string $table,
|
|
|
|
private function addToCache(string $table,
|
|
|
|
string $backendId,
|
|
|
|
string $backendId,
|
|
|
|
$remote): int {
|
|
|
|
$remote): int {
|
|
|
|
$query = $this->dbConnection->getQueryBuilder();
|
|
|
|
$query = $this->dbConnection->getQueryBuilder();
|
|
|
|
$query->insert($table)
|
|
|
|
$query->insert($table)
|
|
|
|
->values([
|
|
|
|
->values([
|
|
|
@ -219,9 +219,9 @@ class UpdateCalendarResourcesRoomsBackgroundJob extends TimedJob {
|
|
|
|
* @param array $metadata
|
|
|
|
* @param array $metadata
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
private function addMetadataToCache(string $table,
|
|
|
|
private function addMetadataToCache(string $table,
|
|
|
|
string $foreignKey,
|
|
|
|
string $foreignKey,
|
|
|
|
int $foreignId,
|
|
|
|
int $foreignId,
|
|
|
|
array $metadata): void {
|
|
|
|
array $metadata): void {
|
|
|
|
foreach ($metadata as $key => $value) {
|
|
|
|
foreach ($metadata as $key => $value) {
|
|
|
|
$query = $this->dbConnection->getQueryBuilder();
|
|
|
|
$query = $this->dbConnection->getQueryBuilder();
|
|
|
|
$query->insert($table)
|
|
|
|
$query->insert($table)
|
|
|
@ -241,7 +241,7 @@ class UpdateCalendarResourcesRoomsBackgroundJob extends TimedJob {
|
|
|
|
* @param int $id
|
|
|
|
* @param int $id
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
private function deleteFromCache(string $table,
|
|
|
|
private function deleteFromCache(string $table,
|
|
|
|
int $id): void {
|
|
|
|
int $id): void {
|
|
|
|
$query = $this->dbConnection->getQueryBuilder();
|
|
|
|
$query = $this->dbConnection->getQueryBuilder();
|
|
|
|
$query->delete($table)
|
|
|
|
$query->delete($table)
|
|
|
|
->where($query->expr()->eq('id', $query->createNamedParameter($id)))
|
|
|
|
->where($query->expr()->eq('id', $query->createNamedParameter($id)))
|
|
|
@ -254,8 +254,8 @@ class UpdateCalendarResourcesRoomsBackgroundJob extends TimedJob {
|
|
|
|
* @param int $id
|
|
|
|
* @param int $id
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
private function deleteMetadataFromCache(string $table,
|
|
|
|
private function deleteMetadataFromCache(string $table,
|
|
|
|
string $foreignKey,
|
|
|
|
string $foreignKey,
|
|
|
|
int $id): void {
|
|
|
|
int $id): void {
|
|
|
|
$query = $this->dbConnection->getQueryBuilder();
|
|
|
|
$query = $this->dbConnection->getQueryBuilder();
|
|
|
|
$query->delete($table)
|
|
|
|
$query->delete($table)
|
|
|
|
->where($query->expr()->eq($foreignKey, $query->createNamedParameter($id)))
|
|
|
|
->where($query->expr()->eq($foreignKey, $query->createNamedParameter($id)))
|
|
|
@ -270,8 +270,8 @@ class UpdateCalendarResourcesRoomsBackgroundJob extends TimedJob {
|
|
|
|
* @param IResource|IRoom $remote
|
|
|
|
* @param IResource|IRoom $remote
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
private function updateCache(string $table,
|
|
|
|
private function updateCache(string $table,
|
|
|
|
int $id,
|
|
|
|
int $id,
|
|
|
|
$remote): void {
|
|
|
|
$remote): void {
|
|
|
|
$query = $this->dbConnection->getQueryBuilder();
|
|
|
|
$query = $this->dbConnection->getQueryBuilder();
|
|
|
|
$query->update($table)
|
|
|
|
$query->update($table)
|
|
|
|
->set('email', $query->createNamedParameter($remote->getEMail()))
|
|
|
|
->set('email', $query->createNamedParameter($remote->getEMail()))
|
|
|
@ -292,10 +292,10 @@ class UpdateCalendarResourcesRoomsBackgroundJob extends TimedJob {
|
|
|
|
* @param array $cachedMetadata
|
|
|
|
* @param array $cachedMetadata
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
private function updateMetadataCache(string $dbTable,
|
|
|
|
private function updateMetadataCache(string $dbTable,
|
|
|
|
string $foreignKey,
|
|
|
|
string $foreignKey,
|
|
|
|
int $id,
|
|
|
|
int $id,
|
|
|
|
array $metadata,
|
|
|
|
array $metadata,
|
|
|
|
array $cachedMetadata): void {
|
|
|
|
array $cachedMetadata): void {
|
|
|
|
$newMetadata = array_diff_key($metadata, $cachedMetadata);
|
|
|
|
$newMetadata = array_diff_key($metadata, $cachedMetadata);
|
|
|
|
$deletedMetadata = array_diff_key($cachedMetadata, $metadata);
|
|
|
|
$deletedMetadata = array_diff_key($cachedMetadata, $metadata);
|
|
|
|
|
|
|
|
|
|
|
@ -371,8 +371,8 @@ class UpdateCalendarResourcesRoomsBackgroundJob extends TimedJob {
|
|
|
|
* @return array
|
|
|
|
* @return array
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
private function getAllMetadataOfCache(string $table,
|
|
|
|
private function getAllMetadataOfCache(string $table,
|
|
|
|
string $foreignKey,
|
|
|
|
string $foreignKey,
|
|
|
|
int $id): array {
|
|
|
|
int $id): array {
|
|
|
|
$query = $this->dbConnection->getQueryBuilder();
|
|
|
|
$query = $this->dbConnection->getQueryBuilder();
|
|
|
|
$query->select(['key', 'value'])
|
|
|
|
$query->select(['key', 'value'])
|
|
|
|
->from($table)
|
|
|
|
->from($table)
|
|
|
@ -398,7 +398,7 @@ class UpdateCalendarResourcesRoomsBackgroundJob extends TimedJob {
|
|
|
|
* @return array
|
|
|
|
* @return array
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
private function getAllCachedByBackend(string $tableName,
|
|
|
|
private function getAllCachedByBackend(string $tableName,
|
|
|
|
string $backendId): array {
|
|
|
|
string $backendId): array {
|
|
|
|
$query = $this->dbConnection->getQueryBuilder();
|
|
|
|
$query = $this->dbConnection->getQueryBuilder();
|
|
|
|
$query->select('resource_id')
|
|
|
|
$query->select('resource_id')
|
|
|
|
->from($tableName)
|
|
|
|
->from($tableName)
|
|
|
@ -417,7 +417,7 @@ class UpdateCalendarResourcesRoomsBackgroundJob extends TimedJob {
|
|
|
|
* @param $principalUri
|
|
|
|
* @param $principalUri
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
private function deleteCalendarDataForResource(string $principalPrefix,
|
|
|
|
private function deleteCalendarDataForResource(string $principalPrefix,
|
|
|
|
string $principalUri): void {
|
|
|
|
string $principalUri): void {
|
|
|
|
$calendar = $this->calDavBackend->getCalendarByUri(
|
|
|
|
$calendar = $this->calDavBackend->getCalendarByUri(
|
|
|
|
implode('/', [$principalPrefix, $principalUri]),
|
|
|
|
implode('/', [$principalPrefix, $principalUri]),
|
|
|
|
CalDavBackend::RESOURCE_BOOKING_CALENDAR_URI);
|
|
|
|
CalDavBackend::RESOURCE_BOOKING_CALENDAR_URI);
|
|
|
@ -438,8 +438,8 @@ class UpdateCalendarResourcesRoomsBackgroundJob extends TimedJob {
|
|
|
|
* @return int
|
|
|
|
* @return int
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
private function getIdForBackendAndResource(string $table,
|
|
|
|
private function getIdForBackendAndResource(string $table,
|
|
|
|
string $backendId,
|
|
|
|
string $backendId,
|
|
|
|
string $resourceId): int {
|
|
|
|
string $resourceId): int {
|
|
|
|
$query = $this->dbConnection->getQueryBuilder();
|
|
|
|
$query = $this->dbConnection->getQueryBuilder();
|
|
|
|
$query->select('id')
|
|
|
|
$query->select('id')
|
|
|
|
->from($table)
|
|
|
|
->from($table)
|
|
|
|