From 8a2651257d35f3fea39bcc42df22136919b9fe51 Mon Sep 17 00:00:00 2001 From: Barry Brands Date: Thu, 5 Dec 2024 09:11:07 +0100 Subject: [PATCH 1/5] Updated mapping --- .../sharepoint-woo-verzoek-to-publications.json | 13 ++++++++----- .../mappings/xxllnc-suite-to-publications.json | 11 +++++++---- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/configurations/sharepoint-woo/mappings/sharepoint-woo-verzoek-to-publications.json b/configurations/sharepoint-woo/mappings/sharepoint-woo-verzoek-to-publications.json index f97770a..a6cdbad 100644 --- a/configurations/sharepoint-woo/mappings/sharepoint-woo-verzoek-to-publications.json +++ b/configurations/sharepoint-woo/mappings/sharepoint-woo-verzoek-to-publications.json @@ -9,9 +9,10 @@ "category": "d.woo_x005f_categorie", "published": "{% if d['woo_x005f_publicatiedatum']|default %}{{ d['woo_x005f_publicatiedatum']|date('Y-m-d') }}{% endif %}", "modified": "d.vti_x005f_nexttolasttimemodified", - "attachments": "[ {% for file in fileUrls %} { {% if file['Name']|default %}\"title\": \"{{ file['Name'] }}\",{% endif %}{% if file['d']['document_x005f_label']|default %}\"labels\": [\"{{ file['d']['document_x005f_label'] }}\"],{% endif %}{% if file['__metadata']['uri']|default %}\"downloadUrl\": {\"downloadUrl\": \"{{ file['__metadata']['uri']~'/$value' }}\", \"source\": \"1\"}{% endif %} }{{ loop.last ? '' : ',' }} {% endfor %} ]", - "status": "{% if d['woo_x005f_publicatiedatum']|default %}Published{% else %}Concept{% endif %}", - "catalog": "" + "attachments": "[ {% for file in fileUrls %} { {% if file['Name']|default %}\"title\": \"{{ file['Name'] }}\",{% endif %}{% if file['d']['document_x005f_label']|default %}\"labels\": [\"{{ file['d']['document_x005f_label'] }}\"],{% endif %}{% if file['__metadata']['uri']|default %}\"downloadUrl\": {\"accessUrl\": \"{{ file['__metadata']['uri']~'/$value' }}\", \"source\": \"1\"}{% endif %} }{{ loop.last ? '' : ',' }} {% endfor %} ]", + "status": "Concept", + "catalog": "", + "publicationType": "" }, "unset": [], "cast": { @@ -19,9 +20,11 @@ "description": "unsetIfValue==d.woo_x005f_beschrijving", "summary": "unsetIfValue==d.woo_x005f_samenvatting", "category": "unsetIfValue==d.woo_x005f_categorie", - "published": "unsetIfValue==d.woo_x005f_publicatiedatum", + "published": "unsetIfValue==", "modified": "unsetIfValue==d.vti_x005f_nexttolasttimemodified", - "attachments": "jsonToArray" + "attachments": "jsonToArray", + "publicationType": "unsetIfValue==", + "catalog": "unsetIfValue==" }, "passThrough": false } diff --git a/configurations/sharepoint-woo/mappings/xxllnc-suite-to-publications.json b/configurations/sharepoint-woo/mappings/xxllnc-suite-to-publications.json index 54ef536..7a2ea21 100644 --- a/configurations/sharepoint-woo/mappings/xxllnc-suite-to-publications.json +++ b/configurations/sharepoint-woo/mappings/xxllnc-suite-to-publications.json @@ -7,17 +7,20 @@ "title": "omschrijving", "summary": "zaaktypeomschrijving", "description": "zaaktypeomschrijving", - "published" : "{% if startdatum|default %}{{ startdatum|date('Y-m-d') }}{% endif %}", + "published" : "", "modified" : "{{ 'now'|date(H:i:sTm-d-Y') }}", - "status": "{% if startdatum|default %}Published{% else %}Concept{% endif %}", - "catalog": "" + "status": "Concept", + "catalog": "", + "publicationType": "" }, "unset": [], "cast": { "title": "unsetIfValue==omschrijving", "summary": "unsetIfValue==zaaktypeomschrijving", "description": "unsetIfValue==zaaktypeomschrijving", - "published" : "unsetIfValue==" + "published" : "unsetIfValue==", + "catalog": "unsetIfValue==", + "publicationType": "unsetIfValue==" }, "passThrough": false } \ No newline at end of file From 9061076373252a60fc961231f57c83d6c8aed700 Mon Sep 17 00:00:00 2001 From: Robert Zondervan Date: Thu, 5 Dec 2024 10:34:09 +0100 Subject: [PATCH 2/5] Store JobLogs after updating them --- lib/Cron/ActionTask.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/Cron/ActionTask.php b/lib/Cron/ActionTask.php index c5f3f65..471f186 100644 --- a/lib/Cron/ActionTask.php +++ b/lib/Cron/ActionTask.php @@ -136,6 +136,8 @@ public function run($argument) } } + $this->jobLogMapper->update(entity: $jobLog); + // Let's report back about what we have just done return $jobLog; } From 45889f518e43131612a3ebfc8cdf4299dbce5f14 Mon Sep 17 00:00:00 2001 From: Barry Brands Date: Thu, 5 Dec 2024 15:12:01 +0100 Subject: [PATCH 3/5] Check if have to use pagination --- lib/Db/Synchronization.php | 10 ++++++++++ lib/Service/SynchronizationService.php | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/lib/Db/Synchronization.php b/lib/Db/Synchronization.php index 208bef2..1ba4676 100644 --- a/lib/Db/Synchronization.php +++ b/lib/Db/Synchronization.php @@ -65,6 +65,16 @@ public function __construct() { $this->addType(fieldName:'followUps', type: 'json'); } + 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( diff --git a/lib/Service/SynchronizationService.php b/lib/Service/SynchronizationService.php index 0b205ff..3f51acc 100644 --- a/lib/Service/SynchronizationService.php +++ b/lib/Service/SynchronizationService.php @@ -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(); From fdc12e85565a8bab60af26759088d33b6a409b4f Mon Sep 17 00:00:00 2001 From: Barry Brands Date: Thu, 5 Dec 2024 15:27:29 +0100 Subject: [PATCH 4/5] Update config and docblock --- .../xxllnc-suite-to-publications.json | 36 ++++++++++--------- .../xxllnc-suite-to-publications.json | 20 +++++++---- lib/Db/Synchronization.php | 5 +++ 3 files changed, 37 insertions(+), 24 deletions(-) diff --git a/configurations/sharepoint-woo/mappings/xxllnc-suite-to-publications.json b/configurations/sharepoint-woo/mappings/xxllnc-suite-to-publications.json index 7a2ea21..dcd1350 100644 --- a/configurations/sharepoint-woo/mappings/xxllnc-suite-to-publications.json +++ b/configurations/sharepoint-woo/mappings/xxllnc-suite-to-publications.json @@ -4,23 +4,25 @@ "version": "", "reference": "", "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 } \ No newline at end of file diff --git a/configurations/sharepoint-woo/synchronizations/xxllnc-suite-to-publications.json b/configurations/sharepoint-woo/synchronizations/xxllnc-suite-to-publications.json index 6dfedf8..91922ef 100644 --- a/configurations/sharepoint-woo/synchronizations/xxllnc-suite-to-publications.json +++ b/configurations/sharepoint-woo/synchronizations/xxllnc-suite-to-publications.json @@ -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" } \ No newline at end of file diff --git a/lib/Db/Synchronization.php b/lib/Db/Synchronization.php index 1ba4676..473524b 100644 --- a/lib/Db/Synchronization.php +++ b/lib/Db/Synchronization.php @@ -65,6 +65,11 @@ 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')) { From 4119fb760053afdd201407549c4f1e2636939ffc Mon Sep 17 00:00:00 2001 From: Barry Brands Date: Thu, 5 Dec 2024 15:56:21 +0100 Subject: [PATCH 5/5] set version in config --- .../sharepoint-woo/mappings/xxllnc-suite-to-publications.json | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/configurations/sharepoint-woo/mappings/xxllnc-suite-to-publications.json b/configurations/sharepoint-woo/mappings/xxllnc-suite-to-publications.json index dcd1350..744823b 100644 --- a/configurations/sharepoint-woo/mappings/xxllnc-suite-to-publications.json +++ b/configurations/sharepoint-woo/mappings/xxllnc-suite-to-publications.json @@ -1,8 +1,6 @@ { "name": "Xxllnc suite to Publication", - "description": "", - "version": "", - "reference": "", + "version": "0.0.1", "mapping": { "title": "omschrijving", "summary": "zaaktypeomschrijving",