Skip to content

Commit

Permalink
Merge pull request #146 from ConductionNL/test-last-branches-merged
Browse files Browse the repository at this point in the history
Test last branches merged
  • Loading branch information
bbrands02 authored Dec 31, 2024
2 parents b49b77d + daf6add commit 216b8da
Show file tree
Hide file tree
Showing 26 changed files with 914 additions and 251 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"title": "omschrijving",
"summary": "zaaktypeomschrijving",
"description": "zaaktypeomschrijving",
"category": "{% if zaaktypecode|default %}{% set wooVerzoekenEnBesluiten = ['LP00000431', 'B1873', 'cherry'] %}{% set klachtoordelen = ['LP00000091', 'LP00001132', 'LP00000121', 'B0757', 'LP00000832', 'LP00001096'] %}{% if zaaktypecode in wooVerzoekenEnBesluiten %}{{ 'Woo-verzoeken en -besluiten' }}{% elseif zaaktypecode in klachtoordelen %}{{ 'Klachtoordelen' }}{% endif %}{% endif %}",
"category": "{% if zaaktypecode|default %}{% set wooVerzoekenEnBesluiten = ['LP00000431', 'B1873'] %}{% set klachtoordelen = ['LP00000091', 'LP00001132', 'LP00000121', 'B0757', 'LP00000832', 'LP00001096'] %}{% if zaaktypecode in wooVerzoekenEnBesluiten %}{{ 'Woo-verzoeken en -besluiten' }}{% elseif zaaktypecode in klachtoordelen %}{{ 'Klachtoordelen' }}{% endif %}{% endif %}",
"published": "startdatum",
"modified": "{{ 'now'|date('H:i:sTm-d-Y') }}",
"attachments": "[{% if files|default %}{% for file in files %} { {% if file['titel']|default %}\"title\": \"{{ file['titel'] }}\",{% endif %}\"labels\": [\"{{ 'Informatieverzoek' }}\"],{% if file['formaat']|default %}\"extension\": \"{{ file['formaat']|split('/')|last }}\",\"type\": \"{{ file['formaat'] }}\",{% endif %}{% if file['inhoud']|default and file['formaat']|default %}\"accessUrl\": \"data:{{ file['formaat'] }};base64,{{ file.inhoud }}\"{% endif %} }{{ loop.last ? '' : ',' }} {% endfor %}{% endif %}]",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"sourceId": "1",
"sourceType": "api",
"sourceHash": "",
"sourceHashMapping": "1",
"sourceTargetMapping": "1",
"sourceConfig": {
"idPosition": "identificatie",
Expand All @@ -13,6 +14,7 @@
"headers": [],
"query.startdatum__gte": "2024-08-01",
"query.einddatum__lt": "2025-01-01",
"query.maximaleVertrouwelijkheidaanduiding": "openbaar",
"usesPagination": "false",
"extraDataConfigs.0.staticEndpoint": "/tlb/zaaksysteem/api/v1/zaken/{{ originId }}/informatieobjecten",
"extraDataConfigs.0.mergeExtraData": "true",
Expand All @@ -21,5 +23,17 @@
"extraDataConfigs.0.extraDataConfigPerResult.staticEndpoint": "/tlb/zaaksysteem/api/v1/informatieobjecten/{{ originId }}"
},
"targetId": "1/1",
"targetType": "register/schema"
"targetType": "register/schema",
"conditions": {
"if": [
{
"or": [
{ "in": [{ "var": "zaaktypecode" }, ["LP00000431", "B1873"]] },
{ "in": [{ "var": "zaaktypecode" }, ["LP00000091", "LP00001132", "LP00000121", "B0757", "LP00000832", "LP00001096"]] }
]
},
true,
false
]
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"name": "Xxllnc document to attachment",
"version": "0.0.1",
"mapping": {
"title": "filename",
"labels": "[{{ label }}]",
"size": "size",
"type": "mimetype",
"extension": "{{ filename|split('.')|last }}",
"shareUrl": "{ \"accessUrl\": \"https://urlvanzaaksysteem/{{ caseId }}/document/{{ uuid }}/download\",\"downloadUrl\": \"https://zaaksysteem-accept.noordwijk.nl/api/case/{{ caseId }}/document/{{ uuid }}/download\",\"shareUrl\": \"https://zaaksysteem-accept.noordwijk.nl/api/case/{{ caseId }}/document/{{ uuid }}/download\", {% if filename|default %}\"filename\": \"filename\",\"extension\": \"{{ filename|split('.')|last }}\",{% endif %}\"source\": \"1\" }"
},
"unset": [],
"cast": {
"title": "unsetIfValue==filename",
"labels": "jsonToArray",
"size": "unsetIfValue==size",
"type": "unsetIfValue==mimetype",
"extension": "unsetIfValue==",
"shareUrl": "jsonToArray"
},
"passThrough": false
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"name": "Xxllnc zoek endpoint to Publication",
"version": "0.0.1",
"mapping": {
"title": "{{ values['case.subject'] }}",
"summary": "{{ values['attribute.woo_samenvatting'] }}",
"description": "{{ values['attribute.woo_beschrijving'] }}",
"category": "{{ values['attribute.woo_categorie'] }}",
"featured": false,
"status": "Published",
"attachmentCount": 0,
"published": "{{ values['attribute.woo_publicatiedatum'] }}",
"modified": "{{ \"now\"|date(\"Y-m-d\\\\TH:i:s.v\\\\Z\") }}",
"license": "eupl2",
"catalog": "1bcb99cd-7e47-4242-b7a7-ac7d36fe5d5e",
"attachments": "[{% set fileCount = 0 %}{% for file in values['attribute.woo_publicatie'] %}{% if fileCount > 0 %}, {% endif %}{% set file = file|merge({'label': 'Publicatie', 'caseId': id}) %}{{ executeMapping(2, file)|json_encode }}{% set fileCount = fileCount + 1 %}{% endfor %}{% for file in values['attribute.woo_inventarisatielijst'] %}{% if fileCount > 0 %}, {% endif %}{% set file = file|merge({'label': 'Inventarisatielijst', 'caseId': id}) %}{{ executeMapping(2, file)|json_encode }}{% set fileCount = fileCount + 1 %}{% endfor %}{% for file in values['attribute.woo_informatieverzoek'] %}{% if fileCount > 0 %}, {% endif %}{% set file = file|merge({'label': 'Informatieverzoek', 'caseId': id}) %}{{ executeMapping(2, file)|json_encode }}{% set fileCount = fileCount + 1 %}{% endfor %}{% for file in values['attribute.woo_besluit'] %}{% if fileCount > 0 %}, {% endif %}{% set file = file|merge({'label': 'Besluit', 'caseId': id}) %}{{ executeMapping(2, file)|json_encode }}{% set fileCount = fileCount + 1 %}{% endfor %}]"
},
"unset": [],
"cast": {
"title": "unsetIfValue==",
"summary": "unsetIfValue==",
"description": "unsetIfValue==",
"category": "unsetIfValue==",
"published": "unsetIfValue==",
"modified": "unsetIfValue==",
"attachments": "jsonToArray"
},
"passThrough": false
}
18 changes: 18 additions & 0 deletions configurations/xxllnc-zoekendpoint-woo/sources/xxllnc-v1.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"name": "Xxllnc zaaksysteem",
"version": "0.0.1",
"location": "",
"isEnabled": true,
"type": "api",
"auth": "none",
"authorizationPassthroughMethod": "header",
"configuration": {
"headers.API-KEY": "",
"headers.API-Interface-ID": ""
},
"endpointsConfig": [],
"logRetention": 3600,
"errorRetention": 86400,
"objectCount": 0,
"test": false
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"name": "Xxllnc zoek endpoint to Publications",
"description": "",
"version": "0.0.1",
"sourceId": "1",
"sourceType": "api",
"sourceTargetMapping": "1",
"sourceConfig": {
"idPosition": "id",
"resultsPosition": "result",
"endpoint": "/public_search/x/search",
"headers": [],
"query": []
},
"currentPage": 1,
"targetId": "1/1",
"targetType": "register/schema",
"conditions": {
"and": [
{
"var": "values['attribute.woo_categorie']"
},
{
"var": "values['case.subject']"
},
{
"var": "values['attribute.woo_publicatiedatum']"
}
]
}
}
11 changes: 10 additions & 1 deletion lib/Action/SynchronizationAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use OCA\OpenConnector\Service\SynchronizationService;
use OCA\OpenConnector\Db\SynchronizationMapper;
use OCA\OpenConnector\Db\SynchronizationContractMapper;
use Symfony\Component\HttpKernel\Exception\TooManyRequestsHttpException;

