From af68ec7e9f4d66354a40a2a07fcbd0d3f33b1f3b Mon Sep 17 00:00:00 2001 From: Thibault Lesuisse Date: Thu, 19 Jul 2018 14:44:43 +0200 Subject: [PATCH 1/4] HOTFIXXXXXXX --- .idea/SmartFlanders.iml | 9 ++ .idea/misc.xml | 6 + .idea/modules.xml | 8 ++ .idea/vcs.xml | 6 + .idea/workspace.xml | 236 +++++++++++++++++++++++++++++++ controllers/serviceController.js | 4 +- helpers/transformer.js | 1 + routes.js | 3 + 8 files changed, 272 insertions(+), 1 deletion(-) create mode 100644 .idea/SmartFlanders.iml create mode 100644 .idea/misc.xml create mode 100644 .idea/modules.xml create mode 100644 .idea/vcs.xml create mode 100644 .idea/workspace.xml diff --git a/.idea/SmartFlanders.iml b/.idea/SmartFlanders.iml new file mode 100644 index 0000000..d6ebd48 --- /dev/null +++ b/.idea/SmartFlanders.iml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..28a804d --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,6 @@ + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..152e8ce --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..35eb1dd --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.idea/workspace.xml b/.idea/workspace.xml new file mode 100644 index 0000000..efebda2 --- /dev/null +++ b/.idea/workspace.xml @@ -0,0 +1,236 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + true + DEFINITION_ORDER + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 1532003177460 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file From 8c763c5282c9ba68a39b69a4b322058f073d8b4e Mon Sep 17 00:00:00 2001 From: Thibault Lesuisse Date: Thu, 19 Jul 2018 14:49:24 +0200 Subject: [PATCH 3/4] HOTFIXXXXXXX --- files/master-catalog.json | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/files/master-catalog.json b/files/master-catalog.json index 4393eab..68a1e99 100644 --- a/files/master-catalog.json +++ b/files/master-catalog.json @@ -1 +1,9 @@ -{"@context":{"dcat":"https://www.w3.org/ns/dcat#","dcterms":"http://purl.org/dc/terms/","foaf":"http://xmlns.com/foaf/0.1/"},"@type":"dcterms:Collection","dcterms:hasPart":[{"foaf:page":"http://smartflanders.ilabt.imec.be/graph/9940/catalog.json","@type":"dcat:Catalog"}]} \ No newline at end of file +{ + "@context": { + "dcat": "https://www.w3.org/ns/dcat#", + "dcterms": "http://purl.org/dc/terms/", + "foaf": "http://xmlns.com/foaf/0.1/" + }, + "@type": "dcterms:Collection", + "dcterms:hasPart": [] +} \ No newline at end of file From 28b95455510561416e6f9f2d54f772d10c2d8b76 Mon Sep 17 00:00:00 2001 From: Thibault Lesuisse Date: Thu, 19 Jul 2018 15:21:11 +0200 Subject: [PATCH 4/4] chore(): pushing hotfix --- controllers/serviceController.js | 20 ++++++++++++++++++-- files/service-example.json | 2 +- helpers/transformer.js | 2 +- routes.js | 10 +++++++++- 4 files changed, 29 insertions(+), 5 deletions(-) diff --git a/controllers/serviceController.js b/controllers/serviceController.js index fd820cc..b0a1a56 100644 --- a/controllers/serviceController.js +++ b/controllers/serviceController.js @@ -1,8 +1,24 @@ const transformer = require("../helpers/transformer") -const fs = require('fs'); +const fs = require("fs"); exports.addService = async (params) => { return await transformer.makeService(params); } -exports.postCodeSearch = async (params) => { +exports.postCodeSearch = (params) => { + return new Promise((resolve, reject) => { + fs.readdir(__dirname + "/../files/", (err, files) => { + if(err) reject() + fs.readdir(__dirname + `/../files/${params.postcode}/gebouwen/`, (err, files) => { + if(err) reject("Geen gebouwen gevonden voor psotcode"); + let response = {} + files.forEach(file => { + fs.readFile(__dirname + `/../files/${params.postcode}/gebouwen/${file}`, (err, data) => { + if(err) reject("Problemen bij het openen van gebouwfile"); + response.push(JSON.parse(data)); + }) + }) + resolve(response); + }) + }) + }) } \ No newline at end of file diff --git a/files/service-example.json b/files/service-example.json index cc0bed7..3c541d5 100644 --- a/files/service-example.json +++ b/files/service-example.json @@ -1,5 +1,5 @@ [{ - "@context": "http://schema.org/", + "@context": "https://schema.org/", "@id": "https://stad.gent/id/products/123", "@type": "Service", "name": "Public toilet library", diff --git a/helpers/transformer.js b/helpers/transformer.js index d53da5b..54d7360 100644 --- a/helpers/transformer.js +++ b/helpers/transformer.js @@ -164,7 +164,7 @@ function jsonLDBuilding(gebouwId, adresId, location) { "xsd": "http://www.w3.org/2001/XMLSchema#" }, "@id": "gebouw:" + gebouwId, - "type": "gebouw:Gebouw", + "@type": "gebouw:Gebouw", "gebouw:Gebouw.adres": { "@id": "http://data.vlaanderen.be/id/adres/" + adresId, "@type": "http://www.w3.org/ns/locn#Address", diff --git a/routes.js b/routes.js index d757cd8..6e9d3bf 100644 --- a/routes.js +++ b/routes.js @@ -74,7 +74,15 @@ router.get('/postcode', async (req, res, next) => { }); router.post('/service/postcode', async (req, res, next) => { - await serviceController + + try { + res.status(200) + var response = await serviceController.postCodeSearch(req.body); + } catch (error) { + res.status(304) + var response = error.message; + } + res.send(response); }) router.post('/services', async (req, res, next) => { try {