Completed
Push — master ( da3b44...325c46 )
by Maxence
02:02
created

TestProvider::getName()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 3
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
/**
3
 * FullTextSearch - Full text search framework for Nextcloud
4
 *
5
 * This file is licensed under the Affero General Public License version 3 or
6
 * later. See the COPYING file.
7
 *
8
 * @author Maxence Lange <[email protected]>
9
 * @copyright 2018
10
 * @license GNU AGPL version 3 or any later version
11
 *
12
 * This program is free software: you can redistribute it and/or modify
13
 * it under the terms of the GNU Affero General Public License as
14
 * published by the Free Software Foundation, either version 3 of the
15
 * License, or (at your option) any later version.
16
 *
17
 * This program is distributed in the hope that it will be useful,
18
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20
 * GNU Affero General Public License for more details.
21
 *
22
 * You should have received a copy of the GNU Affero General Public License
23
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
24
 *
25
 */
26
27
28
namespace OCA\FullTextSearch\Provider;
29
30
use OCA\FullTextSearch\AppInfo\Application;
31
use OCA\FullTextSearch\IFullTextSearchPlatform;
32
use OCA\FullTextSearch\IFullTextSearchProvider;
33
use OCA\FullTextSearch\Model\Index;
34
use OCA\FullTextSearch\Model\IndexDocument;
35
use OCA\FullTextSearch\Model\IndexOptions;
36
use OCA\FullTextSearch\Model\Runner;
37
use OCA\FullTextSearch\Model\SearchRequest;
38
use OCA\FullTextSearch\Model\SearchResult;
39
use OCA\FullTextSearch\Service\ConfigService;
40
use OCA\FullTextSearch\Service\MiscService;
41
use OCA\FullTextSearch\Service\TestService;
42
43
class TestProvider implements IFullTextSearchProvider {
44
45
46
	const TEST_PROVIDER_ID = 'test_provider';
47
48
	/** @var ConfigService */
49
	private $configService;
50
51
	/** @var TestService */
52
	private $testService;
53
54
	/** @var MiscService */
55
	private $miscService;
56
57
	/** @var Runner */
58
	private $runner;
59
60
	/** @var IndexOptions */
61
	private $indexOptions;
62
63
64
	/**
65
	 * TestProvider constructor.
66
	 *
67
	 * @param ConfigService $configService
68
	 * @param TestService $testService
69
	 * @param MiscService $miscService
70
	 */
71
	public function __construct(
72
		ConfigService $configService, TestService $testService, MiscService $miscService
73
	) {
74
		$this->configService = $configService;
75
		$this->testService = $testService;
76
		$this->miscService = $miscService;
77
78
		$this->indexOptions = new IndexOptions();
79
	}
80
81
82
	/**
83
	 * return unique id of the provider
84
	 */
85
	public function getId() {
86
		return self::TEST_PROVIDER_ID;
87
	}
88
89
90
	/**
91
	 * return name of the provider
92
	 */
93
	public function getName() {
94
		return 'Test Provider';
95
	}
96
97
98
	/**
99
	 * @return array
100
	 */
101
	public function getConfiguration() {
102
		return $this->configService->getConfig();
103
	}
104
105
106
	public function setRunner(Runner $runner) {
107
		$this->runner = $runner;
108
	}
109
110
111
	/**
112
	 * @param IndexOptions $options
113
	 */
114
	public function setIndexOptions($options) {
115
		$this->indexOptions = $options;
116
	}
117
118
119
	/**
120
	 * @return array
121
	 */
122
	public function getOptionsTemplate() {
123
		return [];
124
	}
125
126
127
	/**
128
	 * called when loading all providers.
129
	 *
130
	 * Loading some containers.
131
	 */
132
	public function loadProvider() {
133
	}
134
135
136
	/**
137
	 * returns all indexable document for a user.
138
	 * There is no need to fill the document with content at this point.
139
	 *
140
	 * $platform is provided if the mapping needs to be changed.
141
	 *
142
	 * @param string $userId
143
	 *
144
	 * @return IndexDocument[]
145
	 */
146
	public function generateIndexableDocuments($userId) {
147
		$result = [];
148
149
		$result[] = $this->testService->generateIndexDocumentContentLicense($this->indexOptions);
150
		$result[] = $this->testService->generateIndexDocumentSimple($this->indexOptions);
151
152
//		$result[] = $this->testService->generateIndexDocuments(TestService::DOCUMENT_TEST_INDEX3);
153
154
		return $result;
155
	}
156
157
158
	/**
159
	 * generate documents prior to the indexing.
160
	 * throw NoResultException if no more result
161
	 *
162
	 * @param IndexDocument[] $chunk
163
	 *
164
	 * @deprecated
165
	 * @return IndexDocument[]
166
	 */
167
	public function fillIndexDocuments($chunk) {
168
		return $chunk;
169
	}
170
171
172
	/**
173
	 * generate documents prior to the indexing.
174
	 *
175
	 * @param IndexDocument $document
176
	 */
177
	public function fillIndexDocument(IndexDocument $document) {
0 ignored issues
show
Unused Code introduced by
The parameter $document is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
178
	}
179
180
181
	/**
182
	 * @param IndexDocument $document
183
	 *
184
	 * @return bool
185
	 */
186
	public function isDocumentUpToDate($document) {
187
		return false;
188
	}
189
190
191
	/**
192
	 * @param Index $index
193
	 *
194
	 * @return IndexDocument|null
195
	 */
196
	public function updateDocument(Index $index) {
197
		return null;
198
	}
199
200
201
	/**
202
	 * @param IFullTextSearchPlatform $platform
203
	 */
204
	public function onInitializingIndex(IFullTextSearchPlatform $platform) {
205
	}
206
207
208
	/**
209
	 * @param IFullTextSearchPlatform $platform
210
	 */
211
	public function onResettingIndex(IFullTextSearchPlatform $platform) {
212
	}
213
214
215
	/**
216
	 * not used yet
217
	 */
218
	public function unloadProvider() {
219
	}
220
221
222
	/**
223
	 * before a search, improve the request
224
	 *
225
	 * @param SearchRequest $request
226
	 */
227
	public function improveSearchRequest(SearchRequest $request) {
228
	}
229
230
231
	/**
232
	 * after a search, improve results
233
	 *
234
	 * @param SearchResult $searchResult
235
	 */
236
	public function improveSearchResult(SearchResult $searchResult) {
237
	}
238
239
240
}
241