Skip to content

Commit

Permalink
Merge pull request #99 from ConductionNL/feature/AXCVDWOF-37/merge-re…
Browse files Browse the repository at this point in the history
…sult-single-endpoint

Merge result from singleEndpoint
  • Loading branch information
bbrands02 authored Nov 28, 2024
2 parents a3ac631 + a8021cc commit 1e06100
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,21 @@
"description": "",
"version": "0.0.1",
"mapping": {
"title": "Name"
"title": "d.woo_x005f_titel",
"description": "d.woo_x005f_beschrijving",
"summary": "d.woo_x005f_samenvatting",
"category": "d.woo_x005f_categorie",
"published": "d.woo_x005f_publicatiedatum",
"modified": "d.vti_x005f_nexttolasttimemodified"
},
"unset": [],
"unset": {
"title": "d.woo_x005f_titel",
"description": "d.woo_x005f_beschrijving",
"summary": "d.woo_x005f_samenvatting",
"category": "d.woo_x005f_categorie",
"published": "d.woo_x005f_publicatiedatum",
"modified": "d.vti_x005f_nexttolasttimemodified"
},
"cast": [],
"passThrough": false
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@
"reference": "",
"mapping": {
"title": "omschrijving",
"summary": "statustoelichting",
"description": "statusomschrijving"
"summary": "zaaktypeomschrijving",
"description": "zaaktypeomschrijving",
"published" : "startdatum",
"modified" : "{{ 'now'|date(H:i:sTm-d-Y') }}"
},
"unset": [],
"cast": [],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@
"sourceHash": "",
"sourceTargetMapping": "1",
"sourceConfig": {
"idPosition": "UniqueId",
"idPosition": "Properties.__deferred.uri",
"resultsPosition": "d.results",
"endpoint": "/Web/GetFolderByServerRelativePath(decodedurl='/WOO/Convenanten')/folders",
"singleEndpoint": "{{ originId }}",
"mergeDataSingleEndpoint": true,
"headers": [],
"query": []
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@
"sourceHash": "",
"sourceTargetMapping": "1",
"sourceConfig": {
"idPosition": "UniqueId",
"idPosition": "Properties.__deferred.uri",
"resultsPosition": "d.results",
"endpoint": "/Web/GetFolderByServerRelativePath(decodedurl='/WOO/Woo-verzoeken en -besluiten')/folders",
"singleEndpoint": "{{ originId }}",
"mergeDataSingleEndpoint": true,
"headers": [],
"query": []
},
Expand Down
16 changes: 11 additions & 5 deletions lib/Service/SynchronizationService.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ class SynchronizationService
private ObjectService $objectService;
private Source $source;

const SINGLE_ENDPOINT = 'singleEndpoint';
const MERGE_DATA_SINGLE_ENDPOINT = 'mergeDataSingleEndpoint';


public function __construct(
CallService $callService,
Expand Down Expand Up @@ -230,16 +233,19 @@ public function getObjectFromSource(Synchronization $synchronization, string $en
*/
public function synchronizeContract(SynchronizationContract $synchronizationContract, Synchronization $synchronization = null, array $object = [], ?bool $isTest = false): SynchronizationContract|Exception|array
{

if ($synchronization !== null && isset($synchronization->getSourceConfig()['singleEndpoint']) === true) {
$sourceConfig = $synchronization->getSourceConfig();
if ($synchronization !== null && isset($sourceConfig[$this::SINGLE_ENDPOINT]) === true) {

// Update endpoint
$endpoint = str_replace(search: '{{ originId }}', replace: $this->getOriginId($synchronization, $object), subject: $synchronization->getSourceConfig()['singleEndpoint']);
$endpoint = str_replace(search: '{{ originId }}', replace: $this->getOriginId($synchronization, $object), subject: $sourceConfig[$this::SINGLE_ENDPOINT]);
$endpoint = str_replace(search: '{{originId}}', replace: $this->getOriginId($synchronization, $object), subject: $endpoint);

// Get object from source
$object = $this->getObjectFromSource(synchronization: $synchronization, endpoint: $endpoint);

if (isset($sourceConfig[$this::MERGE_DATA_SINGLE_ENDPOINT]) === true && $sourceConfig[$this::MERGE_DATA_SINGLE_ENDPOINT] === true) {
$object = array_merge($object, $this->getObjectFromSource(synchronization: $synchronization, endpoint: $endpoint));
} else {
$object = $this->getObjectFromSource(synchronization: $synchronization, endpoint: $endpoint);
}
}


Expand Down

0 comments on commit 1e06100

Please sign in to comment.