IIndex.php 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352
  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. /**
  44. * @since 15.0.0
  45. */
  46. public const INDEX_OK = 1;
  47. /**
  48. * @since 15.0.0
  49. */
  50. public const INDEX_IGNORE = 2;
  51. /**
  52. * @since 15.0.0
  53. */
  54. public const INDEX_META = 4;
  55. /**
  56. * @since 15.0.0
  57. */
  58. public const INDEX_CONTENT = 8;
  59. /**
  60. * @since 16.0.0
  61. */
  62. public const INDEX_PARTS = 16;
  63. /**
  64. * @since 15.0.0
  65. */
  66. public const INDEX_FULL = 28;
  67. /**
  68. * @since 15.0.0
  69. */
  70. public const INDEX_REMOVE = 32;
  71. /**
  72. * @since 15.0.0
  73. */
  74. public const INDEX_DONE = 64;
  75. /**
  76. * @since 15.0.0
  77. */
  78. public const INDEX_FAILED = 128;
  79. /**
  80. * @since 15.0.0
  81. */
  82. public const ERROR_FAILED = 1;
  83. /**
  84. * @since 15.0.0
  85. */
  86. public const ERROR_FAILED2 = 2;
  87. /**
  88. * @since 15.0.0
  89. */
  90. public const ERROR_FAILED3 = 4;
  91. /**
  92. * @since 15.0.0
  93. */
  94. public const ERROR_SEV_1 = 1;
  95. /**
  96. * @since 15.0.0
  97. */
  98. public const ERROR_SEV_2 = 2;
  99. /**
  100. * @since 15.0.0
  101. */
  102. public const ERROR_SEV_3 = 3;
  103. /**
  104. * @since 15.0.0
  105. */
  106. public const ERROR_SEV_4 = 4;
  107. /**
  108. * Get the Id of the Content Provider.
  109. *
  110. * @since 15.0.0
  111. *
  112. * @return string
  113. */
  114. public function getProviderId(): string;
  115. /**
  116. * Get the Id of the original document.
  117. *
  118. * @since 15.0.0
  119. *
  120. * @return string
  121. */
  122. public function getDocumentId(): string;
  123. /**
  124. * Get the collection of the index.
  125. * If empty (''), means collection is the default one used by the internal framework
  126. *
  127. * @since 24.0.0
  128. *
  129. * @return string
  130. */
  131. public function getCollection(): string;
  132. /**
  133. * Set the source of the original document.
  134. *
  135. * @since 15.0.0
  136. *
  137. * @param string $source
  138. *
  139. * @return IIndex
  140. */
  141. public function setSource(string $source): IIndex;
  142. /**
  143. * Get the source of the original document.
  144. *
  145. * @since 15.0.0
  146. *
  147. * @return string
  148. */
  149. public function getSource(): string;
  150. /**
  151. * Set the owner of the original document.
  152. *
  153. * @since 15.0.0
  154. *
  155. * @param string $ownerId
  156. *
  157. * @return IIndex
  158. */
  159. public function setOwnerId(string $ownerId): IIndex;
  160. /**
  161. * Get the owner of the original document.
  162. *
  163. * @since 15.0.0
  164. *
  165. * @return string
  166. */
  167. public function getOwnerId(): string;
  168. /**
  169. * Set the current index status (bit flag) of the original document.
  170. * If $reset is true, the status is reset to the defined value.
  171. *
  172. * @since 15.0.0
  173. *
  174. * @param int $status
  175. * @param bool $reset
  176. *
  177. * @return IIndex
  178. */
  179. public function setStatus(int $status, bool $reset = false): IIndex;
  180. /**
  181. * Get the current index status of the original document.
  182. *
  183. * @since 15.0.0
  184. *
  185. * @return int
  186. */
  187. public function getStatus(): int;
  188. /**
  189. * Check if the document fit a specific status.
  190. *
  191. * @since 15.0.0
  192. *
  193. * @param int $status
  194. *
  195. * @return bool
  196. */
  197. public function isStatus(int $status): bool;
  198. /**
  199. * Remove a status.
  200. *
  201. * @since 15.0.0
  202. *
  203. * @param int $status
  204. *
  205. * @return IIndex
  206. */
  207. public function unsetStatus(int $status): IIndex;
  208. /**
  209. * Add an option related to the original document (as string).
  210. *
  211. * @since 15.0.0
  212. *
  213. * @param string $option
  214. * @param string $value
  215. *
  216. * @return IIndex
  217. */
  218. public function addOption(string $option, string $value): IIndex;
  219. /**
  220. * Add an option related to the original document (as integer).
  221. *
  222. * @since 15.0.0
  223. *
  224. * @param string $option
  225. * @param int $value
  226. *
  227. * @return IIndex
  228. */
  229. public function addOptionInt(string $option, int $value): IIndex;
  230. /**
  231. * Get the option related to the original document (as string).
  232. *
  233. * @since 15.0.0
  234. *
  235. * @param string $option
  236. * @param string $default
  237. *
  238. * @return string
  239. */
  240. public function getOption(string $option, string $default = ''): string;
  241. /**
  242. * Get the option related to the original document (as integer).
  243. *
  244. * @since 15.0.0
  245. *
  246. * @param string $option
  247. * @param int $default
  248. *
  249. * @return int
  250. */
  251. public function getOptionInt(string $option, int $default = 0): int;
  252. /**
  253. * Get all options related to the original document.
  254. *
  255. * @since 15.0.0
  256. *
  257. * @return array
  258. */
  259. public function getOptions(): array;
  260. /**
  261. * Add an error log related to the Index.
  262. *
  263. * @since 15.0.0
  264. *
  265. * @param string $message
  266. * @param string $exception
  267. * @param int $sev
  268. *
  269. * @return IIndex
  270. */
  271. public function addError(string $message, string $exception = '', int $sev = self::ERROR_SEV_3): IIndex;
  272. /**
  273. * Returns the number of known errors related to the Index.
  274. *
  275. * @since 15.0.0
  276. *
  277. * @return int
  278. */
  279. public function getErrorCount(): int;
  280. /**
  281. * Reset all error logs related to the Index.
  282. *
  283. * @since 15.0.0
  284. */
  285. public function resetErrors(): IIndex;
  286. /**
  287. * Set the date of the last index.
  288. *
  289. * @since 15.0.0
  290. *
  291. * @param int $lastIndex
  292. *
  293. * @return IIndex
  294. */
  295. public function setLastIndex(int $lastIndex = -1): IIndex;
  296. /**
  297. * Get the date of the last index.
  298. *
  299. * @since 15.0.0
  300. *
  301. * @return int
  302. */
  303. public function getLastIndex(): int;
  304. }