@igea/oac_backend 1.0.35 → 1.0.36
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -202,4 +202,105 @@ router.get('/export/:format/:entity/:id', (req, res) => {
|
|
|
202
202
|
|
|
203
203
|
});
|
|
204
204
|
|
|
205
|
+
// GENERAL SPARQL QUERIES ---------------------------------------------------------------
|
|
206
|
+
|
|
207
|
+
router.get("/endpoint/sparql", async (req, res) => {
|
|
208
|
+
try {
|
|
209
|
+
const query = req.query.query;
|
|
210
|
+
if (!query) return res.status(400).json({ error: "Missing ?query=" });
|
|
211
|
+
|
|
212
|
+
const url = fusekiUrl + "?query=" + encodeURIComponent(query);
|
|
213
|
+
|
|
214
|
+
axios.get(url, {
|
|
215
|
+
headers: {
|
|
216
|
+
'Accept': 'application/sparql-results+json'
|
|
217
|
+
}
|
|
218
|
+
})
|
|
219
|
+
.then(response => {
|
|
220
|
+
res.status(200).json(response.data);
|
|
221
|
+
}).catch(error => {
|
|
222
|
+
let message = (error.response?.status + error.response?.data) || error.message
|
|
223
|
+
res.status(500).json({
|
|
224
|
+
message: 'Error from SPARQL end-point: ' + message,
|
|
225
|
+
query
|
|
226
|
+
});
|
|
227
|
+
});
|
|
228
|
+
} catch (err) {
|
|
229
|
+
console.error(err);
|
|
230
|
+
res.status(500).json({ error: "SPARQL request failed" });
|
|
231
|
+
}
|
|
232
|
+
});
|
|
233
|
+
|
|
234
|
+
router.post("/endpoint/sparql", async (req, res) => {
|
|
235
|
+
try {
|
|
236
|
+
const { query, format = "json" } = req.body;
|
|
237
|
+
if (!query) return res.status(400).json({ error: "Missing query" });
|
|
238
|
+
|
|
239
|
+
// INVIO A FUSEKI
|
|
240
|
+
axios.post(fusekiUrl, query, {
|
|
241
|
+
headers: {
|
|
242
|
+
"Content-Type": "application/sparql-query",
|
|
243
|
+
"Accept":
|
|
244
|
+
format === "xml"
|
|
245
|
+
? "application/sparql-results+xml"
|
|
246
|
+
: "application/sparql-results+json",
|
|
247
|
+
}
|
|
248
|
+
})
|
|
249
|
+
.then(response => {
|
|
250
|
+
if(format === "xml")
|
|
251
|
+
res.send(response.data);
|
|
252
|
+
else
|
|
253
|
+
res.status(200).json(response.data);
|
|
254
|
+
}).catch(error => {
|
|
255
|
+
let message = (error.response?.status + error.response?.data) || error.message
|
|
256
|
+
res.status(500).json({
|
|
257
|
+
message: 'Error from SPARQL end-point: ' + message,
|
|
258
|
+
query
|
|
259
|
+
});
|
|
260
|
+
});
|
|
261
|
+
|
|
262
|
+
|
|
263
|
+
} catch (err) {
|
|
264
|
+
console.error(err);
|
|
265
|
+
res.status(500).json({ error: "SPARQL request failed" });
|
|
266
|
+
}
|
|
267
|
+
});
|
|
268
|
+
|
|
269
|
+
router.post('/endpoint/update', (req, res) => {
|
|
270
|
+
try {
|
|
271
|
+
const updateQuery =
|
|
272
|
+
typeof req.body === "string"
|
|
273
|
+
? req.body
|
|
274
|
+
: req.body.update;
|
|
275
|
+
|
|
276
|
+
if (!updateQuery)
|
|
277
|
+
return res.status(400).json({
|
|
278
|
+
error: "Missing SPARQL UPDATE in request body"
|
|
279
|
+
});
|
|
280
|
+
|
|
281
|
+
// INVIO A FUSEKI
|
|
282
|
+
axios.post(fusekiUrlUpdate, updateQuery, {
|
|
283
|
+
headers: {
|
|
284
|
+
'Content-Type': 'application/sparql-update',
|
|
285
|
+
'Accept': 'application/sparql-results+json'
|
|
286
|
+
}
|
|
287
|
+
})
|
|
288
|
+
.then(response => {
|
|
289
|
+
res.status(200).json({
|
|
290
|
+
message: 'Query update executed correctly: ' + response.data
|
|
291
|
+
});
|
|
292
|
+
}).catch(error => {
|
|
293
|
+
let message = (error.response?.status + error.response?.data) || error.message
|
|
294
|
+
res.status(500).json({
|
|
295
|
+
message: 'Error from SPARQL end-point: ' + message,
|
|
296
|
+
query
|
|
297
|
+
});
|
|
298
|
+
});
|
|
299
|
+
|
|
300
|
+
} catch (err) {
|
|
301
|
+
console.error(err);
|
|
302
|
+
res.status(500).json({ error: "SPARQL UPDATE request failed" });
|
|
303
|
+
}
|
|
304
|
+
})
|
|
305
|
+
|
|
205
306
|
module.exports = router
|
|
@@ -26,6 +26,7 @@
|
|
|
26
26
|
@prefix dc: <http://purl.org/dc/elements/1.1/> .
|
|
27
27
|
@prefix skos: <http://www.w3.org/2004/02/skos/core#> .
|
|
28
28
|
@prefix skosxl: <http://www.w3.org/2008/05/skos-xl#> .
|
|
29
|
+
@prefix ex: <http://example.com/ns#> .
|
|
29
30
|
|
|
30
31
|
<https://data.mydomain.com/ontologies/sparnatural-config> a owl:Ontology .
|
|
31
32
|
|
|
@@ -62,7 +63,20 @@ this:Vehicle_VIN sh:path odb:VIN;
|
|
|
62
63
|
sh:maxCount "1"^^xsd:integer;
|
|
63
64
|
sh:nodeKind sh:Literal;
|
|
64
65
|
sh:datatype xsd:string;
|
|
65
|
-
|
|
66
|
+
|
|
67
|
+
#dash:searchWidget core:AutocompleteProperty;
|
|
68
|
+
|
|
69
|
+
dash:searchWidget core:ListProperty ;
|
|
70
|
+
sh:in (
|
|
71
|
+
"Orange"
|
|
72
|
+
"Lemon"
|
|
73
|
+
"Strawberry"
|
|
74
|
+
"Blueberry"
|
|
75
|
+
"Carrot"
|
|
76
|
+
"Beetroot"
|
|
77
|
+
"Lettuce"
|
|
78
|
+
"Spinach"
|
|
79
|
+
) ;
|
|
66
80
|
dash:propertyRole dash:LabelRole .
|
|
67
81
|
|
|
68
82
|
this:Vehicle_hasManufacturer sh:path odb:hasManufacturer;
|
|
@@ -1902,6 +1902,7 @@ sh:minCount 1 ;
|
|
|
1902
1902
|
ex:CP20_Construction_WorkShape
|
|
1903
1903
|
a sh:NodeShape ;
|
|
1904
1904
|
sh:targetClass <http://ontome.net/ns/cpm/CP20_Construction_Work> ;
|
|
1905
|
+
volipi:iconName "fa-solid fa-building" ;
|
|
1905
1906
|
sh:property [
|
|
1906
1907
|
sh:name "type" ;
|
|
1907
1908
|
sh:description "CP20_Construction_Work.type" ;
|
|
@@ -1962,6 +1963,7 @@ sh:minCount 1 ;
|
|
|
1962
1963
|
.
|
|
1963
1964
|
ex:E58_Measurement_UnitShape
|
|
1964
1965
|
a sh:NodeShape ;
|
|
1966
|
+
volipi:iconName "fa-solid fa-ruler" ;
|
|
1965
1967
|
sh:targetClass <http://www.cidoc-crm.org/cidoc-crm/E58_Measurement_Unit> ;
|
|
1966
1968
|
sh:property [
|
|
1967
1969
|
sh:name "type" ;
|