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.

282 lines
5.6 KiB

3 years ago
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * @copyright 2018
  5. *
  6. * @author Christoph Wurst <christoph@winzerhof-wurst.at>
  7. * @author Maxence Lange <maxence@artificial-owl.com>
  8. *
  9. * @license GNU AGPL version 3 or any later version
  10. *
  11. * This program is free software: you can redistribute it and/or modify
  12. * it under the terms of the GNU Affero General Public License as
  13. * published by the Free Software Foundation, either version 3 of the
  14. * License, or (at your option) any later version.
  15. *
  16. * This program is distributed in the hope that it will be useful,
  17. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  18. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  19. * GNU Affero General Public License for more details.
  20. *
  21. * You should have received a copy of the GNU Affero General Public License
  22. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  23. *
  24. */
  25. namespace OCP\FullTextSearch\Model;
  26. /**
  27. * Interface IIndex
  28. *
  29. * Index are generated by FullTextSearch to manage the status of a document
  30. * regarding the date of the last index and the date of the last modification
  31. * of the original document.
  32. *
  33. * The uniqueness of an IIndexDocument is made by the Id of the Content Provider
  34. * and the Id of the original document within the Content Provider.
  35. *
  36. * We will call original document the source from which the IIndexDocument is
  37. * generated. As an example, an original document can be a file, a mail, ...
  38. *
  39. * @since 15.0.0
  40. *
  41. */
  42. interface IIndex {
  43. public const INDEX_OK = 1;
  44. public const INDEX_IGNORE = 2;
  45. public const INDEX_META = 4;
  46. public const INDEX_CONTENT = 8;
  47. public const INDEX_PARTS = 16;
  48. public const INDEX_FULL = 28;
  49. public const INDEX_REMOVE = 32;
  50. public const INDEX_DONE = 64;
  51. public const INDEX_FAILED = 128;
  52. public const ERROR_FAILED = 1;
  53. public const ERROR_FAILED2 = 2;
  54. public const ERROR_FAILED3 = 4;
  55. public const ERROR_SEV_1 = 1;
  56. public const ERROR_SEV_2 = 2;
  57. public const ERROR_SEV_3 = 3;
  58. public const ERROR_SEV_4 = 4;
  59. /**
  60. * Get the Id of the Content Provider.
  61. *
  62. * @since 15.0.0
  63. *
  64. * @return string
  65. */
  66. public function getProviderId(): string;
  67. /**
  68. * Get the Id of the original document.
  69. *
  70. * @since 15.0.0
  71. *
  72. * @return string
  73. */
  74. public function getDocumentId(): string;
  75. /**
  76. * Set the source of the original document.
  77. *
  78. * @since 15.0.0
  79. *
  80. * @param string $source
  81. *
  82. * @return IIndex
  83. */
  84. public function setSource(string $source): IIndex;
  85. /**
  86. * Get the source of the original document.
  87. *
  88. * @since 15.0.0
  89. *
  90. * @return string
  91. */
  92. public function getSource(): string;
  93. /**
  94. * Set the owner of the original document.
  95. *
  96. * @since 15.0.0
  97. *
  98. * @param string $ownerId
  99. *
  100. * @return IIndex
  101. */
  102. public function setOwnerId(string $ownerId): IIndex;
  103. /**
  104. * Get the owner of the original document.
  105. *
  106. * @since 15.0.0
  107. *
  108. * @return string
  109. */
  110. public function getOwnerId(): string;
  111. /**
  112. * Set the current index status (bit flag) of the original document.
  113. * If $reset is true, the status is reset to the defined value.
  114. *
  115. * @since 15.0.0
  116. *
  117. * @param int $status
  118. * @param bool $reset
  119. *
  120. * @return IIndex
  121. */
  122. public function setStatus(int $status, bool $reset = false): IIndex;
  123. /**
  124. * Get the current index status of the original document.
  125. *
  126. * @since 15.0.0
  127. *
  128. * @return int
  129. */
  130. public function getStatus(): int;
  131. /**
  132. * Check if the document fit a specific status.
  133. *
  134. * @since 15.0.0
  135. *
  136. * @param int $status
  137. *
  138. * @return bool
  139. */
  140. public function isStatus(int $status): bool;
  141. /**
  142. * Remove a status.
  143. *
  144. * @since 15.0.0
  145. *
  146. * @param int $status
  147. *
  148. * @return IIndex
  149. */
  150. public function unsetStatus(int $status): IIndex;
  151. /**
  152. * Add an option related to the original document (as string).
  153. *
  154. * @since 15.0.0
  155. *
  156. * @param string $option
  157. * @param string $value
  158. *
  159. * @return IIndex
  160. */
  161. public function addOption(string $option, string $value): IIndex;
  162. /**
  163. * Add an option related to the original document (as integer).
  164. *
  165. * @since 15.0.0
  166. *
  167. * @param string $option
  168. * @param int $value
  169. *
  170. * @return IIndex
  171. */
  172. public function addOptionInt(string $option, int $value): IIndex;
  173. /**
  174. * Get the option related to the original document (as string).
  175. *
  176. * @since 15.0.0
  177. *
  178. * @param string $option
  179. * @param string $default
  180. *
  181. * @return string
  182. */
  183. public function getOption(string $option, string $default = ''): string;
  184. /**
  185. * Get the option related to the original document (as integer).
  186. *
  187. * @since 15.0.0
  188. *
  189. * @param string $option
  190. * @param int $default
  191. *
  192. * @return int
  193. */
  194. public function getOptionInt(string $option, int $default = 0): int;
  195. /**
  196. * Get all options related to the original document.
  197. *
  198. * @since 15.0.0
  199. *
  200. * @return array
  201. */
  202. public function getOptions(): array;
  203. /**
  204. * Add an error log related to the Index.
  205. *
  206. * @since 15.0.0
  207. *
  208. * @param string $message
  209. * @param string $exception
  210. * @param int $sev
  211. *
  212. * @return IIndex
  213. */
  214. public function addError(string $message, string $exception = '', int $sev = self::ERROR_SEV_3): IIndex;
  215. /**
  216. * Returns the number of known errors related to the Index.
  217. *
  218. * @since 15.0.0
  219. *
  220. * @return int
  221. */
  222. public function getErrorCount(): int;
  223. /**
  224. * Reset all error logs related to the Index.
  225. *
  226. * @since 15.0.0
  227. */
  228. public function resetErrors(): IIndex;
  229. /**
  230. * Set the date of the last index.
  231. *
  232. * @since 15.0.0
  233. *
  234. * @param int $lastIndex
  235. *
  236. * @return IIndex
  237. */
  238. public function setLastIndex(int $lastIndex = -1): IIndex;
  239. /**
  240. * Get the date of the last index.
  241. *
  242. * @since 15.0.0
  243. *
  244. * @return int
  245. */
  246. public function getLastIndex(): int;
  247. }