results_query.js 3.0 KB

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