Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/feature/MF-12/certificate' into …
Browse files Browse the repository at this point in the history
…feature/MF-12/certificate
  • Loading branch information
Sarai Misidjan authored and Sarai Misidjan committed Nov 2, 2023
2 parents f915726 + f95755a commit a2e2ed0
Showing 1 changed file with 18 additions and 20 deletions.
38 changes: 18 additions & 20 deletions src/Service/WPZaakService.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ public function synchronizeUpstream(Synchronization $synchronization): bool
$data = $this->mappingService->mapping($synchronization->getMapping(), $synchronization->getObject()->toArray());

try {
$response = $this->callService->call($synchronization->getSource(), $synchronization->getEndpoint(), 'POST', ['json' => $data]);
$response = $this->callService->call($synchronization->getSource(), $synchronization->getEndpoint(), 'POST', ['json' => $data]);
} catch (Exception $exception) {
throw new Exception($exception->getMessage());
}
Expand Down Expand Up @@ -147,9 +147,9 @@ public function synchronizeUpstream(Synchronization $synchronization): bool
/**
* Store information objects to an upstream source
*
* @param ObjectEntity $informatieobject The information object to store
* @param ObjectEntity $informatieobject The information object to store
* @param ObjectEntity $zaakinformatieobject The case-information-object to store
* @param ObjectEntity $zaak The case the objects belong to
* @param ObjectEntity $zaak The case the objects belong to
*
* @return bool Whether the synchronization has passed.
* @throws Exception
Expand Down Expand Up @@ -192,7 +192,6 @@ public function storeWaardepapierInSourceDRC(ObjectEntity $informatieobject, Obj

$result = $this->synchronizeUpstream($gebruiksrechtSync);


if ($result === false) {
return false;
}
Expand All @@ -216,9 +215,9 @@ public function storeWaardepapierInSourceDRC(ObjectEntity $informatieobject, Obj
/**
* Store information objects to an upstream source
*
* @param string $data
* @param ObjectEntity $zaakObject The case as object.
* @param string $informatieobjecttypeUrl The url of the information object type that is related to the case type.
* @param string $data
* @param ObjectEntity $zaakObject The case as object.
* @param string $informatieobjecttypeUrl The url of the information object type that is related to the case type.
*
* @return void Whether the synchronization has passed.
* @throws Exception
Expand All @@ -237,7 +236,7 @@ public function saveWaardepapierInDRC(string $data, ObjectEntity $zaakObject, st
'auteur' => 'Common Gateway',
'taal' => 'NLD',
'bestandsnaam' => 'waardepapier.pdf',
'versie' => null
'versie' => null,
];

$informationObjectSchema = $this->resourceService->getSchema('https://vng.opencatalogi.nl/schemas/drc.enkelvoudigInformatieObject.schema.json', 'common-gateway/waardepapieren-bundle');
Expand All @@ -251,15 +250,14 @@ public function saveWaardepapierInDRC(string $data, ObjectEntity $zaakObject, st
$this->entityManager->persist($informationObject);
$this->entityManager->flush();


$gebruiksrechtSchema = $this->resourceService->getSchema('https://vng.opencatalogi.nl/schemas/drc.gebruiksrecht.schema.json', 'common-gateway/waardepapieren-bundle');
if ($gebruiksrechtSchema === null) {
return;
}

$gebruiksrechtArray = [
'informatieobject' => $informationObject,
'startdatum' => $now->format('c'),
'informatieobject' => $informationObject,
'startdatum' => $now->format('c'),
'omschrijvingVoorwaarden' => 'Voorwaarden',
];

Expand Down Expand Up @@ -292,9 +290,9 @@ public function saveWaardepapierInDRC(string $data, ObjectEntity $zaakObject, st
/**
* Gets the zaaktype from the given zaak
*
* @param string $objectUrl The url of the zaaktype.
* @param string $schemaRef The reference of the schema
* @param string $endpoint The endpoint
* @param string $objectUrl The url of the zaaktype.
* @param string $schemaRef The reference of the schema
* @param string $endpoint The endpoint
*
* @return ObjectEntity|null The zaaktype of the given source
* @throws Exception
Expand Down Expand Up @@ -387,7 +385,7 @@ public function getSubobjects(array $response): array
/**
* Gets the zaaktype from the given zaak
*
* @param string $zaaktypeUrl The url of the zaaktype.
* @param string $zaaktypeUrl The url of the zaaktype.
*
* @return ObjectEntity|null The zaaktype of the given source
* @throws Exception
Expand All @@ -400,7 +398,7 @@ public function getZaaktypeFromSource(string $zaaktypeUrl): ?ObjectEntity

// Get the uuid from the zaaktype url.
$explodedUrl = explode('/', $zaaktypeUrl);
$zaaktypeId = null;
$zaaktypeId = null;
foreach ($explodedUrl as $item) {
if (Uuid::isValid($item)) {
$zaaktypeId = $item;
Expand Down Expand Up @@ -563,7 +561,7 @@ public function saveInZRC(ObjectEntity $zaakObject, ObjectEntity $zaaktype): voi
*/
public function getZaakFromSource(ObjectEntity $zaak): ?ObjectEntity
{
$source = $this->resourceService->getSource($this->configuration['zrcSource'], 'common-gateway/waardepapieren-bundle');
$source = $this->resourceService->getSource($this->configuration['zrcSource'], 'common-gateway/waardepapieren-bundle');
$zaakSync = $zaak->getSynchronizations()->first();

try {
Expand Down Expand Up @@ -591,7 +589,7 @@ public function getZaakFromSource(ObjectEntity $zaak): ?ObjectEntity
* Creates a certificate for a ZGW Zaak.
* This action is triggered by a notification.
*
* @param array $data Data from the handler where the xxllnc casetype is in.
* @param array $data Data from the handler where the xxllnc casetype is in.
* @param array $configuration Configuration for the Action.
*
* @return array $this->data Zaak which we updated with new data
Expand All @@ -612,7 +610,7 @@ public function wpZaakHandler(array $data, array $configuration): array
$zaakUrl = $this->data['body']['resourceUrl'];
// Get the uuid from the zaaktype url.
$explodedUrl = explode('/', $zaakUrl);
$zaakId = null;
$zaakId = null;
foreach ($explodedUrl as $item) {
if (Uuid::isValid($item)) {
$zaakId = $item;
Expand Down Expand Up @@ -654,7 +652,7 @@ public function wpZaakHandler(array $data, array $configuration): array
// TODO: how do we know which we need to get?
// Fill certificate with persons information and/or zaak.
$message['message'] = 'Waardepapier aangemaakt voor zaak met id: '.$zaakObject->getId()->toString();
$certificate = $this->downloadService->downloadPdf($message);
$certificate = $this->downloadService->downloadPdf($message);

// Store waardepapier in DRC source.
$this->saveWaardepapierInDRC($certificate, $zaakObject, $informatieobjecttypeUrl);
Expand Down

0 comments on commit a2e2ed0

Please sign in to comment.