diff --git a/.github/workflows/CI-workflows.yaml b/.github/workflows/CI-workflows.yaml new file mode 100644 index 00000000..696b38c8 --- /dev/null +++ b/.github/workflows/CI-workflows.yaml @@ -0,0 +1,120 @@ +name: CI Workflow + +on: [push, pull_request] + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: '8.2' + extensions: mbstring, zip, xml, curl, intl, sqlite, gd, pdo_mysql + tools: cs2pr, phpcbf, phpcs, phpmd, phpunit + + - name: Install Composer dependencies + run: composer install + + - name: Run phpcbf + run: phpcbf . + continue-on-error: ${{ github.ref != 'refs/heads/main' }} + + #- name: Commit code formatting changes + # if: success() && github.ref != 'refs/heads/main' + # run: | + # git config user.name "GitHub Actions" + # git config user.email "actions@github.com" + # git add src + # git diff --cached --quiet || (git commit -m "Update src from PHP Codesniffer" && git pull origin $(git rev-parse --abbrev-ref HEAD) --rebase --autostash && git push) + + - name: Run phpcs + run: phpcs -q --report=checkstyle src | cs2pr + continue-on-error: ${{ github.ref != 'refs/heads/main' }} + + - name: Run phpmd + run: phpmd src xml phpmd.xml --not-strict + continue-on-error: ${{ github.ref != 'refs/heads/main' }} + + - name: List files in repository root + run: ls -alh + + - name: List files in tests directory + run: ls -alh ./tests + + - name: List files in vendor directory + run: ls -alh ./vendor + + - name: Run PHPUnit tests + env: + XDEBUG_MODE: coverage + run: | + phpunit --bootstrap ./tests/bootstrap.php --configuration phpunit.xml --coverage-html ./coverage --coverage-text | tee coverage.txt + continue-on-error: ${{ github.ref != 'refs/heads/main' }} + + lint: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Install remark presets + run: npm install remark-cli remark-preset-lint-consistent remark-preset-lint-recommended remark-lint-list-item-indent + - name: Run remark + run: npx remark . --output --use remark-preset-lint-consistent --use remark-preset-lint-recommended --use remark-lint-list-item-indent + - name: Check for linting errors + run: | + npx remark . --use remark-preset-lint-consistent --use remark-preset-lint-recommended --use remark-lint-list-item-indent + continue-on-error: ${{ github.ref != 'refs/heads/main' }} + - name: Git commit + if: success() && github.ref != 'refs/heads/main' + run: | + git config user.name "GitHub Actions" + git config user.email "actions@github.com" + git add . + git add package.json package-lock.json + git diff --cached --quiet || (git commit -m "Update src from remark-lint" && git pull origin $(git rev-parse --abbrev-ref HEAD) --rebase --autostash && git push) + + checks: + needs: [build, lint] + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Setup PHP (for checks) + uses: shivammathur/setup-php@v2 + with: + php-version: '8.2' + extensions: mbstring, zip, xml, curl, intl, sqlite, gd, pdo_mysql + tools: cs2pr, phpcs, phpmd, phpunit + + - name: Run Checks + run: | + if ! command -v phpcs &> /dev/null; then + echo "phpcs could not be found. Please ensure it's installed." + exit 1 + fi + if ! command -v phpmd &> /dev/null; then + echo "phpmd could not be found. Please ensure it's installed." + exit 1 + fi + if phpcs -q --report=checkstyle src | grep -q "ERROR"; then + echo "PHP CodeSniffer found issues. Please fix them before merging." + exit 1 + fi + if phpmd src xml phpmd.xml --strict | grep -q "ERROR"; then + echo "PHP Mess Detector found issues. Please fix them before merging." + exit 1 + fi + # if ! phpunit --bootstrap ./tests/bootstrap.php --configuration phpunit.xml; then + # echo "PHPUnit tests failed. Please fix them before merging." + # exit 1 + #fi + if ! npx remark . --use remark-preset-lint-consistent --use remark-preset-lint-recommended --use remark-lint-list-item-indent; then + echo "Markdown linting failed. Please fix them before merging." + exit 1 + fi + continue-on-error: false diff --git a/.vscode/settings.json b/.vscode/settings.json index e6b78e0b..063aadd0 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,15 +1,21 @@ { - "files.autoSave": "afterDelay", -"editor.defaultFormatter": "dbaeumer.vscode-eslint", -"editor.formatOnSave": true, -"cSpell.words": [ - "gedepubliceerd", - "depubliceren", - "Depubliceren", - "Matadata", - "nextcloud", - "opencatalogi", - "pinia", - "Toegangs" -] + "files.autoSave": "afterDelay", + "editor.defaultFormatter": "dbaeumer.vscode-eslint", + "editor.formatOnSave": true, + "eslint.format.enable": true, + "cSpell.words": [ + "depubliceren", + "Depubliceren", + "gedepubliceerd", + "Matadata", + "nextcloud", + "opencatalogi", + "organisation", + "Organisation", + "pinia", + "Toegangs" + ], + "[javascript]": { + "editor.defaultFormatter": "dbaeumer.vscode-eslint" + }, } diff --git a/appinfo/routes.php b/appinfo/routes.php index 7aadd29c..3a3e2056 100644 --- a/appinfo/routes.php +++ b/appinfo/routes.php @@ -4,6 +4,8 @@ 'resources' => [ 'metadata' => ['url' => '/api/metadata'], 'publications' => ['url' => '/api/publications'], + 'organisations' => ['url' => '/api/organisations'], + 'themes' => ['url' => '/api/themes'], 'attachments' => ['url' => '/api/attachments'], 'catalogi' => ['url' => '/api/catalogi'], 'directory' => ['url' => '/api/directory'] @@ -17,7 +19,9 @@ ['name' => 'search#index', 'url' => '/api/search', 'verb' => 'GET'], ['name' => 'search#show', 'url' => '/api/search/{id}', 'verb' => 'GET'], ['name' => 'directory#page', 'url' => '/directory', 'verb' => 'GET'], + ['name' => 'directory#add', 'url' => '/api/directory/add', 'verb' => 'POST'], ['name' => 'configuration#index', 'url' => '/configuration', 'verb' => 'GET'], - ['name' => 'configuration#create', 'url' => '/configuration', 'verb' => 'POST'] + ['name' => 'configuration#create', 'url' => '/configuration', 'verb' => 'POST'], + ['name' => 'search#preflighted_cors', 'url' => '/api/{path}', 'verb' => 'OPTIONS', 'requirements' => ['path' => '.+']] ], ]; diff --git a/composer.json b/composer.json index c63fb964..b24de24d 100644 --- a/composer.json +++ b/composer.json @@ -43,7 +43,8 @@ "adbario/php-dot-notation": "^3.3.0", "bamarni/composer-bin-plugin": "^1.8", "elasticsearch/elasticsearch": "^v8.14.0", - "guzzlehttp/guzzle": "^7.8", + "adbario/php-dot-notation": "^3.3.0", + "guzzlehttp/guzzle": "^7.0", "symfony/uid": "^6.4" }, "require-dev": { diff --git a/coverage/AppInfo/Application.php.html b/coverage/AppInfo/Application.php.html deleted file mode 100644 index 579786ac..00000000 --- a/coverage/AppInfo/Application.php.html +++ /dev/null @@ -1,223 +0,0 @@ - - -
- -- | Code Coverage |
- |||||||||
- | Lines |
- Functions and Methods |
- Classes and Traits |
- |||||||
Total | -
-
-
- |
- 0.00% |
- 0 / 3 |
-
-
-
- |
- 0.00% |
- 0 / 3 |
- CRAP | -
-
-
- |
- 0.00% |
- 0 / 1 |
-
Application | -
-
-
- |
- 0.00% |
- 0 / 3 |
-
-
-
- |
- 0.00% |
- 0 / 3 |
- 12 | -
-
-
- |
- 0.00% |
- 0 / 1 |
-
__construct | -
-
-
- |
- 0.00% |
- 0 / 1 |
-
-
-
- |
- 0.00% |
- 0 / 1 |
- 2 | -- | ||
register | -
-
-
- |
- 0.00% |
- 0 / 1 |
-
-
-
- |
- 0.00% |
- 0 / 1 |
- 2 | -- | ||
boot | -
-
-
- |
- 0.00% |
- 0 / 1 |
-
-
-
- |
- 0.00% |
- 0 / 1 |
- 2 | -- |
1 | <?php |
2 | |
3 | declare(strict_types=1); |
4 | |
5 | namespace OCA\OpenCatalogi\AppInfo; |
6 | |
7 | use OCP\AppFramework\App; |
8 | use OCP\AppFramework\Bootstrap\IBootContext; |
9 | use OCP\AppFramework\Bootstrap\IBootstrap; |
10 | use OCP\AppFramework\Bootstrap\IRegistrationContext; |
11 | |
12 | class Application extends App implements IBootstrap { |
13 | public const APP_ID = 'opencatalogi'; |
14 | |
15 | /** @psalm-suppress PossiblyUnusedMethod */ |
16 | public function __construct() { |
17 | parent::__construct(self::APP_ID); |
18 | } |
19 | |
20 | public function register(IRegistrationContext $context): void { |
21 | include_once __DIR__ . '/../../vendor/autoload.php'; |
22 | } |
23 | |
24 | public function boot(IBootContext $context): void { |
25 | } |
26 | } |
Class | -Coverage | -
---|---|
OCA\OpenCatalogi\AppInfo\Application | 0% |
Class | -CRAP | -
---|
Method | -Coverage | -
---|---|
__construct | 0% |
register | 0% |
boot | 0% |
Method | -CRAP | -
---|
- | Code Coverage |
- ||||||||
- | Lines |
- Functions and Methods |
- Classes and Traits |
- ||||||
Total | -
-
-
- |
- 0.00% |
- 0 / 3 |
-
-
-
- |
- 0.00% |
- 0 / 3 |
-
-
-
- |
- 0.00% |
- 0 / 1 |
-
Application.php | -
-
-
- |
- 0.00% |
- 0 / 3 |
-
-
-
- |
- 0.00% |
- 0 / 3 |
-
-
-
- |
- 0.00% |
- 0 / 1 |
-
- | Code Coverage |
- |||||||||
- | Lines |
- Functions and Methods |
- Classes and Traits |
- |||||||
Total | -
-
-
- |
- 82.67% |
- 62 / 75 |
-
-
-
- |
- 55.56% |
- 5 / 9 |
- CRAP | -
-
-
- |
- 0.00% |
- 0 / 1 |
-
AttachmentsController | -
-
-
- |
- 82.67% |
- 62 / 75 |
-
-
-
- |
- 55.56% |
- 5 / 9 |
- 24.52 | -
-
-
- |
- 0.00% |
- 0 / 1 |
-
__construct | -
-
-
- |
- 100.00% |
- 1 / 1 |
-
-
-
- |
- 100.00% |
- 1 / 1 |
- 1 | -- | ||
insertNestedObjects | -
-
-
- |
- 0.00% |
- 0 / 9 |
-
-
-
- |
- 0.00% |
- 0 / 1 |
- 56 | -- | ||
page | -
-
-
- |
- 100.00% |
- 5 / 5 |
-
-
-
- |
- 100.00% |
- 1 / 1 |
- 1 | -- | ||
catalog | -
-
-
- |
- 100.00% |
- 5 / 5 |
-
-
-
- |
- 100.00% |
- 1 / 1 |
- 1 | -- | ||
index | -
-
-
- |
- 90.91% |
- 10 / 11 |
-
-
-
- |
- 0.00% |
- 0 / 1 |
- 3.01 | -- | ||
show | -
-
-
- |
- 100.00% |
- 6 / 6 |
-
-
-
- |
- 100.00% |
- 1 / 1 |
- 1 | -- | ||
create | -
-
-
- |
- 92.31% |
- 12 / 13 |
-
-
-
- |
- 0.00% |
- 0 / 1 |
- 3.00 | -- | ||
update | -
-
-
- |
- 87.50% |
- 14 / 16 |
-
-
-
- |
- 0.00% |
- 0 / 1 |
- 4.03 | -- | ||
destroy | -
-
-
- |
- 100.00% |
- 9 / 9 |
-
-
-
- |
- 100.00% |
- 1 / 1 |
- 1 | -- |
1 | <?php |
2 | |
3 | namespace OCA\OpenCatalogi\Controller; |
4 | |
5 | use GuzzleHttp\Exception\GuzzleException; |
6 | use OCA\OpenCatalogi\Service\ElasticSearchService; |
7 | use OCA\OpenCatalogi\Service\ObjectService; |
8 | use OCP\AppFramework\Controller; |
9 | use OCP\AppFramework\Http\TemplateResponse; |
10 | use OCP\AppFramework\Http\JSONResponse; |
11 | use OCP\IAppConfig; |
12 | use OCP\IRequest; |
13 | use Symfony\Component\Uid\Uuid; |
14 | |
15 | class AttachmentsController extends Controller |
16 | { |
17 | |
18 | public function __construct |
19 | ( |
20 | $appName, |
21 | IRequest $request, |
22 | private readonly IAppConfig $config |
23 | ) |
24 | { |
25 | parent::__construct($appName, $request); |
26 | } |
27 | |
28 | private function insertNestedObjects(array $object, ObjectService $objectService, array $config): array |
29 | { |
30 | foreach($object as $key => $value) { |
31 | try { |
32 | if( |
33 | is_string(value: $value) |
34 | && $key !== 'id' |
35 | && Uuid::isValid(uuid: $value) === true |
36 | && $subObject = $objectService->findObject(filters: ['_id' => $value], config: $config) |
37 | ) { |
38 | $object[$key] = $subObject; |
39 | } |
40 | } catch (GuzzleException $exception) { |
41 | continue; |
42 | } |
43 | } |
44 | |
45 | return $object; |
46 | } |
47 | |
48 | /** |
49 | * @NoAdminRequired |
50 | * @NoCSRFRequired |
51 | */ |
52 | public function page(?string $getParameter) |
53 | { |
54 | // The TemplateResponse loads the 'main.php' |
55 | // defined in our app's 'templates' folder. |
56 | // We pass the $getParameter variable to the template |
57 | // so that the value is accessible in the template. |
58 | return new TemplateResponse( |
59 | //Application::APP_ID, |
60 | $this->appName, |
61 | 'AttachmentsIndex', |
62 | [] |
63 | ); |
64 | } |
65 | |
66 | /** |
67 | * Taking it from a catalogue point of view is just adding a filter |
68 | * |
69 | * @NoAdminRequired |
70 | * @NoCSRFRequired |
71 | */ |
72 | public function catalog(string $id): TemplateResponse |
73 | { |
74 | // The TemplateResponse loads the 'main.php' |
75 | // defined in our app's 'templates' folder. |
76 | // We pass the $getParameter variable to the template |
77 | // so that the value is accessible in the template. |
78 | return new TemplateResponse( |
79 | //Application::APP_ID, |
80 | $this->appName, |
81 | 'AttachmentsIndex', |
82 | [] |
83 | ); |
84 | } |
85 | |
86 | /** |
87 | * @NoAdminRequired |
88 | * @NoCSRFRequired |
89 | */ |
90 | public function index(ObjectService $objectService): JSONResponse |
91 | { |
92 | $dbConfig['base_uri'] = $this->config->getValueString(app: $this->appName, key: 'mongodbLocation'); |
93 | $dbConfig['headers']['api-key'] = $this->config->getValueString(app: $this->appName, key: 'mongodbKey'); |
94 | $dbConfig['mongodbCluster'] = $this->config->getValueString(app: $this->appName, key: 'mongodbCluster'); |
95 | |
96 | $filters = $this->request->getParams(); |
97 | |
98 | foreach($filters as $key => $value) { |
99 | if(str_starts_with($key, '_')) { |
100 | unset($filters[$key]); |
101 | } |
102 | } |
103 | |
104 | |
105 | |
106 | $filters['_schema'] = 'attachment'; |
107 | |
108 | $result = $objectService->findObjects(filters: $filters, config: $dbConfig); |
109 | |
110 | $results = ["results" => $result['documents']]; |
111 | return new JSONResponse($results); |
112 | } |
113 | |
114 | /** |
115 | * @NoAdminRequired |
116 | * @NoCSRFRequired |
117 | */ |
118 | public function show(string $id, ObjectService $objectService): JSONResponse |
119 | { |
120 | $dbConfig['base_uri'] = $this->config->getValueString(app: $this->appName, key: 'mongodbLocation'); |
121 | $dbConfig['headers']['api-key'] = $this->config->getValueString(app: $this->appName, key: 'mongodbKey'); |
122 | $dbConfig['mongodbCluster'] = $this->config->getValueString(app: $this->appName, key: 'mongodbCluster'); |
123 | |
124 | $filters['_id'] = $id; |
125 | |
126 | $result = $objectService->findObject(filters: $filters, config: $dbConfig); |
127 | |
128 | return new JSONResponse($result); |
129 | } |
130 | |
131 | |
132 | /** |
133 | * @NoAdminRequired |
134 | * @NoCSRFRequired |
135 | */ |
136 | public function create(ObjectService $objectService, ElasticSearchService $elasticSearchService): JSONResponse |
137 | { |
138 | $dbConfig['base_uri'] = $this->config->getValueString(app: $this->appName, key: 'mongodbLocation'); |
139 | $dbConfig['headers']['api-key'] = $this->config->getValueString(app: $this->appName, key: 'mongodbKey'); |
140 | $dbConfig['mongodbCluster'] = $this->config->getValueString(app: $this->appName, key: 'mongodbCluster'); |
141 | |
142 | $data = $this->request->getParams(); |
143 | |
144 | foreach($data as $key => $value) { |
145 | if(str_starts_with($key, '_')) { |
146 | unset($data[$key]); |
147 | } |
148 | } |
149 | |
150 | $data['_schema'] = 'attachment'; |
151 | |
152 | $returnData = $objectService->saveObject( |
153 | data: $data, |
154 | config: $dbConfig |
155 | ); |
156 | |
157 | // get post from requests |
158 | return new JSONResponse($returnData); |
159 | } |
160 | |
161 | /** |
162 | * @NoAdminRequired |
163 | * @NoCSRFRequired |
164 | */ |
165 | public function update(string $id, ObjectService $objectService, ElasticSearchService $elasticSearchService): JSONResponse |
166 | { |
167 | $dbConfig['base_uri'] = $this->config->getValueString(app: $this->appName, key: 'mongodbLocation'); |
168 | $dbConfig['headers']['api-key'] = $this->config->getValueString(app: $this->appName, key: 'mongodbKey'); |
169 | $dbConfig['mongodbCluster'] = $this->config->getValueString(app: $this->appName, key: 'mongodbCluster'); |
170 | |
171 | $data = $this->request->getParams(); |
172 | |
173 | foreach($data as $key => $value) { |
174 | if(str_starts_with($key, '_')) { |
175 | unset($data[$key]); |
176 | } |
177 | } |
178 | if (isset($data['id'])) { |
179 | unset( $data['id']); |
180 | } |
181 | |
182 | $filters['_id'] = $id; |
183 | $returnData = $objectService->updateObject( |
184 | filters: $filters, |
185 | update: $data, |
186 | config: $dbConfig |
187 | ); |
188 | |
189 | // get post from requests |
190 | return new JSONResponse($returnData); |
191 | } |
192 | |
193 | /** |
194 | * @NoAdminRequired |
195 | * @NoCSRFRequired |
196 | */ |
197 | public function destroy(string $id, ObjectService $objectService, ElasticSearchService $elasticSearchService): JSONResponse |
198 | { |
199 | $dbConfig['base_uri'] = $this->config->getValueString(app: $this->appName, key: 'mongodbLocation'); |
200 | $dbConfig['headers']['api-key'] = $this->config->getValueString(app: $this->appName, key: 'mongodbKey'); |
201 | $dbConfig['mongodbCluster'] = $this->config->getValueString(app: $this->appName, key: 'mongodbCluster'); |
202 | |
203 | $filters['_id'] = $id; |
204 | $returnData = $objectService->deleteObject( |
205 | filters: $filters, |
206 | config: $dbConfig |
207 | ); |
208 | |
209 | // get post from requests |
210 | return new JSONResponse($returnData); |
211 | } |
212 | } |
- | Code Coverage |
- |||||||||
- | Lines |
- Functions and Methods |
- Classes and Traits |
- |||||||
Total | -
-
-
- |
- 93.94% |
- 62 / 66 |
-
-
-
- |
- 57.14% |
- 4 / 7 |
- CRAP | -
-
-
- |
- 0.00% |
- 0 / 1 |
-
CatalogiController | -
-
-
- |
- 93.94% |
- 62 / 66 |
-
-
-
- |
- 57.14% |
- 4 / 7 |
- 19.08 | -
-
-
- |
- 0.00% |
- 0 / 1 |
-
__construct | -
-
-
- |
- 100.00% |
- 1 / 1 |
-
-
-
- |
- 100.00% |
- 1 / 1 |
- 1 | -- | ||
page | -
-
-
- |
- 100.00% |
- 1 / 1 |
-
-
-
- |
- 100.00% |
- 1 / 1 |
- 1 | -- | ||
index | -
-
-
- |
- 92.86% |
- 13 / 14 |
-
-
-
- |
- 0.00% |
- 0 / 1 |
- 4.01 | -- | ||
show | -
-
-
- |
- 100.00% |
- 10 / 10 |
-
-
-
- |
- 100.00% |
- 1 / 1 |
- 2 | -- | ||
create | -
-
-
- |
- 92.86% |
- 13 / 14 |
-
-
-
- |
- 0.00% |
- 0 / 1 |
- 4.01 | -- | ||
update | -
-
-
- |
- 87.50% |
- 14 / 16 |
-
-
-
- |
- 0.00% |
- 0 / 1 |
- 5.05 | -- | ||
destroy | -
-
-
- |
- 100.00% |
- 10 / 10 |
-
-
-
- |
- 100.00% |
- 1 / 1 |
- 2 | -- |
1 | <?php |
2 | |
3 | namespace OCA\OpenCatalogi\Controller; |
4 | |
5 | use OCA\OpenCatalogi\Service\ObjectService; |
6 | use OCP\AppFramework\Controller; |
7 | use OCP\AppFramework\Http\TemplateResponse; |
8 | use OCP\AppFramework\Http\JSONResponse; |
9 | use OCP\IAppConfig; |
10 | use OCP\IRequest; |
11 | |
12 | class CatalogiController extends Controller |
13 | { |
14 | public function __construct( |
15 | $appName, |
16 | IRequest $request, |
17 | private readonly IAppConfig $config |
18 | ) |
19 | { |
20 | parent::__construct($appName, $request); |
21 | } |
22 | |
23 | /** |
24 | * @NoAdminRequired |
25 | * @NoCSRFRequired |
26 | */ |
27 | public function page(?string $getParameter): TemplateResponse |
28 | { |
29 | return new TemplateResponse($this->appName, 'CatalogiIndex', []); |
30 | } |
31 | |
32 | /** |
33 | * @NoAdminRequired |
34 | * @NoCSRFRequired |
35 | */ |
36 | public function index(ObjectService $objectService): JSONResponse |
37 | { |
38 | try { |
39 | $dbConfig = [ |
40 | 'base_uri' => $this->config->getValueString($this->appName, 'mongodbLocation'), |
41 | 'headers' => ['api-key' => $this->config->getValueString($this->appName, 'mongodbKey')], |
42 | 'mongodbCluster' => $this->config->getValueString($this->appName, 'mongodbCluster') |
43 | ]; |
44 | |
45 | $filters = $this->request->getParams(); |
46 | |
47 | foreach ($filters as $key => $value) { |
48 | if (str_starts_with($key, '_')) { |
49 | unset($filters[$key]); |
50 | } |
51 | } |
52 | |
53 | $filters['_schema'] = 'catalog'; |
54 | |
55 | $result = $objectService->findObjects($filters, $dbConfig); |
56 | |
57 | return new JSONResponse(["results" => $result['documents']]); |
58 | } catch (\Exception $e) { |
59 | return new JSONResponse(['error' => $e->getMessage()], 500); |
60 | } |
61 | } |
62 | |
63 | /** |
64 | * @NoAdminRequired |
65 | * @NoCSRFRequired |
66 | */ |
67 | public function show(string $id, ObjectService $objectService): JSONResponse |
68 | { |
69 | try { |
70 | $dbConfig = [ |
71 | 'base_uri' => $this->config->getValueString($this->appName, 'mongodbLocation'), |
72 | 'headers' => ['api-key' => $this->config->getValueString($this->appName, 'mongodbKey')], |
73 | 'mongodbCluster' => $this->config->getValueString($this->appName, 'mongodbCluster') |
74 | ]; |
75 | |
76 | $filters['_id'] = $id; |
77 | |
78 | $result = $objectService->findObject($filters, $dbConfig); |
79 | |
80 | return new JSONResponse($result); |
81 | } catch (\Exception $e) { |
82 | return new JSONResponse(['error' => $e->getMessage()], 500); |
83 | } |
84 | } |
85 | |
86 | /** |
87 | * @NoAdminRequired |
88 | * @NoCSRFRequired |
89 | */ |
90 | public function create(ObjectService $objectService): JSONResponse |
91 | { |
92 | try { |
93 | $dbConfig = [ |
94 | 'base_uri' => $this->config->getValueString($this->appName, 'mongodbLocation'), |
95 | 'headers' => ['api-key' => $this->config->getValueString($this->appName, 'mongodbKey')], |
96 | 'mongodbCluster' => $this->config->getValueString($this->appName, 'mongodbCluster') |
97 | ]; |
98 | |
99 | $data = $this->request->getParams(); |
100 | |
101 | foreach ($data as $key => $value) { |
102 | if (str_starts_with($key, '_')) { |
103 | unset($data[$key]); |
104 | } |
105 | } |
106 | |
107 | $data['_schema'] = 'catalog'; |
108 | |
109 | $returnData = $objectService->saveObject($data, $dbConfig); |
110 | |
111 | return new JSONResponse($returnData); |
112 | } catch (\Exception $e) { |
113 | return new JSONResponse(['error' => $e->getMessage()], 500); |
114 | } |
115 | } |
116 | |
117 | /** |
118 | * @NoAdminRequired |
119 | * @NoCSRFRequired |
120 | */ |
121 | public function update(string $id, ObjectService $objectService): JSONResponse |
122 | { |
123 | try { |
124 | $dbConfig = [ |
125 | 'base_uri' => $this->config->getValueString($this->appName, 'mongodbLocation'), |
126 | 'headers' => ['api-key' => $this->config->getValueString($this->appName, 'mongodbKey')], |
127 | 'mongodbCluster' => $this->config->getValueString($this->appName, 'mongodbCluster') |
128 | ]; |
129 | |
130 | $data = $this->request->getParams(); |
131 | |
132 | foreach ($data as $key => $value) { |
133 | if (str_starts_with($key, '_')) { |
134 | unset($data[$key]); |
135 | } |
136 | } |
137 | if (isset($data['id'])) { |
138 | unset($data['id']); |
139 | } |
140 | |
141 | $filters['_id'] = $id; |
142 | $returnData = $objectService->updateObject($filters, $data, $dbConfig); |
143 | |
144 | return new JSONResponse($returnData); |
145 | } catch (\Exception $e) { |
146 | return new JSONResponse(['error' => $e->getMessage()], 500); |
147 | } |
148 | } |
149 | |
150 | /** |
151 | * @NoAdminRequired |
152 | * @NoCSRFRequired |
153 | */ |
154 | public function destroy(string $id, ObjectService $objectService): JSONResponse |
155 | { |
156 | try { |
157 | $dbConfig = [ |
158 | 'base_uri' => $this->config->getValueString($this->appName, 'mongodbLocation'), |
159 | 'headers' => ['api-key' => $this->config->getValueString($this->appName, 'mongodbKey')], |
160 | 'mongodbCluster' => $this->config->getValueString($this->appName, 'mongodbCluster') |
161 | ]; |
162 | |
163 | $filters['_id'] = $id; |
164 | $returnData = $objectService->deleteObject($filters, $dbConfig); |
165 | |
166 | return new JSONResponse($returnData); |
167 | } catch (\Exception $e) { |
168 | return new JSONResponse(['error' => $e->getMessage()], 500); |
169 | } |
170 | } |
171 | } |
- | Code Coverage |
- |||||||||
- | Lines |
- Functions and Methods |
- Classes and Traits |
- |||||||
Total | -
-
-
- |
- 100.00% |
- 31 / 31 |
-
-
-
- |
- 100.00% |
- 3 / 3 |
- CRAP | -
-
-
- |
- 100.00% |
- 1 / 1 |
-
ConfigurationController | -
-
-
- |
- 100.00% |
- 31 / 31 |
-
-
-
- |
- 100.00% |
- 3 / 3 |
- 7 | -
-
-
- |
- 100.00% |
- 1 / 1 |
-
__construct | -
-
-
- |
- 100.00% |
- 3 / 3 |
-
-
-
- |
- 100.00% |
- 1 / 1 |
- 1 | -- | ||
index | -
-
-
- |
- 100.00% |
- 21 / 21 |
-
-
-
- |
- 100.00% |
- 1 / 1 |
- 3 | -- | ||
create | -
-
-
- |
- 100.00% |
- 7 / 7 |
-
-
-
- |
- 100.00% |
- 1 / 1 |
- 3 | -- |
1 | <?php |
2 | |
3 | namespace OCA\OpenCatalogi\Controller; |
4 | |
5 | use OCP\IAppConfig; |
6 | use OCP\AppFramework\Controller; |
7 | use OCP\AppFramework\Http\TemplateResponse; |
8 | use OCP\AppFramework\Http\JSONResponse; |
9 | use OCP\IRequest; |
10 | |
11 | class ConfigurationController extends Controller |
12 | { |
13 | const TEST_ARRAY = [ |
14 | "5137a1e5-b54d-43ad-abd1-4b5bff5fcd3f" => [ |
15 | "id" => "5137a1e5-b54d-43ad-abd1-4b5bff5fcd3f", |
16 | "name" => "Configuration one", |
17 | "summary" => "summary for one" |
18 | ], |
19 | "7782b511-7034-4d49-a005-e827d5ae603f" => [ |
20 | "id" => "7782b511-7034-4d49-a005-e827d5ae603f", |
21 | "name" => "Configuration two", |
22 | "summary" => "summary for two" |
23 | ] |
24 | ]; |
25 | |
26 | public function __construct( |
27 | $appName, |
28 | IAppConfig $config, |
29 | IRequest $request |
30 | ) { |
31 | parent::__construct($appName, $request); |
32 | $this->config = $config; |
33 | $this->request = $request; |
34 | } |
35 | |
36 | /** |
37 | * @NoAdminRequired |
38 | * @NoCSRFRequired |
39 | */ |
40 | public function index(): JSONResponse |
41 | { |
42 | $data = []; |
43 | $defaults = [ |
44 | 'drcLocation' => '', |
45 | 'drcKey' => '', |
46 | 'orcLocation' => '', |
47 | 'orcKey' => '', |
48 | 'mongodbLocation' => '', |
49 | 'mongodbKey' => '', |
50 | 'mongodbCluster' => '', |
51 | 'elasticLocation' => '', |
52 | 'elasticKey' => '', |
53 | 'elasticIndex' => '', |
54 | 'organisationName' => 'my-organisation', |
55 | 'organisationOin' => '', |
56 | 'organisationPki' => '' |
57 | ]; |
58 | |
59 | try { |
60 | foreach ($defaults as $key => $value) { |
61 | $data[$key] = $this->config->getValueString($this->appName, $key, $value); |
62 | } |
63 | return new JSONResponse($data); |
64 | } catch (\Exception $e) { |
65 | return new JSONResponse(['error' => $e->getMessage()], 500); |
66 | } |
67 | } |
68 | |
69 | /** |
70 | * Handling the post request |
71 | * |
72 | * @NoAdminRequired |
73 | * @NoCSRFRequired |
74 | */ |
75 | public function create(): JSONResponse |
76 | { |
77 | $data = $this->request->getParams(); |
78 | |
79 | try { |
80 | foreach ($data as $key => $value) { |
81 | $this->config->setValueString($this->appName, $key, $value); |
82 | $data[$key] = $this->config->getValueString($this->appName, $key); |
83 | } |
84 | return new JSONResponse($data); |
85 | } catch (\Exception $e) { |
86 | return new JSONResponse(['error' => $e->getMessage()], 500); |
87 | } |
88 | } |
89 | } |
- | Code Coverage |
- |||||||||
- | Lines |
- Functions and Methods |
- Classes and Traits |
- |||||||
Total | -
-
-
- |
- 47.06% |
- 8 / 17 |
-
-
-
- |
- 33.33% |
- 1 / 3 |
- CRAP | -
-
-
- |
- 0.00% |
- 0 / 1 |
-
DashboardController | -
-
-
- |
- 47.06% |
- 8 / 17 |
-
-
-
- |
- 33.33% |
- 1 / 3 |
- 8.71 | -
-
-
- |
- 0.00% |
- 0 / 1 |
-
__construct | -
-
-
- |
- 100.00% |
- 1 / 1 |
-
-
-
- |
- 100.00% |
- 1 / 1 |
- 1 | -- | ||
page | -
-
-
- |
- 41.67% |
- 5 / 12 |
-
-
-
- |
- 0.00% |
- 0 / 1 |
- 2.79 | -- | ||
index | -
-
-
- |
- 50.00% |
- 2 / 4 |
-
-
-
- |
- 0.00% |
- 0 / 1 |
- 2.50 | -- |
1 | <?php |
2 | |
3 | namespace OCA\OpenCatalogi\Controller; |
4 | |
5 | use OCP\AppFramework\Controller; |
6 | use OCP\AppFramework\Http\TemplateResponse; |
7 | use OCP\AppFramework\Http\JSONResponse; |
8 | use OCP\IRequest; |
9 | |
10 | class DashboardController extends Controller |
11 | { |
12 | const TEST_ARRAY = [ |
13 | "d021c5ff-a254-4114-a1fb-7a18db152270" => [ |
14 | "id" => "d021c5ff-a254-4114-a1fb-7a18db152270", |
15 | "name" => "Dashboard one", |
16 | "summary" => "summary for one" |
17 | ], |
18 | "79c02b33-78ba-4d65-aabd-ff9aae6654f7" => [ |
19 | "id" => "79c02b33-78ba-4d65-aabd-ff9aae6654f7", |
20 | "name" => "Dashboard two", |
21 | "summary" => "summary for two" |
22 | ] |
23 | ]; |
24 | |
25 | public function __construct($appName, IRequest $request) |
26 | { |
27 | parent::__construct($appName, $request); |
28 | } |
29 | |
30 | /** |
31 | * @NoAdminRequired |
32 | * @NoCSRFRequired |
33 | */ |
34 | public function page(?string $getParameter) |
35 | { |
36 | try { |
37 | return new TemplateResponse( |
38 | $this->appName, |
39 | 'index', |
40 | [] |
41 | ); |
42 | } catch (\Exception $e) { |
43 | return new TemplateResponse( |
44 | $this->appName, |
45 | 'error', |
46 | ['error' => $e->getMessage()], |
47 | '500' |
48 | ); |
49 | } |
50 | } |
51 | |
52 | /** |
53 | * @NoAdminRequired |
54 | * @NoCSRFRequired |
55 | */ |
56 | public function index(): JSONResponse |
57 | { |
58 | try { |
59 | $results = ["results" => self::TEST_ARRAY]; |
60 | return new JSONResponse($results); |
61 | } catch (\Exception $e) { |
62 | return new JSONResponse(['error' => $e->getMessage()], 500); |
63 | } |
64 | } |
65 | } |
- | Code Coverage |
- |||||||||
- | Lines |
- Functions and Methods |
- Classes and Traits |
- |||||||
Total | -
-
-
- |
- 96.77% |
- 60 / 62 |
-
-
-
- |
- 85.71% |
- 6 / 7 |
- CRAP | -
-
-
- |
- 0.00% |
- 0 / 1 |
-
DirectoryController | -
-
-
- |
- 96.77% |
- 60 / 62 |
-
-
-
- |
- 85.71% |
- 6 / 7 |
- 14 | -
-
-
- |
- 0.00% |
- 0 / 1 |
-
__construct | -
-
-
- |
- 100.00% |
- 1 / 1 |
-
-
-
- |
- 100.00% |
- 1 / 1 |
- 1 | -- | ||
page | -
-
-
- |
- 100.00% |
- 5 / 5 |
-
-
-
- |
- 100.00% |
- 1 / 1 |
- 1 | -- | ||
index | -
-
-
- |
- 100.00% |
- 11 / 11 |
-
-
-
- |
- 100.00% |
- 1 / 1 |
- 3 | -- | ||
show | -
-
-
- |
- 100.00% |
- 6 / 6 |
-
-
-
- |
- 100.00% |
- 1 / 1 |
- 1 | -- | ||
create | -
-
-
- |
- 100.00% |
- 14 / 14 |
-
-
-
- |
- 100.00% |
- 1 / 1 |
- 3 | -- | ||
update | -
-
-
- |
- 87.50% |
- 14 / 16 |
-
-
-
- |
- 0.00% |
- 0 / 1 |
- 4.03 | -- | ||
destroy | -
-
-
- |
- 100.00% |
- 9 / 9 |
-
-
-
- |
- 100.00% |
- 1 / 1 |
- 1 | -- |
1 | <?php |
2 | |
3 | namespace OCA\OpenCatalogi\Controller; |
4 | |
5 | use OCA\OpenCatalogi\Service\DirectoryService; |
6 | use OCA\OpenCatalogi\Service\ObjectService; |
7 | use OCP\AppFramework\Controller; |
8 | use OCP\AppFramework\Http\TemplateResponse; |
9 | use OCP\AppFramework\Http\JSONResponse; |
10 | use OCP\IAppConfig; |
11 | use OCP\IRequest; |
12 | |
13 | class DirectoryController extends Controller |
14 | { |
15 | const TEST_ARRAY = [ |
16 | "64996753-5109-4396-9f07-17040d7fb137" => [ |
17 | "id" => "64996753-5109-4396-9f07-17040d7fb137", |
18 | "title" => "Directory test 1", |
19 | "summary" => "A testing directory", |
20 | "description" => "A testing directory description", |
21 | "search" => "string", |
22 | "metadata" => "string", |
23 | "status" => "A status", |
24 | "lastSync" => "string", |
25 | "default" => "string", |
26 | "available" => "true" |
27 | |
28 | ], |
29 | "0dcb7be0-ce06-4453-9ea7-6d66f67aa4ea" =>[ |
30 | "id" => "0dcb7be0-ce06-4453-9ea7-6d66f67aa4ea", |
31 | "title" => "Directory test 2", |
32 | "summary" => "A testing directory", |
33 | "description" => "A testing directory description", |
34 | "search" => "string", |
35 | "metadata" => "string", |
36 | "status" => "A status", |
37 | "lastSync" => "string", |
38 | "default" => "string", |
39 | "available" => "true" |
40 | |
41 | ] |
42 | ]; |
43 | |
44 | public function __construct($appName, IRequest $request, private readonly IAppConfig $config) |
45 | { |
46 | parent::__construct($appName, $request); |
47 | } |
48 | |
49 | /** |
50 | * @NoAdminRequired |
51 | * @NoCSRFRequired |
52 | */ |
53 | public function page(?string $getParameter) |
54 | { |
55 | // The TemplateResponse loads the 'main.php' |
56 | // defined in our app's 'templates' folder. |
57 | // We pass the $getParameter variable to the template |
58 | // so that the value is accessible in the template. |
59 | return new TemplateResponse( |
60 | //Application::APP_ID, |
61 | $this->appName, |
62 | 'DirectoryIndex', |
63 | [] |
64 | ); |
65 | } |
66 | |
67 | |
68 | /** |
69 | * @NoAdminRequired |
70 | * @NoCSRFRequired |
71 | */ |
72 | public function index(ObjectService $objectService): JSONResponse |
73 | { |
74 | $dbConfig['base_uri'] = $this->config->getValueString(app: $this->appName, key: 'mongodbLocation'); |
75 | $dbConfig['headers']['api-key'] = $this->config->getValueString(app: $this->appName, key: 'mongodbKey'); |
76 | $dbConfig['mongodbCluster'] = $this->config->getValueString(app: $this->appName, key: 'mongodbCluster'); |
77 | |
78 | $filters = $this->request->getParams(); |
79 | |
80 | foreach($filters as $key => $value) { |
81 | if(str_starts_with($key, '_')) { |
82 | unset($filters[$key]); |
83 | } |
84 | } |
85 | |
86 | |
87 | |
88 | $filters['_schema'] = 'directory'; |
89 | |
90 | $result = $objectService->findObjects(filters: $filters, config: $dbConfig); |
91 | |
92 | $results = ["results" => $result['documents']]; |
93 | return new JSONResponse($results); |
94 | } |
95 | |
96 | /** |
97 | * @NoAdminRequired |
98 | * @NoCSRFRequired |
99 | */ |
100 | public function show(string $id, ObjectService $objectService, DirectoryService $directoryService): JSONResponse |
101 | { |
102 | $dbConfig['base_uri'] = $this->config->getValueString(app: $this->appName, key: 'mongodbLocation'); |
103 | $dbConfig['headers']['api-key'] = $this->config->getValueString(app: $this->appName, key: 'mongodbKey'); |
104 | $dbConfig['mongodbCluster'] = $this->config->getValueString(app: $this->appName, key: 'mongodbCluster'); |
105 | |
106 | $filters['_id'] = $id; |
107 | |
108 | $result = $objectService->findObject(filters: $filters, config: $dbConfig); |
109 | |
110 | return new JSONResponse($result); |
111 | } |
112 | |
113 | |
114 | /** |
115 | * @NoAdminRequired |
116 | * @NoCSRFRequired |
117 | */ |
118 | public function create(ObjectService $objectService, DirectoryService $directoryService): JSONResponse |
119 | { |
120 | $dbConfig['base_uri'] = $this->config->getValueString(app: $this->appName, key: 'mongodbLocation'); |
121 | $dbConfig['headers']['api-key'] = $this->config->getValueString(app: $this->appName, key: 'mongodbKey'); |
122 | $dbConfig['mongodbCluster'] = $this->config->getValueString(app: $this->appName, key: 'mongodbCluster'); |
123 | |
124 | $data = $this->request->getParams(); |
125 | |
126 | foreach($data as $key => $value) { |
127 | if(str_starts_with($key, '_')) { |
128 | unset($data[$key]); |
129 | } |
130 | } |
131 | |
132 | $data['_schema'] = 'directory'; |
133 | |
134 | $returnData = $objectService->saveObject( |
135 | data: $data, |
136 | config: $dbConfig |
137 | ); |
138 | |
139 | $directoryService->registerToExternalDirectory(newDirectory: $data); |
140 | |
141 | // get post from requests |
142 | return new JSONResponse($returnData); |
143 | } |
144 | |
145 | /** |
146 | * @NoAdminRequired |
147 | * @NoCSRFRequired |
148 | */ |
149 | public function update(string $id, ObjectService $objectService): JSONResponse |
150 | { |
151 | $dbConfig['base_uri'] = $this->config->getValueString(app: $this->appName, key: 'mongodbLocation'); |
152 | $dbConfig['headers']['api-key'] = $this->config->getValueString(app: $this->appName, key: 'mongodbKey'); |
153 | $dbConfig['mongodbCluster'] = $this->config->getValueString(app: $this->appName, key: 'mongodbCluster'); |
154 | |
155 | $data = $this->request->getParams(); |
156 | |
157 | foreach($data as $key => $value) { |
158 | if(str_starts_with($key, '_')) { |
159 | unset($data[$key]); |
160 | } |
161 | } |
162 | if (isset($data['id'])) { |
163 | unset( $data['id']); |
164 | } |
165 | |
166 | $filters['_id'] = $id; |
167 | $returnData = $objectService->updateObject( |
168 | filters: $filters, |
169 | update: $data, |
170 | config: $dbConfig |
171 | ); |
172 | |
173 | // get post from requests |
174 | return new JSONResponse($returnData); |
175 | } |
176 | |
177 | /** |
178 | * @NoAdminRequired |
179 | * @NoCSRFRequired |
180 | */ |
181 | public function destroy(string $id, ObjectService $objectService): JSONResponse |
182 | { |
183 | $dbConfig['base_uri'] = $this->config->getValueString(app: $this->appName, key: 'mongodbLocation'); |
184 | $dbConfig['headers']['api-key'] = $this->config->getValueString(app: $this->appName, key: 'mongodbKey'); |
185 | $dbConfig['mongodbCluster'] = $this->config->getValueString(app: $this->appName, key: 'mongodbCluster'); |
186 | |
187 | $filters['_id'] = $id; |
188 | $returnData = $objectService->deleteObject( |
189 | filters: $filters, |
190 | config: $dbConfig |
191 | ); |
192 | |
193 | // get post from requests |
194 | return new JSONResponse($returnData); |
195 | } |
196 | } |
- | Code Coverage |
- |||||||||
- | Lines |
- Functions and Methods |
- Classes and Traits |
- |||||||
Total | -
-
-
- |
- 96.72% |
- 59 / 61 |
-
-
-
- |
- 85.71% |
- 6 / 7 |
- CRAP | -
-
-
- |
- 0.00% |
- 0 / 1 |
-
MetaDataController | -
-
-
- |
- 96.72% |
- 59 / 61 |
-
-
-
- |
- 85.71% |
- 6 / 7 |
- 14 | -
-
-
- |
- 0.00% |
- 0 / 1 |
-
__construct | -
-
-
- |
- 100.00% |
- 1 / 1 |
-
-
-
- |
- 100.00% |
- 1 / 1 |
- 1 | -- | ||
page | -
-
-
- |
- 100.00% |
- 5 / 5 |
-
-
-
- |
- 100.00% |
- 1 / 1 |
- 1 | -- | ||
index | -
-
-
- |
- 100.00% |
- 11 / 11 |
-
-
-
- |
- 100.00% |
- 1 / 1 |
- 3 | -- | ||
show | -
-
-
- |
- 100.00% |
- 6 / 6 |
-
-
-
- |
- 100.00% |
- 1 / 1 |
- 1 | -- | ||
create | -
-
-
- |
- 100.00% |
- 13 / 13 |
-
-
-
- |
- 100.00% |
- 1 / 1 |
- 3 | -- | ||
update | -
-
-
- |
- 87.50% |
- 14 / 16 |
-
-
-
- |
- 0.00% |
- 0 / 1 |
- 4.03 | -- | ||
destroy | -
-
-
- |
- 100.00% |
- 9 / 9 |
-
-
-
- |
- 100.00% |
- 1 / 1 |
- 1 | -- |
1 | <?php |
2 | |
3 | namespace OCA\OpenCatalogi\Controller; |
4 | |
5 | use OCA\OpenCatalogi\Service\ObjectService; |
6 | use OCP\AppFramework\Controller; |
7 | use OCP\AppFramework\Http\TemplateResponse; |
8 | use OCP\AppFramework\Http\JSONResponse; |
9 | use OCP\IAppConfig; |
10 | use OCP\IRequest; |
11 | |
12 | class MetaDataController extends Controller |
13 | { |
14 | const TEST_ARRAY = [ |
15 | "6892aeb1-d92d-4da5-ad41-f1c3278f40c2" => [ |
16 | "id" => "6892aeb1-d92d-4da5-ad41-f1c3278f40c2", |
17 | "title" => "Woo verzoek en -besluit", |
18 | "description" => "Woo verzoek", |
19 | "version" => "0.0.1", |
20 | "properties" => '{ |
21 | "id": { |
22 | "type": "string" |
23 | }, |
24 | "titel": { |
25 | "type": "string" |
26 | }, |
27 | "beschrijving": { |
28 | "type": "string" |
29 | }, |
30 | "samenvatting": { |
31 | "type": "string" |
32 | }, |
33 | "categorie": { |
34 | "type": "string", |
35 | "required": true |
36 | }, |
37 | "gepubliceerd": { |
38 | "type": "boolean", |
39 | "default": true |
40 | }, |
41 | "portalUrl": { |
42 | "type": "string", |
43 | "format": "url" |
44 | }, |
45 | "publicatiedatum": { |
46 | "description": "Publicatiedatum van een Woo object is nooit in de toekomst.", |
47 | "type": "string", |
48 | "maxDate": "now", |
49 | "required": true |
50 | }, |
51 | "organisatie": { |
52 | "type": "object", |
53 | "$ref": "https://commongateway.nl/woo.organisatie.schema.json", |
54 | "format": "json", |
55 | "cascadeDelete": true |
56 | }, |
57 | "bijlagen": { |
58 | "type": "array", |
59 | "items": { |
60 | "$ref": "https://commongateway.nl/woo.bijlage.schema.json" |
61 | }, |
62 | "format": "json", |
63 | "cascadeDelete": true |
64 | }, |
65 | "metadata": { |
66 | "type": "object", |
67 | "$ref": "https://commongateway.nl/woo.metadata.schema.json", |
68 | "format": "json", |
69 | "cascadeDelete": true |
70 | }, |
71 | "themas": { |
72 | "type": "array", |
73 | "items": { |
74 | "$ref": "https://commongateway.nl/woo.thema.schema.json" |
75 | }, |
76 | "format": "json", |
77 | "cascadeDelete": true |
78 | } |
79 | }' |
80 | ], |
81 | "a375d626-ffe8-4a26-a024-1ad452d1b931" => [ |
82 | "id" => "a375d626-ffe8-4a26-a024-1ad452d1b931", |
83 | "title" => "Convenant", |
84 | "descriptiont" => "Woo Convenant", |
85 | "version" => "0.0.1", |
86 | "properties" => '{ |
87 | "id": { |
88 | "type": "string" |
89 | }, |
90 | "titel": { |
91 | "type": "string" |
92 | }, |
93 | "beschrijving": { |
94 | "type": "string" |
95 | }, |
96 | "samenvatting": { |
97 | "type": "string" |
98 | }, |
99 | "categorie": { |
100 | "type": "string", |
101 | "required": true |
102 | }, |
103 | "gepubliceerd": { |
104 | "type": "boolean", |
105 | "default": true |
106 | }, |
107 | "portalUrl": { |
108 | "type": "string", |
109 | "format": "url" |
110 | }, |
111 | "publicatiedatum": { |
112 | "description": "Publicatiedatum van een Woo object is nooit in de toekomst.", |
113 | "type": "string", |
114 | "maxDate": "now", |
115 | "required": true |
116 | }, |
117 | "organisatie": { |
118 | "type": "object", |
119 | "$ref": "https://commongateway.nl/woo.organisatie.schema.json", |
120 | "format": "json", |
121 | "cascadeDelete": true |
122 | }, |
123 | "bijlagen": { |
124 | "type": "array", |
125 | "items": { |
126 | "$ref": "https://commongateway.nl/woo.bijlage.schema.json" |
127 | }, |
128 | "format": "json", |
129 | "cascadeDelete": true |
130 | }, |
131 | "metadata": { |
132 | "type": "object", |
133 | "$ref": "https://commongateway.nl/woo.metadata.schema.json", |
134 | "format": "json", |
135 | "cascadeDelete": true |
136 | }, |
137 | "themas": { |
138 | "type": "array", |
139 | "items": { |
140 | "$ref": "https://commongateway.nl/woo.thema.schema.json" |
141 | }, |
142 | "format": "json", |
143 | "cascadeDelete": true |
144 | } |
145 | }' |
146 | ] |
147 | ]; |
148 | |
149 | public function __construct( |
150 | $appName, |
151 | IRequest $request, |
152 | private readonly IAppConfig $config |
153 | ) |
154 | { |
155 | parent::__construct($appName, $request); |
156 | } |
157 | |
158 | /** |
159 | * @NoAdminRequired |
160 | * @NoCSRFRequired |
161 | */ |
162 | public function page(?string $getParameter) |
163 | { |
164 | // The TemplateResponse loads the 'main.php' |
165 | // defined in our app's 'templates' folder. |
166 | // We pass the $getParameter variable to the template |
167 | // so that the value is accessible in the template. |
168 | return new TemplateResponse( |
169 | $this->appName, |
170 | 'metaDataIndex', |
171 | [] |
172 | ); |
173 | } |
174 | |
175 | /** |
176 | * @NoAdminRequired |
177 | * @NoCSRFRequired |
178 | */ |
179 | public function index(ObjectService $objectService): JSONResponse |
180 | { |
181 | $dbConfig['base_uri'] = $this->config->getValueString(app: $this->appName, key: 'mongodbLocation'); |
182 | $dbConfig['headers']['api-key'] = $this->config->getValueString(app: $this->appName, key: 'mongodbKey'); |
183 | $dbConfig['mongodbCluster'] = $this->config->getValueString(app: $this->appName, key: 'mongodbCluster'); |
184 | |
185 | $filters = $this->request->getParams(); |
186 | |
187 | foreach($filters as $key => $value) { |
188 | if(str_starts_with($key, '_')) { |
189 | unset($filters[$key]); |
190 | } |
191 | } |
192 | |
193 | |
194 | |
195 | $filters['_schema'] = 'metadata'; |
196 | |
197 | $result = $objectService->findObjects(filters: $filters, config: $dbConfig); |
198 | |
199 | $results = ["results" => $result['documents']]; |
200 | return new JSONResponse($results); |
201 | } |
202 | |
203 | /** |
204 | * @NoAdminRequired |
205 | * @NoCSRFRequired |
206 | */ |
207 | public function show(string $id, ObjectService $objectService): JSONResponse |
208 | { |
209 | $dbConfig['base_uri'] = $this->config->getValueString(app: $this->appName, key: 'mongodbLocation'); |
210 | $dbConfig['headers']['api-key'] = $this->config->getValueString(app: $this->appName, key: 'mongodbKey'); |
211 | $dbConfig['mongodbCluster'] = $this->config->getValueString(app: $this->appName, key: 'mongodbCluster'); |
212 | |
213 | $filters['_id'] = $id; |
214 | |
215 | $result = $objectService->findObject(filters: $filters, config: $dbConfig); |
216 | |
217 | return new JSONResponse($result); |
218 | } |
219 | |
220 | |
221 | /** |
222 | * @NoAdminRequired |
223 | * @NoCSRFRequired |
224 | */ |
225 | public function create(ObjectService $objectService): JSONResponse |
226 | { |
227 | $dbConfig['base_uri'] = $this->config->getValueString(app: $this->appName, key: 'mongodbLocation'); |
228 | $dbConfig['headers']['api-key'] = $this->config->getValueString(app: $this->appName, key: 'mongodbKey'); |
229 | $dbConfig['mongodbCluster'] = $this->config->getValueString(app: $this->appName, key: 'mongodbCluster'); |
230 | |
231 | $data = $this->request->getParams(); |
232 | |
233 | foreach($data as $key => $value) { |
234 | if(str_starts_with($key, '_')) { |
235 | unset($data[$key]); |
236 | } |
237 | } |
238 | |
239 | $data['_schema'] = 'metadata'; |
240 | |
241 | $returnData = $objectService->saveObject( |
242 | data: $data, |
243 | config: $dbConfig |
244 | ); |
245 | |
246 | // get post from requests |
247 | return new JSONResponse($returnData); |
248 | } |
249 | |
250 | /** |
251 | * @NoAdminRequired |
252 | * @NoCSRFRequired |
253 | */ |
254 | public function update(string $id, ObjectService $objectService): JSONResponse |
255 | { |
256 | $dbConfig['base_uri'] = $this->config->getValueString(app: $this->appName, key: 'mongodbLocation'); |
257 | $dbConfig['headers']['api-key'] = $this->config->getValueString(app: $this->appName, key: 'mongodbKey'); |
258 | $dbConfig['mongodbCluster'] = $this->config->getValueString(app: $this->appName, key: 'mongodbCluster'); |
259 | |
260 | $data = $this->request->getParams(); |
261 | |
262 | foreach($data as $key => $value) { |
263 | if(str_starts_with($key, '_')) { |
264 | unset($data[$key]); |
265 | } |
266 | } |
267 | if (isset($data['id'])) { |
268 | unset( $data['id']); |
269 | } |
270 | |
271 | $filters['_id'] = $id; |
272 | $returnData = $objectService->updateObject( |
273 | filters: $filters, |
274 | update: $data, |
275 | config: $dbConfig |
276 | ); |
277 | |
278 | // get post from requests |
279 | return new JSONResponse($returnData); |
280 | } |
281 | |
282 | /** |
283 | * @NoAdminRequired |
284 | * @NoCSRFRequired |
285 | */ |
286 | public function destroy(string $id, ObjectService $objectService): JSONResponse |
287 | { |
288 | $dbConfig['base_uri'] = $this->config->getValueString(app: $this->appName, key: 'mongodbLocation'); |
289 | $dbConfig['headers']['api-key'] = $this->config->getValueString(app: $this->appName, key: 'mongodbKey'); |
290 | $dbConfig['mongodbCluster'] = $this->config->getValueString(app: $this->appName, key: 'mongodbCluster'); |
291 | |
292 | $filters['_id'] = $id; |
293 | $returnData = $objectService->deleteObject( |
294 | filters: $filters, |
295 | config: $dbConfig |
296 | ); |
297 | |
298 | // get post from requests |
299 | return new JSONResponse($returnData); |
300 | } |
301 | } |
- | Code Coverage |
- |||||||||
- | Lines |
- Functions and Methods |
- Classes and Traits |
- |||||||
Total | -
-
-
- |
- 60.40% |
- 61 / 101 |
-
-
-
- |
- 33.33% |
- 3 / 9 |
- CRAP | -
-
-
- |
- 0.00% |
- 0 / 1 |
-
PublicationsController | -
-
-
- |
- 60.40% |
- 61 / 101 |
-
-
-
- |
- 33.33% |
- 3 / 9 |
- 100.65 | -
-
-
- |
- 0.00% |
- 0 / 1 |
-
__construct | -
-
-
- |
- 100.00% |
- 1 / 1 |
-
-
-
- |
- 100.00% |
- 1 / 1 |
- 1 | -- | ||
insertNestedObjects | -
-
-
- |
- 0.00% |
- 0 / 12 |
-
-
-
- |
- 0.00% |
- 0 / 1 |
- 90 | -- | ||
page | -
-
-
- |
- 100.00% |
- 5 / 5 |
-
-
-
- |
- 100.00% |
- 1 / 1 |
- 1 | -- | ||
catalog | -
-
-
- |
- 0.00% |
- 0 / 5 |
-
-
-
- |
- 0.00% |
- 0 / 1 |
- 2 | -- | ||
index | -
-
-
- |
- 81.82% |
- 9 / 11 |
-
-
-
- |
- 0.00% |
- 0 / 1 |
- 3.05 | -- | ||
show | -
-
-
- |
- 100.00% |
- 6 / 6 |
-
-
-
- |
- 100.00% |
- 1 / 1 |
- 1 | -- | ||
create | -
-
-
- |
- 66.67% |
- 14 / 21 |
-
-
-
- |
- 0.00% |
- 0 / 1 |
- 7.33 | -- | ||
update | -
-
-
- |
- 66.67% |
- 16 / 24 |
-
-
-
- |
- 0.00% |
- 0 / 1 |
- 8.81 | -- | ||
destroy | -
-
-
- |
- 62.50% |
- 10 / 16 |
-
-
-
- |
- 0.00% |
- 0 / 1 |
- 4.84 | -- |
1 | <?php |
2 | |
3 | namespace OCA\OpenCatalogi\Controller; |
4 | |
5 | use Elastic\Elasticsearch\Client; |
6 | use GuzzleHttp\Exception\GuzzleException; |
7 | use OCA\OpenCatalogi\Service\ElasticSearchService; |
8 | use OCA\OpenCatalogi\Service\ObjectService; |
9 | use OCP\AppFramework\Controller; |
10 | use OCP\AppFramework\Http\TemplateResponse; |
11 | use OCP\AppFramework\Http\JSONResponse; |
12 | use OCP\IAppConfig; |
13 | use OCP\IRequest; |
14 | use Symfony\Component\Uid\Uuid; |
15 | |
16 | class PublicationsController extends Controller |
17 | { |
18 | const TEST_ARRAY = [ |
19 | "354980e5-c967-4ba5-989b-65c2b0cd2ff4" => [ |
20 | "id" => "354980e5-c967-4ba5-989b-65c2b0cd2ff4", |
21 | "name" => "Input voor OpenCatalogi", |
22 | "summary" => "Dit is een selectie van high-value datasets in DCAT-AP 2.0 standaard x" |
23 | ], |
24 | "2ab0011e-9b4c-4c50-a50d-a16fc0be0178" => [ |
25 | "id" => "2ab0011e-9b4c-4c50-a50d-a16fc0be0178", |
26 | "title" => "Publication two", |
27 | "description" => "summary for two" |
28 | ] |
29 | ]; |
30 | |
31 | public function __construct |
32 | ( |
33 | $appName, |
34 | IRequest $request, |
35 | private readonly IAppConfig $config |
36 | ) |
37 | { |
38 | parent::__construct($appName, $request); |
39 | } |
40 | |
41 | private function insertNestedObjects(array $object, ObjectService $objectService, array $config): array |
42 | { |
43 | //@TODO keep in mind that unpublished objects should not be inserted, and that objects should be updated if a subobject is updated. |
44 | foreach($object as $key => $value) { |
45 | try { |
46 | if( |
47 | is_string(value: $value) |
48 | && $key !== 'id' |
49 | && Uuid::isValid(uuid: $value) === true |
50 | && $subObject = $objectService->findObject(filters: ['_id' => $value], config: $config) |
51 | ) { |
52 | $object[$key] = $subObject; |
53 | } |
54 | |
55 | if( |
56 | is_array(value: $value) === true |
57 | && array_is_list(array: $value) === true |
58 | ) { |
59 | $object[$key] = $this->insertNestedObjects(object: $value, objectService: $objectService, config: $config); |
60 | } |
61 | } catch (GuzzleException $exception) { |
62 | continue; |
63 | } |
64 | } |
65 | |
66 | return $object; |
67 | } |
68 | |
69 | |
70 | /** |
71 | * @NoAdminRequired |
72 | * @NoCSRFRequired |
73 | */ |
74 | public function page(?string $getParameter) |
75 | { |
76 | // The TemplateResponse loads the 'main.php' |
77 | // defined in our app's 'templates' folder. |
78 | // We pass the $getParameter variable to the template |
79 | // so that the value is accessible in the template. |
80 | return new TemplateResponse( |
81 | $this->appName, |
82 | 'PublicationsIndex', |
83 | [] |
84 | ); |
85 | } |
86 | |
87 | /** |
88 | * Taking it from a catalogue point of view is just adding a filter |
89 | * |
90 | * @NoAdminRequired |
91 | * @NoCSRFRequired |
92 | */ |
93 | public function catalog(string $id): TemplateResponse |
94 | { |
95 | // The TemplateResponse loads the 'main.php' |
96 | // defined in our app's 'templates' folder. |
97 | // We pass the $getParameter variable to the template |
98 | // so that the value is accessible in the template. |
99 | return new TemplateResponse( |
100 | $this->appName, |
101 | 'PublicationsIndex', |
102 | [] |
103 | ); |
104 | } |
105 | |
106 | /** |
107 | * @NoAdminRequired |
108 | * @NoCSRFRequired |
109 | */ |
110 | public function index(ObjectService $objectService): JSONResponse |
111 | { |
112 | $dbConfig['base_uri'] = $this->config->getValueString(app: $this->appName, key: 'mongodbLocation'); |
113 | $dbConfig['headers']['api-key'] = $this->config->getValueString(app: $this->appName, key: 'mongodbKey'); |
114 | $dbConfig['mongodbCluster'] = $this->config->getValueString(app: $this->appName, key: 'mongodbCluster'); |
115 | |
116 | $filters = $this->request->getParams(); |
117 | |
118 | foreach($filters as $key => $value) { |
119 | if(str_starts_with($key, '_')) { |
120 | unset($filters[$key]); |
121 | } |
122 | } |
123 | |
124 | |
125 | |
126 | $filters['_schema'] = 'publication'; |
127 | |
128 | $result = $objectService->findObjects(filters: $filters, config: $dbConfig); |
129 | |
130 | $results = ["results" => $result['documents']]; |
131 | return new JSONResponse($results); |
132 | } |
133 | |
134 | /** |
135 | * @NoAdminRequired |
136 | * @NoCSRFRequired |
137 | */ |
138 | public function show(string $id, ObjectService $objectService): JSONResponse |
139 | { |
140 | $dbConfig['base_uri'] = $this->config->getValueString(app: $this->appName, key: 'mongodbLocation'); |
141 | $dbConfig['headers']['api-key'] = $this->config->getValueString(app: $this->appName, key: 'mongodbKey'); |
142 | $dbConfig['mongodbCluster'] = $this->config->getValueString(app: $this->appName, key: 'mongodbCluster'); |
143 | |
144 | $filters['_id'] = $id; |
145 | |
146 | $result = $objectService->findObject(filters: $filters, config: $dbConfig); |
147 | |
148 | return new JSONResponse($result); |
149 | } |
150 | |
151 | |
152 | /** |
153 | * @NoAdminRequired |
154 | * @NoCSRFRequired |
155 | */ |
156 | public function create(ObjectService $objectService, ElasticSearchService $elasticSearchService): JSONResponse |
157 | { |
158 | $dbConfig['base_uri'] = $this->config->getValueString(app: $this->appName, key: 'mongodbLocation'); |
159 | $dbConfig['headers']['api-key'] = $this->config->getValueString(app: $this->appName, key: 'mongodbKey'); |
160 | $dbConfig['mongodbCluster'] = $this->config->getValueString(app: $this->appName, key: 'mongodbCluster'); |
161 | |
162 | $data = $this->request->getParams(); |
163 | |
164 | foreach($data as $key => $value) { |
165 | if(str_starts_with($key, '_')) { |
166 | unset($data[$key]); |
167 | } |
168 | } |
169 | |
170 | $data['_schema'] = 'publication'; |
171 | |
172 | $returnData = $objectService->saveObject( |
173 | data: $data, |
174 | config: $dbConfig |
175 | ); |
176 | |
177 | |
178 | if( |
179 | $this->config->hasKey(app: $this->appName, key: 'elasticLocation') === true |
180 | && $this->config->hasKey(app: $this->appName, key: 'elasticKey') === true |
181 | && $this->config->hasKey(app: $this->appName, key: 'elasticIndex') === true |
182 | ) { |
183 | $elasticConfig['location'] = $this->config->getValueString(app: $this->appName, key: 'elasticLocation'); |
184 | $elasticConfig['key'] = $this->config->getValueString(app: $this->appName, key: 'elasticKey'); |
185 | $elasticConfig['index'] = $this->config->getValueString(app: $this->appName, key: 'elasticIndex'); |
186 | |
187 | $returnData = $this->insertNestedObjects($returnData, $objectService, $dbConfig); |
188 | |
189 | $returnData = $elasticSearchService->addObject(object: $returnData, config: $elasticConfig); |
190 | |
191 | } |
192 | // get post from requests |
193 | return new JSONResponse($returnData); |
194 | } |
195 | |
196 | /** |
197 | * @NoAdminRequired |
198 | * @NoCSRFRequired |
199 | */ |
200 | public function update(string $id, ObjectService $objectService, ElasticSearchService $elasticSearchService): JSONResponse |
201 | { |
202 | $dbConfig['base_uri'] = $this->config->getValueString(app: $this->appName, key: 'mongodbLocation'); |
203 | $dbConfig['headers']['api-key'] = $this->config->getValueString(app: $this->appName, key: 'mongodbKey'); |
204 | $dbConfig['mongodbCluster'] = $this->config->getValueString(app: $this->appName, key: 'mongodbCluster'); |
205 | |
206 | $data = $this->request->getParams(); |
207 | |
208 | foreach($data as $key => $value) { |
209 | if(str_starts_with($key, '_')) { |
210 | unset($data[$key]); |
211 | } |
212 | } |
213 | if (isset($data['id'])) { |
214 | unset( $data['id']); |
215 | } |
216 | |
217 | $filters['_id'] = $id; |
218 | $returnData = $objectService->updateObject( |
219 | filters: $filters, |
220 | update: $data, |
221 | config: $dbConfig |
222 | ); |
223 | |
224 | if( |
225 | $this->config->hasKey(app: $this->appName, key: 'elasticLocation') === true |
226 | && $this->config->hasKey(app: $this->appName, key: 'elasticKey') === true |
227 | && $this->config->hasKey(app: $this->appName, key: 'elasticIndex') === true |
228 | ) { |
229 | $elasticConfig['location'] = $this->config->getValueString(app: $this->appName, key: 'elasticLocation'); |
230 | $elasticConfig['key'] = $this->config->getValueString(app: $this->appName, key: 'elasticKey'); |
231 | $elasticConfig['index'] = $this->config->getValueString(app: $this->appName, key: 'elasticIndex'); |
232 | |
233 | $returnData = $this->insertNestedObjects($returnData, $objectService, $dbConfig); |
234 | |
235 | $returnData = $elasticSearchService->updateObject(id: $id, object: $returnData, config: $elasticConfig); |
236 | |
237 | } |
238 | |
239 | // get post from requests |
240 | return new JSONResponse($returnData); |
241 | } |
242 | |
243 | /** |
244 | * @NoAdminRequired |
245 | * @NoCSRFRequired |
246 | */ |
247 | public function destroy(string $id, ObjectService $objectService, ElasticSearchService $elasticSearchService): JSONResponse |
248 | { |
249 | $dbConfig['base_uri'] = $this->config->getValueString(app: $this->appName, key: 'mongodbLocation'); |
250 | $dbConfig['headers']['api-key'] = $this->config->getValueString(app: $this->appName, key: 'mongodbKey'); |
251 | $dbConfig['mongodbCluster'] = $this->config->getValueString(app: $this->appName, key: 'mongodbCluster'); |
252 | |
253 | $filters['_id'] = $id; |
254 | $returnData = $objectService->deleteObject( |
255 | filters: $filters, |
256 | config: $dbConfig |
257 | ); |
258 | |
259 | if( |
260 | $this->config->hasKey(app: $this->appName, key: 'elasticLocation') === true |
261 | && $this->config->hasKey(app: $this->appName, key: 'elasticKey') === true |
262 | && $this->config->hasKey(app: $this->appName, key: 'elasticIndex') === true |
263 | ) { |
264 | $elasticConfig['location'] = $this->config->getValueString(app: $this->appName, key: 'elasticLocation'); |
265 | $elasticConfig['key'] = $this->config->getValueString(app: $this->appName, key: 'elasticKey'); |
266 | $elasticConfig['index'] = $this->config->getValueString(app: $this->appName, key: 'elasticIndex'); |
267 | |
268 | $returnData = $elasticSearchService->removeObject(id: $id, config: $elasticConfig); |
269 | |
270 | } |
271 | |
272 | // get post from requests |
273 | return new JSONResponse($returnData); |
274 | } |
275 | } |
- | Code Coverage |
- |||||||||
- | Lines |
- Functions and Methods |
- Classes and Traits |
- |||||||
Total | -
-
-
- |
- 100.00% |
- 31 / 31 |
-
-
-
- |
- 100.00% |
- 4 / 4 |
- CRAP | -
-
-
- |
- 100.00% |
- 1 / 1 |
-
SearchController | -
-
-
- |
- 100.00% |
- 31 / 31 |
-
-
-
- |
- 100.00% |
- 4 / 4 |
- 5 | -
-
-
- |
- 100.00% |
- 1 / 1 |
-
__construct | -
-
-
- |
- 100.00% |
- 1 / 1 |
-
-
-
- |
- 100.00% |
- 1 / 1 |
- 1 | -- | ||
page | -
-
-
- |
- 100.00% |
- 5 / 5 |
-
-
-
- |
- 100.00% |
- 1 / 1 |
- 1 | -- | ||
index | -
-
-
- |
- 100.00% |
- 14 / 14 |
-
-
-
- |
- 100.00% |
- 1 / 1 |
- 1 | -- | ||
show | -
-
-
- |
- 100.00% |
- 11 / 11 |
-
-
-
- |
- 100.00% |
- 1 / 1 |
- 2 | -- |
1 | <?php |
2 | |
3 | namespace OCA\OpenCatalogi\Controller; |
4 | |
5 | use OCA\OpenCatalogi\Service\ElasticSearchService; |
6 | use OCA\OpenCatalogi\Service\SearchService; |
7 | use OCP\AppFramework\Controller; |
8 | use OCP\AppFramework\Http\TemplateResponse; |
9 | use OCP\AppFramework\Http\JSONResponse; |
10 | use OCP\IAppConfig; |
11 | use OCP\IRequest; |
12 | |
13 | class SearchController extends Controller |
14 | { |
15 | const TEST_ARRAY = [ |
16 | "d9e1467e-fc55-44c8-bf5c-bf139ac10eda" => [ |
17 | "id" => "d9e1467e-fc55-44c8-bf5c-bf139ac10eda", |
18 | "name" => "Search one", |
19 | "summary" => "summary for one" |
20 | ], |
21 | "e9d0131b-06c4-4d20-aa17-3b2aaad186d7" => [ |
22 | "id" => "e9d0131b-06c4-4d20-aa17-3b2aaad186d7", |
23 | "name" => "Search two", |
24 | "summary" => "summary for two" |
25 | ] |
26 | ]; |
27 | |
28 | public function __construct($appName, IRequest $request, private readonly IAppConfig $config) |
29 | { |
30 | parent::__construct($appName, $request); |
31 | } |
32 | |
33 | /** |
34 | * @NoAdminRequired |
35 | * @NoCSRFRequired |
36 | */ |
37 | public function page(?string $getParameter) |
38 | { |
39 | // The TemplateResponse loads the 'main.php' |
40 | // defined in our app's 'templates' folder. |
41 | // We pass the $getParameter variable to the template |
42 | // so that the value is accessible in the template. |
43 | return new TemplateResponse( |
44 | $this->appName, |
45 | 'SearchIndex', |
46 | [] |
47 | ); |
48 | } |
49 | |
50 | /** |
51 | * @PublicPage |
52 | * @NoCSRFRequired |
53 | */ |
54 | public function index(SearchService $searchService): JSONResponse |
55 | { |
56 | $elasticConfig['location'] = $this->config->getValueString(app: $this->appName, key: 'elasticLocation'); |
57 | $elasticConfig['key'] = $this->config->getValueString(app: $this->appName, key: 'elasticKey'); |
58 | $elasticConfig['index'] = $this->config->getValueString(app: $this->appName, key: 'elasticIndex'); |
59 | |
60 | $dbConfig['base_uri'] = $this->config->getValueString(app: $this->appName, key: 'mongodbLocation'); |
61 | $dbConfig['headers']['api-key'] = $this->config->getValueString(app: $this->appName, key: 'mongodbKey'); |
62 | $dbConfig['mongodbCluster'] = $this->config->getValueString(app: $this->appName, key: 'mongodbCluster'); |
63 | |
64 | $filters = $this->request->getParams(); |
65 | unset($filters['_route']); |
66 | |
67 | //@TODO: find a better way to get query params. This fixes it for now. |
68 | $keys = array_keys(array: $filters); |
69 | $values = array_values(array: $filters); |
70 | |
71 | $keys = str_replace('_', '.', $keys); |
72 | |
73 | $filters = array_combine(keys: $keys, values: $values); |
74 | |
75 | |
76 | $data = $searchService->search(parameters: $filters, elasticConfig: $elasticConfig, dbConfig: $dbConfig); |
77 | |
78 | return new JSONResponse($data); |
79 | } |
80 | |
81 | /** |
82 | * @PublicPage |
83 | * @NoCSRFRequired |
84 | */ |
85 | public function show(string $id, SearchService $searchService): JSONResponse |
86 | { |
87 | $elasticConfig['location'] = $this->config->getValueString(app: $this->appName, key: 'elasticLocation'); |
88 | $elasticConfig['key'] = $this->config->getValueString(app: $this->appName, key: 'elasticKey'); |
89 | $elasticConfig['index'] = $this->config->getValueString(app: $this->appName, key: 'elasticIndex'); |
90 | |
91 | $dbConfig['base_uri'] = $this->config->getValueString(app: $this->appName, key: 'mongodbLocation'); |
92 | $dbConfig['headers']['api-key'] = $this->config->getValueString(app: $this->appName, key: 'mongodbKey'); |
93 | $dbConfig['mongodbCluster'] = $this->config->getValueString(app: $this->appName, key: 'mongodbCluster'); |
94 | |
95 | $filters = ['_id' => $id]; |
96 | |
97 | $data = $searchService->search(parameters: $filters, elasticConfig: $elasticConfig, dbConfig: $dbConfig); |
98 | |
99 | if(count($data['results']) > 0) { |
100 | return new JSONResponse($data['results'][0]); |
101 | } |
102 | |
103 | return new JSONResponse(data: ['error' => ['code' => 404, 'message' => 'the requested resource could not be found']], statusCode: 404); |
104 | } |
105 | } |
Class | -Coverage | -
---|---|
OCA\OpenCatalogi\Controller\DashboardController | 47% |
OCA\OpenCatalogi\Controller\PublicationsController | 60% |
OCA\OpenCatalogi\Controller\AttachmentsController | 82% |
Class | -CRAP | -
---|---|
OCA\OpenCatalogi\Controller\PublicationsController | 100 |
OCA\OpenCatalogi\Controller\AttachmentsController | 24 |
OCA\OpenCatalogi\Controller\DashboardController | 8 |
- | Code Coverage |
- ||||||||
- | Lines |
- Functions and Methods |
- Classes and Traits |
- ||||||
Total | -
-
-
- |
- 84.23% |
- 374 / 444 |
-
-
-
- |
- 65.31% |
- 32 / 49 |
-
-
-
- |
- 25.00% |
- 2 / 8 |
-
AttachmentsController.php | -
-
-
- |
- 82.67% |
- 62 / 75 |
-
-
-
- |
- 55.56% |
- 5 / 9 |
-
-
-
- |
- 0.00% |
- 0 / 1 |
-
CatalogiController.php | -
-
-
- |
- 93.94% |
- 62 / 66 |
-
-
-
- |
- 57.14% |
- 4 / 7 |
-
-
-
- |
- 0.00% |
- 0 / 1 |
-
ConfigurationController.php | -
-
-
- |
- 100.00% |
- 31 / 31 |
-
-
-
- |
- 100.00% |
- 3 / 3 |
-
-
-
- |
- 100.00% |
- 1 / 1 |
-
DashboardController.php | -
-
-
- |
- 47.06% |
- 8 / 17 |
-
-
-
- |
- 33.33% |
- 1 / 3 |
-
-
-
- |
- 0.00% |
- 0 / 1 |
-
DirectoryController.php | -
-
-
- |
- 96.77% |
- 60 / 62 |
-
-
-
- |
- 85.71% |
- 6 / 7 |
-
-
-
- |
- 0.00% |
- 0 / 1 |
-
MetaDataController.php | -
-
-
- |
- 96.72% |
- 59 / 61 |
-
-
-
- |
- 85.71% |
- 6 / 7 |
-
-
-
- |
- 0.00% |
- 0 / 1 |
-
PublicationsController.php | -
-
-
- |
- 60.40% |
- 61 / 101 |
-
-
-
- |
- 33.33% |
- 3 / 9 |
-
-
-
- |
- 0.00% |
- 0 / 1 |
-
SearchController.php | -
-
-
- |
- 100.00% |
- 31 / 31 |
-
-
-
- |
- 100.00% |
- 4 / 4 |
-
-
-
- |
- 100.00% |
- 1 / 1 |
-
- | Code Coverage |
- |||||||||
- | Lines |
- Functions and Methods |
- Classes and Traits |
- |||||||
Total | -
-
-
- |
- 0.00% |
- 0 / 43 |
-
-
-
- |
- 0.00% |
- 0 / 6 |
- CRAP | -
-
-
- |
- 0.00% |
- 0 / 1 |
-
DirectoryService | -
-
-
- |
- 0.00% |
- 0 / 43 |
-
-
-
- |
- 0.00% |
- 0 / 6 |
- 110 | -
-
-
- |
- 0.00% |
- 0 / 1 |
-
__construct | -
-
-
- |
- 0.00% |
- 0 / 2 |
-
-
-
- |
- 0.00% |
- 0 / 1 |
- 2 | -- | ||
getDirectoryEntry | -
-
-
- |
- 0.00% |
- 0 / 13 |
-
-
-
- |
- 0.00% |
- 0 / 1 |
- 2 | -- | ||
registerToExternalDirectory | -
-
-
- |
- 0.00% |
- 0 / 9 |
-
-
-
- |
- 0.00% |
- 0 / 1 |
- 6 | -- | ||
createDirectoryFromResult | -
-
-
- |
- 0.00% |
- 0 / 13 |
-
-
-
- |
- 0.00% |
- 0 / 1 |
- 12 | -- | ||
fetchFromExternalDirectory | -
-
-
- |
- 0.00% |
- 0 / 5 |
-
-
-
- |
- 0.00% |
- 0 / 1 |
- 6 | -- | ||
updateToExternalDirectory | -
-
-
- |
- 0.00% |
- 0 / 1 |
-
-
-
- |
- 0.00% |
- 0 / 1 |
- 2 | -- |
1 | <?php |
2 | |
3 | namespace OCA\OpenCatalogi\Service; |
4 | |
5 | use DateTime; |
6 | use GuzzleHttp\Client; |
7 | use OCP\IAppConfig; |
8 | use OCP\IURLGenerator; |
9 | |
10 | class DirectoryService |
11 | { |
12 | private Client $client; |
13 | |
14 | public function __construct( |
15 | private readonly IURLGenerator $urlGenerator, |
16 | private readonly IAppConfig $config, |
17 | private readonly ObjectService $objectService, |
18 | ) |
19 | { |
20 | $this->config = $config; |
21 | $this->client = new Client([]); |
22 | } |
23 | |
24 | private function getDirectoryEntry(string $catalogId): array |
25 | { |
26 | $now = new DateTime(); |
27 | return [ |
28 | 'title' => '', |
29 | 'summary' => '', |
30 | 'description' => '', |
31 | 'search' => $this->urlGenerator->getAbsoluteURL($this->urlGenerator->linkToRoute(routeName:"opencatalogi.search.index")), |
32 | 'directory' => $this->urlGenerator->getAbsoluteURL($this->urlGenerator->linkToRoute(routeName:"opencatalogi.directory.index")), |
33 | 'metadata' => '', |
34 | 'status' => '', |
35 | 'lastSync' => $now->format(format: 'c'), |
36 | 'default' => true, |
37 | 'catalogId' => $catalogId |
38 | ]; |
39 | } |
40 | |
41 | public function registerToExternalDirectory (array $newDirectory): int |
42 | { |
43 | $dbConfig['base_uri'] = $this->config->getValueString('opencatalogi', 'mongodbLocation'); |
44 | $dbConfig['headers']['api-key'] = $this->config->getValueString('opencatalogi', 'mongodbKey'); |
45 | $dbConfig['mongodbCluster'] = $this->config->getValueString('opencatalogi', 'mongodbCluster'); |
46 | |
47 | $catalogi = $this->objectService->findObjects(filters: ['_schema' => 'catalog'], config: $dbConfig)['documents']; |
48 | |
49 | foreach($catalogi as $catalog) { |
50 | $directory = $this->getDirectoryEntry($catalog['id']); |
51 | $result = $this->client->post(uri: $newDirectory['directory'], options: ['json' => $directory, 'http_errors' => false]); |
52 | } |
53 | |
54 | $externalDirectories = $this->fetchFromExternalDirectory($newDirectory); |
55 | |
56 | return $result->getStatusCode(); |
57 | |
58 | } |
59 | |
60 | private function createDirectoryFromResult(array $result): ?array |
61 | { |
62 | $myDirectory = $this->getDirectoryEntry(''); |
63 | |
64 | if(isset($result['directory']) === false || $result['directory'] === $myDirectory['directory']) { |
65 | return null; |
66 | } |
67 | |
68 | $dbConfig['base_uri'] = $this->config->getValueString(app: 'opencatalogi', key: 'mongodbLocation'); |
69 | $dbConfig['headers']['api-key'] = $this->config->getValueString(app: 'opencatalogi', key: 'mongodbKey'); |
70 | $dbConfig['mongodbCluster'] = $this->config->getValueString(app: 'opencatalogi', key: 'mongodbCluster'); |
71 | |
72 | $result['_schema'] = 'directory'; |
73 | |
74 | $returnData = $this->objectService->saveObject( |
75 | data: $result, |
76 | config: $dbConfig |
77 | ); |
78 | |
79 | $this->registerToExternalDirectory(newDirectory: $result); |
80 | |
81 | return $returnData; |
82 | } |
83 | |
84 | public function fetchFromExternalDirectory(array $directory): array |
85 | { |
86 | $result = $this->client->get($directory['directory']); |
87 | |
88 | $results = json_decode($result->getBody()->getContents()); |
89 | |
90 | foreach($results['results'] as $record) { |
91 | $this->createDirectoryFromResult($record); |
92 | } |
93 | |
94 | return $results['results']; |
95 | } |
96 | |
97 | public function updateToExternalDirectory(): array |
98 | { |
99 | |
100 | } |
101 | } |
- | Code Coverage |
- |||||||||
- | Lines |
- Functions and Methods |
- Classes and Traits |
- |||||||
Total | -
-
-
- |
- 0.00% |
- 0 / 78 |
-
-
-
- |
- 0.00% |
- 0 / 9 |
- CRAP | -
-
-
- |
- 0.00% |
- 0 / 1 |
-
ElasticSearchService | -
-
-
- |
- 0.00% |
- 0 / 78 |
-
-
-
- |
- 0.00% |
- 0 / 9 |
- 380 | -
-
-
- |
- 0.00% |
- 0 / 1 |
-
getClient | -
-
-
- |
- 0.00% |
- 0 / 7 |
-
-
-
- |
- 0.00% |
- 0 / 1 |
- 2 | -- | ||
addObject | -
-
-
- |
- 0.00% |
- 0 / 14 |
-
-
-
- |
- 0.00% |
- 0 / 1 |
- 12 | -- | ||
removeObject | -
-
-
- |
- 0.00% |
- 0 / 8 |
-
-
-
- |
- 0.00% |
- 0 / 1 |
- 6 | -- | ||
updateObject | -
-
-
- |
- 0.00% |
- 0 / 11 |
-
-
-
- |
- 0.00% |
- 0 / 1 |
- 12 | -- | ||
parseFilters | -
-
-
- |
- 0.00% |
- 0 / 17 |
-
-
-
- |
- 0.00% |
- 0 / 1 |
- 30 | -- | ||
formatResults | -
-
-
- |
- 0.00% |
- 0 / 4 |
-
-
-
- |
- 0.00% |
- 0 / 1 |
- 2 | -- | ||
renameBucketItems | -
-
-
- |
- 0.00% |
- 0 / 4 |
-
-
-
- |
- 0.00% |
- 0 / 1 |
- 2 | -- | ||
mapAggregationResults | -
-
-
- |
- 0.00% |
- 0 / 3 |
-
-
-
- |
- 0.00% |
- 0 / 1 |
- 2 | -- | ||
searchObject | -
-
-
- |
- 0.00% |
- 0 / 10 |
-
-
-
- |
- 0.00% |
- 0 / 1 |
- 6 | -- |
1 | <?php |
2 | |
3 | namespace OCA\OpenCatalogi\Service; |
4 | |
5 | |
6 | |
7 | use Elastic\Elasticsearch\Client; |
8 | use Elastic\Elasticsearch\ClientBuilder; |
9 | use Symfony\Component\Uid\Uuid; |
10 | |
11 | class ElasticSearchService |
12 | { |
13 | private function getClient(array $config): Client |
14 | { |
15 | $uri = $config['location']; |
16 | $apiKey = explode(separator: ':', string: base64_decode(string: $config['key'])); |
17 | |
18 | $client = ClientBuilder::create() |
19 | ->setHosts([$uri]) |
20 | ->setApiKey(apiKey: $apiKey[1],id: $apiKey[0]) |
21 | ->build(); |
22 | |
23 | return $client; |
24 | } |
25 | |
26 | |
27 | /** |
28 | * Add an object to ElasticSearch |
29 | * |
30 | * @param array $object The object to add to the data store. |
31 | * @param array $config The configuration of ElasticSearch. |
32 | * |
33 | * @return array |
34 | */ |
35 | public function addObject(array $object, array $config): array |
36 | { |
37 | $client = $this->getClient(config: $config); |
38 | |
39 | if(isset($object['_id']) === true) { |
40 | unset($object['_id']); |
41 | } |
42 | |
43 | try { |
44 | $result = $client->index(params: [ |
45 | 'index' => $config['index'], |
46 | 'id' => $object['id'], |
47 | 'body' => $object, |
48 | ]); |
49 | } catch (\Exception $exception) { |
50 | return ['exception' => ['message' => $exception->getMessage(), 'trace' => $exception->getTraceAsString()]]; |
51 | } |
52 | |
53 | return $client->get(params: [ |
54 | 'index' => $config['index'], |
55 | 'id' => $object['id'], |
56 | ])['_source']; |
57 | |
58 | } |
59 | |
60 | public function removeObject(string $id, array $config): array |
61 | { |
62 | $client = $this->getClient(config: $config); |
63 | |
64 | try { |
65 | $client->delete(params: [ |
66 | 'index' => $config['index'], |
67 | 'id' => $id, |
68 | ]); |
69 | return []; |
70 | } catch (\Exception $exception) { |
71 | return ['exception' => ['message' => $exception->getMessage(), 'trace' => $exception->getTraceAsString()]]; |
72 | } |
73 | } |
74 | |
75 | public function updateObject(string $id, array $object, array $config): array |
76 | { |
77 | $client = $this->getClient(config: $config); |
78 | |
79 | if(isset($object['_id']) === true) { |
80 | unset($object['_id']); |
81 | } |
82 | |
83 | try { |
84 | $client->update(params: [ |
85 | 'index' => $config['index'], |
86 | 'id' => $id, |
87 | 'body' => ['doc' => $object], |
88 | ]); |
89 | return []; |
90 | } catch (\Exception $exception) { |
91 | return ['exception' => ['message' => $exception->getMessage(), 'trace' => $exception->getTraceAsString()]]; |
92 | } |
93 | } |
94 | |
95 | private function parseFilters (array $filters): array |
96 | { |
97 | $body = [ |
98 | 'query' => [ |
99 | 'bool' => [ |
100 | 'must' => [] |
101 | ] |
102 | ] |
103 | ]; |
104 | |
105 | if(isset($filters['_search']) === true) { |
106 | $body['query']['bool']['must'][] = ['query_string' => ['query' => '*'.$filters['_search'].'*']]; |
107 | } |
108 | |
109 | if(isset($filters['_queries']) === true) { |
110 | foreach($filters['_queries'] as $query) { |
111 | $body['runtime_mappings'][$query] = ['type' => 'keyword']; |
112 | $body['aggs'][$query] = ['terms' => ['field' => $query]]; |
113 | } |
114 | } |
115 | |
116 | unset($filters['_search'], $filters['_queries']); |
117 | |
118 | foreach ($filters as $name => $filter) { |
119 | $body['query']['bool']['must'][] = ['match' => [$name => $filter]]; |
120 | } |
121 | |
122 | return $body; |
123 | } |
124 | |
125 | private function formatResults(array $hit): array |
126 | { |
127 | $source = $hit['_source']; |
128 | |
129 | unset($hit['_source']); |
130 | $hit = array_merge($hit, $source); |
131 | |
132 | return $hit; |
133 | |
134 | }//end formatResults() |
135 | |
136 | /** |
137 | * Rename the items in an aggregation bucket according to the response standard for aggregations. |
138 | * |
139 | * @param array $bucketItem The item to rewrite |
140 | * |
141 | * @return array The rewritten array. |
142 | */ |
143 | private function renameBucketItems(array $bucketItem): array |
144 | { |
145 | return [ |
146 | '_id' => $bucketItem['key'], |
147 | 'count' => $bucketItem['doc_count'], |
148 | ]; |
149 | |
150 | }//end renameBucketItems() |
151 | |
152 | /** |
153 | * Map aggregation results to comply to the existing standard for aggregation results. |
154 | * |
155 | * @param array $result The result to map. |
156 | * |
157 | * @return array The mapped result. |
158 | */ |
159 | private function mapAggregationResults(array $result): array |
160 | { |
161 | $buckets = $result['buckets']; |
162 | |
163 | $result = array_map([$this, 'renameBucketItems'], $buckets); |
164 | |
165 | return $result; |
166 | |
167 | }//end mapAggregationResults() |
168 | |
169 | public function searchObject(array $filters, array $config): array |
170 | { |
171 | $body = $this->parseFilters(filters: $filters); |
172 | |
173 | $client = $this->getClient(config: $config); |
174 | |
175 | $result = $client->search(params: [ |
176 | 'index' => $config['index'], |
177 | 'body' => $body |
178 | ]); |
179 | |
180 | $return = ['results' => array_map(callback: [$this, 'formatResults'], array: $result['hits']['hits'])]; |
181 | if(isset($result['aggregations']) === true) { |
182 | $return['facets'] = array_map([$this, 'mapAggregationResults'], $result['aggregations']); |
183 | } |
184 | |
185 | return $return; |
186 | } |
187 | } |
- | Code Coverage |
- |||||||||
- | Lines |
- Functions and Methods |
- Classes and Traits |
- |||||||
Total | -
-
-
- |
- 0.00% |
- 0 / 77 |
-
-
-
- |
- 0.00% |
- 0 / 7 |
- CRAP | -
-
-
- |
- 0.00% |
- 0 / 1 |
-
ObjectService | -
-
-
- |
- 0.00% |
- 0 / 77 |
-
-
-
- |
- 0.00% |
- 0 / 7 |
- 56 | -
-
-
- |
- 0.00% |
- 0 / 1 |
-
getClient | -
-
-
- |
- 0.00% |
- 0 / 3 |
-
-
-
- |
- 0.00% |
- 0 / 1 |
- 2 | -- | ||
saveObject | -
-
-
- |
- 0.00% |
- 0 / 15 |
-
-
-
- |
- 0.00% |
- 0 / 1 |
- 2 | -- | ||
findObjects | -
-
-
- |
- 0.00% |
- 0 / 12 |
-
-
-
- |
- 0.00% |
- 0 / 1 |
- 2 | -- | ||
findObject | -
-
-
- |
- 0.00% |
- 0 / 13 |
-
-
-
- |
- 0.00% |
- 0 / 1 |
- 2 | -- | ||
updateObject | -
-
-
- |
- 0.00% |
- 0 / 12 |
-
-
-
- |
- 0.00% |
- 0 / 1 |
- 2 | -- | ||
deleteObject | -
-
-
- |
- 0.00% |
- 0 / 9 |
-
-
-
- |
- 0.00% |
- 0 / 1 |
- 2 | -- | ||
aggregateObjects | -
-
-
- |
- 0.00% |
- 0 / 13 |
-
-
-
- |
- 0.00% |
- 0 / 1 |
- 2 | -- |
1 | <?php |
2 | |
3 | namespace OCA\OpenCatalogi\Service; |
4 | |
5 | use Adbar\Dot; |
6 | use GuzzleHttp\Client; |
7 | use GuzzleHttp\Exception\ClientException; |
8 | use Symfony\Component\Uid\Uuid; |
9 | |
10 | class ObjectService |
11 | { |
12 | |
13 | public const BASE_OBJECT = [ |
14 | 'database' => 'objects', |
15 | 'collection' => 'json', |
16 | ]; |
17 | |
18 | /** |
19 | * Gets a guzzle client based upon given config. |
20 | * |
21 | * @param array $config The config to be used for the client. |
22 | * @return Client |
23 | */ |
24 | public function getClient(array $config): Client |
25 | { |
26 | $guzzleConf = $config; |
27 | unset($guzzleConf['mongodbCluster']); |
28 | |
29 | return new Client($config); |
30 | } |
31 | |
32 | /** |
33 | * Save an object to MongoDB |
34 | * |
35 | * @param array $data The data to be saved. |
36 | * @param array $config The configuration that should be used by the call. |
37 | * |
38 | * @return array The resulting object. |
39 | * @throws \GuzzleHttp\Exception\GuzzleException |
40 | */ |
41 | public function saveObject(array $data, array $config): array |
42 | { |
43 | $client = $this->getClient(config: $config); |
44 | |
45 | $object = self::BASE_OBJECT; |
46 | $object['dataSource'] = $config['mongodbCluster']; |
47 | $object['document'] = $data; |
48 | $object['document']['id'] = $object['document']['_id'] = Uuid::v4(); |
49 | |
50 | $result = $client->post( |
51 | uri: 'action/insertOne', |
52 | options: ['json' => $object], |
53 | ); |
54 | $resultData = json_decode( |
55 | json: $result->getBody()->getContents(), |
56 | associative: true |
57 | ); |
58 | $id = $resultData['insertedId']; |
59 | |
60 | return $this->findObject(filters: ['_id' => $id], config: $config); |
61 | } |
62 | |
63 | /** |
64 | * Finds objects based upon a set of filters. |
65 | * |
66 | * @param array $filters The filters to compare the object to. |
67 | * @param array $config The configuration that should be used by the call. |
68 | * |
69 | * @return array The objects found for given filters. |
70 | * |
71 | * @throws \GuzzleHttp\Exception\GuzzleException |
72 | */ |
73 | public function findObjects(array $filters, array $config): array |
74 | { |
75 | $client = $this->getClient(config: $config); |
76 | |
77 | $object = self::BASE_OBJECT; |
78 | $object['dataSource'] = $config['mongodbCluster']; |
79 | $object['filter'] = $filters; |
80 | |
81 | $returnData = $client->post( |
82 | uri: 'action/find', |
83 | options: ['json' => $object] |
84 | ); |
85 | |
86 | return json_decode( |
87 | json: $returnData->getBody()->getContents(), |
88 | associative: true |
89 | ); |
90 | } |
91 | |
92 | /** |
93 | * Finds an object based upon a set of filters (usually the id) |
94 | * |
95 | * @param array $filters The filters to compare the objects to. |
96 | * @param array $config The config to be used by the call. |
97 | * |
98 | * @return array The resulting object. |
99 | * |
100 | * @throws \GuzzleHttp\Exception\GuzzleException |
101 | */ |
102 | public function findObject(array $filters, array $config): array |
103 | { |
104 | $client = $this->getClient(config: $config); |
105 | |
106 | $object = self::BASE_OBJECT; |
107 | $object['filter'] = $filters; |
108 | $object['dataSource'] = $config['mongodbCluster']; |
109 | |
110 | $returnData = $client->post( |
111 | uri: 'action/findOne', |
112 | options: ['json' => $object] |
113 | ); |
114 | |
115 | $result = json_decode( |
116 | json: $returnData->getBody()->getContents(), |
117 | associative: true |
118 | ); |
119 | |
120 | return ['document' => $result]; |
121 | } |
122 | |
123 | |
124 | |
125 | /** |
126 | * Updates an object in MongoDB |
127 | * |
128 | * @param array $filters The filter to search the object with (id) |
129 | * @param array $update The fields that should be updated. |
130 | * @param array $config The configuration to be used by the call. |
131 | * |
132 | * @return array The updated object. |
133 | * |
134 | * @throws \GuzzleHttp\Exception\GuzzleException |
135 | */ |
136 | public function updateObject(array $filters, array $update, array $config): array |
137 | { |
138 | $client = $this->getClient(config: $config); |
139 | |
140 | $dotUpdate = new Dot($update); |
141 | |
142 | $object = self::BASE_OBJECT; |
143 | $object['filter'] = $filters; |
144 | $object['update']['$set'] = $update; |
145 | $object['upsert'] = true; |
146 | $object['dataSource'] = $config['mongodbCluster']; |
147 | |
148 | |
149 | |
150 | $returnData = $client->post( |
151 | uri: 'action/updateOne', |
152 | options: ['json' => $object] |
153 | ); |
154 | |
155 | return $this->findObject($filters, $config); |
156 | } |
157 | |
158 | /** |
159 | * Delete an object according to a filter (id specifically) |
160 | * |
161 | * @param array $filters The filters to use. |
162 | * @param array $config The config to be used by the call. |
163 | * |
164 | * @return array An empty array. |
165 | * |
166 | * @throws \GuzzleHttp\Exception\GuzzleException |
167 | */ |
168 | public function deleteObject(array $filters, array $config): array |
169 | { |
170 | $client = $this->getClient(config: $config); |
171 | |
172 | $object = self::BASE_OBJECT; |
173 | $object['filter'] = $filters; |
174 | $object['dataSource'] = $config['mongodbCluster']; |
175 | |
176 | $returnData = $client->post( |
177 | uri: 'action/deleteOne', |
178 | options: ['json' => $object] |
179 | ); |
180 | |
181 | return []; |
182 | } |
183 | |
184 | /** |
185 | * Aggregates objects for search facets. |
186 | * |
187 | * @param array $filters The filters apply to the search request. |
188 | * @param array $pipeline The pipeline to use. |
189 | * @param array $config The configuration to use in the call. |
190 | * @return array |
191 | * @throws \GuzzleHttp\Exception\GuzzleException |
192 | */ |
193 | public function aggregateObjects(array $filters, array $pipeline, array $config):array |
194 | { |
195 | $client = $this->getClient(config: $config); |
196 | |
197 | $object = self::BASE_OBJECT; |
198 | $object['filter'] = $filters; |
199 | $object['pipeline'] = $pipeline; |
200 | $object['dataSource'] = $config['mongodbCluster']; |
201 | |
202 | $returnData = $client->post( |
203 | uri: 'action/aggregate', |
204 | options: ['json' => $object] |
205 | ); |
206 | |
207 | return json_decode( |
208 | json: $returnData->getBody()->getContents(), |
209 | associative: true |
210 | ); |
211 | |
212 | } |
213 | |
214 | } |
- | Code Coverage |
- |||||||||
- | Lines |
- Functions and Methods |
- Classes and Traits |
- |||||||
Total | -
-
-
- |
- 0.00% |
- 0 / 47 |
-
-
-
- |
- 0.00% |
- 0 / 5 |
- CRAP | -
-
-
- |
- 0.00% |
- 0 / 1 |
-
SearchService | -
-
-
- |
- 0.00% |
- 0 / 47 |
-
-
-
- |
- 0.00% |
- 0 / 5 |
- 306 | -
-
-
- |
- 0.00% |
- 0 / 1 |
-
__construct | -
-
-
- |
- 0.00% |
- 0 / 1 |
-
-
-
- |
- 0.00% |
- 0 / 1 |
- 2 | -- | ||
mergeFacets | -
-
-
- |
- 0.00% |
- 0 / 12 |
-
-
-
- |
- 0.00% |
- 0 / 1 |
- 30 | -- | ||
mergeAggregations | -
-
-
- |
- 0.00% |
- 0 / 7 |
-
-
-
- |
- 0.00% |
- 0 / 1 |
- 20 | -- | ||
sortResultArray | -
-
-
- |
- 0.00% |
- 0 / 1 |
-
-
-
- |
- 0.00% |
- 0 / 1 |
- 2 | -- | ||
search | -
-
-
- |
- 0.00% |
- 0 / 26 |
-
-
-
- |
- 0.00% |
- 0 / 1 |
- 42 | -- |
1 | <?php |
2 | |
3 | namespace OCA\OpenCatalogi\Service; |
4 | |
5 | use GuzzleHttp\Client; |
6 | use GuzzleHttp\Promise\Utils; |
7 | use Symfony\Component\Uid\Uuid; |
8 | |
9 | class SearchService |
10 | { |
11 | public $client; |
12 | |
13 | public const BASE_OBJECT = [ |
14 | 'database' => 'objects', |
15 | 'collection' => 'json', |
16 | ]; |
17 | |
18 | public function __construct( |
19 | private readonly ObjectService $objectService, |
20 | private readonly ElasticSearchService $elasticService |
21 | ) { |
22 | $this->client = new Client(); |
23 | } |
24 | |
25 | public function mergeFacets(array $existingAggregation, array $newAggregation): array |
26 | { |
27 | $results = []; |
28 | $existingAggregationMapped = []; |
29 | $newAggregationMapped = []; |
30 | |
31 | foreach($existingAggregation as $value) { |
32 | $existingAggregationMapped[$value['_id']] = $value['count']; |
33 | } |
34 | |
35 | |
36 | foreach($newAggregation as $value) { |
37 | if(isset ($existingAggregationMapped[$value['_id']]) === true) { |
38 | $newAggregationMapped[$value['_id']] = $existingAggregationMapped[$value['_id']] + $value['count']; |
39 | } else { |
40 | $newAggregationMapped[$value['_id']] = $value['count']; |
41 | } |
42 | |
43 | } |
44 | |
45 | |
46 | foreach (array_merge(array_diff($existingAggregationMapped, $newAggregationMapped), array_diff($newAggregationMapped, $existingAggregationMapped)) as $key => $value) { |
47 | $results[] = ['_id' => $key, 'count' => $value]; |
48 | } |
49 | |
50 | return $results; |
51 | } |
52 | |
53 | private function mergeAggregations(?array $existingAggregations, ?array $newAggregations): array |
54 | { |
55 | if($newAggregations === null) { |
56 | return []; |
57 | } |
58 | |
59 | |
60 | foreach($newAggregations as $key => $aggregation) { |
61 | if(isset($existingAggregations[$key]) === false) { |
62 | $existingAggregations[$key] = $aggregation; |
63 | } else { |
64 | $existingAggregations[$key] = $this->mergeFacets($existingAggregations[$key], $aggregation); |
65 | } |
66 | } |
67 | return $existingAggregations; |
68 | } |
69 | |
70 | public function sortResultArray(array $a, array $b): int |
71 | { |
72 | return $a['_score'] <=> $b['_score']; |
73 | } |
74 | |
75 | /** |
76 | * |
77 | */ |
78 | public function search(array $parameters, array $elasticConfig, array $dbConfig, array $catalogi = []): array |
79 | { |
80 | |
81 | $localResults = $this->elasticService->searchObject($parameters, $elasticConfig); |
82 | |
83 | $directory = $this->objectService->findObjects(filters: ['_schema' => 'directory'], config: $dbConfig); |
84 | |
85 | if(count($directory['documents']) === 0) { |
86 | return $localResults; |
87 | } |
88 | |
89 | $results = $localResults['results']; |
90 | $aggregations = $localResults['facets']; |
91 | |
92 | $promises = []; |
93 | foreach($directory['documents'] as $instance) { |
94 | if($instance['default'] === false) { |
95 | continue; |
96 | } |
97 | $url = $instance['search']; |
98 | $promises[] = $this->client->getAsync($url, ['query' => $parameters]); |
99 | } |
100 | |
101 | $responses = Utils::settle($promises)->wait(); |
102 | |
103 | foreach($responses as $response) { |
104 | if($response['state'] === 'fulfilled') { |
105 | $responseData = json_decode( |
106 | json: $response['value']->getBody()->getContents(), |
107 | associative: true |
108 | ); |
109 | |
110 | $results = array_merge( |
111 | $results, |
112 | $responseData['results'] |
113 | ); |
114 | |
115 | usort($results, [$this, 'sortResultArray']); |
116 | |
117 | $aggregations = $this->mergeAggregations($aggregations, $responseData['facets']); |
118 | } |
119 | } |
120 | |
121 | return ['results' => $results, 'facets' => $aggregations]; |
122 | } |
123 | |
124 | } |
Class | -Coverage | -
---|---|
OCA\OpenCatalogi\Service\DirectoryService | 0% |
OCA\OpenCatalogi\Service\ElasticSearchService | 0% |
OCA\OpenCatalogi\Service\ObjectService | 0% |
OCA\OpenCatalogi\Service\SearchService | 0% |
Class | -CRAP | -
---|---|
OCA\OpenCatalogi\Service\ElasticSearchService | 380 |
OCA\OpenCatalogi\Service\SearchService | 306 |
OCA\OpenCatalogi\Service\DirectoryService | 110 |
Method | -Coverage | -
---|---|
__construct | 0% |
getDirectoryEntry | 0% |
registerToExternalDirectory | 0% |
createDirectoryFromResult | 0% |
fetchFromExternalDirectory | 0% |
updateToExternalDirectory | 0% |
getClient | 0% |
addObject | 0% |
removeObject | 0% |
updateObject | 0% |
parseFilters | 0% |
formatResults | 0% |
renameBucketItems | 0% |
mapAggregationResults | 0% |
searchObject | 0% |
getClient | 0% |
saveObject | 0% |
findObjects | 0% |
findObject | 0% |
updateObject | 0% |
deleteObject | 0% |
aggregateObjects | 0% |
__construct | 0% |
mergeFacets | 0% |
mergeAggregations | 0% |
sortResultArray | 0% |
search | 0% |
Method | -CRAP | -
---|---|
search | 42 |
parseFilters | 30 |
mergeFacets | 30 |
mergeAggregations | 20 |
createDirectoryFromResult | 12 |
addObject | 12 |
updateObject | 12 |
registerToExternalDirectory | 6 |
fetchFromExternalDirectory | 6 |
removeObject | 6 |
searchObject | 6 |
- | Code Coverage |
- ||||||||
- | Lines |
- Functions and Methods |
- Classes and Traits |
- ||||||
Total | -
-
-
- |
- 0.00% |
- 0 / 245 |
-
-
-
- |
- 0.00% |
- 0 / 27 |
-
-
-
- |
- 0.00% |
- 0 / 4 |
-
DirectoryService.php | -
-
-
- |
- 0.00% |
- 0 / 43 |
-
-
-
- |
- 0.00% |
- 0 / 6 |
-
-
-
- |
- 0.00% |
- 0 / 1 |
-
ElasticSearchService.php | -
-
-
- |
- 0.00% |
- 0 / 78 |
-
-
-
- |
- 0.00% |
- 0 / 9 |
-
-
-
- |
- 0.00% |
- 0 / 1 |
-
ObjectService.php | -
-
-
- |
- 0.00% |
- 0 / 77 |
-
-
-
- |
- 0.00% |
- 0 / 7 |
-
-
-
- |
- 0.00% |
- 0 / 1 |
-
SearchService.php | -
-
-
- |
- 0.00% |
- 0 / 47 |
-
-
-
- |
- 0.00% |
- 0 / 5 |
-
-
-
- |
- 0.00% |
- 0 / 1 |
-
0)for(u=-1;++u
- Wil je {{ publicationStore.attachmentItem.name ?? publicationStore.attachmentItem.title }} definitief verwijderen? Deze actie kan niet ongedaan worden gemaakt.
- Bijlage succesvol verwijderd {{ error }}
+ Wil je {{ publicationStore.attachmentItem.name ?? publicationStore.attachmentItem.title }} definitief verwijderen? Deze actie kan niet ongedaan worden gemaakt.
+ Bijlage succesvol verwijderd {{ error }} Catalogus succesvol verwijderd Er is iets fout gegaan bij het verwijderen van catalogus {{ error }}
- Wil je {{ catalogiStore.catalogiItem.title }} definitief verwijderen? Deze actie kan niet ongedaan worden gemaakt.
- Catalogus succesvol verwijderd Er is iets fout gegaan bij het verwijderen van catalogus {{ error }}
+ Wil je {{ catalogiStore.catalogiItem.title }} definitief verwijderen? Deze actie kan niet ongedaan worden gemaakt.
+
- Wil je {{ directoryStore.listingItem.name ?? directoryStore.listingItem.title }} definitief verwijderen? Deze actie kan niet ongedaan worden gemaakt.
- Listing succesvol verwijderd {{ error }}
+ Wil je {{ directoryStore.listingItem.name ?? directoryStore.listingItem.title }} definitief verwijderen? Deze actie kan niet ongedaan worden gemaakt.
+ Listing succesvol verwijderd {{ error }}
- Wil je {{ metadataStore.metaDataItem.title ?? metadataStore.metaDataItem.name }} definitief verwijderen? Deze actie kan niet ongedaan worden gemaakt.
- Metadata succesvol verwijderd {{ error }}
+ Wil je {{ metadataStore.metaDataItem.title ?? metadataStore.metaDataItem.name }} definitief verwijderen? Deze actie kan niet ongedaan worden gemaakt.
+ Metadata succesvol verwijderd {{ error }}
- Wil je {{ metadataStore.metadataDataKey }} definitief verwijderen? Deze actie kan niet ongedaan worden gemaakt.
- Metadata eigenschap succesvol verwijderd {{ error }}
+ Wil je {{ metadataStore.metadataDataKey }} definitief verwijderen? Deze actie kan niet ongedaan worden gemaakt.
+ Metadata eigenschap succesvol verwijderd {{ error }}
+ Wil je {{ organisationStore.organisationItem.name ?? organisationStore.organisationItem.title }} kopiëren?
+ Organisatie succesvol gekopieerd {{ error }}
+ Wil je {{ organisationStore.organisationItem.name ?? organisationStore.organisationItem.title }} definitief verwijderen? Deze actie kan niet ongedaan worden gemaakt.
+ Organisatie succesvol verwijderd {{ error }}
- Wil je {{ publicationStore.publicationItem.name ?? publicationStore.publicationItem.title }} definitief verwijderen? Deze actie kan niet ongedaan worden gemaakt.
- Publicatie succesvol verwijderd {{ error }}
+ Wil je {{ publicationStore.publicationItem.name ?? publicationStore.publicationItem.title }} definitief verwijderen? Deze actie kan niet ongedaan worden gemaakt.
+ Publicatie succesvol verwijderd {{ error }}
+ Wil je {{ themeStore.themeItem.name ?? themeStore.themeItem.title }} kopiëren?
+ Thema succesvol gekopieerd {{ error }}
+ Wil je {{ themeStore.themeItem.name ?? themeStore.themeItem.title }} definitief verwijderen? Deze actie kan niet ongedaan worden gemaakt.
+ Thema succesvol verwijderd {{ error }} Catalogus succesvol toegevoegd Er is iets fout gegaan bij het toevoegen van catalogus {{ error }} Catalogus succesvol toegevoegd Er is iets fout gegaan bij het toevoegen van catalogus {{ error }} Catalogus succesvol bewerkt Er is iets fout gegaan bij het bewerken van de catalogus {{ error }} Catalogus succesvol bewerkt Er is iets fout gegaan bij het bewerken van de catalogus {{ error }} Listing succesvol toegevoegd Er is iets fout gegaan bij het toevoegen van Listing {{ error }} Er is geen valide URL ingevoerd. Listing succesvol toegevoegd Er is iets fout gegaan bij het toevoegen van Listing {{ error }} Listing succesvol bewerkt Er is iets fout gegaan bij het bewerken van Listing {{ error }} Listing succesvol bewerkt Er is iets fout gegaan bij het bewerken van Listing {{ error }} Metadata succesvol toegevoegd Er is iets fout gegaan bij het toevoegen van metadata {{ error }} Metadata succesvol toegevoegd Er is iets fout gegaan bij het toevoegen van metadata {{ error }} Metadata succesvol bewerkt Er is iets fout gegaan bij het bewerken van metadata {{ error }} Metadata succesvol bewerkt Er is iets fout gegaan bij het bewerken van metadata {{ error }} Organisatie succesvol toegevoegd Er is iets fout gegaan bij het toevoegen van Organisatie {{ error }} Organisatie succesvol bewerkt Er is iets fout gegaan bij het bewerken van Organisatie {{ error }} Publicatie succesvol toegevoegd Er is iets fout gegaan bij het toevoegen van Publicatie {{ error }} Published Modified Publicatie succesvol toegevoegd Er is iets fout gegaan bij het toevoegen van Publicatie {{ error }} Published Modified Publicatie succesvol bewerkt Er is iets fout gegaan bij het bewerken van Publicatie {{ error }} Published Modified Publicatie succesvol bewerkt Er is iets fout gegaan bij het bewerken van Publicatie {{ error }} Published Modified Publicatie eigenschap succesvol bewerkt Er is iets fout gegaan bij het bewerken van Publicatie eigenschap {{ error }} Publicatie eigenschap succesvol bewerkt Er is iets fout gegaan bij het bewerken van Publicatie eigenschap {{ error }} Thema succesvol toegevoegd Er is iets fout gegaan bij het toevoegen van Thema {{ error }} Thema succesvol bewerkt Er is iets fout gegaan bij het bewerken van Thema {{ error }} {{ searchStore.searchError }} Er zijn op dit moment geen publicaties die uw aandacht vereisen Er zijn op dit moment geen bijlagen die uw aandacht vereisen {{ searchStore.searchError }} Er zijn op dit moment geen publicaties die uw aandacht vereisen Er zijn op dit moment geen bijlagen die uw aandacht vereisen Er zijn op dit moment geen bijlagen die uw aandacht vereisen {{ searchStore.searchError }} {{ searchStore.searchError }} {{ listing.summary }} {{ listing.summary }}","
"],col:[2,"
"],tr:[2,"","
"],td:[3,"
"],_default:[0,"",""]};function ye(e,t){var n;return n="undefined"!=typeof e.getElementsByTagName?e.getElementsByTagName(t||"*"):"undefined"!=typeof e.querySelectorAll?e.querySelectorAll(t||"*"):[],void 0===t||t&&A(e,t)?S.merge([e],n):n}function ve(e,t){for(var n=0,r=e.length;n"," ").append(S.parseHTML(e)).find(r):e)}).always(n&&function(e,t){a.each(function(){n.apply(this,o||[e.responseText,t,e])})}),this},S.expr.pseudos.animated=function(t){return S.grep(S.timers,function(e){return t===e.elem}).length},S.offset={setOffset:function(e,t,n){var r,i,o,a,s,u,l=S.css(e,"position"),c=S(e),f={};"static"===l&&(e.style.position="relative"),s=c.offset(),o=S.css(e,"top"),u=S.css(e,"left"),("absolute"===l||"fixed"===l)&&-1<(o+u).indexOf("auto")?(a=(r=c.position()).top,i=r.left):(a=parseFloat(o)||0,i=parseFloat(u)||0),m(t)&&(t=t.call(e,n,S.extend({},s))),null!=t.top&&(f.top=t.top-s.top+a),null!=t.left&&(f.left=t.left-s.left+i),"using"in t?t.using.call(e,f):c.css(f)}},S.fn.extend({offset:function(t){if(arguments.length)return void 0===t?this:this.each(function(e){S.offset.setOffset(this,t,e)});var e,n,r=this[0];return r?r.getClientRects().length?(e=r.getBoundingClientRect(),n=r.ownerDocument.defaultView,{top:e.top+n.pageYOffset,left:e.left+n.pageXOffset}):{top:0,left:0}:void 0},position:function(){if(this[0]){var e,t,n,r=this[0],i={top:0,left:0};if("fixed"===S.css(r,"position"))t=r.getBoundingClientRect();else{t=this.offset(),n=r.ownerDocument,e=r.offsetParent||n.documentElement;while(e&&(e===n.body||e===n.documentElement)&&"static"===S.css(e,"position"))e=e.parentNode;e&&e!==r&&1===e.nodeType&&((i=S(e).offset()).top+=S.css(e,"borderTopWidth",!0),i.left+=S.css(e,"borderLeftWidth",!0))}return{top:t.top-i.top-S.css(r,"marginTop",!0),left:t.left-i.left-S.css(r,"marginLeft",!0)}}},offsetParent:function(){return this.map(function(){var e=this.offsetParent;while(e&&"static"===S.css(e,"position"))e=e.offsetParent;return e||re})}}),S.each({scrollLeft:"pageXOffset",scrollTop:"pageYOffset"},function(t,i){var o="pageYOffset"===i;S.fn[t]=function(e){return B(this,function(e,t,n){var r;if(x(e)?r=e:9===e.nodeType&&(r=e.defaultView),void 0===n)return r?r[i]:e[t];r?r.scrollTo(o?r.pageXOffset:n,o?n:r.pageYOffset):e[t]=n},t,e,arguments.length)}}),S.each(["top","left"],function(e,n){S.cssHooks[n]=_e(v.pixelPosition,function(e,t){if(t)return t=Be(e,n),Pe.test(t)?S(e).position()[n]+"px":t})}),S.each({Height:"height",Width:"width"},function(a,s){S.each({padding:"inner"+a,content:s,"":"outer"+a},function(r,o){S.fn[o]=function(e,t){var n=arguments.length&&(r||"boolean"!=typeof e),i=r||(!0===e||!0===t?"margin":"border");return B(this,function(e,t,n){var r;return x(e)?0===o.indexOf("outer")?e["inner"+a]:e.document.documentElement["client"+a]:9===e.nodeType?(r=e.documentElement,Math.max(e.body["scroll"+a],r["scroll"+a],e.body["offset"+a],r["offset"+a],r["client"+a])):void 0===n?S.css(e,t,i):S.style(e,t,n,i)},s,n?e:void 0,n)}})}),S.each(["ajaxStart","ajaxStop","ajaxComplete","ajaxError","ajaxSuccess","ajaxSend"],function(e,t){S.fn[t]=function(e){return this.on(t,e)}}),S.fn.extend({bind:function(e,t,n){return this.on(e,null,t,n)},unbind:function(e,t){return this.off(e,null,t)},delegate:function(e,t,n,r){return this.on(t,e,n,r)},undelegate:function(e,t,n){return 1===arguments.length?this.off(e,"**"):this.off(t,e||"**",n)},hover:function(e,t){return this.mouseenter(e).mouseleave(t||e)}}),S.each("blur focus focusin focusout resize scroll click dblclick mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave change select submit keydown keypress keyup contextmenu".split(" "),function(e,n){S.fn[n]=function(e,t){return 0
"}),b},a.models.candlestickBarChart=function(){var b=a.models.historicalBarChart(a.models.candlestickBar());return b.useInteractiveGuideline(!0),b.interactiveLayer.tooltip.contentGenerator(function(a){var c=a.series[0].data,d=c.openopen: "+b.yAxis.tickFormat()(c.open)+" close: "+b.yAxis.tickFormat()(c.close)+" high "+b.yAxis.tickFormat()(c.high)+" low: "+b.yAxis.tickFormat()(c.low)+"
"}),b},a.models.legend=function(){"use strict";function b(p){function q(a,b){return"furious"!=o?"#000":m?a.disengaged?"#000":"#fff":m?void 0:(a.color||(a.color=g(a,b)),a.disabled?a.color:"#fff")}function r(a,b){return m&&"furious"==o&&a.disengaged?"#eee":a.color||g(a,b)}function s(a){return m&&"furious"==o?1:a.disabled?0:1}return p.each(function(b){var g=d-c.left-c.right,p=d3.select(this);a.utils.initSVG(p);var t=p.selectAll("g.nv-legend").data([b]),u=t.enter().append("g").attr("class","nvd3 nv-legend").append("g"),v=t.select("g");t.attr("transform","translate("+c.left+","+c.top+")");var w,x,y=v.selectAll(".nv-series").data(function(a){return"furious"!=o?a:a.filter(function(a){return m?!0:!a.disengaged})}),z=y.enter().append("g").attr("class","nv-series");switch(o){case"furious":x=23;break;case"classic":x=20}if("classic"==o)z.append("circle").style("stroke-width",2).attr("class","nv-legend-symbol").attr("r",5),w=y.select("circle");else if("furious"==o){z.append("rect").style("stroke-width",2).attr("class","nv-legend-symbol").attr("rx",3).attr("ry",3),w=y.select(".nv-legend-symbol"),z.append("g").attr("class","nv-check-box").property("innerHTML",'open: "+b.yAxis.tickFormat()(c.open)+" close: "+b.yAxis.tickFormat()(c.close)+" high "+b.yAxis.tickFormat()(c.high)+" low: "+b.yAxis.tickFormat()(c.low)+" s[c]&&(e.offsets.popper[m]+=d[m]+u-s[c]),e.offsets.popper=g(e.offsets.popper);var b=d[m]+d[l]/2-u/2,w=t(e.instance.popper),y=parseFloat(w['margin'+f]),E=parseFloat(w['border'+f+'Width']),v=b-e.offsets.popper[m]-y-E;return v=ee(Q(s[l]-u,v),0),e.arrowElement=i,e.offsets.arrow=(n={},ae(n,m,$(v)),ae(n,h,''),n),e},element:'[x-arrow]'},flip:{order:600,enabled:!0,fn:function(e,t){if(W(e.instance.modifiers,'inner'))return e;if(e.flipped&&e.placement===e.originalPlacement)return e;var o=v(e.instance.popper,e.instance.reference,t.padding,t.boundariesElement,e.positionFixed),n=e.placement.split('-')[0],i=T(n),r=e.placement.split('-')[1]||'',p=[];switch(t.behavior){case ce.FLIP:p=[n,i];break;case ce.CLOCKWISE:p=G(n);break;case ce.COUNTERCLOCKWISE:p=G(n,!0);break;default:p=t.behavior;}return p.forEach(function(s,d){if(n!==s||p.length===d+1)return e;n=e.placement.split('-')[0],i=T(n);var a=e.offsets.popper,l=e.offsets.reference,f=Z,m='left'===n&&f(a.right)>f(l.left)||'right'===n&&f(a.left)Classes
- Coverage Distribution
- Complexity
- Insufficient Coverage
- Project Risks
- Methods
- Coverage Distribution
- Complexity
- Insufficient Coverage
-
-
-
-
-
-
-
- Method
- Coverage
-
- __construct 0%
- register 0%
- boot 0%
- insertNestedObjects 0%
- insertNestedObjects 0%
- catalog 0%
- __construct 0%
- getDirectoryEntry 0%
- registerToExternalDirectory 0%
- createDirectoryFromResult 0%
- fetchFromExternalDirectory 0%
- updateToExternalDirectory 0%
- getClient 0%
- addObject 0%
- removeObject 0%
- updateObject 0%
- parseFilters 0%
- formatResults 0%
- renameBucketItems 0%
- mapAggregationResults 0%
- searchObject 0%
- getClient 0%
- saveObject 0%
- findObjects 0%
- findObject 0%
- updateObject 0%
- deleteObject 0%
- aggregateObjects 0%
- __construct 0%
- mergeFacets 0%
- mergeAggregations 0%
- sortResultArray 0%
- search 0%
- page 41%
- index 50%
- destroy 62%
- create 66%
- update 66%
- index 81%
- update 87%
- update 87%
- update 87%
-
-
- update 87% Project Risks
-
-
-
-
-
-
-
- Method
- CRAP
-
- insertNestedObjects 90
- insertNestedObjects 56
- search 42
- parseFilters 30
- mergeFacets 30
- mergeAggregations 20
- createDirectoryFromResult 12
- addObject 12
- updateObject 12
- update 8
- create 7
- registerToExternalDirectory 6
- fetchFromExternalDirectory 6
- removeObject 6
- searchObject 6
- update 5
- destroy 4
- update 4
- update 4
- update 4
- index 3
- page 2
-
-
- index 2
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Total
-
-
-
-
-
-
-
-
-
-
-
-
- AppInfo
-
-
-
-
-
-
-
-
-
-
-
-
- Controller
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Service
-
-
-
-
-
-
-
-
-
- Catalogus toevoegen
- Catalogus toevoegen
+ Catalogus bewerken
- Catalogus bewerken
+ Directory toevoegen
- Directory toevoegen
+ Je directory bevat alle bij jouw installatie bekende catalogi. Om nieuwe catalogi te ontdekken heb je de directory van een andere (externe) installatie nodig. Nadat deze is opgegeven zullen de twee installaties een federatief netwerk vormen en catalogi blijven uitwisselen.
+ Directory bewerken
- Directory bewerken
+ MetaData toevoegen
- MetaData toevoegen
+ MetaData bewerken
- MetaData bewerken
+ Organisatie toevoegen
+ Organisatie Bewerken
+ Publicatie toevoegen
- Publicatie toevoegen
+ Edit publication
- Edit publication
+ Bewerk publicatie eigenschappen
- Bewerk publicatie eigenschappen
+ Thema toevoegen
+ Thema bewerken
+
DRC
- Location
+ Locatie
- Key
+ Sleutel
- Location
+ Locatie
- Key
+ Sleutel
- Location
+ Locatie
- Key
+ Sleutel
- Location
+ Locatie
- Key
+ Sleutel
- Cluster name
+ Cluster naam
- Username
+ Gebruikersnaam
- Password
+ Wachwoord
@@ -197,6 +212,7 @@ import {
NcAppSettingsDialog,
NcAppSettingsSection,
NcAppNavigationItem,
+ NcCheckboxRadioSwitch,
NcTextField,
NcTextArea,
NcButton,
@@ -206,6 +222,7 @@ import Database from 'vue-material-design-icons/Database.vue'
import CogOutline from 'vue-material-design-icons/CogOutline.vue'
import AccountLockOpenOutline from 'vue-material-design-icons/AccountLockOpenOutline.vue'
import ContentSave from 'vue-material-design-icons/ContentSave.vue'
+import LanConnect from 'vue-material-design-icons/LanConnect.vue'
export default {
name: 'Configuration',
@@ -213,6 +230,7 @@ export default {
NcAppSettingsDialog,
NcAppSettingsSection,
NcAppNavigationItem,
+ NcCheckboxRadioSwitch,
NcTextField,
NcTextArea,
NcButton,
@@ -221,6 +239,7 @@ export default {
Database,
ContentSave,
AccountLockOpenOutline,
+ LanConnect,
},
data() {
return {
@@ -238,6 +257,9 @@ export default {
organisation_oin: '',
organisation_pki: '',
configuration: {
+ federationActive: true,
+ federationListed: false,
+ federationLocation: '',
external: false,
drcLocation: '',
drcKey: '',
@@ -253,7 +275,7 @@ export default {
organisationOin: '',
organisationPki: '',
adminUsername: '',
- adminPassword: ''
+ adminPassword: '',
},
configurationSuccess: -1,
feedbackPosition: '',
diff --git a/src/navigation/MainMenu.vue b/src/navigation/MainMenu.vue
index 0a514f81..2d052ea9 100644
--- a/src/navigation/MainMenu.vue
+++ b/src/navigation/MainMenu.vue
@@ -1,200 +1,200 @@
-
-
-
-
-
+
- {{ catalogi.title }}
-
-
-
+ {{ catalogi.title }}
+
+
+
-
-
+
+ Dashboard
-
+ Dashboard
+
+ Aantal zoekopdrachten afgelopen maand
+
+ Directory
+
+
-
-
+
+
+
+
diff --git a/src/views/directory/ListingDetails.vue b/src/views/directory/ListingDetails.vue
index 526b9e59..81d357d7 100644
--- a/src/views/directory/ListingDetails.vue
+++ b/src/views/directory/ListingDetails.vue
@@ -1,219 +1,219 @@
-
-
-
-
- {{ listing.title }}
-
- Samenvatting:
- Search:
- {{ listing.search }}
- MetaData:
- {{ listing.metadata }}
- Status:
- {{ listing.status }}
- Last synchronized:
- {{ listing.lastSync }}
- Default:
- {{ listing.default }}
- Available:
- {{ listing.available }}
-
+ {{ listing.title }}
+
+ Samenvatting:
+ Search:
+ {{ listing.search }}
+ MetaData:
+ {{ listing.metadata }}
+ Status:
+ {{ listing.status }}
+ Last synchronized:
+ {{ listing.lastSync }}
+ Default:
+ {{ listing.default }}
+ Available:
+ {{ listing.available }}
+
- {{ metadata.title }}
-
- {{ metadata.description }}
-
-
-
-
- Tijdstip
- Gebruiker
- Actie
- Details
-
-
- 18-07-2024 11:55:21
- Ruben van der Linde
- Created
-
-
-
+ {{ metadata.title }}
+
+ {{ metadata.description }}
+
+
+
+
+ Tijdstip
+ Gebruiker
+ Actie
+ Details
+
+
+ 18-07-2024 11:55:21
+ Ruben van der Linde
+ Created
+
+
+
-
-
+
+
+ {{ organisation.title }}
+
+
+
+
+
@@ -334,29 +340,29 @@ import { catalogiStore, metadataStore, navigationStore, publicationStore } from
-
-
-
-
-
+
+ Resultaten
-
-
-
+ Resultaten
+
+
+
+
+ {{ theme.title }}
+
+
+
+
+