Skip to content

Commit

Permalink
Merge pull request #120 from ConductionNL/feature/check-to-use-pagina…
Browse files Browse the repository at this point in the history
…tion

Check if have to use pagination
  • Loading branch information
bbrands02 authored Dec 5, 2024
2 parents 4d48122 + 4119fb7 commit f61236c
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 28 deletions.
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
{
"name": "Xxllnc suite to Publication",
"description": "",
"version": "",
"reference": "",
"version": "0.0.1",
"mapping": {
"title": "omschrijving",
"summary": "zaaktypeomschrijving",
"description": "zaaktypeomschrijving",
"published" : "",
"modified" : "{{ 'now'|date(H:i:sTm-d-Y') }}",
"status": "Concept",
"catalog": "",
"publicationType": ""
},
"unset": [],
"cast": {
"title": "unsetIfValue==omschrijving",
"summary": "unsetIfValue==zaaktypeomschrijving",
"description": "unsetIfValue==zaaktypeomschrijving",
"published" : "unsetIfValue==",
"catalog": "unsetIfValue==",
"publicationType": "unsetIfValue=="
"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 %}",
"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 %}]",
"status": "Concept"
},
"unset": [
""
],
"cast": {
"title": "unsetIfValue==omschrijving",
"summary": "unsetIfValue==zaaktypeomschrijving",
"description": "unsetIfValue==zaaktypeomschrijving",
"category": "unsetIfValue==",
"published": "unsetIfValue==startdatum",
"attachments": "jsonToArray"
},
"passThrough": false
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,19 @@
"sourceHash": "",
"sourceTargetMapping": "1",
"sourceConfig": {
"idPosition": "id",
"resultsPosition": "results",
"endpoint": "/tlb/zaaksysteem/api/v1/zaken",
"headers": [],
"query.startdatum__gte": "2024-07-06",
"query.einddatum__lt": "2024-08-01"
},
"idPosition": "identificatie",
"resultsPosition": "results",
"endpoint": "\/tlb\/zaaksysteem\/api\/v1\/zaken",
"headers": [],
"query.startdatum__gte": "2024-08-01",
"query.einddatum__lt": "2025-01-01",
"usesPagination": "false",
"extraDataConfigs.0.staticEndpoint": "/tlb/zaaksysteem/api/v1/zaken/{{ originId }}/informatieobjecten",
"extraDataConfigs.0.mergeExtraData": "true",
"extraDataConfigs.0.keyToSetExtraData": "files",
"extraDataConfigs.0.resultsLocation": "results",
"extraDataConfigs.0.extraDataConfigPerResult.staticEndpoint": "/tlb/zaaksysteem/api/v1/informatieobjecten/{{ originId }}"
},
"targetId": "1/1",
"targetType": "register/schema"
}
15 changes: 15 additions & 0 deletions lib/Db/Synchronization.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,21 @@ public function __construct() {
$this->addType(fieldName:'followUps', type: 'json');
}

/**
* Checks through sourceConfig if the source of this sync uses pagination
*
* @return bool true if its uses pagination
*/
public function usesPagination(): bool
{
if (isset($this->sourceConfig['usesPagination']) === true && ($this->sourceConfig['usesPagination'] === false || $this->sourceConfig['usesPagination'] === 'false')) {
return false;
}

// By default sources use basic pagination.
return true;
}

public function getJsonFields(): array
{
return array_keys(
Expand Down
2 changes: 1 addition & 1 deletion lib/Service/SynchronizationService.php
Original file line number Diff line number Diff line change
Expand Up @@ -554,7 +554,7 @@ public function getAllObjectsFromApi(Synchronization $synchronization, ?bool $is
$objects = array_merge($objects, $this->getAllObjectsFromArray($body, $synchronization));
}

if ($useNextEndpoint === false) {
if ($useNextEndpoint === false && $synchronization->usesPagination() === true) {
do {
$config = $this->getNextPage(config: $config, sourceConfig: $sourceConfig, currentPage: $currentPage);
$response = $this->callService->call(source: $source, endpoint: $endpoint, method: 'GET', config: $config)->getResponse();
Expand Down

0 comments on commit f61236c

Please sign in to comment.