|
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 2021 Marcel Scherello |
|
10
|
|
|
*/ |
|
11
|
|
|
|
|
12
|
|
|
namespace OCA\Analytics\Controller; |
|
13
|
|
|
|
|
14
|
|
|
use OCA\Analytics\Service\DatasetService; |
|
15
|
|
|
use OCP\AppFramework\Controller; |
|
16
|
|
|
use OCP\AppFramework\Http\DataResponse; |
|
17
|
|
|
use OCP\IRequest; |
|
18
|
|
|
use Psr\Log\LoggerInterface; |
|
19
|
|
|
|
|
20
|
|
|
class DatasetController extends Controller |
|
21
|
|
|
{ |
|
22
|
|
|
private $logger; |
|
23
|
|
|
private $DatasetService; |
|
24
|
|
|
|
|
25
|
|
|
public function __construct( |
|
26
|
|
|
$appName, |
|
27
|
|
|
IRequest $request, |
|
28
|
|
|
LoggerInterface $logger, |
|
29
|
|
|
DatasetService $DatasetService |
|
30
|
|
|
) |
|
31
|
|
|
{ |
|
32
|
|
|
parent::__construct($appName, $request); |
|
33
|
|
|
$this->logger = $logger; |
|
34
|
|
|
$this->DatasetService = $DatasetService; |
|
35
|
|
|
} |
|
36
|
|
|
|
|
37
|
|
|
/** |
|
38
|
|
|
* get all datasets |
|
39
|
|
|
* |
|
40
|
|
|
* @NoAdminRequired |
|
41
|
|
|
* @return DataResponse |
|
42
|
|
|
*/ |
|
43
|
|
|
public function index() |
|
44
|
|
|
{ |
|
45
|
|
|
return $this->DatasetService->index(); |
|
46
|
|
|
} |
|
47
|
|
|
|
|
48
|
|
|
/** |
|
49
|
|
|
* create new dataset |
|
50
|
|
|
* |
|
51
|
|
|
* @NoAdminRequired |
|
52
|
|
|
* @param string $file |
|
53
|
|
|
* @return int |
|
54
|
|
|
*/ |
|
55
|
|
|
public function create($file = '') |
|
56
|
|
|
{ |
|
57
|
|
|
return $this->DatasetService->create($file); |
|
|
|
|
|
|
58
|
|
|
} |
|
59
|
|
|
|
|
60
|
|
|
/** |
|
61
|
|
|
* get own dataset details |
|
62
|
|
|
* |
|
63
|
|
|
* @NoAdminRequired |
|
64
|
|
|
* @param int $datasetId |
|
65
|
|
|
* @return array |
|
66
|
|
|
*/ |
|
67
|
|
|
public function read(int $datasetId) |
|
68
|
|
|
{ |
|
69
|
|
|
return $this->DatasetService->read($datasetId); |
|
70
|
|
|
} |
|
71
|
|
|
|
|
72
|
|
|
/** |
|
73
|
|
|
* Delete Dataset and all depending objects |
|
74
|
|
|
* |
|
75
|
|
|
* @NoAdminRequired |
|
76
|
|
|
* @param int $datasetId |
|
77
|
|
|
* @return bool |
|
78
|
|
|
*/ |
|
79
|
|
|
public function delete(int $datasetId) |
|
80
|
|
|
{ |
|
81
|
|
|
return $this->DatasetService->delete($datasetId); |
|
82
|
|
|
} |
|
83
|
|
|
|
|
84
|
|
|
/** |
|
85
|
|
|
* get dataset details |
|
86
|
|
|
* |
|
87
|
|
|
* @NoAdminRequired |
|
88
|
|
|
* @param int $datasetId |
|
89
|
|
|
* @param $name |
|
90
|
|
|
* @param null $dimension1 |
|
|
|
|
|
|
91
|
|
|
* @param null $dimension2 |
|
|
|
|
|
|
92
|
|
|
* @param null $value |
|
|
|
|
|
|
93
|
|
|
* @return bool |
|
94
|
|
|
* @throws \OCP\DB\Exception |
|
95
|
|
|
*/ |
|
96
|
|
|
public function update(int $datasetId, $name, $dimension1 = null, $dimension2 = null, $value = null) |
|
97
|
|
|
{ |
|
98
|
|
|
return $this->DatasetService->update($datasetId, $name, $dimension1, $dimension2, $value); |
|
99
|
|
|
} |
|
100
|
|
|
|
|
101
|
|
|
} |
This check compares calls to functions or methods with their respective definitions. If the call has less arguments than are defined, it raises an issue.
If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.