1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* Analytics |
4
|
|
|
* |
5
|
|
|
* SPDX-FileCopyrightText: 2019-2022 Marcel Scherello |
6
|
|
|
* SPDX-License-Identifier: AGPL-3.0-or-later |
7
|
|
|
*/ |
8
|
|
|
|
9
|
|
|
namespace OCA\Analytics\Controller; |
10
|
|
|
|
11
|
|
|
use OCA\Analytics\Service\DatasetService; |
12
|
|
|
use OCA\Analytics\Service\ReportService; |
13
|
|
|
use OCP\AppFramework\Controller; |
|
|
|
|
14
|
|
|
use OCP\AppFramework\Http\DataResponse; |
|
|
|
|
15
|
|
|
use OCP\DB\Exception; |
|
|
|
|
16
|
|
|
use OCP\IRequest; |
|
|
|
|
17
|
|
|
use Psr\Log\LoggerInterface; |
|
|
|
|
18
|
|
|
use OCA\Analytics\ContextChat\ContentManager; |
19
|
|
|
|
20
|
|
|
class DatasetController extends Controller { |
21
|
|
|
private $logger; |
22
|
|
|
private $DatasetService; |
23
|
|
|
private $ReportService; |
24
|
|
|
private $ContentManager; |
25
|
|
|
|
26
|
|
|
public function __construct( |
27
|
|
|
$appName, |
28
|
|
|
IRequest $request, |
29
|
|
|
LoggerInterface $logger, |
30
|
|
|
DatasetService $DatasetService, |
31
|
|
|
ReportService $ReportService, |
32
|
|
|
ContentManager $ContentManager |
33
|
|
|
) { |
34
|
|
|
parent::__construct($appName, $request); |
35
|
|
|
$this->logger = $logger; |
36
|
|
|
$this->DatasetService = $DatasetService; |
37
|
|
|
$this->ReportService = $ReportService; |
38
|
|
|
$this->ContentManager = $ContentManager; |
39
|
|
|
} |
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* get all datasets |
43
|
|
|
* |
44
|
|
|
* @NoAdminRequired |
45
|
|
|
* @return DataResponse |
46
|
|
|
*/ |
47
|
|
|
public function index() { |
48
|
|
|
return new DataResponse($this->DatasetService->index()); |
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
/** |
52
|
|
|
* create new dataset |
53
|
|
|
* |
54
|
|
|
* @NoAdminRequired |
55
|
|
|
* @param $name |
56
|
|
|
* @param $dimension1 |
57
|
|
|
* @param $dimension2 |
58
|
|
|
* @param $value |
59
|
|
|
* @return int |
60
|
|
|
* @throws \OCP\DB\Exception |
61
|
|
|
*/ |
62
|
|
|
public function create($name, $dimension1, $dimension2, $value) { |
63
|
|
|
return $this->DatasetService->create($name, $dimension1, $dimension2, $value); |
64
|
|
|
} |
65
|
|
|
|
66
|
|
|
/** |
67
|
|
|
* get own dataset details |
68
|
|
|
* |
69
|
|
|
* @NoAdminRequired |
70
|
|
|
* @param int $datasetId |
71
|
|
|
* @return array|bool |
72
|
|
|
*/ |
73
|
|
|
public function read(int $datasetId) { |
74
|
|
|
return $this->DatasetService->readOwn($datasetId); |
75
|
|
|
} |
76
|
|
|
|
77
|
|
|
/** |
78
|
|
|
* Delete Dataset and all depending objects |
79
|
|
|
* |
80
|
|
|
* @NoAdminRequired |
81
|
|
|
* @param int $datasetId |
82
|
|
|
* @return DataResponse |
83
|
|
|
* @throws \OCP\DB\Exception |
84
|
|
|
*/ |
85
|
|
|
public function delete(int $datasetId) { |
86
|
|
|
if ($this->DatasetService->isOwn($datasetId)) { |
87
|
|
|
$reports = $this->ReportService->reportsForDataset($datasetId); |
88
|
|
|
foreach ($reports as $report) { |
89
|
|
|
$this->ReportService->delete((int)$report['id']); |
90
|
|
|
} |
91
|
|
|
$this->DatasetService->delete($datasetId); |
92
|
|
|
return new DataResponse('true'); |
93
|
|
|
} else { |
94
|
|
|
return new DataResponse('false'); |
95
|
|
|
} |
96
|
|
|
} |
97
|
|
|
|
98
|
|
|
/** |
99
|
|
|
* get dataset details |
100
|
|
|
* |
101
|
|
|
* @NoAdminRequired |
102
|
|
|
* @param int $datasetId |
103
|
|
|
* @param $name |
104
|
|
|
* @param null $subheader |
|
|
|
|
105
|
|
|
* @param null $dimension1 |
|
|
|
|
106
|
|
|
* @param null $dimension2 |
|
|
|
|
107
|
|
|
* @param null $value |
|
|
|
|
108
|
|
|
* @param null $aiIndex |
|
|
|
|
109
|
|
|
* @return bool |
110
|
|
|
* @throws Exception |
111
|
|
|
*/ |
112
|
|
|
public function update( |
113
|
|
|
int $datasetId, |
114
|
|
|
$name, |
115
|
|
|
$subheader = null, |
116
|
|
|
$dimension1 = null, |
117
|
|
|
$dimension2 = null, |
118
|
|
|
$value = null, |
119
|
|
|
$aiIndex = null |
120
|
|
|
) { |
121
|
|
|
return $this->DatasetService->update($datasetId, $name, $subheader, $dimension1, $dimension2, $value, $aiIndex); |
122
|
|
|
} |
123
|
|
|
|
124
|
|
|
/** |
125
|
|
|
* get status of the dataset |
126
|
|
|
* |
127
|
|
|
* @NoAdminRequired |
128
|
|
|
* @param int $datasetId |
129
|
|
|
* @throws \OCP\DB\Exception |
130
|
|
|
*/ |
131
|
|
|
public function status(int $datasetId) { |
132
|
|
|
return $this->DatasetService->status($datasetId); |
133
|
|
|
} |
134
|
|
|
|
135
|
|
|
/** |
136
|
|
|
* Update the context chat provider |
137
|
|
|
* |
138
|
|
|
* @NoAdminRequired |
139
|
|
|
* @param int $datasetId |
140
|
|
|
* @return DataResponse |
141
|
|
|
*/ |
142
|
|
|
public function provider(int $datasetId) { |
143
|
|
|
if ($this->DatasetService->isOwn($datasetId)) { |
144
|
|
|
$this->ContentManager->submitContent($datasetId); |
145
|
|
|
return new DataResponse('true'); |
146
|
|
|
} else { |
147
|
|
|
return new DataResponse('false'); |
148
|
|
|
} |
149
|
|
|
} |
150
|
|
|
} |
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