From 4d6d1228a48a4e87343f8144bd368a566495a1b7 Mon Sep 17 00:00:00 2001 From: Barry Brands Date: Mon, 21 Aug 2023 17:13:36 +0200 Subject: [PATCH 01/15] mapping zgw -> woo --- ...dd.zgwZaakInfoObjectToBijlage.mapping.json | 14 +++++++ .../Mapping/pdd.zgwZaakToWoo.mapping.json | 42 +++++++++++++++++++ 2 files changed, 56 insertions(+) create mode 100644 Installation/Mapping/pdd.zgwZaakInfoObjectToBijlage.mapping.json create mode 100644 Installation/Mapping/pdd.zgwZaakToWoo.mapping.json diff --git a/Installation/Mapping/pdd.zgwZaakInfoObjectToBijlage.mapping.json b/Installation/Mapping/pdd.zgwZaakInfoObjectToBijlage.mapping.json new file mode 100644 index 0000000..e013e4a --- /dev/null +++ b/Installation/Mapping/pdd.zgwZaakInfoObjectToBijlage.mapping.json @@ -0,0 +1,14 @@ +{ + "title": "ZGWZaakInfoObjectToBijlage", + "$id": "https://commongateway.nl/mapping/pdd.zgwZaakInfoObjectToBijlage.mapping.json", + "$schema": "https://docs.commongateway.nl/schemas/Mapping.schema.json", + "version": "0.0.1", + "passTrough": false, + "mapping": { + "Type_Bijlage": "mimetype", + "Status_Bijlage": "{% if accepted == 1 %}{{ 'accepted' }}{% endif %}", + "Tijdstip_laatste_wijziging_bijlage": "", + "Titel_Bijlage": "filename", + "URL_Bijlage": "informatieobject.inhoud" + } +} diff --git a/Installation/Mapping/pdd.zgwZaakToWoo.mapping.json b/Installation/Mapping/pdd.zgwZaakToWoo.mapping.json new file mode 100644 index 0000000..5a0a269 --- /dev/null +++ b/Installation/Mapping/pdd.zgwZaakToWoo.mapping.json @@ -0,0 +1,42 @@ +{ + "title": "ZGWZaakToWoo", + "$id": "https://commongateway.nl/mapping/pdd.xxllncCaseToWoo.mapping.json", + "$schema": "https://docs.commongateway.nl/schemas/Mapping.schema.json", + "version": "0.0.1", + "passTrough": false, + "mapping": { + "_sourceId": "uuid", + "UUID": "uuid", + "ID": "identificatie", + "Object_ID": "", + "Portal_url": "", + "Behandelend_bestuursorgaan": "", + "Ontvanger_informatieverzoek": "", + "Volgnummer": "", + "Titel": "zaaktype.omschrijving", + "Beschrijving": "omschrijving", + "Samenvatting": "omschrijving", + "Verzoeker": "rollen.0.omschrijving", + "Ontvangstdatum": "startdatum", + "Besluitdatum": "einddatum", + "Behandelstatus": "status.statustype.omschrijving", + "Besluit": "besluit.besluittype.omschrijving", + "Termijnoverschrijding": "", + "URL_informatieverzoek": "", + "URL_inventarisatielijst": "", + "URL_besluit": "", + "Geografisch_gebied": "", + "BAG_ID": "", + "BGT_ID": "", + "Postcodegebied": "", + "Adres": "", + "COORDS": "", + "Geografische_positie": "", + "Bijlagen": "[{% set index=0 %}{% if zaakinformatieobjecten|default %}{% for infoObject in zaakinformatieobjecten %}{% if index != 0 %},{% endif %}{{ map('https://commongateway.nl/mapping/pdd.zgwZaakInfoObjectToBijlage.mapping.json', infoObject)|json_encode }}{% set index=index+1 %}{% endfor %}{% endif %}]", + "Themas": "" + }, + "cast": { + "Bijlagen": "jsonToArray" + } + } + \ No newline at end of file From d6d853cd271b4539529eed8c55e91f461992f8ef Mon Sep 17 00:00:00 2001 From: Barry Brands Date: Tue, 22 Aug 2023 11:28:54 +0200 Subject: [PATCH 02/15] SyncZaken action --- .../Action/pdd.SyncCasesAction.action.json | 6 +- .../Action/pdd.SyncZGWZakenAction.action.json | 12 ++ ...dd.zgwZaakInfoObjectToBijlage.mapping.json | 6 +- .../Mapping/pdd.zgwZaakToWoo.mapping.json | 2 +- Installation/Source/zgw.source.json | 8 + ...Handler.php => SyncXxllncCasesHandler.php} | 22 +-- src/ActionHandler/SyncZGWZakenHandler.php | 78 ++++++++ ...Service.php => SyncXxllncCasesService.php} | 10 +- src/Service/SyncZGWZakenService.php | 180 ++++++++++++++++++ 9 files changed, 301 insertions(+), 23 deletions(-) create mode 100644 Installation/Action/pdd.SyncZGWZakenAction.action.json create mode 100644 Installation/Source/zgw.source.json rename src/ActionHandler/{SyncCasesHandler.php => SyncXxllncCasesHandler.php} (72%) create mode 100644 src/ActionHandler/SyncZGWZakenHandler.php rename src/Service/{SyncCasesService.php => SyncXxllncCasesService.php} (95%) create mode 100644 src/Service/SyncZGWZakenService.php diff --git a/Installation/Action/pdd.SyncCasesAction.action.json b/Installation/Action/pdd.SyncCasesAction.action.json index 530d1ab..e72eaa1 100644 --- a/Installation/Action/pdd.SyncCasesAction.action.json +++ b/Installation/Action/pdd.SyncCasesAction.action.json @@ -1,12 +1,12 @@ { - "title": "SyncCasesAction", + "title": "SyncXxllncCasesAction", "$id": "https://commongateway.nl/pdd.SyncCasesAction.action.json", "$schema": "https://docs.commongateway.nl/schemas/Action.schema.json", - "version": "0.0.2", + "version": "0.0.3", "listens": ["pdd.default.listens"], "conditions": { "==": [1, 1] }, - "class": "CommonGateway\\PDDBundle\\ActionHandler\\SyncCasesHandler" + "class": "CommonGateway\\PDDBundle\\ActionHandler\\SyncXxllncCasesHandler" } \ No newline at end of file diff --git a/Installation/Action/pdd.SyncZGWZakenAction.action.json b/Installation/Action/pdd.SyncZGWZakenAction.action.json new file mode 100644 index 0000000..dd4c388 --- /dev/null +++ b/Installation/Action/pdd.SyncZGWZakenAction.action.json @@ -0,0 +1,12 @@ +{ + "title": "SyncZGWZakenAction", + "$id": "https://commongateway.nl/pdd.SyncZGWZakenAction.action.json", + "$schema": "https://docs.commongateway.nl/schemas/Action.schema.json", + "version": "0.0.1", + "listens": ["pdd.default.listens"], + "conditions": + { + "==": [1, 1] + }, + "class": "CommonGateway\\PDDBundle\\ActionHandler\\SyncZGWZakenHandler" +} \ No newline at end of file diff --git a/Installation/Mapping/pdd.zgwZaakInfoObjectToBijlage.mapping.json b/Installation/Mapping/pdd.zgwZaakInfoObjectToBijlage.mapping.json index e013e4a..9486c46 100644 --- a/Installation/Mapping/pdd.zgwZaakInfoObjectToBijlage.mapping.json +++ b/Installation/Mapping/pdd.zgwZaakInfoObjectToBijlage.mapping.json @@ -5,10 +5,10 @@ "version": "0.0.1", "passTrough": false, "mapping": { - "Type_Bijlage": "mimetype", - "Status_Bijlage": "{% if accepted == 1 %}{{ 'accepted' }}{% endif %}", + "Type_Bijlage": "informatieobject.formaat", + "Status_Bijlage": "informatieobject.status", "Tijdstip_laatste_wijziging_bijlage": "", - "Titel_Bijlage": "filename", + "Titel_Bijlage": "informatieobject.titel", "URL_Bijlage": "informatieobject.inhoud" } } diff --git a/Installation/Mapping/pdd.zgwZaakToWoo.mapping.json b/Installation/Mapping/pdd.zgwZaakToWoo.mapping.json index 5a0a269..7460e7b 100644 --- a/Installation/Mapping/pdd.zgwZaakToWoo.mapping.json +++ b/Installation/Mapping/pdd.zgwZaakToWoo.mapping.json @@ -1,6 +1,6 @@ { "title": "ZGWZaakToWoo", - "$id": "https://commongateway.nl/mapping/pdd.xxllncCaseToWoo.mapping.json", + "$id": "https://commongateway.nl/mapping/pdd.zgwZaakToWoo.mapping.json", "$schema": "https://docs.commongateway.nl/schemas/Mapping.schema.json", "version": "0.0.1", "passTrough": false, diff --git a/Installation/Source/zgw.source.json b/Installation/Source/zgw.source.json new file mode 100644 index 0000000..069118c --- /dev/null +++ b/Installation/Source/zgw.source.json @@ -0,0 +1,8 @@ +{ + "title": "ZGW", + "$id": "https://commongateway.woo.nl/source/zgw.source.json", + "$schema": "https://docs.commongateway.nl/schemas/Gateway.schema.json", + "version": "0.0.1", + "description": "ZGW api", + "location": "!ChangeMe!" +} \ No newline at end of file diff --git a/src/ActionHandler/SyncCasesHandler.php b/src/ActionHandler/SyncXxllncCasesHandler.php similarity index 72% rename from src/ActionHandler/SyncCasesHandler.php rename to src/ActionHandler/SyncXxllncCasesHandler.php index 1591f11..fbdec60 100644 --- a/src/ActionHandler/SyncCasesHandler.php +++ b/src/ActionHandler/SyncXxllncCasesHandler.php @@ -2,7 +2,7 @@ namespace CommonGateway\PDDBundle\ActionHandler; -use CommonGateway\PDDBundle\Service\SyncCasesService; +use CommonGateway\PDDBundle\Service\SyncXxllncCasesService; use Symfony\Component\Mailer\Exception\TransportExceptionInterface; use Twig\Error\LoaderError; use Twig\Error\RuntimeError; @@ -10,7 +10,7 @@ use CommonGateway\CoreBundle\ActionHandler\ActionHandlerInterface; /** - * ActionHandler executing SyncCasesService->syncCasesHandler. + * ActionHandler executing SyncXxllncCasesService->syncXxllncCasesHandler. * * @author Conduction BV (info@conduction.nl), Barry Brands (barry@conduction.nl) * @license EUPL @@ -18,21 +18,21 @@ * @package CommonGateway\PDDBundle * @category ActionHandler */ -class SyncCasesHandler implements ActionHandlerInterface +class SyncXxllncCasesHandler implements ActionHandlerInterface { /** - * @var SyncCasesService + * @var SyncXxllncCasesService */ - private SyncCasesService $service; + private SyncXxllncCasesService $service; /** - * SyncPubHandler constructor. + * SyncXxllncCasesHandler constructor. * - * @param SyncCasesService $service + * @param SyncXxllncCasesService $service */ - public function __construct(SyncCasesService $service) + public function __construct(SyncXxllncCasesService $service) { $this->service = $service; @@ -49,7 +49,7 @@ public function getConfiguration(): array return [ '$id' => 'https://commongateway.nl/pdd.SyncCasesAction.action.json', '$schema' => 'https://docs.commongateway.nl/schemas/ActionHandler.schema.json', - 'title' => 'SyncCasesHandler', + 'title' => 'SyncXxllncCasesHandler', 'description' => 'Handles the sync for xxllnc cases.', 'required' => [], 'properties' => [], @@ -59,7 +59,7 @@ public function getConfiguration(): array /** - * This function runs the SyncCases service plugin. + * This function runs the SyncXxllncCases service plugin. * * @param array $data The data from the call * @param array $configuration The configuration of the action @@ -70,7 +70,7 @@ public function getConfiguration(): array */ public function run(array $data, array $configuration): array { - return $this->service->syncCasesHandler($data, $configuration); + return $this->service->syncXxllncCasesHandler($data, $configuration); }//end run() diff --git a/src/ActionHandler/SyncZGWZakenHandler.php b/src/ActionHandler/SyncZGWZakenHandler.php new file mode 100644 index 0000000..67e911e --- /dev/null +++ b/src/ActionHandler/SyncZGWZakenHandler.php @@ -0,0 +1,78 @@ +SyncZGWZakenHandler. + * + * @author Conduction BV (info@conduction.nl), Barry Brands (barry@conduction.nl) + * @license EUPL + * + * @package CommonGateway\PDDBundle + * @category ActionHandler + */ +class SyncZGWZakenHandler implements ActionHandlerInterface +{ + + /** + * @var SyncZGWZakenService + */ + private SyncZGWZakenService $service; + + + /** + * SyncZGWZakenHandler constructor. + * + * @param SyncZGWZakenService $service + */ + public function __construct(SyncZGWZakenService $service) + { + $this->service = $service; + + }//end __construct() + + + /** + * This function returns the requered configuration as a [json-schema](https://json-schema.org/) array. + * + * @throws array a [json-schema](https://json-schema.org/) that this action should comply to + */ + public function getConfiguration(): array + { + return [ + '$id' => 'https://commongateway.nl/pdd.SyncZGWZaken.action.json', + '$schema' => 'https://docs.commongateway.nl/schemas/ActionHandler.schema.json', + 'title' => 'SyncZGWZakenHandler', + 'description' => 'Handles the sync for zgw zaken.', + 'required' => [], + 'properties' => [], + ]; + + }//end getConfiguration() + + + /** + * This function runs the SyncZGWZaken service plugin. + * + * @param array $data The data from the call + * @param array $configuration The configuration of the action + * + * @throws TransportExceptionInterface|LoaderError|RuntimeError|SyntaxError + * + * @return array + */ + public function run(array $data, array $configuration): array + { + return $this->service->syncZGWZakenHandler($data, $configuration); + + }//end run() + + +}//end class diff --git a/src/Service/SyncCasesService.php b/src/Service/SyncXxllncCasesService.php similarity index 95% rename from src/Service/SyncCasesService.php rename to src/Service/SyncXxllncCasesService.php index b75a4df..a69d121 100644 --- a/src/Service/SyncCasesService.php +++ b/src/Service/SyncXxllncCasesService.php @@ -14,7 +14,7 @@ use Symfony\Component\Console\Style\SymfonyStyle; /** - * Service responsible for synchronizing cases to woo objects. + * Service responsible for synchronizing xxllnc cases to woo objects. * * @author Conduction BV (info@conduction.nl), Barry Brands (barry@conduction.nl). * @license EUPL @@ -22,7 +22,7 @@ * @package CommonGateway\PDDBundle * @category Service */ -class SyncCasesService +class SyncXxllncCasesService { /** @@ -67,7 +67,7 @@ class SyncCasesService /** - * SyncCasesService constructor. + * SyncXxllncCasesService constructor. * * @param GatewayResourceService $resourceService * @param CallService $callService @@ -119,12 +119,12 @@ public function setStyle(SymfonyStyle $style): self * * @return array */ - public function syncCasesHandler(array $data, array $configuration): array + public function syncXxllncCasesHandler(array $data, array $configuration): array { $this->data = $data; $this->configuration = $configuration; - isset($this->style) === true && $this->style->success('SyncCasesService triggered'); + isset($this->style) === true && $this->style->success('SyncXxllncCasesService triggered'); $sourceRef = 'https://commongateway.woo.nl/source/noordwijk.zaaksysteem.source.json'; $source = $this->resourceService->getSource($sourceRef, 'common-gateway/pdd-bundle'); diff --git a/src/Service/SyncZGWZakenService.php b/src/Service/SyncZGWZakenService.php new file mode 100644 index 0000000..9323ad0 --- /dev/null +++ b/src/Service/SyncZGWZakenService.php @@ -0,0 +1,180 @@ + + * + * @package CommonGateway\PDDBundle + * @category Service + */ +class SyncZGWZakenService +{ + + /** + * @var GatewayResourceService + */ + private GatewayResourceService $resourceService; + + /** + * @var CallService + */ + private CallService $callService; + + /** + * @var SynchronizationService + */ + private SynchronizationService $syncService; + + /** + * @var MappingService + */ + private MappingService $mappingService; + + /** + * @var EntityManagerInterface + */ + private EntityManagerInterface $entityManager; + + /** + * @var SymfonyStyle|null + */ + private ?SymfonyStyle $style = null; + + /** + * @var array + */ + private array $data; + + /** + * @var array + */ + private array $configuration; + + + /** + * SyncZGWZakenService constructor. + * + * @param GatewayResourceService $resourceService + * @param CallService $callService + * @param SynchronizationService $syncService + * @param EntityManagerInterface $entityManager + * @param MappingService $mappingService + */ + public function __construct( + GatewayResourceService $resourceService, + CallService $callService, + SynchronizationService $syncService, + EntityManagerInterface $entityManager, + MappingService $mappingService + ) { + $this->resourceService = $resourceService; + $this->callService = $callService; + $this->syncService = $syncService; + $this->entityManager = $entityManager; + $this->mappingService = $mappingService; + + }//end __construct() + + + /** + * Set symfony style in order to output to the console. + * + * @param SymfonyStyle $style + * + * @return self + * + * @todo change to monolog + */ + public function setStyle(SymfonyStyle $style): self + { + $this->style = $style; + + return $this; + + }//end setStyle() + + + /** + * Handles the synchronization of zgw zaken. + * + * @param array $data + * @param array $configuration + * + * @throws CacheException|InvalidArgumentException + * + * @return array + */ + public function syncZGWZakenHandler(array $data, array $configuration): array + { + $this->data = $data; + $this->configuration = $configuration; + + isset($this->style) === true && $this->style->success('SyncZGWZakenService triggered'); + + $sourceRef = 'https://commongateway.woo.nl/source/zgw.source.json'; + $source = $this->resourceService->getSource($sourceRef, 'common-gateway/pdd-bundle'); + if ($source === null) { + isset($this->style) === true && $this->style->error("$sourceRef not found."); + return []; + } + + $schemaRef = 'https://commongateway.nl/pdd.openWOO.schema.json'; + $schema = $this->resourceService->getSchema($schemaRef, 'common-gateway/pdd-bundle'); + if ($schema === null) { + isset($this->style) === true && $this->style->error("$schemaRef not found."); + return []; + } + + $mappingRef = 'https://commongateway.nl/mapping/pdd.zgwZaakToWoo.mapping.json'; + $mapping = $this->resourceService->getMapping($mappingRef, 'common-gateway/pdd-bundle'); + if ($mapping === null) { + isset($this->style) === true && $this->style->error("$mappingRef not found."); + return []; + } + + $sourceConfig = $source->getConfiguration(); + + isset($this->style) === true && $this->style->info("Fetching cases from {$source->getLocation()}"); + + $response = $this->callService->call($source, '/zrc/v1/zaken', 'GET', $sourceConfig); + $decodedResponse = $this->callService->decodeResponse($source, $response); + + $zaken = []; + foreach ($decodedResponse['result'] as $result) { + $result = $this->mappingService->mapping($mapping, $result); + $hydrationService = new HydrationService($this->syncService, $this->entityManager); + $object = $hydrationService->searchAndReplaceSynchronizations( + $result, + $source, + $schema, + true, + true + ); + $zaken[] = $object; + } + + $this->data['response'] = new Response(json_encode($responseItems), 200); + + isset($this->style) === true && $this->style->success("Synchronized cases to woo objects."); + + return $this->data; + + }//end syncCasesHandler() + + +}//end class From a49176d77e914b666de267631c89180abd96ac1a Mon Sep 17 00:00:00 2001 From: GitHub Actions <> Date: Tue, 22 Aug 2023 09:29:17 +0000 Subject: [PATCH 03/15] Update src from PHP Codesniffer --- src/Service/SyncXxllncCasesService.php | 2 +- src/Service/SyncZGWZakenService.php | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Service/SyncXxllncCasesService.php b/src/Service/SyncXxllncCasesService.php index a69d121..861c84d 100644 --- a/src/Service/SyncXxllncCasesService.php +++ b/src/Service/SyncXxllncCasesService.php @@ -175,7 +175,7 @@ public function syncXxllncCasesHandler(array $data, array $configuration): array return $this->data; - }//end syncCasesHandler() + }//end syncXxllncCasesHandler() }//end class diff --git a/src/Service/SyncZGWZakenService.php b/src/Service/SyncZGWZakenService.php index 9323ad0..9cbf615 100644 --- a/src/Service/SyncZGWZakenService.php +++ b/src/Service/SyncZGWZakenService.php @@ -165,7 +165,7 @@ public function syncZGWZakenHandler(array $data, array $configuration): array true, true ); - $zaken[] = $object; + $zaken[] = $object; } $this->data['response'] = new Response(json_encode($responseItems), 200); @@ -174,7 +174,7 @@ public function syncZGWZakenHandler(array $data, array $configuration): array return $this->data; - }//end syncCasesHandler() + }//end syncZGWZakenHandler() }//end class From 329f7858f4b333f78bca3b73da686c18215a5c52 Mon Sep 17 00:00:00 2001 From: Barry Brands Date: Wed, 23 Aug 2023 12:03:42 +0200 Subject: [PATCH 04/15] removed stuff from other branch --- .../Action/pdd.SyncZGWZakenAction.action.json | 12 -- ...dd.zgwZaakInfoObjectToBijlage.mapping.json | 14 -- .../Mapping/pdd.zgwZaakToWoo.mapping.json | 42 ---- Installation/Source/zgw.source.json | 8 - src/ActionHandler/SyncZGWZakenHandler.php | 78 -------- src/Service/SyncZGWZakenService.php | 180 ------------------ 6 files changed, 334 deletions(-) delete mode 100644 Installation/Action/pdd.SyncZGWZakenAction.action.json delete mode 100644 Installation/Mapping/pdd.zgwZaakInfoObjectToBijlage.mapping.json delete mode 100644 Installation/Mapping/pdd.zgwZaakToWoo.mapping.json delete mode 100644 Installation/Source/zgw.source.json delete mode 100644 src/ActionHandler/SyncZGWZakenHandler.php delete mode 100644 src/Service/SyncZGWZakenService.php diff --git a/Installation/Action/pdd.SyncZGWZakenAction.action.json b/Installation/Action/pdd.SyncZGWZakenAction.action.json deleted file mode 100644 index dd4c388..0000000 --- a/Installation/Action/pdd.SyncZGWZakenAction.action.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "title": "SyncZGWZakenAction", - "$id": "https://commongateway.nl/pdd.SyncZGWZakenAction.action.json", - "$schema": "https://docs.commongateway.nl/schemas/Action.schema.json", - "version": "0.0.1", - "listens": ["pdd.default.listens"], - "conditions": - { - "==": [1, 1] - }, - "class": "CommonGateway\\PDDBundle\\ActionHandler\\SyncZGWZakenHandler" -} \ No newline at end of file diff --git a/Installation/Mapping/pdd.zgwZaakInfoObjectToBijlage.mapping.json b/Installation/Mapping/pdd.zgwZaakInfoObjectToBijlage.mapping.json deleted file mode 100644 index 9486c46..0000000 --- a/Installation/Mapping/pdd.zgwZaakInfoObjectToBijlage.mapping.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "title": "ZGWZaakInfoObjectToBijlage", - "$id": "https://commongateway.nl/mapping/pdd.zgwZaakInfoObjectToBijlage.mapping.json", - "$schema": "https://docs.commongateway.nl/schemas/Mapping.schema.json", - "version": "0.0.1", - "passTrough": false, - "mapping": { - "Type_Bijlage": "informatieobject.formaat", - "Status_Bijlage": "informatieobject.status", - "Tijdstip_laatste_wijziging_bijlage": "", - "Titel_Bijlage": "informatieobject.titel", - "URL_Bijlage": "informatieobject.inhoud" - } -} diff --git a/Installation/Mapping/pdd.zgwZaakToWoo.mapping.json b/Installation/Mapping/pdd.zgwZaakToWoo.mapping.json deleted file mode 100644 index 7460e7b..0000000 --- a/Installation/Mapping/pdd.zgwZaakToWoo.mapping.json +++ /dev/null @@ -1,42 +0,0 @@ -{ - "title": "ZGWZaakToWoo", - "$id": "https://commongateway.nl/mapping/pdd.zgwZaakToWoo.mapping.json", - "$schema": "https://docs.commongateway.nl/schemas/Mapping.schema.json", - "version": "0.0.1", - "passTrough": false, - "mapping": { - "_sourceId": "uuid", - "UUID": "uuid", - "ID": "identificatie", - "Object_ID": "", - "Portal_url": "", - "Behandelend_bestuursorgaan": "", - "Ontvanger_informatieverzoek": "", - "Volgnummer": "", - "Titel": "zaaktype.omschrijving", - "Beschrijving": "omschrijving", - "Samenvatting": "omschrijving", - "Verzoeker": "rollen.0.omschrijving", - "Ontvangstdatum": "startdatum", - "Besluitdatum": "einddatum", - "Behandelstatus": "status.statustype.omschrijving", - "Besluit": "besluit.besluittype.omschrijving", - "Termijnoverschrijding": "", - "URL_informatieverzoek": "", - "URL_inventarisatielijst": "", - "URL_besluit": "", - "Geografisch_gebied": "", - "BAG_ID": "", - "BGT_ID": "", - "Postcodegebied": "", - "Adres": "", - "COORDS": "", - "Geografische_positie": "", - "Bijlagen": "[{% set index=0 %}{% if zaakinformatieobjecten|default %}{% for infoObject in zaakinformatieobjecten %}{% if index != 0 %},{% endif %}{{ map('https://commongateway.nl/mapping/pdd.zgwZaakInfoObjectToBijlage.mapping.json', infoObject)|json_encode }}{% set index=index+1 %}{% endfor %}{% endif %}]", - "Themas": "" - }, - "cast": { - "Bijlagen": "jsonToArray" - } - } - \ No newline at end of file diff --git a/Installation/Source/zgw.source.json b/Installation/Source/zgw.source.json deleted file mode 100644 index 069118c..0000000 --- a/Installation/Source/zgw.source.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "title": "ZGW", - "$id": "https://commongateway.woo.nl/source/zgw.source.json", - "$schema": "https://docs.commongateway.nl/schemas/Gateway.schema.json", - "version": "0.0.1", - "description": "ZGW api", - "location": "!ChangeMe!" -} \ No newline at end of file diff --git a/src/ActionHandler/SyncZGWZakenHandler.php b/src/ActionHandler/SyncZGWZakenHandler.php deleted file mode 100644 index 67e911e..0000000 --- a/src/ActionHandler/SyncZGWZakenHandler.php +++ /dev/null @@ -1,78 +0,0 @@ -SyncZGWZakenHandler. - * - * @author Conduction BV (info@conduction.nl), Barry Brands (barry@conduction.nl) - * @license EUPL - * - * @package CommonGateway\PDDBundle - * @category ActionHandler - */ -class SyncZGWZakenHandler implements ActionHandlerInterface -{ - - /** - * @var SyncZGWZakenService - */ - private SyncZGWZakenService $service; - - - /** - * SyncZGWZakenHandler constructor. - * - * @param SyncZGWZakenService $service - */ - public function __construct(SyncZGWZakenService $service) - { - $this->service = $service; - - }//end __construct() - - - /** - * This function returns the requered configuration as a [json-schema](https://json-schema.org/) array. - * - * @throws array a [json-schema](https://json-schema.org/) that this action should comply to - */ - public function getConfiguration(): array - { - return [ - '$id' => 'https://commongateway.nl/pdd.SyncZGWZaken.action.json', - '$schema' => 'https://docs.commongateway.nl/schemas/ActionHandler.schema.json', - 'title' => 'SyncZGWZakenHandler', - 'description' => 'Handles the sync for zgw zaken.', - 'required' => [], - 'properties' => [], - ]; - - }//end getConfiguration() - - - /** - * This function runs the SyncZGWZaken service plugin. - * - * @param array $data The data from the call - * @param array $configuration The configuration of the action - * - * @throws TransportExceptionInterface|LoaderError|RuntimeError|SyntaxError - * - * @return array - */ - public function run(array $data, array $configuration): array - { - return $this->service->syncZGWZakenHandler($data, $configuration); - - }//end run() - - -}//end class diff --git a/src/Service/SyncZGWZakenService.php b/src/Service/SyncZGWZakenService.php deleted file mode 100644 index 9cbf615..0000000 --- a/src/Service/SyncZGWZakenService.php +++ /dev/null @@ -1,180 +0,0 @@ - - * - * @package CommonGateway\PDDBundle - * @category Service - */ -class SyncZGWZakenService -{ - - /** - * @var GatewayResourceService - */ - private GatewayResourceService $resourceService; - - /** - * @var CallService - */ - private CallService $callService; - - /** - * @var SynchronizationService - */ - private SynchronizationService $syncService; - - /** - * @var MappingService - */ - private MappingService $mappingService; - - /** - * @var EntityManagerInterface - */ - private EntityManagerInterface $entityManager; - - /** - * @var SymfonyStyle|null - */ - private ?SymfonyStyle $style = null; - - /** - * @var array - */ - private array $data; - - /** - * @var array - */ - private array $configuration; - - - /** - * SyncZGWZakenService constructor. - * - * @param GatewayResourceService $resourceService - * @param CallService $callService - * @param SynchronizationService $syncService - * @param EntityManagerInterface $entityManager - * @param MappingService $mappingService - */ - public function __construct( - GatewayResourceService $resourceService, - CallService $callService, - SynchronizationService $syncService, - EntityManagerInterface $entityManager, - MappingService $mappingService - ) { - $this->resourceService = $resourceService; - $this->callService = $callService; - $this->syncService = $syncService; - $this->entityManager = $entityManager; - $this->mappingService = $mappingService; - - }//end __construct() - - - /** - * Set symfony style in order to output to the console. - * - * @param SymfonyStyle $style - * - * @return self - * - * @todo change to monolog - */ - public function setStyle(SymfonyStyle $style): self - { - $this->style = $style; - - return $this; - - }//end setStyle() - - - /** - * Handles the synchronization of zgw zaken. - * - * @param array $data - * @param array $configuration - * - * @throws CacheException|InvalidArgumentException - * - * @return array - */ - public function syncZGWZakenHandler(array $data, array $configuration): array - { - $this->data = $data; - $this->configuration = $configuration; - - isset($this->style) === true && $this->style->success('SyncZGWZakenService triggered'); - - $sourceRef = 'https://commongateway.woo.nl/source/zgw.source.json'; - $source = $this->resourceService->getSource($sourceRef, 'common-gateway/pdd-bundle'); - if ($source === null) { - isset($this->style) === true && $this->style->error("$sourceRef not found."); - return []; - } - - $schemaRef = 'https://commongateway.nl/pdd.openWOO.schema.json'; - $schema = $this->resourceService->getSchema($schemaRef, 'common-gateway/pdd-bundle'); - if ($schema === null) { - isset($this->style) === true && $this->style->error("$schemaRef not found."); - return []; - } - - $mappingRef = 'https://commongateway.nl/mapping/pdd.zgwZaakToWoo.mapping.json'; - $mapping = $this->resourceService->getMapping($mappingRef, 'common-gateway/pdd-bundle'); - if ($mapping === null) { - isset($this->style) === true && $this->style->error("$mappingRef not found."); - return []; - } - - $sourceConfig = $source->getConfiguration(); - - isset($this->style) === true && $this->style->info("Fetching cases from {$source->getLocation()}"); - - $response = $this->callService->call($source, '/zrc/v1/zaken', 'GET', $sourceConfig); - $decodedResponse = $this->callService->decodeResponse($source, $response); - - $zaken = []; - foreach ($decodedResponse['result'] as $result) { - $result = $this->mappingService->mapping($mapping, $result); - $hydrationService = new HydrationService($this->syncService, $this->entityManager); - $object = $hydrationService->searchAndReplaceSynchronizations( - $result, - $source, - $schema, - true, - true - ); - $zaken[] = $object; - } - - $this->data['response'] = new Response(json_encode($responseItems), 200); - - isset($this->style) === true && $this->style->success("Synchronized cases to woo objects."); - - return $this->data; - - }//end syncZGWZakenHandler() - - -}//end class From e2e063a5fc0f028a973359c7364a2e62b0181174 Mon Sep 17 00:00:00 2001 From: Barry Brands Date: Wed, 23 Aug 2023 12:05:12 +0200 Subject: [PATCH 05/15] Noordwijk specific sync config added --- .../Action/pdd.SyncCasesAction.action.json | 12 ------------ .../pdd.SyncNoordwijkCasesAction.action.json | 16 ++++++++++++++++ Installation/Cronjob/pdd.default.cronjob.json | 4 ++-- Installation/Cronjob/pdd.noordwijk.cronjob.json | 12 ++++++++++++ .../Mapping/pdd.xxllncCaseToWoo.mapping.json | 3 ++- src/Service/SyncXxllncCasesService.php | 17 ++++++++++++++--- 6 files changed, 46 insertions(+), 18 deletions(-) delete mode 100644 Installation/Action/pdd.SyncCasesAction.action.json create mode 100644 Installation/Action/pdd.SyncNoordwijkCasesAction.action.json create mode 100644 Installation/Cronjob/pdd.noordwijk.cronjob.json diff --git a/Installation/Action/pdd.SyncCasesAction.action.json b/Installation/Action/pdd.SyncCasesAction.action.json deleted file mode 100644 index e72eaa1..0000000 --- a/Installation/Action/pdd.SyncCasesAction.action.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "title": "SyncXxllncCasesAction", - "$id": "https://commongateway.nl/pdd.SyncCasesAction.action.json", - "$schema": "https://docs.commongateway.nl/schemas/Action.schema.json", - "version": "0.0.3", - "listens": ["pdd.default.listens"], - "conditions": - { - "==": [1, 1] - }, - "class": "CommonGateway\\PDDBundle\\ActionHandler\\SyncXxllncCasesHandler" -} \ No newline at end of file diff --git a/Installation/Action/pdd.SyncNoordwijkCasesAction.action.json b/Installation/Action/pdd.SyncNoordwijkCasesAction.action.json new file mode 100644 index 0000000..8e44d08 --- /dev/null +++ b/Installation/Action/pdd.SyncNoordwijkCasesAction.action.json @@ -0,0 +1,16 @@ +{ + "title": "SyncNoordwijkCasesAction", + "$id": "https://commongateway.nl/pdd.SyncNoordwijkAction.action.json", + "$schema": "https://docs.commongateway.nl/schemas/Action.schema.json", + "version": "0.0.1", + "listens": ["pdd.default.listens","pdd.noordwijk.listens"], + "configuration": { + "oidn": "unknown", + "source": "https://commongateway.woo.nl/source/noordwijk.zaaksysteem.source.json" + }, + "conditions": + { + "==": [1, 1] + }, + "class": "CommonGateway\\PDDBundle\\ActionHandler\\SyncXxllncCasesHandler" +} \ No newline at end of file diff --git a/Installation/Cronjob/pdd.default.cronjob.json b/Installation/Cronjob/pdd.default.cronjob.json index 8be5201..0087c36 100644 --- a/Installation/Cronjob/pdd.default.cronjob.json +++ b/Installation/Cronjob/pdd.default.cronjob.json @@ -1,8 +1,8 @@ { - "title": "PDD cronjob", + "title": "PDD default cronjob", "$id": "https://commongateway.nl/pdd.default.cronjob.json", "$schema": "https://docs.commongateway.nl/schemas/Cronjob.schema.json", - "version": "0.0.1", + "version": "0.0.2", "description": "This cronjob fires all the pdd actions every 5 minutes", "crontab": "*/5 * * * *", "throws": [ diff --git a/Installation/Cronjob/pdd.noordwijk.cronjob.json b/Installation/Cronjob/pdd.noordwijk.cronjob.json new file mode 100644 index 0000000..b62c7d6 --- /dev/null +++ b/Installation/Cronjob/pdd.noordwijk.cronjob.json @@ -0,0 +1,12 @@ +{ + "title": "PDD noordwijk cronjob", + "$id": "https://commongateway.nl/pdd.noordwijk.cronjob.json", + "$schema": "https://docs.commongateway.nl/schemas/Cronjob.schema.json", + "version": "0.0.1", + "description": "This cronjob fires the Noordwijk actions every 5 minutes", + "crontab": "*/5 * * * *", + "throws": [ + "pdd.noordwijk.listens" + ], + "isEnabled": false +} \ No newline at end of file diff --git a/Installation/Mapping/pdd.xxllncCaseToWoo.mapping.json b/Installation/Mapping/pdd.xxllncCaseToWoo.mapping.json index fb58ac2..d6bba39 100644 --- a/Installation/Mapping/pdd.xxllncCaseToWoo.mapping.json +++ b/Installation/Mapping/pdd.xxllncCaseToWoo.mapping.json @@ -2,10 +2,11 @@ "title": "XxllncCaseToWoo", "$id": "https://commongateway.nl/mapping/pdd.xxllncCaseToWoo.schema.json", "$schema": "https://docs.commongateway.nl/schemas/Mapping.schema.json", - "version": "0.0.1", + "version": "0.0.2", "passTrough": false, "mapping": { "_sourceId": "id", + "oidn": "{% if oidn|default %}oidn{% else %}unknown{% endif %}", "UUID": "case.class_uuid", "ID": "id", "Object_ID": "object_id", diff --git a/src/Service/SyncXxllncCasesService.php b/src/Service/SyncXxllncCasesService.php index 861c84d..b0a328e 100644 --- a/src/Service/SyncXxllncCasesService.php +++ b/src/Service/SyncXxllncCasesService.php @@ -126,10 +126,20 @@ public function syncXxllncCasesHandler(array $data, array $configuration): array isset($this->style) === true && $this->style->success('SyncXxllncCasesService triggered'); - $sourceRef = 'https://commongateway.woo.nl/source/noordwijk.zaaksysteem.source.json'; - $source = $this->resourceService->getSource($sourceRef, 'common-gateway/pdd-bundle'); + if (isset($this->configuration['source']) === false) { + isset($this->style) === true && $this->style->error('No source configured on this action, ending action.'); + + return []; + } + if (isset($this->configuration['oidn']) === false) { + isset($this->style) === true && $this->style->error('No oidn configured on this action, ending action.'); + + return []; + } + + $source = $this->resourceService->getSource($this->configuration['source'], 'common-gateway/pdd-bundle'); if ($source === null) { - isset($this->style) === true && $this->style->error("$sourceRef not found."); + isset($this->style) === true && $this->style->error("{$this->configuration['source']} not found."); return []; } @@ -156,6 +166,7 @@ public function syncXxllncCasesHandler(array $data, array $configuration): array $responseItems = []; foreach ($decodedResponse['result'] as $result) { + $result = array_merge($result, ['oidn' => $this->configuration['oidn']]); $result = $this->mappingService->mapping($mapping, $result); $hydrationService = new HydrationService($this->syncService, $this->entityManager); $object = $hydrationService->searchAndReplaceSynchronizations( From 98e53712e67a1454388a7f3f57dbf3bbba9e0285 Mon Sep 17 00:00:00 2001 From: Barry Brands Date: Wed, 23 Aug 2023 13:26:31 +0200 Subject: [PATCH 06/15] give action ref to command --- ...Command.php => SyncXxllncCasesCommand.php} | 38 +++++++++++-------- 1 file changed, 22 insertions(+), 16 deletions(-) rename src/Command/{SyncCasesCommand.php => SyncXxllncCasesCommand.php} (62%) diff --git a/src/Command/SyncCasesCommand.php b/src/Command/SyncXxllncCasesCommand.php similarity index 62% rename from src/Command/SyncCasesCommand.php rename to src/Command/SyncXxllncCasesCommand.php index 07eea0f..600201c 100644 --- a/src/Command/SyncCasesCommand.php +++ b/src/Command/SyncXxllncCasesCommand.php @@ -3,7 +3,7 @@ namespace CommonGateway\PDDBundle\Command; use App\Entity\Action; -use CommonGateway\PDDBundle\Service\SyncCasesService; +use CommonGateway\PDDBundle\Service\SyncXxllncCasesService; use Doctrine\ORM\EntityManagerInterface; use Ramsey\Uuid\Uuid; use Symfony\Component\Console\Command\Command; @@ -15,7 +15,7 @@ /** * This class handles the command for the synchronization of a xxllnc case to a woo object. * - * This Command executes the syncCaseService->syncCasesHandler. + * This Command executes the syncXxllncCasesService->syncXxllncCasesHandler. * * @author Conduction BV , Barry Brands * @license EUPL-1.2 https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12 @@ -23,7 +23,7 @@ * @package CommonGateway\PDDBundle * @category Command */ -class SyncCasesCommand extends Command +class SyncXxllncCasesCommand extends Command { /** @@ -36,9 +36,9 @@ class SyncCasesCommand extends Command /** * The case service. * - * @var SyncCasesService + * @var SyncXxllncCasesService */ - private SyncCasesService $syncCaseService; + private SyncXxllncCasesService $syncXxllncCasesService; /** * @var EntityManagerInterface @@ -49,11 +49,11 @@ class SyncCasesCommand extends Command /** * Class constructor. * - * @param SyncCasesService $syncCaseService The case service + * @param SyncXxllncCasesService $syncXxllncCasesService The case service */ - public function __construct(SyncCasesService $syncCaseService, EntityManagerInterface $entityManager) + public function __construct(SyncXxllncCasesService $syncXxllncCasesService, EntityManagerInterface $entityManager) { - $this->syncCaseService = $syncCaseService; + $this->syncXxllncCasesService = $syncXxllncCasesService; $this->entityManager = $entityManager; parent::__construct(); @@ -68,19 +68,24 @@ public function __construct(SyncCasesService $syncCaseService, EntityManagerInte protected function configure(): void { $this - ->setDescription('This command triggers SyncCasesService') - ->setHelp('This command triggers SyncCasesService') + ->setDescription('This command triggers SyncXxllncCasesService') + ->setHelp('This command triggers SyncXxllncCasesService') ->addArgument( 'id', InputArgument::OPTIONAL, 'Case id to fetch from xxllnc' + ) + ->addArgument( + 'action', + InputArgument::OPTIONAL, + 'Action reference to find the action and execute for different organizations (municipalities)' ); }//end configure() /** - * Executes syncCaseService->syncCasesHandler or syncCaseService->getCase if a id is given. + * Executes syncXxllncCasesService->syncXxllncCasesHandler or syncXxllncCasesService->getCase if a id is given. * * @param InputInterface Handles input from cli * @param OutputInterface Handles output from cli @@ -90,12 +95,13 @@ protected function configure(): void protected function execute(InputInterface $input, OutputInterface $output): int { $style = new SymfonyStyle($input, $output); - $this->syncCaseService->setStyle($style); + $this->syncXxllncCasesService->setStyle($style); $caseId = $input->getArgument('id'); + $actionRef = $input->getArgument('action'); - $action = $this->entityManager->getRepository('App:Action')->findOneBy(['reference' => 'https://commongateway.nl/pdd.SyncCasesAction.action.json']); + $action = $this->entityManager->getRepository('App:Action')->findOneBy(['reference' => $actionRef]); if ($action instanceof Action === null) { - $style->error('Action with reference https://commongateway.nl/pdd.SyncCasesAction.action.json not found'); + $style->error("Action with reference $actionRef not found"); return Command::FAILURE; } @@ -103,7 +109,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int if (isset($caseId) === true && Uuid::isValid($caseId) === true ) { - // if ($this->syncCaseService->getZaak($action->getConfiguration(), $caseId) === true) { + // if ($this->syncXxllncCasesService->getZaak($action->getConfiguration(), $caseId) === true) { // return Command::FAILURE; // } isset($style) === true && $style->info("Succesfully synced and created a WOO object from xxllnc case: $caseId."); @@ -111,7 +117,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int return Command::SUCCESS; }//end if - if ($this->syncCaseService->syncCasesHandler([], $action->getConfiguration()) === null) { + if ($this->syncXxllncCasesService->syncXxllncCasesHandler([], $action->getConfiguration()) === null) { return Command::FAILURE; } From dc0d8bbf8c37402a6630221e98f7a0db9dd0d82d Mon Sep 17 00:00:00 2001 From: Barry Brands Date: Wed, 23 Aug 2023 13:27:01 +0200 Subject: [PATCH 07/15] mapping fix --- Installation/Mapping/pdd.xxllncCaseToWoo.mapping.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Installation/Mapping/pdd.xxllncCaseToWoo.mapping.json b/Installation/Mapping/pdd.xxllncCaseToWoo.mapping.json index d6bba39..b4f8336 100644 --- a/Installation/Mapping/pdd.xxllncCaseToWoo.mapping.json +++ b/Installation/Mapping/pdd.xxllncCaseToWoo.mapping.json @@ -6,7 +6,7 @@ "passTrough": false, "mapping": { "_sourceId": "id", - "oidn": "{% if oidn|default %}oidn{% else %}unknown{% endif %}", + "oidn": "{% if oidn|default %}{{ oidn }}{% else %}unknown{% endif %}", "UUID": "case.class_uuid", "ID": "id", "Object_ID": "object_id", From 30a800ab283496ceda1ff88a2254108f8b016c7e Mon Sep 17 00:00:00 2001 From: GitHub Actions <> Date: Wed, 23 Aug 2023 11:27:27 +0000 Subject: [PATCH 08/15] Update src from PHP Codesniffer --- src/Command/SyncXxllncCasesCommand.php | 4 ++-- src/Service/SyncXxllncCasesService.php | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/Command/SyncXxllncCasesCommand.php b/src/Command/SyncXxllncCasesCommand.php index 600201c..0b782d5 100644 --- a/src/Command/SyncXxllncCasesCommand.php +++ b/src/Command/SyncXxllncCasesCommand.php @@ -54,7 +54,7 @@ class SyncXxllncCasesCommand extends Command public function __construct(SyncXxllncCasesService $syncXxllncCasesService, EntityManagerInterface $entityManager) { $this->syncXxllncCasesService = $syncXxllncCasesService; - $this->entityManager = $entityManager; + $this->entityManager = $entityManager; parent::__construct(); }//end __construct() @@ -96,7 +96,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int { $style = new SymfonyStyle($input, $output); $this->syncXxllncCasesService->setStyle($style); - $caseId = $input->getArgument('id'); + $caseId = $input->getArgument('id'); $actionRef = $input->getArgument('action'); $action = $this->entityManager->getRepository('App:Action')->findOneBy(['reference' => $actionRef]); diff --git a/src/Service/SyncXxllncCasesService.php b/src/Service/SyncXxllncCasesService.php index b0a328e..1766fec 100644 --- a/src/Service/SyncXxllncCasesService.php +++ b/src/Service/SyncXxllncCasesService.php @@ -131,13 +131,14 @@ public function syncXxllncCasesHandler(array $data, array $configuration): array return []; } + if (isset($this->configuration['oidn']) === false) { isset($this->style) === true && $this->style->error('No oidn configured on this action, ending action.'); return []; } - $source = $this->resourceService->getSource($this->configuration['source'], 'common-gateway/pdd-bundle'); + $source = $this->resourceService->getSource($this->configuration['source'], 'common-gateway/pdd-bundle'); if ($source === null) { isset($this->style) === true && $this->style->error("{$this->configuration['source']} not found."); return []; @@ -166,7 +167,7 @@ public function syncXxllncCasesHandler(array $data, array $configuration): array $responseItems = []; foreach ($decodedResponse['result'] as $result) { - $result = array_merge($result, ['oidn' => $this->configuration['oidn']]); + $result = array_merge($result, ['oidn' => $this->configuration['oidn']]); $result = $this->mappingService->mapping($mapping, $result); $hydrationService = new HydrationService($this->syncService, $this->entityManager); $object = $hydrationService->searchAndReplaceSynchronizations( From f095076daeca80de042ac468a60ca6cd05b5f08b Mon Sep 17 00:00:00 2001 From: Barry Brands Date: Fri, 25 Aug 2023 10:31:25 +0200 Subject: [PATCH 09/15] logs added --- src/Service/SyncXxllncCasesService.php | 32 +++++++++++++++++++------- 1 file changed, 24 insertions(+), 8 deletions(-) diff --git a/src/Service/SyncXxllncCasesService.php b/src/Service/SyncXxllncCasesService.php index 1766fec..68dd8dd 100644 --- a/src/Service/SyncXxllncCasesService.php +++ b/src/Service/SyncXxllncCasesService.php @@ -12,6 +12,7 @@ use Psr\Cache\InvalidArgumentException; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\Console\Style\SymfonyStyle; +use Psr\Log\LoggerInterface; /** * Service responsible for synchronizing xxllnc cases to woo objects. @@ -55,6 +56,11 @@ class SyncXxllncCasesService */ private ?SymfonyStyle $style = null; + /** + * @var LoggerInterface $logger. + */ + private LoggerInterface $logger; + /** * @var array */ @@ -74,20 +80,22 @@ class SyncXxllncCasesService * @param SynchronizationService $syncService * @param EntityManagerInterface $entityManager * @param MappingService $mappingService + * @param LoggerInterface $pluginLogger */ public function __construct( GatewayResourceService $resourceService, CallService $callService, SynchronizationService $syncService, EntityManagerInterface $entityManager, - MappingService $mappingService + MappingService $mappingService, + LoggerInterface $pluginLogger ) { $this->resourceService = $resourceService; $this->callService = $callService; $this->syncService = $syncService; $this->entityManager = $entityManager; $this->mappingService = $mappingService; - + $this->logger = $pluginLogger; }//end __construct() @@ -125,42 +133,49 @@ public function syncXxllncCasesHandler(array $data, array $configuration): array $this->configuration = $configuration; isset($this->style) === true && $this->style->success('SyncXxllncCasesService triggered'); + $this->logger->info('SyncXxllncCasesService triggered'); if (isset($this->configuration['source']) === false) { - isset($this->style) === true && $this->style->error('No source configured on this action, ending action.'); + isset($this->style) === true && $this->style->error('No source configured on this action, ending syncXxllncCasesHandler'); + $this->logger->error('No source configured on this action, ending syncXxllncCasesHandler'); return []; } if (isset($this->configuration['oidn']) === false) { - isset($this->style) === true && $this->style->error('No oidn configured on this action, ending action.'); + isset($this->style) === true && $this->style->error('No oidn configured on this action, ending syncXxllncCasesHandler'); + $this->logger->error('No oidn configured on this action, ending syncXxllncCasesHandler'); return []; } $source = $this->resourceService->getSource($this->configuration['source'], 'common-gateway/pdd-bundle'); if ($source === null) { - isset($this->style) === true && $this->style->error("{$this->configuration['source']} not found."); + isset($this->style) === true && $this->style->error("{$this->configuration['source']} not found, ending syncXxllncCasesHandler"); + $this->logger->error("{$this->configuration['source']} not found, ending syncXxllncCasesHandler"); return []; } $schemaRef = 'https://commongateway.nl/pdd.openWOO.schema.json'; $schema = $this->resourceService->getSchema($schemaRef, 'common-gateway/pdd-bundle'); if ($schema === null) { - isset($this->style) === true && $this->style->error("$schemaRef not found."); + isset($this->style) === true && $this->style->error("$schemaRef not found, ending syncXxllncCasesHandler"); + $this->logger->error("$schemaRef not found, ending syncXxllncCasesHandlerr"); return []; } $mappingRef = 'https://commongateway.nl/mapping/pdd.xxllncCaseToWoo.schema.json'; $mapping = $this->resourceService->getMapping($mappingRef, 'common-gateway/pdd-bundle'); if ($mapping === null) { - isset($this->style) === true && $this->style->error("$mappingRef not found."); + isset($this->style) === true && $this->style->error("$mappingRef not found, ending syncXxllncCasesHandler"); + $this->logger->error("$mappingRef not found, ending syncXxllncCasesHandlerr"); return []; } $sourceConfig = $source->getConfiguration(); isset($this->style) === true && $this->style->info("Fetching cases from {$source->getLocation()}"); + $this->logger->info("Fetching cases from {$source->getLocation()}"); $response = $this->callService->call($source, '', 'GET', $sourceConfig); $decodedResponse = $this->callService->decodeResponse($source, $response); @@ -183,7 +198,8 @@ public function syncXxllncCasesHandler(array $data, array $configuration): array $this->data['response'] = new Response(json_encode($responseItems), 200); - isset($this->style) === true && $this->style->success("Synchronized cases to woo objects."); + isset($this->style) === true && $this->style->success("Synchronized cases to woo objects for " . $source->getName()); + $this->logger->info("Synchronized cases to woo objects for " . $source->getName()); return $this->data; From 62987377b6b96fae44be24dd8ad1a601c0569a58 Mon Sep 17 00:00:00 2001 From: Barry Brands Date: Fri, 25 Aug 2023 10:32:56 +0200 Subject: [PATCH 10/15] .phpdoc-md added new service --- .phpdoc-md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.phpdoc-md b/.phpdoc-md index 60ca52d..26856a4 100644 --- a/.phpdoc-md +++ b/.phpdoc-md @@ -5,6 +5,8 @@ return (object)[ 'format' => 'github', 'classes' => [ '\CommonGateway\PDDBundle\Service\InstallationService', - '\CommonGateway\PDDBundle\Service\PDDService' + '\CommonGateway\PDDBundle\Service\PDDService', + '\CommonGateway\PDDBundle\Service\SyncXxllncCasesService', + '\CommonGateway\PDDBundle\Command\SyncXxllncCasesCommand' ], ]; From beeed6ff7b010e6cff74cc61e4d0b977f6540f58 Mon Sep 17 00:00:00 2001 From: GitHub Actions <> Date: Fri, 25 Aug 2023 08:35:35 +0000 Subject: [PATCH 11/15] Update src from PHP Codesniffer --- src/Service/SyncXxllncCasesService.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Service/SyncXxllncCasesService.php b/src/Service/SyncXxllncCasesService.php index 68dd8dd..ef5a0a7 100644 --- a/src/Service/SyncXxllncCasesService.php +++ b/src/Service/SyncXxllncCasesService.php @@ -96,6 +96,7 @@ public function __construct( $this->entityManager = $entityManager; $this->mappingService = $mappingService; $this->logger = $pluginLogger; + }//end __construct() @@ -198,8 +199,8 @@ public function syncXxllncCasesHandler(array $data, array $configuration): array $this->data['response'] = new Response(json_encode($responseItems), 200); - isset($this->style) === true && $this->style->success("Synchronized cases to woo objects for " . $source->getName()); - $this->logger->info("Synchronized cases to woo objects for " . $source->getName()); + isset($this->style) === true && $this->style->success("Synchronized cases to woo objects for ".$source->getName()); + $this->logger->info("Synchronized cases to woo objects for ".$source->getName()); return $this->data; From 69853980608e3f4037d2116645ba2d240024e2db Mon Sep 17 00:00:00 2001 From: GitHub Actions <> Date: Fri, 25 Aug 2023 08:36:21 +0000 Subject: [PATCH 12/15] Update phpdoc --- .../classes/Command/SyncXxllncCasesCommand.md | 57 ++++++++++ docs/classes/README.md | 2 + .../classes/Service/SyncXxllncCasesService.md | 106 ++++++++++++++++++ 3 files changed, 165 insertions(+) create mode 100644 docs/classes/Command/SyncXxllncCasesCommand.md create mode 100644 docs/classes/Service/SyncXxllncCasesService.md diff --git a/docs/classes/Command/SyncXxllncCasesCommand.md b/docs/classes/Command/SyncXxllncCasesCommand.md new file mode 100644 index 0000000..c1060c5 --- /dev/null +++ b/docs/classes/Command/SyncXxllncCasesCommand.md @@ -0,0 +1,57 @@ +# CommonGateway\PDDBundle\Command\SyncXxllncCasesCommand + +This class handles the command for the synchronization of a xxllnc case to a woo object. + +This Command executes the syncXxllncCasesService->syncXxllncCasesHandler. + + + +## Extend: + +Symfony\Component\Console\Command\Command + +## Methods + +| Name | Description | +|------|-------------| + +## Inherited methods + +| Name | Description | +|------|-------------| +| [__construct](https://secure.php.net/manual/en/symfony\component\console\command\command.__construct.php) | - | +|addArgument|Adds an argument.| +|addOption|Adds an option.| +|addUsage|Add a command usage example, it'll be prefixed with the command name.| +|getAliases|Returns the aliases for the command.| +|getApplication|Gets the application instance for this command.| +| [getDefaultDescription](https://secure.php.net/manual/en/symfony\component\console\command\command.getdefaultdescription.php) | - | +| [getDefaultName](https://secure.php.net/manual/en/symfony\component\console\command\command.getdefaultname.php) | - | +|getDefinition|Gets the InputDefinition attached to this Command.| +|getDescription|Returns the description for the command.| +|getHelp|Returns the help for the command.| +|getHelper|Gets a helper instance by name.| +|getHelperSet|Gets the helper set.| +|getName|Returns the command name.| +|getNativeDefinition|Gets the InputDefinition to be used to create representations of this Command.| +|getProcessedHelp|Returns the processed help for the command replacing the %command.name% and +%command.full_name% patterns with the real values dynamically.| +|getSynopsis|Returns the synopsis for the command.| +|getUsages|Returns alternative usages of the command.| +|ignoreValidationErrors|Ignores validation errors.| +|isEnabled|Checks whether the command is enabled or not in the current environment.| +| [isHidden](https://secure.php.net/manual/en/symfony\component\console\command\command.ishidden.php) | - | +|mergeApplicationDefinition|Merges the application definition with the command definition.| +|run|Runs the command.| +|setAliases|Sets the aliases for the command.| +| [setApplication](https://secure.php.net/manual/en/symfony\component\console\command\command.setapplication.php) | - | +|setCode|Sets the code to execute when running this command.| +|setDefinition|Sets an array of argument and option instances.| +|setDescription|Sets the description for the command.| +|setHelp|Sets the help for the command.| +| [setHelperSet](https://secure.php.net/manual/en/symfony\component\console\command\command.sethelperset.php) | - | +| [setHidden](https://secure.php.net/manual/en/symfony\component\console\command\command.sethidden.php) | - | +|setName|Sets the name of the command.| +|setProcessTitle|Sets the process title of the command.| + + diff --git a/docs/classes/README.md b/docs/classes/README.md index b7c9076..e4ec272 100644 --- a/docs/classes/README.md +++ b/docs/classes/README.md @@ -2,3 +2,5 @@ * [Service\InstallationService](Service/InstallationService.md) * [Service\PDDService](Service/PDDService.md) +* [Service\SyncXxllncCasesService](Service/SyncXxllncCasesService.md) +* [Command\SyncXxllncCasesCommand](Command/SyncXxllncCasesCommand.md) diff --git a/docs/classes/Service/SyncXxllncCasesService.md b/docs/classes/Service/SyncXxllncCasesService.md new file mode 100644 index 0000000..3bb21cc --- /dev/null +++ b/docs/classes/Service/SyncXxllncCasesService.md @@ -0,0 +1,106 @@ +# CommonGateway\PDDBundle\Service\SyncXxllncCasesService + +Service responsible for synchronizing xxllnc cases to woo objects. + + + + + +## Methods + +| Name | Description | +|------|-------------| +|[__construct](#syncxxllnccasesservice__construct)|SyncXxllncCasesService constructor.| +|[setStyle](#syncxxllnccasesservicesetstyle)|Set symfony style in order to output to the console.| +|[syncXxllncCasesHandler](#syncxxllnccasesservicesyncxxllnccaseshandler)|Handles the synchronization of xxllnc cases.| + + + + +### SyncXxllncCasesService::__construct + +**Description** + +```php +public __construct (\GatewayResourceService $resourceService, \CallService $callService, \SynchronizationService $syncService, \EntityManagerInterface $entityManager, \MappingService $mappingService, \LoggerInterface $pluginLogger) +``` + +SyncXxllncCasesService constructor. + + + +**Parameters** + +* `(\GatewayResourceService) $resourceService` +* `(\CallService) $callService` +* `(\SynchronizationService) $syncService` +* `(\EntityManagerInterface) $entityManager` +* `(\MappingService) $mappingService` +* `(\LoggerInterface) $pluginLogger` + +**Return Values** + +`void` + + +
+ + +### SyncXxllncCasesService::setStyle + +**Description** + +```php +public setStyle (\SymfonyStyle $style) +``` + +Set symfony style in order to output to the console. + + + +**Parameters** + +* `(\SymfonyStyle) $style` + +**Return Values** + +`self` + + + + +
+ + +### SyncXxllncCasesService::syncXxllncCasesHandler + +**Description** + +```php +public syncXxllncCasesHandler (array $data, array $configuration) +``` + +Handles the synchronization of xxllnc cases. + + + +**Parameters** + +* `(array) $data` +* `(array) $configuration` + +**Return Values** + +`array` + + + + +**Throws Exceptions** + + +`\CacheException|\InvalidArgumentException` + + +
+ From 0923adfda6fda1f2c7f52cb2e1c65862012a8fb7 Mon Sep 17 00:00:00 2001 From: Barry Brands Date: Fri, 25 Aug 2023 14:48:58 +0200 Subject: [PATCH 13/15] flush for logs --- src/Service/SyncXxllncCasesService.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Service/SyncXxllncCasesService.php b/src/Service/SyncXxllncCasesService.php index ef5a0a7..a573647 100644 --- a/src/Service/SyncXxllncCasesService.php +++ b/src/Service/SyncXxllncCasesService.php @@ -180,6 +180,7 @@ public function syncXxllncCasesHandler(array $data, array $configuration): array $response = $this->callService->call($source, '', 'GET', $sourceConfig); $decodedResponse = $this->callService->decodeResponse($source, $response); + $this->entityManager->flush(); $responseItems = []; foreach ($decodedResponse['result'] as $result) { From 28ddbf906f58a7e10807f699e51ed60d7834e7dc Mon Sep 17 00:00:00 2001 From: Barry Brands Date: Fri, 25 Aug 2023 14:49:05 +0200 Subject: [PATCH 14/15] mapping fixes --- Installation/Mapping/pdd.xxllncCaseToWoo.mapping.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Installation/Mapping/pdd.xxllncCaseToWoo.mapping.json b/Installation/Mapping/pdd.xxllncCaseToWoo.mapping.json index 81dcf7b..422bc1b 100644 --- a/Installation/Mapping/pdd.xxllncCaseToWoo.mapping.json +++ b/Installation/Mapping/pdd.xxllncCaseToWoo.mapping.json @@ -18,8 +18,8 @@ "Beschrijving": "values.case.subject", "Samenvatting": "values.case.subject", "Verzoeker": "values.case.requestor.name", - "Ontvangstdatum": "values.date_created", - "Besluitdatum": "", + "Ontvangstdatum": "{{ 'now'|date('Y-m-dTH:i:sZ') }}", + "Besluitdatum": "values.case.date_target", "Behandelstatus": "values.case.status", "Besluit": "", "Termijnoverschrijding": "", From 0b7bfbb36f64963411711c68acaa4a47daafcf20 Mon Sep 17 00:00:00 2001 From: Barry Brands Date: Fri, 25 Aug 2023 15:02:21 +0200 Subject: [PATCH 15/15] fix --- Installation/Mapping/pdd.xxllncCaseToWoo.mapping.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Installation/Mapping/pdd.xxllncCaseToWoo.mapping.json b/Installation/Mapping/pdd.xxllncCaseToWoo.mapping.json index 422bc1b..f337c24 100644 --- a/Installation/Mapping/pdd.xxllncCaseToWoo.mapping.json +++ b/Installation/Mapping/pdd.xxllncCaseToWoo.mapping.json @@ -18,7 +18,7 @@ "Beschrijving": "values.case.subject", "Samenvatting": "values.case.subject", "Verzoeker": "values.case.requestor.name", - "Ontvangstdatum": "{{ 'now'|date('Y-m-dTH:i:sZ') }}", + "Ontvangstdatum": "{{ 'now'|date('Y-m-dTH:i:s') }}", "Besluitdatum": "values.case.date_target", "Behandelstatus": "values.case.status", "Besluit": "",