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

Synchronize object to source #203

Open
wants to merge 7 commits into
base: development
Choose a base branch
from
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
"version": "0.0.1",
"mapping": {
"originId": "reference",
"_sourceId": "reference",
"identificatie": "reference",
"omschrijving": "instance.subject",
"toelichting": "instance.subject_external",
Expand All @@ -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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
"version": "0.0.1",
"mapping": {
"originId": "reference",
"_sourceId": "reference",
"identificatie": "instance.legacy.zaaktype_id",
"catalogus": "_catalogus",
"onderwerp": "instance.title",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -21,6 +22,7 @@
},
"unset": [],
"cast": {
"originId": "unsetIfValue==reference",
"informatieobject.versie": "integer",
"informatieobject.bestandsomvang": "integer",
"informatieobject.inhoud": "jsonToArray",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 %}",
Expand All @@ -11,6 +12,7 @@
},
"unset": [],
"cast": {
"originId": "unsetIfValue==id",
"naam": "unsetIfValue==magic_string",
"definitie": "unsetIfValue==",
"catalogus": "unsetIfValue==_catalogus",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@
"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') }}",
"informatieobjectcategorie": "xxllnc informatieobject"
},
"unset": [],
"cast": {
"originId": "unsetIfValue==id",
"omschrijving": "unsetIfValue=="
},
"passTrough": false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@
"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 }}",
"statustype": "{% for statustype in statustypen %}{% if statustype.omschrijving == milestone.instance.phase_label %}{{ statustype['_self']['id'] }}{% endif %}{% endfor %}"
},
"unset": [],
"cast": {
"originId": "unsetIfValue==",
"indicatieLaatstGezetteStatus": "bool",
"statustype": "unsetIfValue==",
"datumStatusGezet": "unsetIfValue==milestone.instance.date_modified",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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=="
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 %}",
Expand All @@ -12,7 +12,7 @@
},
"unset": [],
"cast": {
"_sourceId": "unsetIfValue==",
"originId": "unsetIfValue==",
"volgnummer": "unsetIfValue==seq",
"omschrijving": "unsetIfValue==name",
"catalogus": "unsetIfValue==_catalogus",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 %}",
Expand All @@ -10,6 +11,7 @@
},
"unset": [],
"cast": {
"originId": "unsetIfValue==resultaat_id",
"omschrijving": "unsetIfValue==type",
"toelichting": "unsetIfValue==label",
"archiefactietermijn": "unsetIfValue=="
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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=="
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 %}",
Expand Down Expand Up @@ -30,6 +31,7 @@
},
"unset": [],
"cast": {
"originId": "unsetIfValue==",
"roltype": "unsetIfValue==",
"betrokkeneIdentificatie": "unsetIfValue==",
"omschrijving": "unsetIfValue==",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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=="
Expand Down
34 changes: 34 additions & 0 deletions docs/connections/ZGWAndXxllnc.md
Original file line number Diff line number Diff line change
@@ -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

<!-- ![alt text](image.png) -->


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.

<!-- ![alt text](image-1.png) ![alt text](image-2.png) -->

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.
4 changes: 4 additions & 0 deletions lib/AppInfo/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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 {
Expand Down
70 changes: 70 additions & 0 deletions lib/EventListener/RegisterEventListener.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
<?php

namespace OCA\OpenConnector\EventListener;

use OCA\OpenConnector\Service\SynchronizationService;
use OCP\EventDispatcher\Event;
use OCP\EventDispatcher\IEventListener;
use OCA\OpenRegister\Event\ObjectCreatedEvent;
use OCA\OpenRegister\Event\ObjectUpdatedEvent;
use OCA\OpenRegister\Event\ObjectDeletedEvent;
use Psr\Log\LoggerInterface;

/**
* Listener that forwards object changes to the SynchronizationService
*/
class RegisterEventListener implements IEventListener
{
/**
* @param SynchronizationService $synchronizationService Service for synchronizing
* @param LoggerInterface $logger Logger instance
*/
public function __construct(
private readonly SynchronizationService $synchronizationService,
private readonly LoggerInterface $logger
) {}

/**
* Handle incoming events by forwarding them to the EventService
*
* @param Event $event The incoming event
* @return void
*/
public function handle(Event $event): void
{
if ($event instanceof ObjectCreatedEvent === false
&& $event instanceof ObjectUpdatedEvent === false
&& $event instanceof ObjectDeletedEvent === false
) {
return;
}

if (method_exists($event, 'getObject') === false) {
return;
}


$object = $event->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)
]);
}
}
}
}
Loading
Loading