results_query.js 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  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.params);
  9. var params = thisUrlParams.params;
  10. const pp = params.split(";");
  11. var tipo = pp[0];
  12. prefixes = queryManager['prefixes']['all'];
  13. if (tipo=="lemma") {
  14. var uri_lemma = pp[1];
  15. var lemma = pp[2].replace(/%20/g, " ");;
  16. queryEsplora = prefixes + (queryManager['queryRES']['queryEsploraDocumenti']).replaceAll('{URI}', uri_lemma);
  17. queryMappa = prefixes + (queryManager['queryRES']['queryEsploraMappa']).replaceAll('{LEMMA}', uri_lemma);
  18. doJsonQuery(queryEsplora).done(function(r) { handleLemma(r, lemma); });
  19. doJsonQuery(queryMappa).done(function(r) { handle_map(r); });
  20. }
  21. if (tipo=="lettera") {
  22. var uri_mittente = pp[2];
  23. var uri_destinatario = pp[4];
  24. var mittente = pp[1].replace(/%20/g, " ");
  25. var destinatario = pp[3].replace(/%20/g, " ");
  26. queryLettere = prefixes + (queryManager['queryRES']['queryExchange']).replace('{MITTENTE}', uri_mittente).replace('{DESTINATARIO}', uri_destinatario);
  27. doJsonQuery(queryLettere).done(function(r) { handle_Letters(r, mittente, destinatario); });
  28. }
  29. function prepareQueryURL(query){
  30. sparqlEndpoint = 'http://dev.restore.ovi.cnr.it:8890/sparql/';
  31. sparqlUrlParams = '?default-graph-uri=&query=' + encodeURIComponent(query) + '&output=json&callback=?';
  32. return sparqlEndpoint + sparqlUrlParams;
  33. }
  34. function doJsonQuery(query) {
  35. queryURL = prepareQueryURL(query);
  36. return $.ajax({
  37. url: queryURL,
  38. dataType: "json",
  39. type: 'GET'
  40. });
  41. }
  42. // Funzioni per raccattare + stringhificare l'output
  43. queryStringOutput = "";
  44. function stringifyResponse(val){
  45. resultArray = val['results']['bindings'];
  46. out = "";
  47. for(i = 0; i < resultArray.length; i++){
  48. out = out + JSON.stringify(resultArray[i])
  49. }
  50. queryStringOutput = (queryStringOutput + out).replace("}{",",");
  51. }
  52. ////////////////////
  53. // TESTI DELLE QUERY
  54. ////////////////////
  55. /*prefixes = "PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> \
  56. PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> \
  57. PREFIX crm: <http://www.cidoc-crm.org/cidoc-crm/> \
  58. PREFIX dat: <http://datini.archiviodistato.prato.it/la-ricerca/scheda/> \
  59. PREFIX mpp: <http://palazzopretorio.comune.prato.it/it/le-opere/alcuni-capolavori/> \
  60. PREFIX aut: <http://palazzopretorio.comune.prato.it/it/opere/autori/>"
  61. queryLettere = prefixes + " SELECT DISTINCT ?uri_document ?document ?time_span_from ?time_span_to ?uri_place_from ?place_from ?uri_place_to ?place_to \
  62. { \
  63. ?event_from rdfs:subClassOf ?event ; \
  64. rdf:type crm:EL2_Send_Letter . \
  65. ?event_to rdfs:subClassOf ?event ; \
  66. rdf:type crm:EL3_Receive_Letter . \
  67. \
  68. ?event_from crm:P01_has_domain ?pc_from . \
  69. ?pc_from crm:P02_has_range <" + uri_mittente + "> . \
  70. OPTIONAL {?event_from crm:P4_has_time-span ?uri_time_span_from . \
  71. ?uri_time_span_from rdfs:label ?time_span_from} \
  72. OPTIONAL {?event_from crm:P27_moved_from ?aspo_place_from . \
  73. ?aspo_place_from owl:sameAs ?uri_place_from . \
  74. ?uri_place_from rdfs:label ?place_from ; \
  75. crm:P168_place_is_defined_by ?coords_from} \
  76. \
  77. ?event_to crm:P01_has_domain ?pc_to . \
  78. ?pc_to crm:P02_has_range <" + uri_destinatario + "> . \
  79. OPTIONAL {?event_to crm:P4_has_time-span ?uri_time_span_to . \
  80. ?uri_time_span_to rdfs:label ?time_span_to} \
  81. OPTIONAL {?event_to crm:P26_moved_to ?aspo_place_to . \
  82. ?aspo_place_to owl:sameAs ?uri_place_to . \
  83. ?uri_place_to rdfs:label ?place_to ; \
  84. crm:P168_place_is_defined_by ?coords_to} \
  85. \
  86. ?uri_document crm:P25i_moved_by ?event ; \
  87. rdfs:label ?document . \
  88. }"*/