2023-11-07 01:21:29 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
declare(strict_types=1);
|
|
|
|
/**
|
2024-05-23 07:26:56 +00:00
|
|
|
* SPDX-FileCopyrightText: 2023 Nextcloud GmbH and Nextcloud contributors
|
|
|
|
* SPDX-License-Identifier: AGPL-3.0-or-later
|
2023-11-07 01:21:29 +00:00
|
|
|
*/
|
|
|
|
|
2023-11-13 23:25:22 +00:00
|
|
|
namespace OCP\FilesMetadata;
|
|
|
|
|
|
|
|
use OCP\FilesMetadata\Model\IFilesMetadata;
|
2023-11-07 01:21:29 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Model that help building queries with metadata and metadata indexes
|
|
|
|
*
|
|
|
|
* @since 28.0.0
|
|
|
|
*/
|
|
|
|
interface IMetadataQuery {
|
2023-11-07 13:43:01 +00:00
|
|
|
/** @since 28.0.0 */
|
2023-11-07 01:21:29 +00:00
|
|
|
public const EXTRA = 'metadata';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Add metadata linked to file id to the query
|
|
|
|
*
|
|
|
|
* @see self::extractMetadata()
|
|
|
|
* @since 28.0.0
|
|
|
|
*/
|
|
|
|
public function retrieveMetadata(): void;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* extract metadata from a result row
|
|
|
|
*
|
|
|
|
* @param array $row result row
|
|
|
|
*
|
|
|
|
* @return IFilesMetadata metadata
|
|
|
|
* @see self::retrieveMetadata()
|
|
|
|
* @since 28.0.0
|
|
|
|
*/
|
|
|
|
public function extractMetadata(array $row): IFilesMetadata;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* join the metadata_index table, based on a metadataKey.
|
|
|
|
* This will prep the query for condition based on this specific metadataKey.
|
|
|
|
* If a link to the metadataKey already exists, returns known alias.
|
|
|
|
*
|
|
|
|
* TODO: investigate how to support a search done on multiple values for same key (AND).
|
|
|
|
*
|
|
|
|
* @param string $metadataKey metadata key
|
|
|
|
* @param bool $enforce limit the request only to existing metadata
|
|
|
|
*
|
|
|
|
* @return string generated table alias
|
|
|
|
* @since 28.0.0
|
|
|
|
*/
|
|
|
|
public function joinIndex(string $metadataKey, bool $enforce = false): string;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* returns the name of the field for metadata key to be used in query expressions
|
|
|
|
*
|
|
|
|
* @param string $metadataKey metadata key
|
|
|
|
*
|
|
|
|
* @return string table field
|
|
|
|
* @since 28.0.0
|
|
|
|
*/
|
|
|
|
public function getMetadataKeyField(string $metadataKey): string;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* returns the name of the field for metadata string value to be used in query expressions
|
|
|
|
*
|
2024-02-14 14:30:11 +00:00
|
|
|
* Note: this method loads lazy appconfig values.
|
|
|
|
*
|
2023-11-07 01:21:29 +00:00
|
|
|
* @param string $metadataKey metadata key
|
|
|
|
*
|
|
|
|
* @return string table field
|
|
|
|
* @since 28.0.0
|
|
|
|
*/
|
|
|
|
public function getMetadataValueField(string $metadataKey): string;
|
|
|
|
}
|