lettera_query.js 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. thisUrlParams = {};
  2. window.location.href.replace(/[?&]+([^=&]+)=([^&]*)/gi, function(m,key,value) {
  3. thisUrlParams[key] = value;
  4. });
  5. console.log('URL get params: ', thisUrlParams);
  6. function prepareQueryURL(query){
  7. sparqlEndpoint = 'http://dev.restore.ovi.cnr.it:8890/sparql/';
  8. sparqlUrlParams = '?default-graph-uri=&query=' + encodeURIComponent(query) + '&output=json&callback=?';
  9. return sparqlEndpoint + sparqlUrlParams;
  10. }
  11. queryStringOutput = "";
  12. function doJsonQuery(query){
  13. queryURL = prepareQueryURL(query);
  14. response = $.ajax({//OGGETTO
  15. url: queryURL,
  16. dataType: "json",
  17. success: function (data){},
  18. error: function (e) {}
  19. });
  20. return response;
  21. }
  22. prefixes = "PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> \
  23. PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> \
  24. PREFIX crm: <http://www.cidoc-crm.org/cidoc-crm/> \
  25. PREFIX dat: <http://datini.archiviodistato.prato.it/la-ricerca/scheda/> \
  26. PREFIX mpp: <http://palazzopretorio.comune.prato.it/it/le-opere/alcuni-capolavori/> \
  27. PREFIX aut: <http://palazzopretorio.comune.prato.it/it/opere/autori/>"
  28. query1 = prefixes + " SELECT DISTINCT ?mittente ?destinatario ?data_partenza ?data_arrivo ?luogo_partenza ?luogo_arrivo \
  29. WHERE {?subject crm:P128_carries <" + thisUrlParams.link + "> \
  30. GRAPH <http://dev.restore.ovi.cnr.it:8890/ovi/datini/ex> {?subject crm:P25i_moved_by ?mov_ev .} \
  31. ?send rdfs:subClassOf ?mov_ev ; \
  32. rdf:type crm:EL2_Send_Letter ; \
  33. crm:P4_has_time-span ?time_spanA; \
  34. crm:P27_moved_from ?placeA; \
  35. crm:P01_has_domain ?sender . \
  36. \
  37. ?time_spanA rdfs:label ?data_partenza . \
  38. ?placeA rdfs:label ?luogo_partenza . \
  39. ?sender crm:P02_has_range ?mittente . \
  40. \
  41. ?receive rdfs:subClassOf ?mov_ev; \
  42. rdf:type crm:EL3_Receive_Letter ; \
  43. crm:P4_has_time-span ?time_spanB; \
  44. crm:P26_moved_to ?placeB; \
  45. crm:P01_has_domain ?receiver . \
  46. \
  47. ?time_spanB rdfs:label ?data_arrivo . \
  48. ?placeB rdfs:label ?luogo_arrivo . \
  49. ?receiver crm:P02_has_range ?destinatario . \
  50. }"
  51. queryAreaLinguistica = prefixes + " SELECT DISTINCT ?lingua ?area_linguistica \
  52. WHERE {<" + thisUrlParams.link + "> crm:P72_has_language ?language . \
  53. ?language crm:P3_has_note ?area ; \
  54. rdfs:label ?lingua . \
  55. ?area rdfs:label ?area_linguistica \
  56. }"
  57. queryDescrizione = prefixes + " SELECT DISTINCT ?descrizione \
  58. WHERE {<" + thisUrlParams.link + "> crm:P3_has_note ?description . \
  59. ?description rdfs:label ?descrizione \
  60. }"
  61. queryTipo = prefixes + " SELECT DISTINCT ?tipologia \
  62. WHERE {<" + thisUrlParams.link + "> crm:P2_has_type ?type . \
  63. ?type rdf:type crm:E55_Type; \
  64. rdfs:label ?tipologia . \
  65. }"
  66. querySiglaOVI = prefixes + " SELECT DISTINCT ?sigla_OVI \
  67. WHERE {<" + thisUrlParams.link + "> crm:P1_is_identified_by ?id . \
  68. ?id rdf:type crm:E42_Identifier; \
  69. crm:P2_has_type ?type ; \
  70. rdfs:label ?sigla_OVI . \
  71. ?type rdfs:label 'Sigla OVI'. \
  72. }"
  73. queryTitolo = prefixes + " SELECT DISTINCT ?titolo \
  74. WHERE {<" + thisUrlParams.link + "> crm:P1_is_identified_by ?title . \
  75. ?title rdf:type crm:E35_Title; \
  76. rdfs:label ?titolo . \
  77. }"
  78. queryTestoLemmatizzato = prefixes + " SELECT DISTINCT ?testo_lemmatizzato \
  79. WHERE {<" + thisUrlParams.link + "> crm:P190_has_symbolic_content ?testo_lemmatizzato . \
  80. }"
  81. queryEdizione = prefixes + " SELECT DISTINCT ?edizione ?edizione_abbreviata \
  82. WHERE {?edition crm:P70_documents <" + thisUrlParams.link + "> ; \
  83. crm:P1_is_identified_by ?edition_id . \
  84. ?edition_id rdfs:label ?edizione; \
  85. crm:P139_has_alternative_form ?ed_abbr . \
  86. ?ed_abbr rdfs:label ?edizione_abbreviata \
  87. }"
  88. queryRaccolta = prefixes + " SELECT DISTINCT ?raccolta \
  89. WHERE {?racc crm:P148_has_component <" + thisUrlParams.link + "> ; \
  90. crm:P2_has_type ?racc_type ; \
  91. rdfs:label ?raccolta . \
  92. ?racc_type rdfs:label 'Raccolta'. \
  93. }"
  94. function stringifyResponse(val){
  95. resultArray = val['results']['bindings'];
  96. out = "";
  97. for(i = 0; i < resultArray.length; i++){
  98. out = out + JSON.stringify(resultArray[i])
  99. }
  100. queryStringOutput = (queryStringOutput + out).replace("}{",",");
  101. }