-
Notifications
You must be signed in to change notification settings - Fork 2
/
QueryFunzionalità.txt
496 lines (385 loc) · 15.1 KB
/
QueryFunzionalità.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
############## Info artist CON AGGREGATION ##############
PREFIX umbelrc: <http://umbel.org/umbel/rc/>
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
PREFIX dbo: <http://dbpedia.org/ontology/>
PREFIX dbp: <http://dbpedia.org/property/>
SELECT DISTINCT ?name ?bDate ?abstract ?image ?origin ?caption
(GROUP_CONCAT(DISTINCT ?artistRelated; separator="|||") AS ?artistRelateds)
(GROUP_CONCAT(DISTINCT ?bandRelated; separator="|||") AS ?bandRelateds)
WHERE
{
<${req.query.uri}> a umbelrc:MusicalPerformer;
foaf:name ?name;
dbo:abstract ?abstract;
dbo:birthDate ?bDate.
OPTIONAL{<${req.query.uri}> dbo:thumbnail ?image} .
OPTIONAL{<${req.query.uri}> dbo:associatedBand ?bandRelated} .
OPTIONAL{<${req.query.uri}> dbo:associatedMusicalArtist ?artistRelated} .
OPTIONAL{<${req.query.uri}> dbp:caption ?caption} .
OPTIONAL{<${req.query.uri}> dbp:origin ?origin} .
}group by ?name ?bDate ?abstract ?image ?origin ?caption
############## Info Artist + Band (JOIN) CON AGGREGATION ##############
PREFIX umbelrc: <http://umbel.org/umbel/rc/>
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
PREFIX dbo: <http://dbpedia.org/ontology/>
PREFIX dbp: <http://dbpedia.org/property/>
SELECT DISTINCT ?name ?bDate ?abstract ?image ?origin ?caption
(GROUP_CONCAT(DISTINCT ?artistRelated; separator="|||") AS ?artistRelateds)
(GROUP_CONCAT(DISTINCT ?bandRelated; separator="|||") AS ?bandRelateds)
(GROUP_CONCAT(DISTINCT ?band; separator="|||") AS ?bands)
WHERE
{
<${req.query.uri}> a umbelrc:MusicalPerformer;
foaf:name ?name;
dbo:abstract ?abstract;
dbo:birthDate ?bDate.
OPTIONAL{?band dbp:currentMembers <${req.query.uri}>} .
OPTIONAL{<${req.query.uri}> dbo:thumbnail ?image} .
OPTIONAL{<${req.query.uri}> dbo:associatedBand ?bandRelated} .
OPTIONAL{<${req.query.uri}> dbo:associatedMusicalArtist ?artistRelated} .
OPTIONAL{<${req.query.uri}> dbp:caption ?caption} .
OPTIONAL{<${req.query.uri}> dbp:origin ?origin} .
}group by ?name ?bDate ?abstract ?image ?origin ?caption
}group by ?name ?bDate ?abstract ?image ?origin ?caption
############## Band di un artista ##############
PREFIX dbo: <http://dbpedia.org/ontology/>
PREFIX dbr: <http://dbpedia.org/resource/>
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
PREFIX dbp: <http://dbpedia.org/property/>
SELECT ?band
WHERE{
?band a dbo:Band;
dbp:currentMembers $param.
}
############## Info Band ##############
PREFIX dbo: <http://dbpedia.org/ontology/>
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
PREFIX dbp: <http://dbpedia.org/property/>
SELECT ?website ?abstract ?genre ?image ?member ?artistRelated ?bandRelated ?origin ?caption
WHERE{
$param a dbo:Band ;
foaf:name ?name;
dbo:abstract ?abstract ;
dbp:currentMembers ?member .
OPTIONAL{$param dbo:genre ?genre } .
OPTIONAL{$param dbp:website ?website} .
OPTIONAL{$param dbo:associatedBand ?bandRelated} .
OPTIONAL{$param dbo:associatedMusicalArtist ?artistRelated} .
OPTIONAL{ $param dbp:caption ?caption} .
OPTIONAL{$param dbp:origin ?origin} .
OPTIONAL{$param dbo:image ?image} .
}
------------CON AGGREGATION-----------
SELECT ?name
?image
?abstract
(GROUP_CONCAT(DISTINCT ?website; separator="|||") AS ?websites)
(GROUP_CONCAT(DISTINCT ?genre; separator="|||") AS ?genres)
(GROUP_CONCAT(DISTINCT ?member; separator="|||") AS ?members)
(GROUP_CONCAT(DISTINCT ?artistRelated; separator="|||") AS ?artistRelateds)
(GROUP_CONCAT(DISTINCT ?bandRelated; separator="|||") AS ?bandRelateds)
?origin
?caption
WHERE{
VALUES ?s {$param}
?s a dbo:Band ;
foaf:name ?name;
dbo:abstract ?abstract .
OPTIONAL{?s dbo:genre ?genre } .
OPTIONAL{?s dbp:website ?website} .
OPTIONAL{?s dbo:associatedBand ?bandRelated} .
OPTIONAL{?s dbo:associatedMusicalArtist ?artistRelated} .
OPTIONAL{?s dbp:caption ?caption} .
OPTIONAL{?s dbp:origin ?origin} .
OPTIONAL{?s dbo:image ?image} .
FILTER LANGMATCHES(LANG(?abstract ), "en")
} group by ?name ?abstract ?image ?origin ?caption
############## Info Album ##############
PREFIX dbo: <http://dbpedia.org/ontology/>
PREFIX schema: <http://schema.org/>
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
SELECT DISTINCT ?name ?abstract ?recordLabel ?releaseDate ?genre ?artist
WHERE{
$param a schema:MusicAlbum;
foaf:name ?name;
dbo:abstract ?abstract;
dbo:recordLabel ?recordLabel;
dbo:releaseDate ?date;
dbo:artist ?band.
OPTIONAL{$param dbo:genre ?genre}.
}
------------CON AGGREGATION-----------
SELECT
?name
?abstract
?releaseDate
(GROUP_CONCAT(DISTINCT ?genre; separator="|||") AS ?genres)
(GROUP_CONCAT(DISTINCT ?recordLabel; separator="|||") AS ?recordLabels)
(GROUP_CONCAT(DISTINCT ?artist; separator="|||") AS ?artists)
WHERE{
<${req.query.uri}> a schema:MusicAlbum;
foaf:name ?name;
dbo:abstract ?abstract;
dbo:recordLabel ?recordLabel;
dbo:releaseDate ?date;
dbo:artist ?band.
OPTIONAL{<${req.query.uri}> dbo:genre ?genre}.
} group by ?name ?abstract ?releaseDate
############## Autocompletamento ricerca globale ($param) ##############
PREFIX umbelrc: <http://umbel.org/umbel/rc/>
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
PREFIX dbo: <http://dbpedia.org/ontology/>
PREFIX dbp: <http://dbpedia.org/property/>
SELECT DISTINCT ?entity ?name
WHERE
{
?entity foaf:name ?name.
FILTER regex(?name, "^$param").
}
##############Info Track ##############
PREFIX umbelrc: <http://umbel.org/umbel/rc/>
PREFIX dbo: <http://dbpedia.org/ontology/>
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
PREFIX dbp: <http://dbpedia.org/property/>
SELECT DISTINCT ?name ?abstract ?releaseDate ?artist ?album ?recordLabel
WHERE
{
{$param a umbelrc:MusicSingle} UNION {$param a dbo:MusicalWork}.
$param foaf:name ?name;
dbo:abstract ?abstract;
dbo:releaseDate ?date;
{ $param dbo:musicalArtist [ a umbelrc:MusicalPerformer;
foaf:name ?artist;]}
UNION {$param dbo:musicalArtist [ a dbo:Band;
foaf:name ?artist;]}
FILTER(lang(?abstract) = "en").
OPTIONAL{?track dbo:album ?album}.
OPTIONAL{?track dbo:recordLabel ?recordLabel}.
}
############## Info track CON AGGREGATION ###############
PREFIX umbelrc: <http://umbel.org/umbel/rc/>
PREFIX dbo: <http://dbpedia.org/ontology/>
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
PREFIX dbp: <http://dbpedia.org/property/>
SELECT DISTINCT ?name ?abstract ?releaseDate
(GROUP_CONCAT(DISTINCT ?recordLabel; separator="|||") AS ?recordLabels)
(GROUP_CONCAT(DISTINCT ?artist; separator="|||") AS ?artists)
(GROUP_CONCAT(DISTINCT ?album; separator="|||") AS ?albums)
WHERE
{
{<${req.query.uri}> a umbelrc:MusicSingle} UNION {<${req.query.uri}> a dbo:MusicalWork}.
<${req.query.uri}> foaf:name ?name;
dbo:abstract ?abstract;
dbo:releaseDate ?date;
{ <${req.query.uri}> dbo:musicalArtist [ a umbelrc:MusicalPerformer;
foaf:name ?artist;]}
UNION {<${req.query.uri}> dbo:musicalArtist [ a dbo:Band;
foaf:name ?artist;]}
FILTER(lang(?abstract) = "en").
OPTIONAL{<${req.query.uri}> dbo:album ?album}.
OPTIONAL{<${req.query.uri}> dbo:recordLabel ?recordLabel}.
}
############## Ricerca di tutti i generi musicali memorizzati ############## -> (1) --------NOTA:aggiungere "starts with" e eliminare i generi che cominciano con "%3.."
#COMMENTI
?genre è la URI da passare come $param2
?genresLiteral è la stringa da mostrare all'utente
#FINE COMMENTI
PREFIX dbo: <http://dbpedia.org/ontology/>
SELECT DISTINCT ?genre
(strafter(str(?genre),'http://dbpedia.org/resource/') as ?genreLiteral)
WHERE{
[] dbo:genre ?genre.
}
############## Ricerca di tutte le etichette discografiche memorizzate ############## -> (2)
#COMMENTI
?recordLabel è la URI da passare come $param2
?recordLabelLiteral è la stringa da mostrare all'utente
#FINE COMMENTI
PREFIX dbo: <http://dbpedia.org/ontology/>
SELECT DISTINCT ?recordLabel
(strafter(str(?recordLabel),'http://dbpedia.org/resource/') as ?recordLabelLiteral)
WHERE{
[] dbo:recordLabel ?recordLabel.
}
############## Ricerca di tutte le band (con autocompletamento) ############## -> (3)
PREFIX umbelrc: <http://umbel.org/umbel/rc/>
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
PREFIX dbo: <http://dbpedia.org/ontology/>
PREFIX dbp: <http://dbpedia.org/property/>
SELECT DISTINCT ?band ?name
WHERE
{
?band a dbo:Band;
foaf:name ?name.
FILTER regex(?name, "^$").
}
############## Ricerca di tutti gli artisti (con autocompletamento) ############## -> (4)
PREFIX umbelrc: <http://umbel.org/umbel/rc/>
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
PREFIX dbo: <http://dbpedia.org/ontology/>
PREFIX dbp: <http://dbpedia.org/property/>
SELECT DISTINCT ?artist ?name
WHERE
{
?artist a umbelrc:MusicalPerformer;
foaf:name ?name.
FILTER regex(?name, "^").
}
############## Ricerca di tutti gli album (con autocompletamento) ############## -> (5)
PREFIX umbelrc: <http://umbel.org/umbel/rc/>
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
PREFIX dbo: <http://dbpedia.org/ontology/>
PREFIX dbp: <http://dbpedia.org/property/>
SELECT ?name ?album
WHERE{
?album foaf:name ?name.
?album a schema:MusicAlbum.
FILTER regex(?name, "^").
}
############## Ricerca di tutte le band e di tutti gli artisti (con autocompletamento) ############## -> (6)
PREFIX umbelrc: <http://umbel.org/umbel/rc/>
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
PREFIX dbo: <http://dbpedia.org/ontology/>
PREFIX dbp: <http://dbpedia.org/property/>
SELECT DISTINCT ?entity ?name
WHERE
{
{?entity a umbelrc:MusicalPerformer} UNION {?entity a dbo:Band}
?entity foaf:name ?name.
FILTER regex(?name, "^").
}
--------------------------------------------------------------------------------------------------------------------------------------------------------------------
QUERY DI INSERIMENTO DATI
--------------------------------------------------------------------------------------------------------------------------------------------------------------------
############## Inserimento Genere per una Band o un Artista o un Album ##############
#COMMENTI
$param1 = URI_band/artist/album
$param2 = URI_genre vedi -> (1)
#FINE COMMENTI
INSERT DATA
{
$param1 dbo:genre $param2.
}
############## Inserimento Etichetta Discografica per una Track o per un Album ##############
#COMMENTI
$param1 = URI_album/track
$param2 = URI_recordLabel vedi -> (2)
#FINE COMMENTI
INSERT DATA
{
$param1 dbo:recordLabel $param2.
}
############## Inserimento Artista ##############
#COMMENTI
Può essere tutto null tranne $name
$uriArtist : Lo dovete costruire come una stringa fatta così: "<http://dbpedia.org/resource/" + trim($name).
$name : nome inserito dall'utente.
$abstract: inserito dall'utente
$date: data in formato aaaa-mm-dd
$uriBandRelated: uri della band selezionata tra quelle presenti vedi -> (3)
$uriArtistRelated: uri dell'artista selezionato tra quelli presenti vedi -> (4)
$caption: caption inserito dall'utente
$city: inserità dall'utente
$uriBand: uri della band selezionata tra quelle presenti vedi -> (3)
#FINE COMMENTI
PREFIX schema: <http://schema.org/>
PREFIX umbelrc: <http://umbel.org/umbel/rc/>
PREFIX dbo: <http://dbpedia.org/ontology/>
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX dbp: <http://dbpedia.org/property/>
INSERT DATA{
$uriArtist a umbelrc:MusicalPerformer;
foaf:name $name;
dbo:abstract $abstract;
dbo:birthDate $date^^xsd:date;
dbo:associatedBand $uriBandRelated;
dbo:associatedMusicalArtist $uriArtistRelated;
dbp:caption $caption;
dbp:origin $city.
$uriBand dbp:currentMember $uriArtist.
}
############## Inserimento Band ##############
#COMMENTI
Può essere tutto null tranne $name, $uriMember
$uriBand : La dovete costruire come una stringa fatta così: "<http://dbpedia.org/resource/" + trim($name).
$name : nome inserito dall'utente.
$abstract: inserito dall'utente
$genre : genere scelto dall'utente dalla lista dei generi già presenti vedi -> (1)
$uriBandRelated: uri della band selezionata tra quelle presenti vedi -> (3)
$uriArtistRelated: uri dell'artista selezionato tra quelli presenti vedi -> (4)
$caption: caption inserito dall'utente
$city: inserità dall'utente
$uriBand: uri della band selezionata tra quelle presenti vedi -> (3)
$uriMember: uri dell'artista selezionato tra quelli presenti vedi -> (4)
#FINE COMMENTI
PREFIX schema: <http://schema.org/>
PREFIX umbelrc: <http://umbel.org/umbel/rc/>
PREFIX dbo: <http://dbpedia.org/ontology/>
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX dbp: <http://dbpedia.org/property/>
INSERT DATA{
$uriBAND a dbo:Band;
foaf:name $name;
dbp:website $website;
dbo:abstract $abstract;
dbo:genre $genre;
dbo:associatedBand $uriBandRelated;
dbo:associatedMusicalArtist $uriArtistRelated;
dbp:caption $caption;
dbp:origin $city.
dbp:currentMembers $uriMember.
}
############## Inserimento Track ##############
#COMMENTI
Può essere tutto null tranne $name, $date
$uriTrack : Lo dovete costruire come una stringa fatta così: "<http://dbpedia.org/resource/" + trim($name).
$name : nome della canzone inserita dall'utente
$abstract : abstract inserito dall'utente
$uriAlbum : uri scelta dall'utente dalla lista mostrata tramite la query vedi -> (5)
$recordLabel : uri dell'etichetta discografica vedi -> (2)
$date: data in formato aaaa-mm-dd
$uriArtist : artista o band della canzone vedi query -> (6)
#FINE COMMENTI
PREFIX schema: <http://schema.org/>
PREFIX umbelrc: <http://umbel.org/umbel/rc/>
PREFIX dbo: <http://dbpedia.org/ontology/>
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX dbp: <http://dbpedia.org/property/>
INSERT DATA{
$uriTrack a dbo:MusicalWork;
foaf:name $name;
dbo:abstract $abstract;
dbo:album $uriAlbum;
dbo:recordLabel $recordLabel;
dbo:releaseDate $date^^xsd:date;
dbo:musicalArtist $uriArtist.
}
############## Inserimento Album ##############
#COMMENTI
Può essere tutto null tranne $name e $date
$uriAlbum : Lo dovete costruire come una stringa fatta così: "<http://dbpedia.org/resource/" + trim($name).
$name : nome inserito dall'utente
$abstract : stringa inserita dall'utente
$recordLabel: uri ottenuta mediante la query di ricerca delle label vedi -> (2)
$date: data in formato aaaa-mm-dd
$genre : genere scelto dall'utente dalla lista dei generi già presenti vedi -> (1)
$uriArtist: artista o band dell'album con query vedi -> (6)
#FINE COMMENTI
PREFIX schema: <http://schema.org/>
PREFIX umbelrc: <http://umbel.org/umbel/rc/>
PREFIX dbo: <http://dbpedia.org/ontology/>
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX dbp: <http://dbpedia.org/property/>
INSERT DATA{
$uriAlbum a schema:MusicAlbum;
foaf:name $name;
dbo:abstract $abstract;
dbo:recordLabel $recordLabel;
dbo:releaseDate $date^^xsd:date;
dbo:genre $genre;
dbo:artist $uriArtist.
}