Skip to content

Commit

Permalink
Fixes for file parts and other fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
rjzondervan committed Jul 25, 2023
1 parent 865bf55 commit ea382e1
Show file tree
Hide file tree
Showing 6 changed files with 199 additions and 3 deletions.
6 changes: 6 additions & 0 deletions Installation/Schema/drc/drc.bestandsDeel.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,12 @@
"readOnly": true,
"description": "Indicatie of dit bestandsdeel volledig is geupload. Dat wil zeggen: het aantal bytes dat staat genoemd bij grootte is daadwerkelijk ontvangen.",
"title": "voltooid"
},
"informatieObject": {
"type": "object",
"$ref": "https://vng.opencatalogi.nl/schemas/drc.enkelvoudigInformatieObject.schema.json",
"nullable": false,
"inversedBy": "bestandsdelen"
}
},
"required": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,8 @@
"$ref": "https://vng.opencatalogi.nl/schemas/drc.bestandsDeel.schema.json"
},
"readOnly": true,
"title": "bestandsdelen"
"title": "bestandsdelen",
"inversedBy": "informatieObject"
}
},
"required": [
Expand Down
8 changes: 8 additions & 0 deletions Installation/Schema/zrc/zrc.geoJSONGeometry.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,14 @@
},
"maxItems": 2,
"required": true
},
"geometries": {
"description": "The geometries of the chosen geometry type",
"type": "array",
"format": "json",
"items": {
"$ref": "https://vng.opencatalogi.nl/schemas/zrc.geoJSONGeometry.schema.json"
}
}
},
"required": [
Expand Down
87 changes: 87 additions & 0 deletions Installation/Schema/zrc/zrc.objectIdentificatie.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,93 @@
"type": "string",
"title": "postcode",
"maxLength": 7
},
"buurtCode": {
"type": "string",
"description": "De code behorende bij de naam van de buurt",
"title": "buurt code",
"maxLength": 2
},
"buurtNaam": {
"type": "string",
"description": "De naam van de buurt, zoals die door het CBS wordt gebruikt.",
"title": "buurt naam",
"maxLength": 40
},
"gemGemeenteCode": {
"type": "string",
"description": "Een numerieke aanduiding waarmee een Nederlandse gemeente uniek wordt aangeduid",
"title": "gem gemeente code",
"maxLength": 4
},
"wykWijkCode": {
"type": "string",
"description": "De code behorende bij de naam van de wijk",
"title": "wyk wijk code",
"maxLength": 2
},
"gemeenteNaam": {
"type": "string",
"description": "De officiële door de gemeente vastgestelde gemeentenaam.",
"title": "gemeente naam",
"maxLength": 80
},
"gemeenteCode": {
"type": "string",
"description": "Een numerieke aanduiding waarmee een Nederlandse gemeente uniek wordt aangeduid",
"title": "gemeente code",
"maxLength": 4
},
"openbareRuimteNaam": {
"type": "string",
"description": "Een door het bevoegde gemeentelijke orgaan aan een OPENBARE RUIMTE toegekende benaming",
"title": "openbare ruimte naam",
"maxLength": 80
},
"nummer": {
"type": "string",
"description": "Uniek identificerend administratienummer van een huishouden zoals toegekend door de gemeente waarin het huishouden woonachtig is.",
"title": "nummer",
"maxLength": 12
},
"isGehuisvestIn": {
"allOf": [
{
"$ref": "#/components/schemas/ObjectTerreinGebouwdObject"
}
],
"nullable": true,
"title": "isGehuisvestIn"
},
"naam": {
"type": "string",
"description": "De benaming van het OBJECT",
"title": "naam",
"maxLength": 500
},
"type": {
"description": "Specificatie van de aard van het inrichtingselement.",
"title": "type"
},
"kadastraleIdentificatie": {
"type": "string",
"description": "De unieke identificatie van het OBJECT",
"title": "kadastrale identificatie",
"maxLength": 100
},
"kadastraleAanduiding": {
"type": "string",
"description": "De typering van de kadastrale aanduiding van een onroerende zaak conform Kadaster",
"title": "kadastrale aanduiding",
"maxLength": 1000
},
"overigeData": {
"type": "array",
"title": "overige data"
},
"adresAanduidingGrp": {
"type": "object",
"$ref": "https://vng.opencatalogi.nl/schemas/zrc.terreinGebouwdObjectAdres.schema.json"
}
},
"required": [
Expand Down
63 changes: 63 additions & 0 deletions Installation/Schema/zrc/zrc.terreinGebouwdObjectAdres.schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
{
"$id": "https://vng.opencatalogi.nl/schemas/zrc.terreinGebouwdObjectAdres.schema.json",
"$schema": "https://docs.commongateway.nl/schemas/Entity.schema.json",
"title": "TerreinGebouwdObjectAdres",
"version": "0.1",
"type": "object",
"properties": {
"numIdentificatie": {
"type": "string",
"title": "num identificatie",
"maxLength": 100
},
"oaoIdentificatie": {
"type": "string",
"description": "De unieke identificatie van het OBJECT",
"title": "identificatie",
"maxLength": 100
},
"wplWoonplaatsNaam": {
"type": "string",
"title": "wpl woonplaats naam",
"maxLength": 80
},
"gorOpenbareRuimteNaam": {
"type": "string",
"description": "Een door het bevoegde gemeentelijke orgaan aan een OPENBARE RUIMTE toegekende benaming",
"title": "gor openbare ruimte naam",
"maxLength": 80
},
"aoaPostcode": {
"type": "string",
"title": "postcode",
"maxLength": 7
},
"aoaHuisnummer": {
"type": "integer",
"maximum": 99999,
"minimum": 0,
"title": "huisnummer"
},
"aoaHuisletter": {
"type": "string",
"title": "huisletter",
"maxLength": 1
},
"aoaHuisnummertoevoeging": {
"type": "string",
"title": "huisnummertoevoeging",
"maxLength": 4
},
"ogoLocatieAanduiding": {
"type": "string",
"title": "locatie aanduiding",
"maxLength": 100
}
},
"required": [
"aoaHuisnummer",
"gorOpenbareRuimteNaam",
"oaoIdentificatie",
"wplWoonplaatsNaam"
]
}
35 changes: 33 additions & 2 deletions Service/DRCService.php
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,15 @@ private function generateDownloadEndpoint(string $id, Endpoint $downloadEndpoint

}//end generateDownloadEndpoint()

public function createFilePart($object, $index, $size): array
{
return [
'omvang' => $size,
'voltooid' => false,
'volgnummer' => $index,
];
}


/**
* Stores content of an Enkelvoudig Informatie Object into a File resource, shows link in object.
Expand Down Expand Up @@ -331,6 +340,9 @@ public function inhoudHandler(array $data, array $configuration): array
throw new HttpException(400, 'Lock not valid');
}




$data = $objectEntity->toArray();

$file = new File();
Expand All @@ -345,7 +357,27 @@ public function inhoudHandler(array $data, array $configuration): array
}
$file->setSize(mb_strlen(base64_decode($data['inhoud'])));
$file->setBase64($data['inhoud']);
} else if($data['inhoud'] === null && $data['link'] === null && $data['bestandsomvang'] !== null) {
$parts = ceil($data['bestandsomvang'] / 1000000);

$fileParts = [];

for ($iterator = 0; $iterator < $parts; $iterator++) {
$fileParts[] = $this->createFilePart($objectEntity, $iterator, ceil($data['bestandsomvang'] / $parts));
}

$objectEntity->hydrate(['bestandsdelen' => $fileParts]);

$this->entityManager->persist($objectEntity);
$this->entityManager->flush();

$this->data['response'] = new Response(
\Safe\json_encode($objectEntity->toArray()),
$this->data['method'] === 'POST' ? 201 : 200,
['content-type' => 'application/json']
);
}

$file->setValue($objectEntity->getValueObject('inhoud'));
$objectEntity->hydrate(['inhoud' => $this->generateDownloadEndpoint($objectEntity->getId()->toString(), $downloadEndpoint)]);
$this->entityManager->persist($file);
Expand Down Expand Up @@ -376,8 +408,7 @@ public function uploadFilePartHandler(array $data, array $configuration): array
{
$this->data = $data;

$path = $data['path'];
$objectEntity = $this->entityManager->getRepository('App:ObjectEntity')->find($path['id']);
$objectEntity = $this->entityManager->getRepository('App:ObjectEntity')->findOneBy(['self' => $data['informatieObject']]);
$filePartEntity = $this->entityManager->getRepository('App:Entity')->findOneBy(['reference' => 'https://vng.opencatalogi.nl/schemas/drc.bestandsDeel.schema.json']);

if($objectEntity->getEntity()->getId()->toString() !== $configuration['enkelvoudigInformatieObjectEntityId']) {
Expand Down

0 comments on commit ea382e1

Please sign in to comment.