You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

90 lines
2.6 KiB

  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * @copyright 2023 Maxence Lange <maxence@artificial-owl.com>
  5. *
  6. * @author Maxence Lange <maxence@artificial-owl.com>
  7. *
  8. * @license GNU AGPL version 3 or any later version
  9. *
  10. * This program is free software: you can redistribute it and/or modify
  11. * it under the terms of the GNU Affero General Public License as
  12. * published by the Free Software Foundation, either version 3 of the
  13. * License, or (at your option) any later version.
  14. *
  15. * This program is distributed in the hope that it will be useful,
  16. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18. * GNU Affero General Public License for more details.
  19. *
  20. * You should have received a copy of the GNU Affero General Public License
  21. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  22. *
  23. */
  24. namespace OCP\FilesMetadata\Model;
  25. /**
  26. * Model that help building queries with metadata and metadata indexes
  27. *
  28. * @since 28.0.0
  29. */
  30. interface IMetadataQuery {
  31. /** @since 28.0.0 */
  32. public const EXTRA = 'metadata';
  33. /**
  34. * Add metadata linked to file id to the query
  35. *
  36. * @see self::extractMetadata()
  37. * @since 28.0.0
  38. */
  39. public function retrieveMetadata(): void;
  40. /**
  41. * extract metadata from a result row
  42. *
  43. * @param array $row result row
  44. *
  45. * @return IFilesMetadata metadata
  46. * @see self::retrieveMetadata()
  47. * @since 28.0.0
  48. */
  49. public function extractMetadata(array $row): IFilesMetadata;
  50. /**
  51. * join the metadata_index table, based on a metadataKey.
  52. * This will prep the query for condition based on this specific metadataKey.
  53. * If a link to the metadataKey already exists, returns known alias.
  54. *
  55. * TODO: investigate how to support a search done on multiple values for same key (AND).
  56. *
  57. * @param string $metadataKey metadata key
  58. * @param bool $enforce limit the request only to existing metadata
  59. *
  60. * @return string generated table alias
  61. * @since 28.0.0
  62. */
  63. public function joinIndex(string $metadataKey, bool $enforce = false): string;
  64. /**
  65. * returns the name of the field for metadata key to be used in query expressions
  66. *
  67. * @param string $metadataKey metadata key
  68. *
  69. * @return string table field
  70. * @since 28.0.0
  71. */
  72. public function getMetadataKeyField(string $metadataKey): string;
  73. /**
  74. * returns the name of the field for metadata string value to be used in query expressions
  75. *
  76. * @param string $metadataKey metadata key
  77. *
  78. * @return string table field
  79. * @since 28.0.0
  80. */
  81. public function getMetadataValueField(string $metadataKey): string;
  82. }