Skip to content

Commit 96c1d9c

Browse files
authored
Merge pull request #3 from CommonGateway/feature/GW-1736/test-with-mapping
Synchronization code and notifications
2 parents 871f424 + f1a7474 commit 96c1d9c

13 files changed

+812
-120
lines changed
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
{
2+
"title": "Sync Cases from VrijBRP",
3+
"$id": "https://commongateway.nl/action/vrijbrp.synczaken.action.json",
4+
"$schema": "https://docs.commongateway.nl/schemas/Action.schema.json",
5+
"version": "0.0.1",
6+
"listens": [
7+
"vrijbrp.zaken.sync"
8+
],
9+
"throws": [],
10+
"conditions": {
11+
"==": [
12+
1,
13+
1
14+
]
15+
},
16+
"class": "CommonGateway\\VrijBRPToZGWBundle\\ActionHandler\\SynchronizeCollectionHandler",
17+
"configuration": {
18+
"source": "https://vrijbrp.nl/source/vrijbrp.dossiers.source.json",
19+
"schema": "https://vng.opencatalogi.nl/schemas/zrc.zaak.schema.json",
20+
"mapping": "https://commongateway.nl/mapping/vrijbrp.dossierToZaak.mapping.json",
21+
"endpoint": "/api/v1/dossiers/search",
22+
"idField": "dossierId",
23+
"resultsPath": "result.content",
24+
"method": "POST",
25+
"body": {
26+
"types": [
27+
"intra_mun_relocation",
28+
"inter_mun_relocation"
29+
]
30+
}
31+
},
32+
"isLockable": false,
33+
"isEnabled": true
34+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"title": "CreateCaseNotification",
3+
"$id": "https://commongateway.nl/action/vrijbrp.createCaseNotification.action.json",
4+
"$schema": "https://docs.commongateway.nl/schemas/Action.schema.json",
5+
"version": "0.0.1",
6+
"description": "This is an example Action. This action is triggered when commongateway.object.create event is thrown and the data (object) of the event has entity = https://example.com/schema/example.schema.json. In order for this condition to work the ref https://example.com/schema/example.schema.json has to be translated to an id, see installation.json['actions']['fixConfigRef'] for how to do this.",
7+
"listens": [
8+
"commongateway.object.post.create"
9+
],
10+
"conditions":
11+
{
12+
"==": [
13+
{
14+
"var": "entity.reference"
15+
}, "https://vng.opencatalogi.nl/schemas/zrc.zaak.schema.json"
16+
]
17+
},
18+
"class": "CommonGateway\\VrijBRPToZGWBundle\\ActionHandler\\NotificationCaseHandler",
19+
"configuration": {
20+
}
21+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"title": "CreateStatusNotification",
3+
"$id": "https://commongateway.nl/action/vrijbrp.createStatusNotification.action.json",
4+
"$schema": "https://docs.commongateway.nl/schemas/Action.schema.json",
5+
"version": "0.0.1",
6+
"description": "This is an example Action. This action is triggered when commongateway.object.create event is thrown and the data (object) of the event has entity = https://example.com/schema/example.schema.json. In order for this condition to work the ref https://example.com/schema/example.schema.json has to be translated to an id, see installation.json['actions']['fixConfigRef'] for how to do this.",
7+
"listens": [
8+
"commongateway.object.post.create"
9+
],
10+
"conditions":
11+
{
12+
"==": [
13+
{
14+
"var": "entity.reference"
15+
}, "https://vng.opencatalogi.nl/schemas/zrc.status.schema.json"
16+
]
17+
},
18+
"class": "CommonGateway\\VrijBRPToZGWBundle\\ActionHandler\\NotificationUpdateHandler",
19+
"configuration": {
20+
}
21+
}