/**
* This action handles the synchronization of data from the source to the target.
Expand Down Expand Up @@ -70,7 +71,15 @@ public function run(array $argument = []): array
$response['stackTrace'][] = 'Doing the synchronization';
try {
$objects = $this->synchronizationService->synchronize($synchronization);
} catch (Exception $e) {
} catch (TooManyRequestsHttpException $e) {
$response['level'] = 'WARNING';
$response['stackTrace'][] = $response['message'] = 'Stopped synchronization: ' . $e->getMessage();
if (isset($e->getHeaders()['X-RateLimit-Reset']) === true) {
$response['nextRun'] = $e->getHeaders()['X-RateLimit-Reset'];
$response['stackTrace'][] = 'Returning X-RateLimit-Reset header to update Job nextRun: ' . $response['nextRun'];
}
return $response;
} catch (Exception $e) {
$response['level'] = 'ERROR';
$response['stackTrace'][] = $response['message'] = 'Failed to synchronize: ' . $e->getMessage();
return $response;
Expand Down
25 changes: 17 additions & 8 deletions lib/Controller/SynchronizationsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -256,17 +256,26 @@ public function test(int $id): JSONResponse

// Try to synchronize
try {
$logAndContractArray = $this->synchronizationService->synchronize(synchronization: $synchronization, isTest: true);
$logAndContractArray = $this->synchronizationService->synchronize(
synchronization: $synchronization,
isTest: true
);

// Return the result as a JSON response
return new JSONResponse(data: $logAndContractArray, statusCode: 200);
} catch (Exception $e) {
// If synchronizaiton fails, return an error response
return new JSONResponse([
'error' => 'Synchronization error',
'message' => $e->getMessage()
], 400);
}
// Check if getHeaders method exists and use it if available
$headers = method_exists($e, 'getHeaders') ? $e->getHeaders() : [];

return new JSONResponse($resultFromTest, 200);
// If synchronization fails, return an error response
return new JSONResponse(
data: [
'error' => 'Synchronization error',
'message' => $e->getMessage()
],
statusCode: $e->getCode() ?? 400,
headers: $headers
);
}
}
}
Loading

0 comments on commit 216b8da

Please sign in to comment.