diff --git a/configurations/xxllnc-zgw/mappings/xxllnc-v1-case-to-zgw-zaak.json b/configurations/xxllnc-zgw/mappings/xxllnc-v1-case-to-zgw-zaak.json index 5143ad57..85f9d5d1 100644 --- a/configurations/xxllnc-zgw/mappings/xxllnc-v1-case-to-zgw-zaak.json +++ b/configurations/xxllnc-zgw/mappings/xxllnc-v1-case-to-zgw-zaak.json @@ -3,7 +3,6 @@ "version": "0.0.1", "mapping": { "originId": "reference", - "_sourceId": "reference", "identificatie": "reference", "omschrijving": "instance.subject", "toelichting": "instance.subject_external", @@ -23,7 +22,7 @@ "rollen": "[{% if instance.route.instance.role|default %}{% set dataRol = {'requestor': instance.requestor, 'role': instance.route.instance.role, 'roltypen': zaaktype.roltypen} %}{{ executeMapping(3, dataRol)|json_encode }}{% endif %}]", "status": "{% if instance.milestone|default %}{% set data = {'milestone': instance.milestone, 'statustypen': zaaktype.statustypen} %}{{ executeMapping(4, data)|json_encode }}{% endif %}", "zaaktype": "{% if casetype.result|default %}{{ executeMapping(5, casetype.result)|json_encode }}{% endif %}", - "eigenschappen": "[{% set index=0 %}{% if zaaktype.eigenschappen|default %}{% for key, attribute in instance.attributes %}{% if index != 0 %},{% endif %}{% set data = {'name': key, 'value': attribute, 'eigenschappen': zaaktype.eigenschappen} %}{% if attribute[0][0]|default and attribute[0][0] is iterable %}{{ attribute|json_encode }}{% else %}{{ executeMapping(6, data)|json_encode }}{% endif %}{% set index=index+1 %}{% endfor %}{% endif %}]", + "eigenschappen": "[{% set index=0 %}{% if zaaktype.eigenschappen|default %}{% for key, attribute in instance.attributes %}{% if index != 0 %},{% endif %}{% set data = {'name': key, 'value': attribute, 'eigenschappen': zaaktype.eigenschappen, 'caseReference': reference} %}{% if attribute[0][0]|default and attribute[0][0] is iterable %}{{ attribute|json_encode }}{% else %}{{ executeMapping(6, data)|json_encode }}{% endif %}{% set index=index+1 %}{% endfor %}{% endif %}]", "zaakinformatieobjecten": "[{% set index=0 %}{% if documents.result.instance.rows|default %}{% for document in documents.result.instance.rows %}{% set document = document|merge({'caseId': reference}) %}{% if index != 0 %},{% endif %}{{ executeMapping(7, document)|json_encode }}{% set index=index+1 %}{% endfor %}{% endif %}]", "bronorganisatie": "bronorganisatie", "verantwoordelijkeOrganisatie": "bronorganisatie", diff --git a/configurations/xxllnc-zgw/mappings/xxllnc-v1-casetype-to-zgw-zaaktype.json b/configurations/xxllnc-zgw/mappings/xxllnc-v1-casetype-to-zgw-zaaktype.json index 736a64be..92ae80e7 100644 --- a/configurations/xxllnc-zgw/mappings/xxllnc-v1-casetype-to-zgw-zaaktype.json +++ b/configurations/xxllnc-zgw/mappings/xxllnc-v1-casetype-to-zgw-zaaktype.json @@ -3,7 +3,6 @@ "version": "0.0.1", "mapping": { "originId": "reference", - "_sourceId": "reference", "identificatie": "instance.legacy.zaaktype_id", "catalogus": "_catalogus", "onderwerp": "instance.title", diff --git a/configurations/xxllnc-zgw/mappings/xxllnc-v1-document-to-zgw-zaakinformatieobject.json b/configurations/xxllnc-zgw/mappings/xxllnc-v1-document-to-zgw-zaakinformatieobject.json index 5833a3e1..07d669f1 100644 --- a/configurations/xxllnc-zgw/mappings/xxllnc-v1-document-to-zgw-zaakinformatieobject.json +++ b/configurations/xxllnc-zgw/mappings/xxllnc-v1-document-to-zgw-zaakinformatieobject.json @@ -2,6 +2,7 @@ "name": "Xxllnc Document to ZGW ZaakInformatieObject", "version": "0.0.1", "mapping": { + "originId": "reference", "titel": "instance.name", "registratiedatum": "instance.file.instance.date_created", "informatieobject.identificatie": "instance.number", @@ -21,6 +22,7 @@ }, "unset": [], "cast": { + "originId": "unsetIfValue==reference", "informatieobject.versie": "integer", "informatieobject.bestandsomvang": "integer", "informatieobject.inhoud": "jsonToArray", diff --git a/configurations/xxllnc-zgw/mappings/xxllnc-v1-field-to-zgw-eigenschap.json b/configurations/xxllnc-zgw/mappings/xxllnc-v1-field-to-zgw-eigenschap.json index 1e791b51..d72040e6 100644 --- a/configurations/xxllnc-zgw/mappings/xxllnc-v1-field-to-zgw-eigenschap.json +++ b/configurations/xxllnc-zgw/mappings/xxllnc-v1-field-to-zgw-eigenschap.json @@ -2,6 +2,7 @@ "name": "Xxllnc Field to ZGW Eigenschap", "version": "0.0.1", "mapping": { + "originId": "id", "naam": "magic_string", "definitie": "{% if original_label|default %}{{ original_label }}{% elseif label|default %}{{ label }}{% else %}{{ magic_string }}{% endif %}", "specificatie.formaat": "{% if type == 'date' %}datum{% elseif type == 'datetime' %}datum_tijd{% elseif type=='number' %}getal{% else %}tekst{% endif %}", @@ -11,6 +12,7 @@ }, "unset": [], "cast": { + "originId": "unsetIfValue==id", "naam": "unsetIfValue==magic_string", "definitie": "unsetIfValue==", "catalogus": "unsetIfValue==_catalogus", diff --git a/configurations/xxllnc-zgw/mappings/xxllnc-v1-field-to-zgw-informatieobjecttype.json b/configurations/xxllnc-zgw/mappings/xxllnc-v1-field-to-zgw-informatieobjecttype.json index 35f7fb1c..fbac59d6 100644 --- a/configurations/xxllnc-zgw/mappings/xxllnc-v1-field-to-zgw-informatieobjecttype.json +++ b/configurations/xxllnc-zgw/mappings/xxllnc-v1-field-to-zgw-informatieobjecttype.json @@ -2,6 +2,7 @@ "name": "Xxllnc Field to ZGW InformatieObjectType", "version": "0.0.1", "mapping": { + "originId": "id", "omschrijving": "{% if original_label|default %}{{ original_label }}{% elseif label|default %}{{ label }}{% else %}{{ magic_string }}{% endif %}", "vertrouwelijkheidsaanduiding": "{% if publish_public|default and publish_public == true %}openbaar{% else %}zaakvertrouwelijk{% endif %}", "beginGeldigheid": "{{ 'now'|date('Y-m-d') }}", @@ -9,6 +10,7 @@ }, "unset": [], "cast": { + "originId": "unsetIfValue==id", "omschrijving": "unsetIfValue==" }, "passTrough": false diff --git a/configurations/xxllnc-zgw/mappings/xxllnc-v1-milestone-to-zgw-status.json b/configurations/xxllnc-zgw/mappings/xxllnc-v1-milestone-to-zgw-status.json index e5ca2020..15da7ce3 100644 --- a/configurations/xxllnc-zgw/mappings/xxllnc-v1-milestone-to-zgw-status.json +++ b/configurations/xxllnc-zgw/mappings/xxllnc-v1-milestone-to-zgw-status.json @@ -2,6 +2,7 @@ "name": "Xxllnc Milestone to ZGW Status", "version": "0.0.1", "mapping": { + "originId": "{% if milestone.reference|default %}{{ milestone.reference }}{% endif %}", "datumStatusGezet": "milestone.instance.date_modified", "statustoelichting": "milestone.instance.phase_label", "indicatieLaatstGezetteStatus": "{{ true }}", @@ -9,6 +10,7 @@ }, "unset": [], "cast": { + "originId": "unsetIfValue==", "indicatieLaatstGezetteStatus": "bool", "statustype": "unsetIfValue==", "datumStatusGezet": "unsetIfValue==milestone.instance.date_modified", diff --git a/configurations/xxllnc-zgw/mappings/xxllnc-v1-outcome-to-zgw-resultaat.json b/configurations/xxllnc-zgw/mappings/xxllnc-v1-outcome-to-zgw-resultaat.json index 8c1c45ca..d5d0d957 100644 --- a/configurations/xxllnc-zgw/mappings/xxllnc-v1-outcome-to-zgw-resultaat.json +++ b/configurations/xxllnc-zgw/mappings/xxllnc-v1-outcome-to-zgw-resultaat.json @@ -2,11 +2,13 @@ "name": "Xxllnc Outcome to ZGW Resultaat", "version": "0.0.1", "mapping": { + "originId": "{% if outcome.reference|default %}{{ outcome.reference }}{% endif %}", "toelichting": "{% if outcome.instance.name|default %}{{ outcome.instance.name }}{% endif %}", "resultaattype": "{% if resultaattypen|default %}{% for resultaattype in resultaattypen %}{% if resultaattype.toelichting == outcome.instance.name %}{{ resultaattype['_self']['id'] }}{% endif %}{% endfor %}{% endif %}" }, "unset": [], "cast": { + "originId": "unsetIfValue==", "resultaattype": "unsetIfValue==", "toelichting": "unsetIfValue==" }, diff --git a/configurations/xxllnc-zgw/mappings/xxllnc-v1-phase-to-zgw-statustype.json b/configurations/xxllnc-zgw/mappings/xxllnc-v1-phase-to-zgw-statustype.json index 92b89871..7af01d9d 100644 --- a/configurations/xxllnc-zgw/mappings/xxllnc-v1-phase-to-zgw-statustype.json +++ b/configurations/xxllnc-zgw/mappings/xxllnc-v1-phase-to-zgw-statustype.json @@ -2,7 +2,7 @@ "name": "Xxllnc Phase to ZGW StatusType", "version": "0.0.1", "mapping": { - "_sourceId": "{% if fields.0.label|default and casetypeReference|default %}{{ casetypeReference~fields.0.label }}{% endif %}", + "originId": "{% if fields.0.label|default and casetypeReference|default %}{{ casetypeReference~fields.0.label }}{% endif %}", "volgnummer": "seq", "omschrijving": "name", "omschrijvingGeneriek": "{% if fields.0.label|default %}{{ fields.0.label }}{% else %}geen statustekst{% endif %}", @@ -12,7 +12,7 @@ }, "unset": [], "cast": { - "_sourceId": "unsetIfValue==", + "originId": "unsetIfValue==", "volgnummer": "unsetIfValue==seq", "omschrijving": "unsetIfValue==name", "catalogus": "unsetIfValue==_catalogus", diff --git a/configurations/xxllnc-zgw/mappings/xxllnc-v1-result-to-zgw-resultaattype.json b/configurations/xxllnc-zgw/mappings/xxllnc-v1-result-to-zgw-resultaattype.json index b37e3822..205a4658 100644 --- a/configurations/xxllnc-zgw/mappings/xxllnc-v1-result-to-zgw-resultaattype.json +++ b/configurations/xxllnc-zgw/mappings/xxllnc-v1-result-to-zgw-resultaattype.json @@ -2,6 +2,7 @@ "name": "Xxllnc Result to ZGW ResultaatType", "version": "0.0.1", "mapping": { + "originId": "resultaat_id", "omschrijving": "type", "toelichting": "label", "selectielijstklasse": "{% if selection_list|default %}https://inavigator.bizzib.nl/bsd/sl2020.gem.html#{{ selection_list_number|replace({'.': '_'}) }}{% else %}http://localhost{% endif %}", @@ -10,6 +11,7 @@ }, "unset": [], "cast": { + "originId": "unsetIfValue==resultaat_id", "omschrijving": "unsetIfValue==type", "toelichting": "unsetIfValue==label", "archiefactietermijn": "unsetIfValue==" diff --git a/configurations/xxllnc-zgw/mappings/xxllnc-v1-role-to-zgw-roltype.json b/configurations/xxllnc-zgw/mappings/xxllnc-v1-role-to-zgw-roltype.json index 91eecd23..25634a6c 100644 --- a/configurations/xxllnc-zgw/mappings/xxllnc-v1-role-to-zgw-roltype.json +++ b/configurations/xxllnc-zgw/mappings/xxllnc-v1-role-to-zgw-roltype.json @@ -2,11 +2,13 @@ "name": "Xxllnc Role to ZGW RolType", "version": "0.0.1", "mapping": { + "originId": "instance.role_id", "omschrijving": "{% if instance.description|default %}{{ instance.description }}{% endif %}", "omschrijvingGeneriek": "{% if instance.name|default %}{{ instance.name|lower }}{% endif %}" }, "unset": [], "cast": { + "originId": "unsetIfValue==instance.role_id", "omschrijving": "unsetIfValue==", "omschrijvingGeneriek": "unsetIfValue==" }, diff --git a/configurations/xxllnc-zgw/mappings/xxllnc-v1-rolerequestor-to-zgw-rol.json b/configurations/xxllnc-zgw/mappings/xxllnc-v1-rolerequestor-to-zgw-rol.json index 98296e69..f028d850 100644 --- a/configurations/xxllnc-zgw/mappings/xxllnc-v1-rolerequestor-to-zgw-rol.json +++ b/configurations/xxllnc-zgw/mappings/xxllnc-v1-rolerequestor-to-zgw-rol.json @@ -2,6 +2,7 @@ "name": "Xxllnc RoleRequestor to ZGW Rol", "version": "0.0.1", "mapping": { + "originId": "{% if role.reference|default %}{{ role.reference }}{% endif %}", "betrokkeneType": "{% if role.instance.name|default %}{% if role.instance.name == 'Behandelaar'|lower %}medewerker{% else %}medewerker{% endif %}{% endif %}", "omschrijving": "{% if role.instance.name|default %}{{ role.instance.name }}{% endif %}", "omschrijvingGeneriek": "{% if role.instance.description|default %}{{ role.instance.description }}{% endif %}", @@ -30,6 +31,7 @@ }, "unset": [], "cast": { + "originId": "unsetIfValue==", "roltype": "unsetIfValue==", "betrokkeneIdentificatie": "unsetIfValue==", "omschrijving": "unsetIfValue==", diff --git a/configurations/xxllnc-zgw/mappings/xxllnc-v1-value-to-zgw-zaakeigenschap.json b/configurations/xxllnc-zgw/mappings/xxllnc-v1-value-to-zgw-zaakeigenschap.json index 83f762dd..1abf4749 100644 --- a/configurations/xxllnc-zgw/mappings/xxllnc-v1-value-to-zgw-zaakeigenschap.json +++ b/configurations/xxllnc-zgw/mappings/xxllnc-v1-value-to-zgw-zaakeigenschap.json @@ -2,12 +2,14 @@ "name": "Xxllnc Value to ZGW ZaakEigenschap", "version": "0.0.1", "mapping": { + "originId": "{% if caseReference|default and name|default %}{{ caseReference~name }}{% endif %}", "naam": "{% if name|default %}{{ name }}{% endif %}", "waarde": "{% if value[0]|default and value[0] is not iterable %}{{ value[0] }}{% elseif value[0][0]|default and value[0][0] is not iterable %}{{ value[0][0] }}{% elseif value[0][0][0]|default and value[0][0][0] is not iterable %}{{ value[0][0][0] }}{% else %}{{ value|json_encode}}{% endif %}", "eigenschap": "{% for eigenschap in eigenschappen %}{% if eigenschap.naam == name %}{{ eigenschap['_self']['id'] }}{% endif %}{% endfor %}" }, "unset": [], "cast": { + "originId": "unsetIfValue==", "naam": "unsetIfValue==", "waarde": "unsetIfValue==", "eigenschap": "unsetIfValue==" diff --git a/docs/connections/ZGWAndXxllnc.md b/docs/connections/ZGWAndXxllnc.md new file mode 100644 index 00000000..4816756f --- /dev/null +++ b/docs/connections/ZGWAndXxllnc.md @@ -0,0 +1,34 @@ + # ZGW to and from xxllnc zaaksysteem + + This document describes the connection between the Xxllnce (zaaksysteem) v1 and v2 api and the Zaak Register (ZGW configured on OpenRegister and OpenConnector). + + ## Overview + + The xxllnc zaaksysteem is a system used by the Dutch government to manage and publish administrative decisions. The v1 and v2 apis are used to fetch and write cases, casetypes and files. + + The Zaak Register is a system used to manage all sorts of municipality cases. The Zaak object is the core object in the Zaak Register. + + ## Preparation + + Make sure you have the following information: + + - The base url of the v1 and v2 api + - An installation of Open Register and Open Connector + - An configuration of the Zaak Register (ZGW) on Open Register + + ## Setting up the connection + + Create a new source (connection), set the type to API and location to the base url of the xxllnc v1 api. This api needs a API-KEY and a API-Interface-ID + + + + +Open the source and click on 'Test' in the action menu. This wil open the test dialog. Presss test and you will see the data that is available. + + + +I everything checks out we can write down the source id and are now ready to setup a mapping. + +## Setting up the mapping + +Mappings are used to map the data from object A tot object B or visa versa. In the case of the xxlnc v1 api we need to create a mapping between the v1 api and the publication ZGW Zaak object. \ No newline at end of file diff --git a/lib/AppInfo/Application.php b/lib/AppInfo/Application.php index 7bde69df..1a62b790 100644 --- a/lib/AppInfo/Application.php +++ b/lib/AppInfo/Application.php @@ -7,6 +7,7 @@ use OCA\OpenConnector\EventListener\ObjectCreatedEventListener; use OCA\OpenConnector\EventListener\ObjectDeletedEventListener; use OCA\OpenConnector\EventListener\ObjectUpdatedEventListener; +use OCA\OpenConnector\EventListener\RegisterEventListener; use OCA\OpenRegister\Event\ObjectCreatedEvent; use OCA\OpenRegister\Event\ObjectDeletedEvent; use OCA\OpenRegister\Event\ObjectUpdatedEvent; @@ -32,6 +33,9 @@ public function register(IRegistrationContext $context): void { $dispatcher->addServiceListener(eventName: ObjectCreatedEvent::class, className: ObjectCreatedEventListener::class); $dispatcher->addServiceListener(eventName: ObjectUpdatedEvent::class, className: ObjectUpdatedEventListener::class); $dispatcher->addServiceListener(eventName: ObjectDeletedEvent::class, className: ObjectDeletedEventListener::class); + $dispatcher->addServiceListener(eventName: ObjectCreatedEvent::class, className: RegisterEventListener::class); + $dispatcher->addServiceListener(eventName: ObjectUpdatedEvent::class, className: RegisterEventListener::class); + $dispatcher->addServiceListener(eventName: ObjectDeletedEvent::class, className: RegisterEventListener::class); } public function boot(IBootContext $context): void { diff --git a/lib/EventListener/RegisterEventListener.php b/lib/EventListener/RegisterEventListener.php new file mode 100644 index 00000000..7e83ffef --- /dev/null +++ b/lib/EventListener/RegisterEventListener.php @@ -0,0 +1,70 @@ +getObject(); + if ($object === null || $object->getRegister() === null || $object->getSchema() === null) { + return; + } + + $synchronizations = $this->synchronizationService->findAllBySourceId(register: $object->getRegister(), schema: $object->getSchema()); + foreach ($synchronizations as $synchronization) { + try { + if ($event instanceof ObjectCreatedEvent) { + $this->synchronizationService->synchronize($synchronization, false, $object); + } elseif ($event instanceof ObjectUpdatedEvent) { + $this->synchronizationService->synchronize($synchronization, false, $object); + } elseif ($event instanceof ObjectDeletedEvent) { + $this->synchronizationService->synchronize($synchronization, false, $object); + } + } catch (\Exception $e) { + $this->logger->error('Failed to process object event: ' . $e->getMessage() . ' for synchronization ' . $synchronization->getId(), [ + 'exception' => $e, + 'event' => get_class($event) + ]); + } + } + } +} diff --git a/lib/Service/SynchronizationService.php b/lib/Service/SynchronizationService.php index 01cae91e..7f133fa3 100644 --- a/lib/Service/SynchronizationService.php +++ b/lib/Service/SynchronizationService.php @@ -79,6 +79,80 @@ public function __construct( $this->sourceMapper = $sourceMapper; } + /** + * Finds all synchronizations by the given source ID, which is a combination of register and schema. + * + * @param $register The register id. + * @param $schema The schema id. + * + * @return array The list of records matching the source ID. + */ + public function findAllBySourceId($register, $schema) { + $sourceId = "$register/$schema"; + return $this->synchronizationMapper->findAll(limit: null, offset: null, filters: ['source_id' => $sourceId]); + } + + /** + * Synchronizes internal data to external sources based on synchronization rules. + * + * @param Synchronization $synchronization The synchronization configuration. + * @param bool $isTest Whether this is a test run (does not persist data if true). + * @param $object The object to be synchronized. + * + * @return SynchronizationContract|array|null Returns a synchronization contract, an array for test cases, or null if conditions are not met. + */ + private function synchronizeInternToExtern(Synchronization $synchronization, ?bool $isTest = false, $object) + { + if ($synchronization->getConditions() !== [] && !JsonLogic::apply($synchronization->getConditions(), $object)) { + + return; + } + + // If the source configuration contains a dot notation for the id position, we need to extract the id from the source object + $originId = $object->getUuid(); + + // Get the synchronization contract for this object + $synchronizationContract = $this->synchronizationContractMapper->findSyncContractByOriginId(synchronizationId: $synchronization->id, originId: $originId); + + if ($synchronizationContract instanceof SynchronizationContract === false) { + // Only persist if not test + if ($isTest === false) { + $synchronizationContract = $this->synchronizationContractMapper->createFromArray([ + 'synchronizationId' => $synchronization->getId(), + 'originId' => $originId, + ]); + } else { + $synchronizationContract = new SynchronizationContract(); + $synchronizationContract->setSynchronizationId($synchronization->getId()); + $synchronizationContract->setOriginId($originId); + } + + $synchronizationContract = $this->synchronizeContract(synchronizationContract: $synchronizationContract, synchronization: $synchronization, object: $object->getObject(), isTest: $isTest); + + if ($isTest === true && is_array($synchronizationContract) === true) { + // If this is a log and contract array return for the test endpoint. + $logAndContractArray = $synchronizationContract; + + return $logAndContractArray; + } + } else { + // @todo this is wierd + $synchronizationContract = $this->synchronizeContract(synchronizationContract: $synchronizationContract, synchronization: $synchronization, object: $object->getObject(), isTest: $isTest); + if ($isTest === false && $synchronizationContract instanceof SynchronizationContract === true) { + // If this is a regular synchronizationContract update it to the database. + $this->synchronizationContractMapper->update(entity: $synchronizationContract); + } elseif ($isTest === true && is_array($synchronizationContract) === true) { + // If this is a log and contract array return for the test endpoint. + $logAndContractArray = $synchronizationContract; + + return $logAndContractArray; + } + } + + $synchronizationContract = $this->synchronizationContractMapper->update($synchronizationContract); + return $synchronizationContract; + } + /** * Synchronizes a given synchronization (or a complete source). * @@ -94,7 +168,7 @@ public function __construct( * @throws MultipleObjectsReturnedException * @throws \OCP\DB\Exception */ - public function synchronize(Synchronization $synchronization, ?bool $isTest = false): array + public function synchronize(Synchronization $synchronization, ?bool $isTest = false, $object = null): array { $sourceConfig = $this->callService->applyConfigDot($synchronization->getSourceConfig()); @@ -111,7 +185,14 @@ public function synchronize(Synchronization $synchronization, ?bool $isTest = fa throw new Exception('sourceId of synchronization cannot be empty. Canceling synchronization...'); } + // Synchronize a object from OpenRegister register and schema to a external source. + if ($synchronization->getSourceType() === 'register/schema' && $object !== null) { + return [$this->synchronizeInternToExtern($synchronization, $isTest, $object)]; + } + + + // Synchronize multiple objects from a source to a target (register/schema, api or other methods). try { $objectList = $this->getAllObjectsFromSource(synchronization: $synchronization, isTest: $isTest); } catch (TooManyRequestsHttpException $e) { @@ -302,9 +383,9 @@ public function getObjectFromSource(Synchronization $synchronization, string $en * @throws Exception If both dynamic and static endpoint configurations are missing or the endpoint cannot be determined. */ private function fetchExtraDataForObject( - Synchronization $synchronization, - array $extraDataConfig, - array $object, ?string + Synchronization $synchronization, + array $extraDataConfig, + array $object, ?string $originId = null ) { @@ -1236,7 +1317,26 @@ private function writeObjectToTarget( $object = $this->objectService->getOpenRegisters()->find( id: $contract->getOriginId(), )->jsonSerialize(); - } + + + $objectService = $this->containerInterface->get('OCA\OpenRegister\Service\ObjectService'); + $object = $objectService->extendEntity($object, ['all']); + + if (empty($synchronization->getTargetSourceMapping()) === true) { + $targetSourceMapping = null; + } else { + try { + $targetSourceMapping = $this->mappingMapper->find(id: $synchronization->getTargetSourceMapping()); + } catch (DoesNotExistException $exception) { + return new Exception($exception->getMessage()); + } + } + + if ($targetSourceMapping) { + $object = $this->mappingService->executeMapping(mapping: $targetSourceMapping, input: $object); + } + + } $targetConfig = $this->callService->applyConfigDot($synchronization->getTargetConfig());