Installation/Mapping/vrijbrp.dossierToZaak.mapping.json

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,14 @@
88
"_sourceId": "dossierId",
99
"identificatie": "dossierId",
1010
"omschrijving": "description",
11+
"toelichting": "type.code",
1112
"bronorganisatie": "bronorganisatie",
1213
"verantwoordelijkeOrganisatie": "bronorganisatie",
1314
"zaaktype": "zaaktypeUrl",
1415
"registratiedatum": "entryDateTime",
1516
"startdatum": "startDate",
16-
"eigenschappen": "[{% for eigenschap in eigenschappen %}{% if index > 0 %}, {% endif %}{% set eigenschap = eigenschap|merge({'dossierId': dossierId}) %}{{ map('https://commongateway.nl/mapping/vrijbrp.waardeToZaakEigenschap.mapping.json', eigenschap)|json_encode }}{% endfor %}]",
17-
"rollen": "[{% if declarant.bsn|default %}{% set bsnArray = {'bsn': declarant.bsn, 'dossierId': dossierId} %}{% if roltypeUrl|default %}{% set bsnArray = bsnArray|merge({'roltypeUrl': roltypeUrl}) %}{% endif %}{{ map('https://commongateway.nl/mapping/vrijbrp.bsnToRol.mapping.json', bsnArray)|json_encode }}{% endif %}]",
18-
"zaakinformatieobjecten": "[{% if documents|default %}{% set index = 0 %}{% for document in documents %}{% if index > 0 %}, {% endif %}{% if bronorganisatie|default %}{% set document = document|merge({'bronorganisatie': bronorganisatie}) %}{% endif %}{% if informatieobjecttypeUrl|default %}{% set document = document|merge({'informatieobjecttypeUrl': informatieobjecttypeUrl}) %}{% endif %}{{ map('https://commongateway.nl/mapping/vrijbrp.documentToZaakInformatieObject.mapping.json', document)|json_encode }}{% index = index + 1 %}{% endfor %}{% endif %}]"
19-
"statussen": "[{% if status|default %}{% if dossierId|default and statustypeUrl|default %}{% set status = status|merge({'dossierId': dossierId, 'statustypeUrl': statustypeUrl}) %}{% endif %}{{ map('https://commongateway.nl/mapping/vrijbrp.statusToZGWStatus.mapping.json', status)|json_encode }}]",
17+
"status": "{% if status|default %}{% if dossierId|default %}{% set status = status|merge({'dossierId': dossierId}) %}{% endif %}{{ map('https:\/\/commongateway.nl\/mapping\/vrijbrp.statusToZGWStatus.mapping.json', status)|json_encode }}{% endif %}"
18+
},
2019
"cast": {
2120
"_sourceId": "unsetIfValue==dossierId",
2221
"identificatie": "unsetIfValue==dossierId",
@@ -26,8 +25,6 @@
2625
"zaaktype": "unsetIfValue==zaaktypeUrl",
2726
"registratiedatum": "unsetIfValue==entryDateTime",
2827
"startdatum": "unsetIfValue==startDate",
29-
"rollen": "jsonToArray",
30-
"statussen": "jsonToArray",
31-
"zaakinformatieobjecten": "jsonToArray"
28+
"status": "jsonToArray"
3229
}
3330
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
{
2+
"title": "DossierToZaakDetail",
3+
"$id": "https://commongateway.nl/mapping/vrijbrp.dossierToZaakDetail.mapping.json",
4+
"$schema": "https://docs.commongateway.nl/schemas/Mapping.schema.json",
5+
"version": "0.0.1",
6+
"passTrough": false,
7+
"mapping": {
8+
"_sourceId": "dossier.dossierId",
9+
"identificatie": "dossier.dossierId",
10+
"omschrijving": "dossier.description",
11+
"bronorganisatie": "bronorganisatie",
12+
"verantwoordelijkeOrganisatie": "bronorganisatie",
13+
"zaaktype": "zaaktypeUrl",
14+
"registratiedatum": "dossier.entryDateTime",
15+
"startdatum": "startDate",
16+
"rollen": "[{% if declarant.bsn|default %}{% set bsnArray = {'bsn': declarant.bsn, 'dossierId': dossier.dossierId} %}{% if roltypeUrl|default %}{% set bsnArray = bsnArray|merge({'roltypeUrl': roltypeUrl}) %}{% endif %}{{ map('https:\/\/commongateway.nl\/mapping\/vrijbrp.bsnToRol.mapping.json', bsnArray)|json_encode }}{% endif %}]",
17+
"zaakinformatieobjecten": "[{% if documents|default %}{% set index = 0 %}{% for document in documents %}{% if index > 0 %}, {% endif %}{% if bronorganisatie|default %}{% set document = document|merge({'bronorganisatie': bronorganisatie}) %}{% endif %}{% if informatieobjecttypeUrl|default %}{% set document = document|merge({'informatieobjecttypeUrl': informatieobjecttypeUrl}) %}{% endif %}{{ map('https:\/\/commongateway.nl\/mapping\/vrijbrp.documentToZaakInformatieObject.mapping.json', document)|json_encode }}{% set index = index + 1 %}{% endfor %}{% endif %}]",
18+
"status": "{% if dossier.status|default %}{% if dossier.dossierId|default %}{% set status = dossier.status|merge({'dossierId': dossier.dossierId}) %}{% else %}{% set status = dossier.status %}{% endif %}{{ map('https:\/\/commongateway.nl\/mapping\/vrijbrp.statusToZGWStatus.mapping.json', status)|json_encode }}{% endif %}",
19+
"eigenschappen": "[{\"naam\": \"VERHUISDATUM\", \"waarde\": \"{{ dossier.startDate }}\", \"eigenschap\": {\"_sourceId\": \"VERHUISDATUM\", \"naam\": \"VERHUISDATUM\"}},{\"naam\": \"STRAATNAAM_NIEUW\", \"waarde\": \"{{ newAddress.street }}\", \"eigenschap\": {\"_sourceId\": \"STRAATNAAM_NIEUW\", \"naam\": \"STRAATNAAM_NIEUW\"}},{\"naam\": \"HUISNUMMER_NIEUW\", \"waarde\": \"{{ newAddress.houseNumber }}\", \"eigenschap\": {\"_sourceId\": \"HUISNUMMER_NIEUW\", \"naam\": \"HUISNUMMER_NIEUW\"}},{\"naam\": \"HUISLETTER_NIEUW\", \"waarde\": \"{{ newAddress.houseLetter }}\", \"eigenschap\": {\"_sourceId\": \"HUISLETTER_NIEUW\", \"naam\": \"HUISLETTER_NIEUW\"}},{\"naam\": \"TOEVOEGINGHUISNUMMER_NIEUW\", \"waarde\": \"{{ newAddress.houseNumberAddition }}\", \"eigenschap\": {\"_sourceId\": \"TOEVOEGINGHUISNUMMER_NIEUW\", \"naam\": \"TOEVOEGINGHUISNUMMER_NIEUW\"}},{\"naam\": \"POSTCODE_NIEUW\", \"waarde\": \"{{ newAddress.postalCode }}\", \"eigenschap\": {\"_sourceId\": \"POSTCODE_NIEUW\", \"naam\": \"POSTCODE_NIEUW\"}},{\"naam\": \"WOONPLAATS_NIEUW\", \"waarde\": \"{{ newAddress.residence }}\", \"eigenschap\": {\"_sourceId\": \"WOONPLAATS_NIEUW\", \"naam\": \"WOONPLAATS_NIEUW\"}},{% if newAddress.mainOccupant|default and newAddress.mainOccupant.bsn|default %}{\"naam\": \"BSN_HOOFDBEWONER\", \"waarde\": \"{{ newAddress.mainOccupant.bsn }}\", \"eigenschap\": {\"_sourceId\": \"BSN_HOOFDBEWONER\", \"naam\": \"BSN_HOOFDBEWONER\"}},{% endif %}{% if previousMunicipality.code|default %}{\"naam\": \"GEMEENTECODE\", \"waarde\": \"{{ previousMunicipality.code }}\", \"eigenschap\": {\"_sourceId\": \"GEMEENTECODE\", \"naam\": \"GEMEENTECODE\"}},{% endif %}{% set index = 0 %}{% for relocator in relocators %}{\"naam\": \"MEEVERHUIZENDE_GEZINSLEDEN.MEEVERHUIZEND_GEZINSLID.{{ index }}.BSN\", \"waarde\": \"{{ relocator.bsn }}\", \"eigenschap\": {\"_sourceId\": \"MEEVERHUIZENDE_GEZINSLEDEN.MEEVERHUIZEND_GEZINSLID.{{ index }}.BSN\", \"naam\": \"MEEVERHUIZENDE_GEZINSLEDEN.MEEVERHUIZEND_GEZINSLID.{{ index }}.BSN\"}},{\"naam\": \"MEEVERHUIZENDE_GEZINSLEDEN.MEEVERHUIZEND_GEZINSLID.{{ index }}.ROL\", \"waarde\": \"{{ relocator.declarationType }}\", \"eigenschap\": {\"_sourceId\": \"MEEVERHUIZENDE_GEZINSLEDEN.MEEVERHUIZEND_GEZINSLID.{{ index }}.ROL\", \"naam\": \"MEEVERHUIZENDE_GEZINSLEDEN.MEEVERHUIZEND_GEZINSLID.{{ index }}.ROL\"}},{% endfor %}{\"naam\": \"AANTAL_PERS_NIEUW_ADRES\", \"waarde\": \"{{ newAddress.numberOfResidents }}\", \"eigenschap\": {\"_sourceId\": \"AANTAL_PERS_NIEUW_ADRES\", \"naam\": \"AANTAL_PERS_NIEUW_ADRES\"}}]"
20+
},
21+
"cast": {
22+
"_sourceId": "unsetIfValue==dossierId",
23+
"identificatie": "unsetIfValue==dossierId",
24+
"omschrijving": "unsetIfValue==description",
25+
"bronorganisatie": "unsetIfValue==bronorganisatie",
26+
"verantwoordelijkeOrganisatie": "unsetIfValue==bronorganisatie",
27+
"zaaktype": "unsetIfValue==zaaktypeUrl",
28+
"registratiedatum": "unsetIfValue==entryDateTime",
29+
"startdatum": "unsetIfValue==startDate",
30+
"rollen": "jsonToArray",
31+
"zaakinformatieobjecten": "jsonToArray",
32+
"status": "jsonToArray",
33+
"eigenschappen": "jsonToArray"
34+
}
35+
}

