1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* Analytics |
4
|
|
|
* |
5
|
|
|
* This file is licensed under the Affero General Public License version 3 or |
6
|
|
|
* later. See the LICENSE.md file. |
7
|
|
|
* |
8
|
|
|
* @author Marcel Scherello <[email protected]> |
9
|
|
|
* @copyright 2019-2022 Marcel Scherello |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
namespace OCA\Analytics\Controller; |
13
|
|
|
|
14
|
|
|
use Exception; |
15
|
|
|
use OCA\Analytics\Service\DataloadService; |
16
|
|
|
use OCP\AppFramework\Controller; |
|
|
|
|
17
|
|
|
use OCP\AppFramework\Http\DataResponse; |
|
|
|
|
18
|
|
|
use OCP\AppFramework\Http\NotFoundResponse; |
|
|
|
|
19
|
|
|
use OCP\Files\NotFoundException; |
|
|
|
|
20
|
|
|
use OCP\IRequest; |
|
|
|
|
21
|
|
|
use Psr\Log\LoggerInterface; |
|
|
|
|
22
|
|
|
|
23
|
|
|
class DataloadController extends Controller |
24
|
|
|
{ |
25
|
|
|
private $logger; |
26
|
|
|
private $DataloadService; |
27
|
|
|
|
28
|
|
|
public function __construct( |
29
|
|
|
string $appName, |
30
|
|
|
IRequest $request, |
31
|
|
|
LoggerInterface $logger, |
32
|
|
|
DataloadService $DataloadService |
33
|
|
|
) |
34
|
|
|
{ |
35
|
|
|
parent::__construct($appName, $request); |
36
|
|
|
$this->logger = $logger; |
37
|
|
|
$this->DataloadService = $DataloadService; |
38
|
|
|
} |
39
|
|
|
|
40
|
|
|
/** |
41
|
|
|
* create a new dataload |
42
|
|
|
* |
43
|
|
|
* @NoAdminRequired |
44
|
|
|
* @param $datasetId |
45
|
|
|
* @param int $datasourceId |
46
|
|
|
* @return DataResponse |
47
|
|
|
* @throws \OCP\DB\Exception |
48
|
|
|
*/ |
49
|
|
|
public function create($datasetId, int $datasourceId): DataResponse |
50
|
|
|
{ |
51
|
|
|
return new DataResponse(['id' => $this->DataloadService->create($datasetId, $datasourceId)]); |
52
|
|
|
} |
53
|
|
|
|
54
|
|
|
/** |
55
|
|
|
* get all data loads for a dataset or report |
56
|
|
|
* |
57
|
|
|
* @NoAdminRequired |
58
|
|
|
* @param $datasetId |
59
|
|
|
* @param $reportId |
60
|
|
|
* @return DataResponse |
61
|
|
|
*/ |
62
|
|
|
public function read($datasetId): DataResponse |
63
|
|
|
{ |
64
|
|
|
return new DataResponse(['dataloads' => $this->DataloadService->read($datasetId)]); |
65
|
|
|
} |
66
|
|
|
|
67
|
|
|
/** |
68
|
|
|
* update dataload |
69
|
|
|
* |
70
|
|
|
* @NoAdminRequired |
71
|
|
|
* @param int $dataloadId |
72
|
|
|
* @param $name |
73
|
|
|
* @param $option |
74
|
|
|
* @param $schedule |
75
|
|
|
* @return DataResponse |
76
|
|
|
*/ |
77
|
|
|
public function update(int $dataloadId, $name, $option, $schedule): DataResponse |
78
|
|
|
{ |
79
|
|
|
return new DataResponse(['update' => $this->DataloadService->update($dataloadId, $name, $option, $schedule)]); |
80
|
|
|
} |
81
|
|
|
|
82
|
|
|
/** |
83
|
|
|
* copy a dataload |
84
|
|
|
* |
85
|
|
|
* @NoAdminRequired |
86
|
|
|
* @param int $dataloadId |
87
|
|
|
* @return DataResponse |
88
|
|
|
* @throws NotFoundException |
89
|
|
|
*/ |
90
|
|
|
public function copy(int $dataloadId): DataResponse |
91
|
|
|
{ |
92
|
|
|
return new DataResponse($this->DataloadService->copy($dataloadId)); |
93
|
|
|
} |
94
|
|
|
|
95
|
|
|
/** |
96
|
|
|
* delete a dataload |
97
|
|
|
* |
98
|
|
|
* @NoAdminRequired |
99
|
|
|
* @param int $dataloadId |
100
|
|
|
* @return bool |
101
|
|
|
*/ |
102
|
|
|
public function delete(int $dataloadId): bool |
103
|
|
|
{ |
104
|
|
|
return $this->DataloadService->delete($dataloadId); |
105
|
|
|
} |
106
|
|
|
|
107
|
|
|
/** |
108
|
|
|
* simulate a dataload and output its data |
109
|
|
|
* |
110
|
|
|
* @NoAdminRequired |
111
|
|
|
* @param int $dataloadId |
112
|
|
|
* @return DataResponse |
113
|
|
|
* @throws NotFoundException |
114
|
|
|
*/ |
115
|
|
|
public function simulate(int $dataloadId): DataResponse |
116
|
|
|
{ |
117
|
|
|
return new DataResponse($this->DataloadService->getDataFromDatasource($dataloadId)); |
118
|
|
|
} |
119
|
|
|
|
120
|
|
|
/** |
121
|
|
|
* execute a dataload from datasource and store into dataset |
122
|
|
|
* |
123
|
|
|
* @NoAdminRequired |
124
|
|
|
* @param int $dataloadId |
125
|
|
|
* @return DataResponse |
126
|
|
|
* @throws Exception |
127
|
|
|
*/ |
128
|
|
|
public function execute(int $dataloadId): DataResponse |
129
|
|
|
{ |
130
|
|
|
return new DataResponse($this->DataloadService->execute($dataloadId)); |
131
|
|
|
} |
132
|
|
|
|
133
|
|
|
|
134
|
|
|
// Data Manipulation |
135
|
|
|
// Data Manipulation |
136
|
|
|
// Data Manipulation |
137
|
|
|
|
138
|
|
|
/** |
139
|
|
|
* update data from input form |
140
|
|
|
* |
141
|
|
|
* @NoAdminRequired |
142
|
|
|
* @param int $reportId |
143
|
|
|
* @param $dimension1 |
144
|
|
|
* @param $dimension2 |
145
|
|
|
* @param $value |
146
|
|
|
* @param bool $isDataset |
147
|
|
|
* @return DataResponse|NotFoundResponse |
148
|
|
|
* @throws Exception |
149
|
|
|
*/ |
150
|
|
|
public function updateData(int $reportId, $dimension1, $dimension2, $value, bool $isDataset) |
151
|
|
|
{ |
152
|
|
|
$result = $this->DataloadService->updateData($reportId, $dimension1, $dimension2, $value, $isDataset); |
153
|
|
|
if ($result) { |
154
|
|
|
return new DataResponse($result); |
155
|
|
|
} else { |
156
|
|
|
return new NotFoundResponse(); |
157
|
|
|
} |
158
|
|
|
} |
159
|
|
|
|
160
|
|
|
/** |
161
|
|
|
* delete data from input form |
162
|
|
|
* |
163
|
|
|
* @NoAdminRequired |
164
|
|
|
* @param int $reportId |
165
|
|
|
* @param $dimension1 |
166
|
|
|
* @param $dimension2 |
167
|
|
|
* @param bool $isDataset |
168
|
|
|
* @return DataResponse|NotFoundResponse |
169
|
|
|
*/ |
170
|
|
|
public function deleteData(int $reportId, $dimension1, $dimension2, bool $isDataset) |
171
|
|
|
{ |
172
|
|
|
$result = $this->DataloadService->deleteData($reportId, $dimension1, $dimension2, $isDataset); |
173
|
|
|
if ($result) { |
174
|
|
|
return new DataResponse($result); |
175
|
|
|
} else { |
176
|
|
|
return new NotFoundResponse(); |
177
|
|
|
} |
178
|
|
|
} |
179
|
|
|
|
180
|
|
|
/** |
181
|
|
|
* Simulate delete data from input form |
182
|
|
|
* |
183
|
|
|
* @NoAdminRequired |
184
|
|
|
* @param int $reportId |
185
|
|
|
* @param $dimension1 |
186
|
|
|
* @param $dimension2 |
187
|
|
|
* @param bool $isDataset |
188
|
|
|
* @return DataResponse|NotFoundResponse |
189
|
|
|
*/ |
190
|
|
|
public function deleteDataSimulate(int $reportId, $dimension1, $dimension2, bool $isDataset) |
191
|
|
|
{ |
192
|
|
|
$result = $this->DataloadService->deleteDataSimulate($reportId, $dimension1, $dimension2, $isDataset); |
193
|
|
|
if ($result) { |
194
|
|
|
return new DataResponse($result); |
195
|
|
|
} else { |
196
|
|
|
return new NotFoundResponse(); |
197
|
|
|
} |
198
|
|
|
} |
199
|
|
|
|
200
|
|
|
/** |
201
|
|
|
* Import clipboard data |
202
|
|
|
* |
203
|
|
|
* @NoAdminRequired |
204
|
|
|
* @param int $reportId |
205
|
|
|
* @param $import |
206
|
|
|
* @param bool $isDataset |
207
|
|
|
* @return DataResponse|NotFoundResponse |
208
|
|
|
* @throws Exception |
209
|
|
|
*/ |
210
|
|
|
public function importClipboard(int $reportId, $import, bool $isDataset) |
211
|
|
|
{ |
212
|
|
|
$result = $this->DataloadService->importClipboard($reportId, $import, $isDataset); |
213
|
|
|
if ($result) { |
214
|
|
|
return new DataResponse($result); |
215
|
|
|
} else { |
216
|
|
|
return new NotFoundResponse(); |
217
|
|
|
} |
218
|
|
|
} |
219
|
|
|
|
220
|
|
|
/** |
221
|
|
|
* Import data into dataset from an internal or external file |
222
|
|
|
* |
223
|
|
|
* @NoAdminRequired |
224
|
|
|
* @param int $reportId |
225
|
|
|
* @param $path |
226
|
|
|
* @param bool $isDataset |
227
|
|
|
* @return DataResponse|NotFoundResponse |
228
|
|
|
* @throws Exception |
229
|
|
|
*/ |
230
|
|
|
public function importFile(int $reportId, $path, bool $isDataset) |
231
|
|
|
{ |
232
|
|
|
$result = $this->DataloadService->importFile($reportId, $path, $isDataset); |
233
|
|
|
if ($result) { |
234
|
|
|
return new DataResponse($result); |
235
|
|
|
} else { |
236
|
|
|
return new NotFoundResponse(); |
237
|
|
|
} |
238
|
|
|
} |
239
|
|
|
} |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths