Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ZGW mappings and extra fetch fix #141

Merged
merged 6 commits into from
Dec 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions configurations/xxllnc-zgw/mappings/xxllnc-v1-case-to-zgw-zaak.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
{
"name": "Xxllnc Case to ZGW Zaak",
"version": "0.0.1",
"mapping": {
"identificatie": "reference",
"omschrijving": "instance.subject",
"toelichting": "instance.subject_external",
"registratiedatum": "instance.date_of_registration",
"startdatum": "instance.date_of_registration",
"einddatum": "instance.date_of_completion",
"einddatumGepland": "instance.date_target",
"publicatiedatum": "instance.date_target",
"communicatiekanaal": "instance.channel_of_contact",
"vertrouwelijkheidaanduidng": "instance.confidentiality.mapped",
"kenmerken.0.kenmerk": "reference",
"kenmerken.0.bron": "xxllnc v1 api",
"betalingsindicatie": "{% if instance.price == '-' %}{{ 'nvt' }}{% elseif instance.payment_status is null or instance.payment_status == '' %}{{ 'nog_niet' }}{% else %}{{ 'geheel' }}{% endif %}",
"betalingsindicatieWeergave": "{% if instance.price == '-' %}{{ 'Zaak kent geen prijs' }}{% elseif instance.payment_status is null or instance.payment_status == '' %}{{ 'Er moet nog betaald worden' }}{% else %}{{ 'De volledige kosten zijn betaald' }}{% endif %}",
"resultaattoelichting": "{% if instance.outcome.instance.name|default %}{{ instance.outcome.instance.name }}{% endif %}",
"resultaat": "{% if instance.outcome|default %}{% set data = {'outcome': instance.outcome, 'resultaattypen': zaaktype.resultaattypen} %}{{ executeMapping(2, data)|json_encode }}{% endif %}",
"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|default %}{{ executeMapping(5, casetype)|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 %}]",
"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",
"opschorting.indicatie": "{% if instance.stalled_until|default %}true{% else %}{% endif %}",
"opschorting.reden": "{% if instance.stalled_until|default %}Unknown{% endif %}"
},
"unset": [],
"cast": {
"resultaat": "jsonToArray",
"rollen": "jsonToArray",
"status": "jsonToArray",
"eigenschappen": "jsonToArray",
"opschorting.indicatie": "unsetIfValue==",
"opschorting.reden": "unsetIfValue==",
"opschorting": "unsetIfValue==",
"zaakinformatieobjecten": "jsonToArray",
"zaaktype": "jsonToArray"
},
"passTrough": false
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"name": "Xxllnc Casetype to ZGW ZaakType",
"version": "0.0.1",
"mapping": {
"identificatie": "instance.legacy.zaaktype_id",
"catalogus": "_catalogus",
"onderwerp": "instance.title",
"indicatieInternOfExtern": "extern",
"doorlooptijd": "{% if instance.properties.lead_time_legal.weken|default %}P{{ instance.properties.lead_time_legal.weken }}W{% elseif instance.properties.lead_time_legal.kalenderdagen|default %}P{{ instance.properties.lead_time_legal.kalenderdagen }}D{% else %}{{ \"\" }}{% endif %}",
"servicenorm": "{% if instance.properties.lead_time_service.weken|default %}P{{ instance.properties.lead_time_service.weken }}W{% elseif instance.properties.lead_time_service.kalenderdagen|default %}P{{ instance.properties.lead_time_service.kalenderdagen }}D{% else %}{{ \"\" }}{% endif %}",
"vertrouwelijkheidaanduiding": "{{ instance.properties.designation_of_confidentiality|lower }}",
"verlengingMogelijk": "instance.properties.extension",
"publicatieIndicatie": "instance.properties.publication",
"omschrijving": "instance.title",
"opschortingEnAanhoudingMogelijk": "instance.properties.suspension",
"bronzaaktype.url": "url",
"bronzaaktype.identificatie": "reference",
"bronzaaktype.omschrijving": "instance.title",
"referentieproces.naam": "preview",
"verantwoordelijke": "instance.properties.supervisor"
},
"unset": [],
"cast": {
"identificatie": "unsetIfValue==instance.legacy.zaaktype_id"
},
"passTrough": false
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"name": "Xxllnc Document to ZGW ZaakInformatieObject",
"version": "0.0.1",
"mapping": {
"titel": "instance.name",
"registratiedatum": "instance.file.instance.date_created",
"informatieobject.identificatie": "instance.number",
"informatieobject.creatiedatum": "instance.file.instance.date_created",
"informatieobject.titel": "instance.name",
"informatieobject.vertrouwelijksheidaanduiding": "{% if instance.metadata.instance.trust_level|default %}{{ instance.metadata.instance.trust_level|lower }}{% endif %}",
"informatieobject.formaat": "instance.file.instance.mimetype",
"informatieobject.versie": "1",
"informatieobject.beginRegistratie": "instance.file.instance.date_modified",
"informatieobject.bestandsnaam": "instance.filename",
"informatieobject.bestandsomvang": "instance.file.instance.size",
"informatieobject.verschijningsvorm": "{% if instance.metadata.instance.category|default %}{{ instance.metadata.instance.category }}{% endif %}",
"informatieobject.integriteit.algoritme": "{% if instance.file.instance|default %}{% set algoritmeArray = ['crc_16','crc_32','crc_64','fletcher4','fletcher8','fletcher16','fletcher32','hmac','md5','sha_1','sha_256','sha_512','sha_3'] %}{% for algoritme in algoritmeArray %}{% if result.instance.file.instance[algoritme]|default %}{{ algoritme }}{% endif %}{% endfor %}{% endif %}",
"informatieobject.integriteit.waarde": "{% if instance.file.instance|default %}{% set algoritmeArray = ['crc_16','crc_32','crc_64','fletcher4','fletcher8','fletcher16','fletcher32','hmac','md5','sha_1','sha_256','sha_512','sha_3'] %}{% for algoritme in algoritmeArray %}{% if result.instance.file.instance[algoritme]|default %}{{ result.instance.file.instance[algoritme] }}{% endif %}{% endfor %}{% endif %}",
"informatieobject.integriteit.datum": "instance.file.instance.date_created",
"informatieobject.inhoud": "{\"downloadUrl\": \"{{ 'https://xxllncapiv1/case/'~caseId~'/document/'~reference~'/download' }}\", \"source\": \"2\"}"
},
"unset": [],
"cast": {
"informatieobject.versie": "integer",
"informatieobject.bestandsomvang": "integer",
"informatieobject.inhoud": "jsonToArray"
},
"passTrough": false
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"name": "Xxllnc Milestone to ZGW Status",
"version": "0.0.1",
"mapping": {
"datumStatusGezet": "milestone.instance.date_modified",
"statustoelichting": "milestone.instance.phase_label",
"indicatieLaatstGezetteStatus": "{{ true }}",
"statustype": "{% for statustype in statustypen %}{% if statustype.omschrijving == milestone.instance.phase_label %}{{ statustype['_self']['id'] }}{% endif %}{% endfor %}"
},
"unset": [],
"cast": {
"indicatieLaatstGezetteStatus": "bool",
"statustype": "unsetIfValue=="
},
"passTrough": false
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"name": "Xxllnc Outcome to ZGW Resultaat",
"version": "0.0.1",
"mapping": {
"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": {
"resultaattype": "unsetIfValue=="
},
"passTrough": false
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{
"name": "Xxllnc RoleRequestor to ZGW Rol",
"version": "0.0.1",
"mapping": {
"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 %}",
"roltoelichting": "{% if role.instance.name|default %}{{ role.instance.name }}{% endif %}",
"registratiedatum": "{% if role.instance.date_created|default %}{{ role.instance.date_created }}{% endif %}",
"contactpersoonRol.emailadres": "{% if requestor.instance.subject.instance.email_adress|default %}{{ requestor.instance.subject.instance.email_adress }}{% endif %}",
"contactpersoonRol.functie": "{% if requestor.instance.subject.instance.positions.instance.rows|default %}{% for position in requestor.instance.subject.instance.positions.instance.rows %}{% if role.preview|default %}{{ role.preview }}{% endif %}{% endfor %}{% endif %}",
"contactpersoonRol.telefoonnummer": "{% if requestor.instance.subject.instance.phone_number|default %}{{ requestor.instance.subject.instance.phone_number }}{% endif %}",
"contactpersoonRol.naam": "{% if requestor.instance.subject.instance.firstname|default %}{{ requestor.instance.subject.instance.firstname }} {% endif %}{% if requestor.instance.subject.instance.surname|default %}{{ requestor.instance.subject.instance.surname }}{% endif %}",
"betrokkeneIdentificatie._sourceId": "{% if requestor.reference|default %}{{ requestor.reference }}{% endif %}",
"betrokkeneIdentificatie.inpBsn": "{% if requestor.instance.subject.instance.personal_number|default %}{{ requestor.instance.subject.instance.personal_number }}{% endif %}",
"betrokkeneIdentificatie.inpA_nummer": "{% if requestor.instance.subject.instance.personal_number_a|default %}{{ requestor.instance.subject.instance.personal_number_a }}{% endif %}",
"betrokkeneIdentificatie.geslachtsnaam": "{% if requestor.instance.subject.instance.gender|default %}{{ requestor.instance.subject.instance.gender }}{% endif %}",
"betrokkeneIdentificatie.voorvoegselGeslachtsnaam": "{% if requestor.instance.subject.instance.prefix|default %}{{ requestor.instance.subject.instance.prefix }}{% endif %}",
"betrokkeneIdentificatie.voorletters": "{% if requestor.instance.subject.instance.initials|default %}{{ requestor.instance.subject.instance.initials }}{% endif %}",
"betrokkeneIdentificatie.voornamen": "{% if requestor.instance.subject.instance.first_names|default %}{{ requestor.instance.subject.instance.first_names }}{% endif %}",
"betrokkeneIdentificatie.geslachtsaanduiding": "{% if requestor.instance.subject.instance.geslachtsnaam|default %}{{ requestor.instance.subject.instance.geslachtsnaam }}{% endif %}",
"betrokkeneIdentificatie.geboortedatum": "{% if requestor.instance.subject.instance.date_of_birth|default %}{{ requestor.instance.subject.instance.date_of_birth }}{% endif %}",
"betrokkeneIdentificatie.achternaam": "{% if requestor.instance.subject.instance.surname|default %}{{ requestor.instance.subject.instance.surname }}{% endif %}",
"betrokkeneIdentificatie.verblijfsadres.wplWoonplaatsNaam": "{% if requestor.instance.subject.instance.address_residence.instance.city|default %}{{ requestor.instance.subject.instance.address_residence.instance.city }}{% endif %}",
"betrokkeneIdentificatie.verblijfsadres.aoaPostcode": "{% if requestor.instance.subject.instance.address_residence.instance.zipcode|default %}{{ requestor.instance.subject.instance.address_residence.instance.zipcode }}{% endif %}",
"betrokkeneIdentificatie.verblijfsadres.aoaHuisnummer": "{% if requestor.instance.subject.instance.address_residence.instance.street_number|default %}{{ requestor.instance.subject.instance.address_residence.instance.street_number }}{% endif %}",
"betrokkeneIdentificatie.verblijfsadres.aoaHuisletter": "{% if requestor.instance.subject.instance.address_residence.instance.street_number_letter|default %}{{ requestor.instance.subject.instance.address_residence.instance.street_number_letter }}{% endif %}",
"betrokkeneIdentificatie.verblijfsadres.aoaHuisnummertoevoeging": "{% if requestor.instance.subject.instance.address_residence.instance.street_number_suffix|default %}{{ requestor.instance.subject.instance.address_residence.instance.street_number_suffix }}{% endif %}",
"roltype": "{% if role.instance.name|default %}{% for roltype in roltypen %}{% if roltype.omschrijvingGeneriek|lower == role.instance.name|lower %}{{ roltype['_self']['id'] }}{% endif %}{% endfor %}{% endif %}"
},
"unset": [],
"cast": {
"roltype": "unsetIfValue==",
"betrokkeneIdentificatie": "unsetIfValue=="
},
"passTrough": false
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"name": "Xxllnc Value to ZGW ZaakEigenschap",
"version": "0.0.1",
"mapping": {
"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": [],
"passTrough": false
}
7 changes: 7 additions & 0 deletions configurations/xxllnc-zgw/sources/xxllnc-v1.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"name": "Xxllnc V1 API",
"version": "0.0.1",
"location": "",
"isEnabled": true,
"type": "api"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"name": "Xxllnc cases to ZGW zaken",
"description": "",
"version": "0.0.1",
"sourceId": "1",
"sourceType": "api",
"sourceHash": "",
"sourceHashMapping": "",
"sourceTargetMapping": "1",
"sourceConfig": {
"idPosition": "reference",
"resultsPosition": "result.instance.rows",
"endpoint": "\/case",
"query.zql": "select {} from case where case.casetype.id=",
"extraDataConfigs.0.staticEndpoint": "/case/{{ originId }}/document",
"extraDataConfigs.0.mergeExtraData": "true",
"extraDataConfigs.0.keyToSetExtraData": "documents",
"extraDataConfigs.1.staticEndpoint": "/casetype/{{ originId }}",
"extraDataConfigs.1.endpointIdLocation": "instance.casetype.reference",
"extraDataConfigs.1.mergeExtraData": "true",
"extraDataConfigs.1.keyToSetExtraData": "casetype"
},
"currentPage": 1,
"targetId": "1\/1",
"targetType": "register\/schema",
"targetHash": "",
"targetSourceMapping": "",
"targetConfig": [],
"followUps": []
}
22 changes: 17 additions & 5 deletions lib/Service/SynchronizationService.php
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ public function getObjectFromSource(Synchronization $synchronization, string $en
$source = $this->sourceMapper->find(id: $synchronization->getSourceId());

// Lets get the source config
$sourceConfig = $synchronization->getSourceConfig();
$sourceConfig = $this->callService->applyConfigDot($synchronization->getSourceConfig());
$headers = $sourceConfig['headers'] ?? [];
$query = $sourceConfig['query'] ?? [];
$config = [
Expand Down Expand Up @@ -234,12 +234,13 @@ public function getObjectFromSource(Synchronization $synchronization, string $en
* - KEY_FOR_EXTRA_DATA_LOCATION: The key under which the extra data should be returned.
* - MERGE_EXTRA_DATA_OBJECT_LOCATION: Boolean flag indicating whether to merge the extra data with the object.
* @param array $object The original object for which extra data needs to be fetched.
* @param string|null $originId
*
* @return array The original object merged with the extra data, or the extra data itself based on the configuration.
*
* @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)
private function fetchExtraDataForObject(Synchronization $synchronization, array $extraDataConfig, array $object, ?string $originId = null)
{
if (isset($extraDataConfig[$this::EXTRA_DATA_DYNAMIC_ENDPOINT_LOCATION]) === false && isset($extraDataConfig[$this::EXTRA_DATA_STATIC_ENDPOINT_LOCATION]) === false) {
return $object;
Expand All @@ -253,9 +254,20 @@ private function fetchExtraDataForObject(Synchronization $synchronization, array

// Get endpoint static defined in config.
if (isset($extraDataConfig[$this::EXTRA_DATA_STATIC_ENDPOINT_LOCATION]) === true) {

if ($originId === null) {
$originId = $this->getOriginId($synchronization, $object);
}

if (isset($extraDataConfig['endpointIdLocation']) === true) {
$dotObject = new Dot($object);
$originId = $dotObject->get($extraDataConfig['endpointIdLocation']);
}


$endpoint = $extraDataConfig[$this::EXTRA_DATA_STATIC_ENDPOINT_LOCATION];
$endpoint = str_replace(search: '{{ originId }}', replace: $this->getOriginId($synchronization, $object), subject: $endpoint);
$endpoint = str_replace(search: '{{originId}}', replace: $this->getOriginId($synchronization, $object), subject: $endpoint);
$endpoint = str_replace(search: '{{ originId }}', replace: $originId, subject: $endpoint);
$endpoint = str_replace(search: '{{originId}}', replace: $originId, subject: $endpoint);
}

if (!$endpoint) {
Expand All @@ -275,7 +287,7 @@ private function fetchExtraDataForObject(Synchronization $synchronization, array
$results = $dotObject->get($extraDataConfig['resultsLocation']);

foreach ($results as $key => $result) {
$results[$key] = $this->fetchExtraDataForObject($synchronization, $extraDataConfig['extraDataConfigPerResult'], $result);
$results[$key] = $this->fetchExtraDataForObject(synchronization: $synchronization, extraDataConfig: $extraDataConfig['extraDataConfigPerResult'], object: $result, originId: $originId);
}

$extraData = $results;
Expand Down
Loading