IIndex.php 5.6 KB

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