From 2dc79e583902bd591f9c56943f9296654b0781e5 Mon Sep 17 00:00:00 2001 From: Georg Ehrke Date: Mon, 22 Jul 2019 11:36:26 +0200 Subject: [PATCH] Add \OCP\Calendar\IMetadataProvider interface and provider for common metadata keys Signed-off-by: Georg Ehrke --- lib/composer/composer/autoload_classmap.php | 3 + lib/composer/composer/autoload_static.php | 3 + lib/public/Calendar/IMetadataProvider.php | 65 +++++++++++ .../Calendar/Resource/IResourceMetadata.php | 103 ++++++++++++++++++ lib/public/Calendar/Room/IRoom.php | 8 +- lib/public/Calendar/Room/IRoomMetadata.php | 57 ++++++++++ 6 files changed, 235 insertions(+), 4 deletions(-) create mode 100644 lib/public/Calendar/IMetadataProvider.php create mode 100644 lib/public/Calendar/Resource/IResourceMetadata.php create mode 100644 lib/public/Calendar/Room/IRoomMetadata.php diff --git a/lib/composer/composer/autoload_classmap.php b/lib/composer/composer/autoload_classmap.php index 7d1d5b50c0..22909fe171 100644 --- a/lib/composer/composer/autoload_classmap.php +++ b/lib/composer/composer/autoload_classmap.php @@ -100,12 +100,15 @@ return array( 'OCP\\Calendar\\BackendTemporarilyUnavailableException' => $baseDir . '/lib/public/Calendar/BackendTemporarilyUnavailableException.php', 'OCP\\Calendar\\ICalendar' => $baseDir . '/lib/public/Calendar/ICalendar.php', 'OCP\\Calendar\\IManager' => $baseDir . '/lib/public/Calendar/IManager.php', + 'OCP\\Calendar\\IMetadataProvider' => $baseDir . '/lib/public/Calendar/IMetadataProvider.php', 'OCP\\Calendar\\Resource\\IBackend' => $baseDir . '/lib/public/Calendar/Resource/IBackend.php', 'OCP\\Calendar\\Resource\\IManager' => $baseDir . '/lib/public/Calendar/Resource/IManager.php', 'OCP\\Calendar\\Resource\\IResource' => $baseDir . '/lib/public/Calendar/Resource/IResource.php', + 'OCP\\Calendar\\Resource\\IResourceMetadata' => $baseDir . '/lib/public/Calendar/Resource/IResourceMetadata.php', 'OCP\\Calendar\\Room\\IBackend' => $baseDir . '/lib/public/Calendar/Room/IBackend.php', 'OCP\\Calendar\\Room\\IManager' => $baseDir . '/lib/public/Calendar/Room/IManager.php', 'OCP\\Calendar\\Room\\IRoom' => $baseDir . '/lib/public/Calendar/Room/IRoom.php', + 'OCP\\Calendar\\Room\\IRoomMetadata' => $baseDir . '/lib/public/Calendar/Room/IRoomMetadata.php', 'OCP\\Capabilities\\ICapability' => $baseDir . '/lib/public/Capabilities/ICapability.php', 'OCP\\Capabilities\\IPublicCapability' => $baseDir . '/lib/public/Capabilities/IPublicCapability.php', 'OCP\\Collaboration\\AutoComplete\\AutoCompleteEvent' => $baseDir . '/lib/public/Collaboration/AutoComplete/AutoCompleteEvent.php', diff --git a/lib/composer/composer/autoload_static.php b/lib/composer/composer/autoload_static.php index f9dd644a2c..4ddbc050e5 100644 --- a/lib/composer/composer/autoload_static.php +++ b/lib/composer/composer/autoload_static.php @@ -134,12 +134,15 @@ class ComposerStaticInit53792487c5a8370acc0b06b1a864ff4c 'OCP\\Calendar\\BackendTemporarilyUnavailableException' => __DIR__ . '/../../..' . '/lib/public/Calendar/BackendTemporarilyUnavailableException.php', 'OCP\\Calendar\\ICalendar' => __DIR__ . '/../../..' . '/lib/public/Calendar/ICalendar.php', 'OCP\\Calendar\\IManager' => __DIR__ . '/../../..' . '/lib/public/Calendar/IManager.php', + 'OCP\\Calendar\\IMetadataProvider' => __DIR__ . '/../../..' . '/lib/public/Calendar/IMetadataProvider.php', 'OCP\\Calendar\\Resource\\IBackend' => __DIR__ . '/../../..' . '/lib/public/Calendar/Resource/IBackend.php', 'OCP\\Calendar\\Resource\\IManager' => __DIR__ . '/../../..' . '/lib/public/Calendar/Resource/IManager.php', 'OCP\\Calendar\\Resource\\IResource' => __DIR__ . '/../../..' . '/lib/public/Calendar/Resource/IResource.php', + 'OCP\\Calendar\\Resource\\IResourceMetadata' => __DIR__ . '/../../..' . '/lib/public/Calendar/Resource/IResourceMetadata.php', 'OCP\\Calendar\\Room\\IBackend' => __DIR__ . '/../../..' . '/lib/public/Calendar/Room/IBackend.php', 'OCP\\Calendar\\Room\\IManager' => __DIR__ . '/../../..' . '/lib/public/Calendar/Room/IManager.php', 'OCP\\Calendar\\Room\\IRoom' => __DIR__ . '/../../..' . '/lib/public/Calendar/Room/IRoom.php', + 'OCP\\Calendar\\Room\\IRoomMetadata' => __DIR__ . '/../../..' . '/lib/public/Calendar/Room/IRoomMetadata.php', 'OCP\\Capabilities\\ICapability' => __DIR__ . '/../../..' . '/lib/public/Capabilities/ICapability.php', 'OCP\\Capabilities\\IPublicCapability' => __DIR__ . '/../../..' . '/lib/public/Capabilities/IPublicCapability.php', 'OCP\\Collaboration\\AutoComplete\\AutoCompleteEvent' => __DIR__ . '/../../..' . '/lib/public/Collaboration/AutoComplete/AutoCompleteEvent.php', diff --git a/lib/public/Calendar/IMetadataProvider.php b/lib/public/Calendar/IMetadataProvider.php new file mode 100644 index 0000000000..fcf56b47e1 --- /dev/null +++ b/lib/public/Calendar/IMetadataProvider.php @@ -0,0 +1,65 @@ + + * + * @author Georg Ehrke + * + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + * + */ + +namespace OCP\Calendar; + +/** + * Interface IMetadataProvider + * + * Provider for metadata of a resource or a room + * + * @package OCP\Calendar + * @since 17.0.0 + */ +interface IMetadataProvider { + + /** + * Get a list of all metadata keys available for this room + * + * Room backends are allowed to return custom keys, beyond the ones + * defined in this class. If they do, they should make sure to use their + * own namespace. + * + * @return String[] - A list of available keys + * @since 17.0.0 + */ + public function getAllAvailableMetadataKeys():array; + + /** + * Get whether or not a metadata key is set for this room + * + * @param string $key - The key to check for + * @return bool - Whether or not key is available + * @since 17.0.0 + */ + public function hasMetadataForKey(string $key):boolean; + + /** + * Get the value for a metadata key + * + * @param string $key - The key to check for + * @return string|null - The value stored for the key, null if no value stored + * @since 17.0.0 + */ + public function getMetadataForKey(string $key):?string; +} diff --git a/lib/public/Calendar/Resource/IResourceMetadata.php b/lib/public/Calendar/Resource/IResourceMetadata.php new file mode 100644 index 0000000000..a48bcfb682 --- /dev/null +++ b/lib/public/Calendar/Resource/IResourceMetadata.php @@ -0,0 +1,103 @@ + + * + * @author Georg Ehrke + * + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + * + */ + +namespace OCP\Calendar\Resource; + +/** + * Interface IResourceMetadata + * + * This interface provides keys for common metadata. + * Resource Backends are not limited to this list and can provide + * any metadata they want. + * + * @package OCP\Calendar\Resource + * @since 17.0.0 + */ +interface IResourceMetadata { + + /** + * Type of resource + * + * Allowed values for this key include: + * - projector + * - tv + * - vehicle + * - other + * + * @since 17.0.0 + */ + public const RESOURCE_TYPE = '{http://nextcloud.com/ns}resource-type'; + + /** + * If resource is of type vehicle, this describes the type of vehicle + * + * Allowed values: + * - bicycle + * - scooter + * - motorbike + * - car + * - plane + * - helicopter + * - other + * + * @since 17.0.0 + */ + public const VEHICLE_TYPE = '{http://nextcloud.com/ns}resource-vehicle-type'; + + /** + * Make of the vehicle + * + * @since 17.0.0 + */ + public const VEHICLE_MAKE = '{http://nextcloud.com/ns}resource-vehicle-make'; + + /** + * Model of the vehicle + * + * @since 17.0.0 + */ + public const VEHICLE_MODEL = '{http://nextcloud.com/ns}resource-vehicle-model'; + + /** + * Whether or not the car is electric + * + * use '1' for electric, '0' for non-electric + * + * @since 17.0.0 + */ + public const VEHICLE_IS_ELECTRIC = '{http://nextcloud.com/ns}resource-vehicle-is-electric'; + + /** + * Range of vehicle with a full tank + * + * @since 17.0.0 + */ + public const VEHICLE_RANGE = '{http://nextcloud.com/ns}resource-vehicle-range'; + + /** + * Seating capacity of the vehicle + * + * @since 17.0.0 + */ + public const VEHICLE_SEATING_CAPACITY = '{http://nextcloud.com/ns}resource-vehicle-seating-capacity'; +} diff --git a/lib/public/Calendar/Room/IRoom.php b/lib/public/Calendar/Room/IRoom.php index d860bb6fc5..1475f0e716 100644 --- a/lib/public/Calendar/Room/IRoom.php +++ b/lib/public/Calendar/Room/IRoom.php @@ -32,7 +32,7 @@ namespace OCP\Calendar\Room; interface IRoom { /** - * get the room id + * Get a unique ID for the room * * This id has to be unique within the backend * @@ -42,7 +42,7 @@ interface IRoom { public function getId():string; /** - * get the display name for a room + * Get the display name for the room * * @return string * @since 14.0.0 @@ -61,9 +61,9 @@ interface IRoom { public function getGroupRestrictions():array; /** - * get email-address for room + * Get the email-address for the room * - * The email address has to be globally unique + * The email-address has to be globally unique * * @return string * @since 14.0.0 diff --git a/lib/public/Calendar/Room/IRoomMetadata.php b/lib/public/Calendar/Room/IRoomMetadata.php new file mode 100644 index 0000000000..3d501d4d12 --- /dev/null +++ b/lib/public/Calendar/Room/IRoomMetadata.php @@ -0,0 +1,57 @@ + + * + * @author Georg Ehrke + * + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + * + */ + +namespace OCP\Calendar\Room; + +/** + * Interface IRoomMetadata + * + * This interface provides keys for common metadata. + * Room Backends are not limited to this list and can provide + * any metadata they want. + * + * @package OCP\Calendar\Room + * @since 17.0.0 + */ +interface IRoomMetadata { + + /** + * Type of room + * + * Allowed values for this key include: + * - meeting-room + * - lecture-hall + * - seminar-room + * - other + * + * @since 17.0.0 + */ + public const ROOM_TYPE = '{http://nextcloud.com/ns}room-type'; + + /** + * Seating capacity of the room + * + * @since 17.0.0 + */ + public const CAPACITY = '{http://nextcloud.com/ns}room-seating-capacity'; +}