results_query.js 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. // Raccatto i parametri dall'URL -- mi aspetto un parametro di nome 'link'!
  2. thisUrlParams = {};
  3. window.location.href.replace(/[?&]+([^=&]+)=([^&]*)/gi, function(m,key,value) {
  4. thisUrlParams[key] = value;
  5. });
  6. //console.log('URL get params: ', thisUrlParams);
  7. // Funzioni per eseguire le queries
  8. function prepareQueryURL(query){
  9. sparqlEndpoint = 'http://dev.restore.ovi.cnr.it:8890/sparql/';
  10. sparqlUrlParams = '?default-graph-uri=&query=' + encodeURIComponent(query) + '&output=json&callback=?';
  11. return sparqlEndpoint + sparqlUrlParams;
  12. }
  13. function doJsonQuery(query){
  14. queryURL = prepareQueryURL(query);
  15. response = $.ajax({//OGGETTO
  16. url: queryURL,
  17. dataType: "json",
  18. success: function (data){},
  19. error: function (e) {}
  20. });
  21. return response;
  22. }
  23. // Funzioni per raccattare + stringhificare l'output
  24. queryStringOutput = "";
  25. function stringifyResponse(val){
  26. resultArray = val['results']['bindings'];
  27. out = "";
  28. for(i = 0; i < resultArray.length; i++){
  29. out = out + JSON.stringify(resultArray[i])
  30. }
  31. queryStringOutput = (queryStringOutput + out).replace("}{",",");
  32. }
  33. ////////////////////
  34. // TESTI DELLE QUERY
  35. ////////////////////
  36. prefixes = "PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> \
  37. PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> \
  38. PREFIX crm: <http://www.cidoc-crm.org/cidoc-crm/> \
  39. PREFIX dat: <http://datini.archiviodistato.prato.it/la-ricerca/scheda/> \
  40. PREFIX mpp: <http://palazzopretorio.comune.prato.it/it/le-opere/alcuni-capolavori/> \
  41. PREFIX aut: <http://palazzopretorio.comune.prato.it/it/opere/autori/>"
  42. queryLettere = prefixes + " SELECT DISTINCT ?uri_document ?document ?time_span_from ?time_span_to ?uri_place_from ?place_from ?uri_place_to ?place_to \
  43. { \
  44. ?event_from rdfs:subClassOf ?event ; \
  45. rdf:type crm:EL2_Send_Letter . \
  46. ?event_to rdfs:subClassOf ?event ; \
  47. rdf:type crm:EL3_Receive_Letter . \
  48. \
  49. ?event_from crm:P01_has_domain ?pc_from . \
  50. ?pc_from crm:P02_has_range <http://www.archiviodistato.prato.it/accedi-e-consulta/aspoMV001/scheda/IT-ASPO-AU00003-0000806> . \
  51. OPTIONAL {?event_from crm:P4_has_time-span ?uri_time_span_from . \
  52. ?uri_time_span_from rdfs:label ?time_span_from} \
  53. OPTIONAL {?event_from crm:P27_moved_from ?aspo_place_from . \
  54. ?aspo_place_from owl:sameAs ?uri_place_from . \
  55. ?uri_place_from rdfs:label ?place_from ; \
  56. crm:P168_place_is_defined_by ?coords_from} \
  57. \
  58. ?event_to crm:P01_has_domain ?pc_to . \
  59. ?pc_to crm:P02_has_range <http://www.archiviodistato.prato.it/accedi-e-consulta/aspoMV001/scheda/IT-ASPO-AU00003-0001817> . \
  60. OPTIONAL {?event_to crm:P4_has_time-span ?uri_time_span_to . \
  61. ?uri_time_span_to rdfs:label ?time_span_to} \
  62. OPTIONAL {?event_to crm:P26_moved_to ?aspo_place_to . \
  63. ?aspo_place_to owl:sameAs ?uri_place_to . \
  64. ?uri_place_to rdfs:label ?place_to ; \
  65. crm:P168_place_is_defined_by ?coords_to} \
  66. \
  67. ?uri_document crm:P25i_moved_by ?event ; \
  68. rdfs:label ?document . \
  69. }"