From 99390249797961f933e14fb2470755cd344195c4 Mon Sep 17 00:00:00 2001 From: Barry Brands Date: Mon, 2 Dec 2024 11:45:34 +0100 Subject: [PATCH 1/6] fetch extra data foreach result fetched from extra data --- lib/Service/SynchronizationService.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/lib/Service/SynchronizationService.php b/lib/Service/SynchronizationService.php index 5e3f1838..abec6d8c 100644 --- a/lib/Service/SynchronizationService.php +++ b/lib/Service/SynchronizationService.php @@ -269,6 +269,18 @@ private function fetchExtraDataForObject(Synchronization $synchronization, array $extraData = $this->getObjectFromSource($synchronization, $endpoint); + // Temporary fix, this goes too deep + if ($extraDataConfig['extraDataConfigPerResult']) { + $dotObject = new Dot($extraData); + $results = $dotObject->get($extraDataConfig['resultsLocation']); + + foreach ($results as $key => $result) { + $results[$key] = $this->fetchExtraDataForObject($synchronization, $extraDataConfig['extraDataConfigPerResult'], $result); + } + + $extraData = $results; + } + // Set new key if configured. if (isset($extraDataConfig[$this::KEY_FOR_EXTRA_DATA_LOCATION]) === true) { $extraData = [$extraDataConfig[$this::KEY_FOR_EXTRA_DATA_LOCATION] => $extraData]; From ca92a46fa7cf89e0861ce6eb2ae5879d675b94d4 Mon Sep 17 00:00:00 2001 From: Barry Brands Date: Mon, 2 Dec 2024 12:26:11 +0100 Subject: [PATCH 2/6] Mapping fix --- .../mappings/sharepoint-woo-verzoek-to-publications.json | 2 +- lib/Service/SynchronizationService.php | 2 +- 2 files changed, 2 insertions(+), 2 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 23b63987..e38960a5 100644 --- a/configurations/sharepoint-woo/mappings/sharepoint-woo-verzoek-to-publications.json +++ b/configurations/sharepoint-woo/mappings/sharepoint-woo-verzoek-to-publications.json @@ -9,7 +9,7 @@ "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": "{{ '[' }}{% if fileUrls['d']['results']|default %}{% set index = 0 %}{% for file in fileUrls['d']['results'] %}{% if index > 0 %}{{ ', ' }}{% endif %}{{ '{' }}{% if file['Name']|default %} \"title\": \"{{ file['Name'] }}\",{% endif %} \"downloadUrl\": {{ '{' }}{% set uri = file['__metadata']['uri']~'/$value' %}{{ '\"downloadUrl\": \"'~uri~'\",\"source\": \"1\"' }}{{ '}' }}{{ '}' }}{% endfor %}{% endif %}{{ ']' }}", + "attachments": "{{ '[' }}{% if fileUrls|default %}{% set index = 0 %}{% for file in fileUrls %}{% if index \u003E 0 %}{{ ', ' }}{% endif %}{{ '{' }}{% if file['Name']|default %} \"title\": \"{{ file['Name'] }}\",{% endif %}{% if file['d']['document_x005f_label']|default %}\"labels\": [\"{{ file['d']['document_x005f_label'] }}\"],{% endif %} \"downloadUrl\": {{ '{' }}{% set uri = file['__metadata']['uri']~'\/$value' %}{{ '\"downloadUrl\": \"'~uri~'\",\"source\": \"2\"' }}{{ '}' }}{{ '}' }}{% endfor %}{% endif %}{{ ']' }}", "status": "{% if d['woo_x005f_publicatiedatum']|default %}Published{% else %}Concept{% endif %}", "catalog": "" }, diff --git a/lib/Service/SynchronizationService.php b/lib/Service/SynchronizationService.php index abec6d8c..35b43434 100644 --- a/lib/Service/SynchronizationService.php +++ b/lib/Service/SynchronizationService.php @@ -269,7 +269,7 @@ private function fetchExtraDataForObject(Synchronization $synchronization, array $extraData = $this->getObjectFromSource($synchronization, $endpoint); - // Temporary fix, this goes too deep + // Temporary fix, if ($extraDataConfig['extraDataConfigPerResult']) { $dotObject = new Dot($extraData); $results = $dotObject->get($extraDataConfig['resultsLocation']); From 943bd66489eb11b688ad4f597e39bd80d8eedbc8 Mon Sep 17 00:00:00 2001 From: Barry Brands Date: Mon, 2 Dec 2024 12:29:55 +0100 Subject: [PATCH 3/6] Update sync configs sharepoint --- .../sharepoint-convenanten-to-publications.json | 3 +++ .../sharepoint-woo-verzoeken-to-publications.json | 3 +++ 2 files changed, 6 insertions(+) diff --git a/configurations/sharepoint-woo/synchronizations/sharepoint-convenanten-to-publications.json b/configurations/sharepoint-woo/synchronizations/sharepoint-convenanten-to-publications.json index 030054f2..539175ce 100644 --- a/configurations/sharepoint-woo/synchronizations/sharepoint-convenanten-to-publications.json +++ b/configurations/sharepoint-woo/synchronizations/sharepoint-convenanten-to-publications.json @@ -15,6 +15,9 @@ "extraDataConfigs.1.dynamicEndpointLocation": "Files.__deferred.uri", "extraDataConfigs.1.mergeExtraData": "true", "extraDataConfigs.1.keyToSetExtraData": "fileUrls", + "extraDataConfigs.1.resultsLocation": "d.results", + "extraDataConfigs.1.extraDataConfigPerResult.dynamicEndpointLocation": "Properties.__deferred.uri", + "extraDataConfigs.1.extraDataConfigPerResult.mergeExtraData": "true", "headers": [], "query": [] }, diff --git a/configurations/sharepoint-woo/synchronizations/sharepoint-woo-verzoeken-to-publications.json b/configurations/sharepoint-woo/synchronizations/sharepoint-woo-verzoeken-to-publications.json index e4c66965..88568b92 100644 --- a/configurations/sharepoint-woo/synchronizations/sharepoint-woo-verzoeken-to-publications.json +++ b/configurations/sharepoint-woo/synchronizations/sharepoint-woo-verzoeken-to-publications.json @@ -15,6 +15,9 @@ "extraDataConfigs.1.dynamicEndpointLocation": "Files.__deferred.uri", "extraDataConfigs.1.mergeExtraData": "true", "extraDataConfigs.1.keyToSetExtraData": "fileUrls", + "extraDataConfigs.1.resultsLocation": "d.results", + "extraDataConfigs.1.extraDataConfigPerResult.dynamicEndpointLocation": "Properties.__deferred.uri", + "extraDataConfigs.1.extraDataConfigPerResult.mergeExtraData": "true", "headers": [], "query": [] }, From 7e3309850e212b5035c138194b319155ba9527c0 Mon Sep 17 00:00:00 2001 From: Barry Brands Date: Mon, 2 Dec 2024 14:34:50 +0100 Subject: [PATCH 4/6] fix mapping --- .../mappings/sharepoint-woo-verzoek-to-publications.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 e38960a5..76ae88fb 100644 --- a/configurations/sharepoint-woo/mappings/sharepoint-woo-verzoek-to-publications.json +++ b/configurations/sharepoint-woo/mappings/sharepoint-woo-verzoek-to-publications.json @@ -9,7 +9,7 @@ "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": "{{ '[' }}{% if fileUrls|default %}{% set index = 0 %}{% for file in fileUrls %}{% if index \u003E 0 %}{{ ', ' }}{% endif %}{{ '{' }}{% if file['Name']|default %} \"title\": \"{{ file['Name'] }}\",{% endif %}{% if file['d']['document_x005f_label']|default %}\"labels\": [\"{{ file['d']['document_x005f_label'] }}\"],{% endif %} \"downloadUrl\": {{ '{' }}{% set uri = file['__metadata']['uri']~'\/$value' %}{{ '\"downloadUrl\": \"'~uri~'\",\"source\": \"2\"' }}{{ '}' }}{{ '}' }}{% endfor %}{% endif %}{{ ']' }}", + "attachments": "{{ '[' }}{% if fileUrls|default %}{% set index = 0 %}{% for file in fileUrls %}{% if index > 0 %}{{ ', ' }}{% endif %}{{ '{' }}{% if file['Name']|default %} \"title\": \"{{ file['Name'] }}\",{% endif %}{% if file['d']['document_x005f_label']|default %}\"labels\": [\"{{ file['d']['document_x005f_label'] }}\"],{% endif %} \"downloadUrl\": {{ '{' }}{% set uri = file['__metadata']['uri']~'\/$value' %}{{ '\"downloadUrl\": \"'~uri~'\",\"source\": \"1\"' }}{{ '}' }}{{ '}' }}{% endfor %}{% endif %}{{ ']' }}", "status": "{% if d['woo_x005f_publicatiedatum']|default %}Published{% else %}Concept{% endif %}", "catalog": "" }, From 8e499600614e3a5fea3b62e6538b704e6d0c37c0 Mon Sep 17 00:00:00 2001 From: Barry Brands Date: Mon, 2 Dec 2024 15:42:25 +0100 Subject: [PATCH 5/6] Mapping fix --- .../mappings/sharepoint-woo-verzoek-to-publications.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 76ae88fb..f97770ae 100644 --- a/configurations/sharepoint-woo/mappings/sharepoint-woo-verzoek-to-publications.json +++ b/configurations/sharepoint-woo/mappings/sharepoint-woo-verzoek-to-publications.json @@ -9,7 +9,7 @@ "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": "{{ '[' }}{% if fileUrls|default %}{% set index = 0 %}{% for file in fileUrls %}{% if index > 0 %}{{ ', ' }}{% endif %}{{ '{' }}{% if file['Name']|default %} \"title\": \"{{ file['Name'] }}\",{% endif %}{% if file['d']['document_x005f_label']|default %}\"labels\": [\"{{ file['d']['document_x005f_label'] }}\"],{% endif %} \"downloadUrl\": {{ '{' }}{% set uri = file['__metadata']['uri']~'\/$value' %}{{ '\"downloadUrl\": \"'~uri~'\",\"source\": \"1\"' }}{{ '}' }}{{ '}' }}{% endfor %}{% endif %}{{ ']' }}", + "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": "" }, From 9732fe31e8e468777cddf931358bd5def99dc6fb Mon Sep 17 00:00:00 2001 From: Barry Brands Date: Mon, 2 Dec 2024 15:42:32 +0100 Subject: [PATCH 6/6] Config check fix --- lib/Service/SynchronizationService.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/Service/SynchronizationService.php b/lib/Service/SynchronizationService.php index 35b43434..4e019549 100644 --- a/lib/Service/SynchronizationService.php +++ b/lib/Service/SynchronizationService.php @@ -287,7 +287,7 @@ private function fetchExtraDataForObject(Synchronization $synchronization, array } // Merge with earlier fetchde object if configured. - if (isset($extraDataConfig[$this::MERGE_EXTRA_DATA_OBJECT_LOCATION]) === true && $extraDataConfig[$this::MERGE_EXTRA_DATA_OBJECT_LOCATION] === true) { + if (isset($extraDataConfig[$this::MERGE_EXTRA_DATA_OBJECT_LOCATION]) === true && ($extraDataConfig[$this::MERGE_EXTRA_DATA_OBJECT_LOCATION] === true || $extraDataConfig[$this::MERGE_EXTRA_DATA_OBJECT_LOCATION] === 'true')) { return array_merge($object, $extraData); } @@ -359,7 +359,6 @@ public function synchronizeContract(SynchronizationContract $synchronizationCont } } - // set the target hash $targetHash = md5(serialize($targetObject)); $synchronizationContract->setTargetHash($targetHash);