1
0

IIndex.php 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292
  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. * Get the collection of the index.
  77. * If empty (''), means collection is the default one used by the internal framework
  78. *
  79. * @since 24.0.0
  80. *
  81. * @return string
  82. */
  83. public function getCollection(): string;
  84. /**
  85. * Set the source of the original document.
  86. *
  87. * @since 15.0.0
  88. *
  89. * @param string $source
  90. *
  91. * @return IIndex
  92. */
  93. public function setSource(string $source): IIndex;
  94. /**
  95. * Get the source of the original document.
  96. *
  97. * @since 15.0.0
  98. *
  99. * @return string
  100. */
  101. public function getSource(): string;
  102. /**
  103. * Set the owner of the original document.
  104. *
  105. * @since 15.0.0
  106. *
  107. * @param string $ownerId
  108. *
  109. * @return IIndex
  110. */
  111. public function setOwnerId(string $ownerId): IIndex;
  112. /**
  113. * Get the owner of the original document.
  114. *
  115. * @since 15.0.0
  116. *
  117. * @return string
  118. */
  119. public function getOwnerId(): string;
  120. /**
  121. * Set the current index status (bit flag) of the original document.
  122. * If $reset is true, the status is reset to the defined value.
  123. *
  124. * @since 15.0.0
  125. *
  126. * @param int $status
  127. * @param bool $reset
  128. *
  129. * @return IIndex
  130. */
  131. public function setStatus(int $status, bool $reset = false): IIndex;
  132. /**
  133. * Get the current index status of the original document.
  134. *
  135. * @since 15.0.0
  136. *
  137. * @return int
  138. */
  139. public function getStatus(): int;
  140. /**
  141. * Check if the document fit a specific status.
  142. *
  143. * @since 15.0.0
  144. *
  145. * @param int $status
  146. *
  147. * @return bool
  148. */
  149. public function isStatus(int $status): bool;
  150. /**
  151. * Remove a status.
  152. *
  153. * @since 15.0.0
  154. *
  155. * @param int $status
  156. *
  157. * @return IIndex
  158. */
  159. public function unsetStatus(int $status): IIndex;
  160. /**
  161. * Add an option related to the original document (as string).
  162. *
  163. * @since 15.0.0
  164. *
  165. * @param string $option
  166. * @param string $value
  167. *
  168. * @return IIndex
  169. */
  170. public function addOption(string $option, string $value): IIndex;
  171. /**
  172. * Add an option related to the original document (as integer).
  173. *
  174. * @since 15.0.0
  175. *
  176. * @param string $option
  177. * @param int $value
  178. *
  179. * @return IIndex
  180. */
  181. public function addOptionInt(string $option, int $value): IIndex;
  182. /**
  183. * Get the option related to the original document (as string).
  184. *
  185. * @since 15.0.0
  186. *
  187. * @param string $option
  188. * @param string $default
  189. *
  190. * @return string
  191. */
  192. public function getOption(string $option, string $default = ''): string;
  193. /**
  194. * Get the option related to the original document (as integer).
  195. *
  196. * @since 15.0.0
  197. *
  198. * @param string $option
  199. * @param int $default
  200. *
  201. * @return int
  202. */
  203. public function getOptionInt(string $option, int $default = 0): int;
  204. /**
  205. * Get all options related to the original document.
  206. *
  207. * @since 15.0.0
  208. *
  209. * @return array
  210. */
  211. public function getOptions(): array;
  212. /**
  213. * Add an error log related to the Index.
  214. *
  215. * @since 15.0.0
  216. *
  217. * @param string $message
  218. * @param string $exception
  219. * @param int $sev
  220. *
  221. * @return IIndex
  222. */
  223. public function addError(string $message, string $exception = '', int $sev = self::ERROR_SEV_3): IIndex;
  224. /**
  225. * Returns the number of known errors related to the Index.
  226. *
  227. * @since 15.0.0
  228. *
  229. * @return int
  230. */
  231. public function getErrorCount(): int;
  232. /**
  233. * Reset all error logs related to the Index.
  234. *
  235. * @since 15.0.0
  236. */
  237. public function resetErrors(): IIndex;
  238. /**
  239. * Set the date of the last index.
  240. *
  241. * @since 15.0.0
  242. *
  243. * @param int $lastIndex
  244. *
  245. * @return IIndex
  246. */
  247. public function setLastIndex(int $lastIndex = -1): IIndex;
  248. /**
  249. * Get the date of the last index.
  250. *
  251. * @since 15.0.0
  252. *
  253. * @return int
  254. */
  255. public function getLastIndex(): int;
  256. }