Installation/Mapping/vrijbrp.statusToZGWStatus.mapping.json

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,11 @@
66
"passTrough": false,
77
"mapping": {
88
"_sourceId": "{% if dossierId|default and code|default %}{{ dossierId~code }}{% endif %}",
9-
"statustype": "statustypeUrl",
10-
"datumStatusGezet": "entryDateTime",
11-
"indicatieLaatstGezetteStatus": "endStatus"
9+
"statustype.omschrijving": "description",
10+
"statustype.omschrijvingGeneriek": "code",
11+
"statustype.isEindstatus": "endStatus",
12+
"statustype._sourceId": "code",
13+
"datumStatusGezet": "entryDateTime"
1214
},
1315
"cast": {
1416
"_sourceId": "unsetIfValue==",

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
"license": "EUPL-1.2",
1717
"minimum-stability": "dev",
1818
"require": {
19-
"php": ">=7.4",
19+
"php": ">=8.2",
2020
"commongateway/corebundle": "^1.2.68 | <2.0"
2121
},
2222
"require-dev": {
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
<?php
2+
3+
namespace CommonGateway\VrijBRPToZGWBundle\ActionHandler;
4+
5+
use CommonGateway\VrijBRPToZGWBundle\Service\NewSynchronizationService;
6+
use CommonGateway\VrijBRPToZGWBundle\Service\VrijBrpService;
7+
use CommonGateway\CoreBundle\ActionHandler\ActionHandlerInterface;
8+
/**
9+
* Handler for firing notifications for new cases.
10+
*
11+
* @author Robert Zondervan, Barry Brands, Ruben van der Linde
12+
* @license EUPL<github.com/ConductionNL/contactcatalogus/blob/master/LICENSE.md>
13+
*
14+
* @category ActionHandler
15+
*/
16+
class NotificationCaseHandler implements ActionHandlerInterface
17+
{
18+
19+
20+
/**
21+
* The constructor.
22+
*
23+
* @param VrijBrpService $vrijBrpService The VrijBRP Service
24+
*/
25+
public function __construct(
26+
private readonly VrijBrpService $vrijBrpService,
27+
) {
28+
29+
}//end __construct()
30+
31+
32+
/**
33+
* This function returns the requered configuration as a [json-schema](https://json-schema.org/) array.
34+
*
35+
* @throws array a [json-schema](https://json-schema.org/) that this action should comply to
36+
* @return array The default configuration options of this action handler.
37+
*/
38+
public function getConfiguration(): array
39+
{
40+
return [
41+
'$id' => 'https://commongateway.nl/ActionHandler/SynchronizationCollectionHandler.ActionHandler.json',
42+
'$schema' => 'https://docs.commongateway.nl/schemas/ActionHandler.schema.json',
43+
'title' => 'SynchronizationCollectionHandler',
44+
'description' => '',
45+
'required' => [],
46+
'properties' => [],
47+
];
48+
49+
}//end getConfiguration()
50+
51+
52+
/**
53+
* Run the actual business logic in the appropriate server.
54+
*
55+
* @param array $data The data from the call
56+
* @param array $configuration The configuration of the action
57+
*
58+
* @return array The updated data array
59+
*/
60+
public function run(array $data, array $configuration): array
61+
{
62+
return $this->vrijBrpService->createCaseNotification($data, $configuration);
63+
64+
}//end run()
65+
66+
67+
}//end class
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
<?php
2+
3+
namespace CommonGateway\VrijBRPToZGWBundle\ActionHandler;
4+
5+
use CommonGateway\VrijBRPToZGWBundle\Service\NewSynchronizationService;
6+
use CommonGateway\VrijBRPToZGWBundle\Service\VrijBrpService;
7+
use CommonGateway\CoreBundle\ActionHandler\ActionHandlerInterface;
8+
9+
/**
10+
* Handler for firing notifications for new statuses.
11+
*
12+
* @author Robert Zondervan, Barry Brands, Ruben van der Linde
13+
* @license EUPL<github.com/ConductionNL/contactcatalogus/blob/master/LICENSE.md>
14+
*
15+
* @category ActionHandler
16+
*/
17+
class NotificationUpdateHandler implements ActionHandlerInterface
18+
{
19+
20+
21+
/**
22+
* The constructor.
23+
*
24+
* @param VrijBrpService $vrijBrpService The VrijBRP Service
25+
*/
26+
public function __construct(
27+
private readonly VrijBrpService $vrijBrpService,
28+
) {
29+
30+
}//end __construct()
31+
32+
33+
/**
34+
* This function returns the requered configuration as a [json-schema](https://json-schema.org/) array.
35+
*
36+
* @throws array a [json-schema](https://json-schema.org/) that this action should comply to
37+
* @return array The default configuration options of this action handler.
38+
*/
39+
public function getConfiguration(): array
40+
{
41+
return [
42+
'$id' => 'https://commongateway.nl/ActionHandler/SynchronizationCollectionHandler.ActionHandler.json',
43+
'$schema' => 'https://docs.commongateway.nl/schemas/ActionHandler.schema.json',
44+
'title' => 'SynchronizationCollectionHandler',
45+
'description' => '',
46+
'required' => [],
47+
'properties' => [],
48+
];
49+
50+
}//end getConfiguration()
51+
52+
53+
/**
54+
* Run the actual business logic in the appropriate server.
55+
*
56+
* @param array $data The data from the call
57+
* @param array $configuration The configuration of the action
58+
*
59+
* @return array The updated data array.
60+
*/
61+
public function run(array $data, array $configuration): array
62+
{
63+
return $this->vrijBrpService->createStatusNotification($data, $configuration);
64+
65+
}//end run()
66+
67+
68+
}//end class

0 commit comments

Comments
 (0)