advanced_search.js 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882
  1. const choiceArray = [
  2. ["Nome risorsa", "Object, OA, Person, Letter, Place", "label"],
  3. ["Identificatore", "Object, OA, Person, Letter, Place", "identifier"],
  4. ["Materia", "Object, OA", "material"],
  5. ["Istituto di conservazione", "Object, OA", "localization"],
  6. ["Tecnica", "OA", "technique"],
  7. ["Artista", "OA", "artist"],
  8. ["Soggetto", "OA", "subject"],
  9. ["Titolo", "Object, Inf", "title"],
  10. ["Tipo di risorsa", "Object, Inf", "type"],
  11. ["Nome proprio", "Person", "givenName"],
  12. ["Nome di famiglia", "Person", "familyName"],
  13. ["Luogo di Nascita", "Person", "birthPlace"],
  14. ["Luogo di Morte", "Person", "deathPlace"],
  15. ["Genere", "Person", "sex"],
  16. ["Data di Nascita", "Person", "birthDate"],
  17. ["Data di Morte", "Person", "deathDate"],
  18. ["Occupazione", "Person", "occupation"],
  19. ["Qualifica", "Person", "qualification"],
  20. ["Mittente", "Letter", "sender"],
  21. ["Destinatario", "Letter", "receiver"],
  22. ["Luogo di Partenza", "Letter", "startPlace"],
  23. ["Luogo di Arrivo", "Letter", "endPlace"],
  24. ["Data partenza", "Letter", "startDate"],
  25. ["Data arrivo", "Letter", "endDate"],
  26. ["Lingua", "Letter", "language"],
  27. ["Area linguistica", "Letter", "languageArea"],
  28. ["Edizione", "Letter", "edition"],
  29. ["Antroponimo", "Letter", "antroponym"],
  30. ["Toponimo", "Letter", "toponym"],
  31. ["Data", "Object, OA", "date"]
  32. ];
  33. const typeArray = [
  34. ["Oggetto", "Object"],
  35. ["Lettera", "Letter"],
  36. ["Opera d'Arte", "OA"],
  37. ["Persona", "Person"],
  38. ["Luogo", "Place"]
  39. ];
  40. const graphArray = [
  41. ["ASPO - Datini", "http://dev.restore.ovi.cnr.it:8890/aspo/datini"],
  42. ["ASPO - Ospedale", "http://dev.restore.ovi.cnr.it:8890/aspo/ospedale"],
  43. ["ASPO - Marcovaldi", "http://dev.restore.ovi.cnr.it:8890/aspo/marcovaldi"],
  44. ["ASPO - Gettatelli", "http://dev.restore.ovi.cnr.it:8890/aspo/gettatelli"],
  45. ["ASPO - Autori ASPO", "http://dev.restore.ovi.cnr.it:8890/aspo/actors"],
  46. ["MPP - Collezione Martini", "http://dev.restore.ovi.cnr.it:8890/mpp/martini"],
  47. ["MPP - Collezione Ospedale", "http://dev.restore.ovi.cnr.it:8890/mpp/ospedale"],
  48. ["MPP - Collezione Datini", "http://dev.restore.ovi.cnr.it:8890/mpp/datini"],
  49. ["OVI - Lettere", "http://dev.restore.ovi.cnr.it:8890/ovi/datini"]
  50. ];
  51. const objectArray = [];
  52. const personArray = [];
  53. const placeArray = [];
  54. const oaArray = [];
  55. const letterArray = [];
  56. $(document).ready(function () {
  57. //#######################################
  58. var type_selector = document.getElementById("type_selector");
  59. var collection_selector = document.getElementById("collection_selector");
  60. let x = typeArray.length;
  61. for(var i=0; i<x; i++) {
  62. var opt = document.createElement("option");
  63. opt.value= typeArray[i][1];
  64. opt.innerHTML = typeArray[i][0]; // whatever property it has
  65. // then append it to the select element
  66. type_selector.add(opt);
  67. }
  68. let y = graphArray.length;
  69. for(var i=0; i<y; i++) {
  70. var opt = document.createElement("option");
  71. opt.value= graphArray[i][1];
  72. opt.innerHTML = graphArray[i][0]; // whatever property it has
  73. // then append it to the select element
  74. collection_selector.add(opt);
  75. }
  76. let z = choiceArray.length;
  77. for(var i=0; i<z; i++) {
  78. var cat = choiceArray[i][1];
  79. if (cat.includes("Object")) {
  80. objectArray.push(choiceArray[i]);
  81. }
  82. if (cat.includes("OA")) {
  83. oaArray.push(choiceArray[i]);
  84. }
  85. if (cat.includes("Person")) {
  86. personArray.push(choiceArray[i]);
  87. }
  88. if (cat.includes("Letter")) {
  89. letterArray.push(choiceArray[i]);
  90. }
  91. if (cat.includes("Place")) {
  92. placeArray.push(choiceArray[i]);
  93. }
  94. }
  95. $("#type_selector").change(function(){
  96. $(this).find("option:selected").each(function(){
  97. var optionValue = $(this).attr("value");
  98. if(optionValue){
  99. $(".box").not("." + optionValue).hide();
  100. $("." + optionValue).show();
  101. } else{
  102. $(".box").hide();
  103. }
  104. });
  105. }).change();
  106. /*$('[name=sel-parent]').on('change', function() {
  107. $(this).attr("id", 'example' + $(this).name());
  108. });*/
  109. });
  110. function populateOptions(selector, myArray) {
  111. var choice_selector = document.getElementById(selector);
  112. let k = myArray.length;
  113. for(var i=0; i<k; i++) {
  114. var opt = document.createElement("option");
  115. opt.value= myArray[i][1];
  116. opt.innerHTML = myArray[i][0]; // whatever property it has
  117. // then append it to the select element
  118. choice_selector.add(opt);
  119. }
  120. $('#' + selector).on( "change", function() {
  121. var numberId= selector.split("-")[1]
  122. var inputText= $( this ).find(":selected").text();
  123. /*$('#inputchoiceSelector_' + numberId).val(inputText);
  124. $('#inputchoiceSelector_' + numberId).id(inputText);*/
  125. });
  126. }
  127. var val = 0;
  128. function addToList() {
  129. val = val+1;
  130. var sel = '<div id="box_' + val + '" class="container_choice"><div class="remove"><a onclick="removeElement(\'box_' + val + '\')"><i class="fa fa-trash" aria-hidden="true"></i></a></div><div class="choice_box"><select id ="choice_selector-' + val + '" value=' + val + ' name="sel-parent" class="advanced-form-select form-control" aria-label="Default select example"> \
  131. <option selected value="0">Scegli un\'opzione</option> \
  132. <input type="text" id="inputchoiceSelector_'+ val +'" class="selected_option form-control" placeholder="Enter search terms" aria-label="Enter search terms" aria-describedby="button-addon2"> \
  133. </select></div></div>';
  134. $('#drop-down-content').append(sel);
  135. var selector = 'choice_selector-' + val;
  136. populateOptions(selector, choiceArray);
  137. }
  138. function addToListObject() {
  139. val = val+100;
  140. var sel = '<div id="box_' + val + '" class="container_choice"><div class="remove"><a onclick="removeElement(\'box_' + val + '\')"><i class="fa fa-trash" aria-hidden="true"></i></a></div><div class="choice_box"><select id ="choice_selector-' + val + '" value=' + val + ' name="sel-parent" class="advanced-form-select form-control" aria-label="Default select example"> \
  141. <option selected value="0">Scegli un\'opzione</option> \
  142. <input type="text" id="inputchoiceSelector_'+ val +'" class="selected_option form-control" placeholder="Enter search terms" aria-label="Enter search terms" aria-describedby="button-addon2"> \
  143. </select></div></div>';
  144. $('#drop-down-content-Object').append(sel);
  145. var selector = 'choice_selector-' + val;
  146. populateOptions(selector, objectArray);
  147. }
  148. function addToListOA() {
  149. val = val+200;
  150. var sel = '<div id="box_' + val + '" class="container_choice"><div class="remove"><a onclick="removeElement(\'box_' + val + '\')"><i class="fa fa-trash" aria-hidden="true"></i></a></div><div class="choice_box"><select id ="choice_selector-' + val + '" value=' + val + ' name="sel-parent" class="advanced-form-select form-control" aria-label="Default select example"> \
  151. <option selected value="0">Scegli un\'opzione</option> \
  152. <input type="text" id="inputchoiceSelector_'+ val +'" class="selected_option form-control" placeholder="Enter search terms" aria-label="Enter search terms" aria-describedby="button-addon2"> \
  153. </select></div></div>';
  154. $('#drop-down-content-OA').append(sel);
  155. var selector = 'choice_selector-' + val;
  156. populateOptions(selector, oaArray);
  157. }
  158. function addToListPerson() {
  159. val = val+300;
  160. var sel = '<div id="box_' + val + '" class="container_choice"><div class="remove"><a onclick="removeElement(\'box_' + val + '\')"><i class="fa fa-trash" aria-hidden="true"></i></a></div><div class="choice_box"><select id ="choice_selector-' + val + '" value=' + val + ' name="sel-parent" class="advanced-form-select form-control" aria-label="Default select example"> \
  161. <option selected value="0">Scegli un\'opzione</option> \
  162. <input type="text" id="inputchoiceSelector_'+ val +'" class="selected_option form-control" placeholder="Enter search terms" aria-label="Enter search terms" aria-describedby="button-addon2"> \
  163. </select></div></div>';
  164. $('#drop-down-content-Person').append(sel);
  165. var selector = 'choice_selector-' + val;
  166. populateOptions(selector, personArray);
  167. }
  168. function addToListLetter() {
  169. val = val+400;
  170. var sel = '<div id="box_' + val + '" class="container_choice"><div class="remove"><a onclick="removeElement(\'box_' + val + '\')"><i class="fa fa-trash" aria-hidden="true"></i></a></div><div class="choice_box"><select id ="choice_selector-' + val + '" value=' + val + ' name="sel-parent" class="advanced-form-select form-control" aria-label="Default select example"> \
  171. <option selected value="0">Scegli un\'opzione</option> \
  172. <input type="text" id="inputchoiceSelector_'+ val +'" class="selected_option form-control" placeholder="Enter search terms" aria-label="Enter search terms" aria-describedby="button-addon2"> \
  173. </select></div></div>';
  174. $('#drop-down-content-Letter').append(sel);
  175. var selector = 'choice_selector-' + val;
  176. populateOptions(selector, letterArray);
  177. }
  178. function addToListPlace() {
  179. val = val+500;
  180. var sel = '<div id="box_' + val + '" class="container_choice"><div class="remove"><a onclick="removeElement(\'box_' + val + '\')"><i class="fa fa-trash" aria-hidden="true"></i></a></div><div class="choice_box"><select id ="choice_selector-' + val + '" value=' + val + ' name="sel-parent" class="advanced-form-select form-control" aria-label="Default select example"> \
  181. <option selected value="0">Scegli un\'opzione</option> \
  182. <input type="text" id="inputchoiceSelector_'+ val +'" class="selected_option form-control" placeholder="Enter search terms" aria-label="Enter search terms" aria-describedby="button-addon2"> \
  183. </select></div></div>';
  184. $('#drop-down-content-Place').append(sel);
  185. var selector = 'choice_selector-' + val;
  186. populateOptions(selector, placeArray);
  187. }
  188. //Get parameters from select and input options to build the query
  189. function getParameters() {
  190. const arr = [];
  191. const collection = document.getElementsByClassName("advanced-form-select");
  192. for (let i = 0; i < collection.length; i++) {
  193. var x = collection[i].id;
  194. var t = document.getElementById(x);
  195. var e = t.options[t.selectedIndex].text;
  196. var numberId= x.split("-")[1]
  197. var inputId = "inputchoiceSelector_" + numberId;
  198. var inputText = document.getElementById(inputId).value;
  199. var el = [e, inputText];
  200. arr.push(el);
  201. }
  202. constructQuery(arr);
  203. /*$('#query_results').append(arr);
  204. testo = $('input#writeText').val();*/
  205. }
  206. function removeElement(id_element) {
  207. const element = document.getElementById(id_element);
  208. element.remove();
  209. }
  210. //Build query with harvested parametes
  211. function constructQuery(params) {
  212. var g = document.getElementById("collection_selector");
  213. var graph = g.value;
  214. var search_graph = "?g";
  215. if (graph != "") {
  216. search_graph = '<' + graph + '>';
  217. }
  218. var search_type = "";
  219. var ct = document.getElementById("type_selector");
  220. var choosen_type = ct.value;
  221. console.log(choosen_type);
  222. if (choosen_type == "Object") {
  223. search_type = "?subject rdf:type crm:E22_Man-Made_Object . ";
  224. }
  225. /*if (choosen_type == "Person") {
  226. search_type = "?subject rdf:type crm:E21_Person . ";
  227. }
  228. if (choosen_type == "Place") {
  229. search_type = "?subject rdf:type crm:E53_Place . ";
  230. }*/
  231. //Letter, OA, Person, Place
  232. var label = ""; //
  233. var identificatore = ""; //
  234. var dimensione = ""; //
  235. var materia = ""; //
  236. var localizzazione = ""; //
  237. var tecnica = ""; //
  238. var artista = ""; //
  239. var soggetto = ""; //
  240. var titolo = ""; //
  241. var tipo = ""; //
  242. var note = ""; //
  243. var riferimenti = ""; //
  244. var nome_proprio = ""; //
  245. var nome_di_famiglia = ""; //
  246. var patronimico = ""; //
  247. var luogo_di_Nascita = ""; //
  248. var luogo_di_Morte = ""; //
  249. var genere = ""; //
  250. var data_di_Nascita = ""; //
  251. var data_di_Morte = ""; //
  252. var occupazione = ""; //
  253. var qualifica = ""; //
  254. var gruppi_di_appartenenza = ""; //
  255. var mittente = ""; //
  256. var destinatario = ""; //
  257. var luogo_di_Partenza = ""; //
  258. var luogo_di_Arrivo = ""; //
  259. var data_partenza = ""; //
  260. var data_arrivo = ""; //
  261. var lingua = ""; //
  262. var area_linguistica = ""; //
  263. var edizione = ""; //
  264. var antroponimo = ""; //
  265. var toponimo = ""; //
  266. var data = ""; //
  267. var letter_event = ""; //
  268. var infObj = ""; //
  269. var id = ""; //
  270. var dm = ""; //
  271. var mt = ""; //
  272. var loc = ""; //
  273. var tec = ""; //
  274. var at = ""; //
  275. var sg = ""; //
  276. var tt = ""; //
  277. var tp = ""; //
  278. var nt = ""; //
  279. var rf = ""; //
  280. var np = ""; //
  281. var nf = ""; //
  282. var pt = ""; //
  283. var ln = ""; //
  284. var lm = ""; //
  285. var gr = ""; //
  286. var dn = ""; //
  287. var dts = ""; //
  288. var oc = ""; //
  289. var qf = ""; //
  290. var ga = ""; //
  291. var mit = ""; //
  292. var des = ""; //
  293. var lp = ""; //
  294. var la = ""; //
  295. var dp = ""; //
  296. var da = ""; //
  297. var lin = ""; //
  298. var alin = ""; //
  299. var ed = ""; //
  300. var antr = ""; //
  301. var topo = ""; //
  302. var dt = ""; //
  303. for (let i = 0; i < params.length; i++) {
  304. if(params[i][0] == "Nome risorsa" && (params[i][1] != "")) {
  305. label = "?label bif:contains \"\' "+ params[i][1] + " \'\" . ";
  306. }
  307. if(params[i][0] == "Identificatore" && (params[i][1] != "")) {
  308. id = " ?identifier";
  309. identificatore = "?subject crm:P1_is_identified_by ?uri_identifier . \
  310. ?uri_identifier rdfs:label ?identifier . \
  311. ?identifier bif:contains \"\'"+ params[i][1] +"\'\" . ";
  312. }
  313. if(params[i][0] == "Dimensione" && (params[i][1] != "")) {
  314. dm = " ?dimension";
  315. dimensione = "?subject crm:P43_has_dimension ?uri_dimension . \
  316. ?uri_dimension rdfs:label ?dimension . \
  317. ?dimension bif:contains \"\'"+ params[i][1] +"\'\" ."
  318. }
  319. if(params[i][0] == "Materia" && (params[i][1] != "")) {
  320. mt = " ?material";
  321. materia = "?subject crm:P45_consists_of ?uri_material . \
  322. ?uri_material rdfs:label ?material . \
  323. ?material bif:contains \"\'"+ params[i][1] +"\'\" ."
  324. }
  325. if(params[i][0] == "Istituto di conservazione" && (params[i][1] != "")) {
  326. loc = " ?location";
  327. localizzazione = "?subject crm:P54_has_current_permanent_location ?uri_location . \
  328. ?uri_location rdfs:label ?location . \
  329. ?location bif:contains \"\'"+ params[i][1] +"\'\" ."
  330. }
  331. if(params[i][0] == "Tecnica" && (params[i][1] != "")) {
  332. tec = " ?technique";
  333. tecnica = "?subject ?property ?event . \
  334. ?event crm:P32_used_general_technique ?uri_technique . \
  335. ?uri_technique rdfs:label ?technique . \
  336. ?technique bif:contains \"\'"+ params[i][1] +"\'\" . "
  337. }
  338. if (params[i][0] == "Artista" && (params[i][1] != "")) {
  339. at = " ?artist";
  340. artista = "?subject rdfs:label ?label . \
  341. ?production crm:P108_has_produced ?subject . \
  342. ?pc crm:P01_has_domain ?production . \
  343. ?pc crm:P02_has_range ?range . \
  344. ?range rdfs:label ?artist . \
  345. ?artist bif:contains \"\'"+ params[i][1] +"\'\" ."
  346. }
  347. if (params[i][0] == "Soggetto" && (params[i][1] != "")) {
  348. sg = " ?depiction";
  349. soggetto = "?subject crm:P62_depicts ?uri_depiction . \
  350. ?uri_depiction rdfs:label ?depiction . \
  351. ?depiction bif:contains \"\'"+ params[i][1] +"\'\" ."
  352. }
  353. if (params[i][0] == "Titolo" && (params[i][1] != "")) {
  354. tt = " ?title";
  355. infObj = "?subject crm:P128_carries ?information_object .";
  356. titolo = "?information_object crm:P1_is_identified_by ?uri_title . \
  357. ?uri_title rdfs:label ?title . \
  358. ?title bif:contains \"\'"+ params[i][1] +"\'\" ."
  359. }
  360. if (params[i][0] == "Tipo di risorsa" && (params[i][1] != "")) {
  361. tp = " ?type";
  362. infObj = "?subject crm:P128_carries ?information_object .";
  363. tipo = "?information_object crm:P2_has_type ?uri_type . \
  364. ?uri_type rdfs:label ?type . \
  365. ?type bif:contains \"\'"+ params[i][1] +"\'\" ."
  366. }
  367. if (params[i][0] == "Note" && (params[i][1] != "")) {
  368. nt = " ?note";
  369. note = "?subject crm:P3_has_note ?uri_note . \
  370. ?uri_note rdfs:label ?note . \
  371. ?note bif:contains \"\'"+ params[i][1] +"\'\" .";
  372. }
  373. if (params[i][0] == "Riferimenti" && (params[i][1] != "")) {
  374. rf = " ?ref";
  375. riferimenti = "?subject crm:P67_refers_to ?uri_ref . \
  376. ?uri_ref rdfs:label ?ref . \
  377. ?ref bif:contains \"\'"+ params[i][1] +"\'\" . "
  378. }
  379. if (params[i][0] == "Nome proprio" && (params[i][1] != "")) {
  380. np = " ?givenName";
  381. nome_proprio = "?subject foaf:givenName ?givenName . \
  382. ?givenName bif:contains \"\'"+ params[i][1] +"\'\" . "
  383. }
  384. if (params[i][0] == "Nome di famiglia" && (params[i][1] != "")) {
  385. nf = " ?familyName";
  386. nome_di_famiglia = "?subject foaf:familyName ?familyName . \
  387. ?familyName bif:contains \"\'"+ params[i][1] +"\'\" . "
  388. }
  389. if (params[i][0] == "Patronimico" && (params[i][1] != "")) {
  390. pt = " ?patronymic";
  391. patronimico = "?subject person:patronymicName ?patronymic . \
  392. ?patronymic bif:contains \"\'"+ params[i][1] +"\'\" . "
  393. }
  394. if (params[i][0] == "Luogo di Nascita" && (params[i][1] != "")) {
  395. ln = " ?birthPlace";
  396. luogo_di_Nascita = "?subject crm:P98i_was_born ?Birth . \
  397. ?Birth crm:P7_took_place_at ?uri_birthPlace . \
  398. ?uri_birthPlace rdfs:label ?birthPlace . \
  399. ?birthPlace bif:contains \""+ params[i][1] +"\" . "
  400. }
  401. if (params[i][0] == "Luogo di Morte" && (params[i][1] != "")) {
  402. lm = " ?deathPlace";
  403. luogo_di_Morte = "?subject crm:P100i_died_in ?Death . \
  404. ?Death crm:P7_took_place_at ?uri_deathPlace . \
  405. ?uri_deathPlace rdfs:label ?deathPlace \
  406. ?deathPlace bif:contains \""+ params[i][1] +"\" . "
  407. }
  408. if (params[i][0] == "Genere" && (params[i][1] != "")) {
  409. gr = "?genere";
  410. genere = "?subject foaf:gender ?genere . \
  411. ?genere bif:contains \""+ params[i][1] +"\" . "
  412. }
  413. if (params[i][0] == "Data di Nascita" && (params[i][1] != "")) {
  414. dn = " ?Birth_TS";
  415. data_di_Nascita = "?subject crm:P98i_was_born ?Birth . \
  416. ?Birth crm:P4_has_time-span ?Birth_TS . \
  417. ?Birth_TS rdfs:label \""+ params[i][1] +"\" ."
  418. }
  419. if (params[i][0] == "Data di Morte" && (params[i][1] != "")) {
  420. dts = " ?Death_TS";
  421. data_di_Morte = "?subject crm:P100i_died_in ?Death . \
  422. ?Death crm:P4_has_time-span ?Death_TS . \
  423. ?Death_TS rdfs:label \""+ params[i][1] +"\" . "
  424. }
  425. if (params[i][0] == "Qualifica" && (params[i][1] != "")) {
  426. qf = " ?qualification";
  427. qualifica = "?subject schema:honorificPrefix ?qualification . \
  428. ?qualification bif:contains \"\'"+ params[i][1] +"\'\" . "
  429. }
  430. if (params[i][0] == "Occupazione" && (params[i][1] != "")) {
  431. oc = " ?occupation";
  432. occupazione = "?subject schema:hasOccupation ?uriOccupation . \
  433. ?uriOccupation rdf:type schema:Occupation; \
  434. rdfs:label ?occupation . \
  435. ?occupation bif:contains \"\'"+ params[i][1] +"\'\" . "
  436. }
  437. if (params[i][0] == "Gruppi di appartenenza" && (params[i][1] != "")) {
  438. ga = " ?group";
  439. gruppi_di_appartenenza = "?subject crm:P107i_is_current_or_former_member_of ?uriGroup . \
  440. ?uriGroup rdfs:label ?group . \
  441. ?group bif:contains \"\'"+ params[i][1] +"\'\" . "
  442. }
  443. if (params[i][0] == "Mittente" && (params[i][1] != "")) {
  444. mit = " ?mittente";
  445. letter_event = "?subject crm:P25i_moved_by ?mov_ev . \
  446. ?send rdfs:subClassOf ?mov_ev ; \
  447. rdf:type crm:EL2_Send_Letter . \
  448. ?receive rdfs:subClassOf ?mov_ev; \
  449. rdf:type crm:EL3_Receive_Letter . ";
  450. mittente = "?send crm:P01_has_domain ?pcS . \
  451. ?pcS crm:P02_has_range ?uriSender . \
  452. ?uriSender rdfs:label ?mittente . \
  453. ?mittente bif:contains \"\'"+ params[i][1] +"\'\" . "
  454. }
  455. if (params[i][0] == "Destinatario" && (params[i][1] != "")) {
  456. des = " ?destinatario";
  457. letter_event = "?subject crm:P25i_moved_by ?mov_ev . \
  458. ?send rdfs:subClassOf ?mov_ev ; \
  459. rdf:type crm:EL2_Send_Letter . \
  460. ?receive rdfs:subClassOf ?mov_ev; \
  461. rdf:type crm:EL3_Receive_Letter . ";
  462. destinatario = "?receive crm:P01_has_domain ?pcR . \
  463. ?pcR crm:P02_has_range ?uriReceiver . \
  464. ?uriReceiver rdfs:label ?destinatario . \
  465. ?destinatario bif:contains \"\'"+ params[i][1] +"\'\" . "
  466. }
  467. if (params[i][0] == "Luogo di Partenza" && (params[i][1] != "")) {
  468. lp = " ?luogo_partenza";
  469. letter_event = "?subject crm:P25i_moved_by ?mov_ev . \
  470. ?send rdfs:subClassOf ?mov_ev ; \
  471. rdf:type crm:EL2_Send_Letter . \
  472. ?receive rdfs:subClassOf ?mov_ev; \
  473. rdf:type crm:EL3_Receive_Letter . ";
  474. luogo_di_Partenza = "?send crm:P27_moved_from ?uriLuogoPartenza . \
  475. ?uriLuogoPartenza rdfs:label ?luogo_partenza . \
  476. ?luogo_partenza bif:contains \"\'"+ params[i][1] +"\'\" . "
  477. }
  478. if (params[i][0] == "Luogo di Arrivo" && (params[i][1] != "")) {
  479. la = " ?luogo_arrivo";
  480. letter_event = "?subject crm:P25i_moved_by ?mov_ev . \
  481. ?send rdfs:subClassOf ?mov_ev ; \
  482. rdf:type crm:EL2_Send_Letter . \
  483. ?receive rdfs:subClassOf ?mov_ev; \
  484. rdf:type crm:EL3_Receive_Letter . ";
  485. luogo_di_Arrivo = "?receive crm:P26_moved_to ?uriLuogoArrivo . \
  486. ?uriLuogoArrivo rdfs:label ?luogo_arrivo . \
  487. ?luogo_arrivo bif:contains \"\'"+ params[i][1] +"\'\" . "
  488. }
  489. if (params[i][0] == "Data partenza" && (params[i][1] != "")) {
  490. dp = " ?timeSpanSend";
  491. letter_event = "?subject crm:P25i_moved_by ?mov_ev . \
  492. ?send rdfs:subClassOf ?mov_ev ; \
  493. rdf:type crm:EL2_Send_Letter . \
  494. ?receive rdfs:subClassOf ?mov_ev; \
  495. rdf:type crm:EL3_Receive_Letter . ";
  496. data_partenza = "?send crm:P4_has_time-span ?time_spanS . \
  497. ?time_spanS rdfs:label ?timeSpanSend . \
  498. ?timeSpanSend bif:contains \"\'"+ params[i][1] +"\'\" . "
  499. }
  500. if (params[i][0] == "Data arrivo" && (params[i][1] != "")) {
  501. da = " ?timeSpanReceive";
  502. letter_event = "?subject crm:P25i_moved_by ?mov_ev . \
  503. ?send rdfs:subClassOf ?mov_ev ; \
  504. rdf:type crm:EL2_Send_Letter . \
  505. ?receive rdfs:subClassOf ?mov_ev; \
  506. rdf:type crm:EL3_Receive_Letter . ";
  507. data_arrivo = "?receive crm:P4_has_time-span ?time_spanR . \
  508. ?time_spanR rdfs:label ?timeSpanReceive .\
  509. ?timeSpanReceive bif:contains \"\'"+ params[i][1] +"\'\" . "
  510. }
  511. if (params[i][0] == "Lingua" && (params[i][1] != "")) {
  512. lin = " ?lingua";
  513. infObj = "?subject crm:P128_carries ?information_object .";
  514. lingua = "?information_object crm:P72_has_language ?language . \
  515. ?language rdfs:label ?lingua . \
  516. ?lingua bif:contains \"\'"+ params[i][1] +"\'\" ."
  517. }
  518. if (params[i][0] == "Area linguistica" && (params[i][1] != "")) {
  519. alin = " ?area_linguistica";
  520. infObj = "?subject crm:P128_carries ?information_object .";
  521. area_linguistica = "?information_object crm:P72_has_language ?language . \
  522. ?language crm:P3_has_note ?area . \
  523. ?area rdfs:label ?area_linguistica .\
  524. ?area_linguistica bif:contains \"\'"+ params[i][1] +"\'\" ."
  525. }
  526. if (params[i][0] == "Edizione" && (params[i][1] != "")) {
  527. ed = " ?edizione";
  528. infObj = "?subject crm:P128_carries ?information_object .";
  529. edizione = "?edition crm:P70_documents ?information_object ; \
  530. crm:P1_is_identified_by ?edition_id . \
  531. ?edition_id rdfs:label ?edizione . \
  532. ?edizione bif:contains \"\'"+ params[i][1] +"\'\" ."
  533. }
  534. if (params[i][0] == "Toponimo" && (params[i][1] != "")) {
  535. topo = " ?toponimo";
  536. infObj = "?subject crm:P128_carries ?information_object .";
  537. toponimo = "?information_object crm:P67_refers_to ?link_toponimo . \
  538. ?link_toponimo rdfs:label ?toponimo ; \
  539. crm:P2_has_type 'Toponimo' . \
  540. ?toponimo bif:contains \"\'"+ params[i][1] +"\'\" ."
  541. }
  542. if (params[i][0] == "Antroponimo" && (params[i][1] != "")) {
  543. antr = " ?antroponimo";
  544. infObj = "?subject crm:P128_carries ?information_object .";
  545. antroponimo = "?information_object crm:P67_refers_to ?link_antroponimo . \
  546. ?link_antroponimo rdfs:label ?antroponimo; \
  547. crm:P2_has_type 'Antroponimo' . \
  548. ?antroponimo bif:contains \"\'"+ params[i][1] +"\'\" ."
  549. }
  550. if (params[i][0] == "Data" && (params[i][1] != "")) {
  551. dt = " ?date";
  552. data = "?subject ?property ?event . \
  553. ?event crm:P4_has_time-span ?uri_date . \
  554. ?uri_date rdfs:label ?date . \
  555. ?date bif:contains \"\'"+ params[i][1] +"\'\" ."
  556. }
  557. }
  558. prefixes = "PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> \
  559. PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> \
  560. PREFIX crm: <http://www.cidoc-crm.org/cidoc-crm/> \
  561. PREFIX owl: <http://www.w3.org/2002/07/owl#> \
  562. PREFIX schema: <http://schema.org/> \
  563. PREFIX foaf: <http://xmlns.com/foaf/0.1/> \
  564. PREFIX person: <http://www.w3.org/ns/person#>"
  565. query = prefixes + " SELECT DISTINCT ?subject ?label" + id + dm + mt + loc + tec + at
  566. + sg + tt + tp + nt + rf + np + nf + pt + ln + lm + gr + dn + dts + oc + qf + ga + mit
  567. + des + lp + la + dp + da + lin + alin + ed + antr + topo + dt + " \
  568. WHERE {GRAPH " + search_graph + " {?subject ?property ?object } \
  569. ?subject rdfs:label ?label . "
  570. + infObj + letter_event + label + search_type + identificatore + dimensione + materia + localizzazione + tecnica
  571. + artista + titolo + tipo + note + riferimenti + nome_proprio + nome_di_famiglia
  572. + patronimico + luogo_di_Nascita + luogo_di_Morte + genere + data_di_Nascita
  573. + data_di_Morte + qualifica + occupazione + gruppi_di_appartenenza + mittente + destinatario
  574. +luogo_di_Partenza + luogo_di_Arrivo + data_partenza + data_arrivo + lingua
  575. + area_linguistica + edizione + toponimo + antroponimo + data + "}"
  576. var query_url = 'http://dev.restore.ovi.cnr.it:8890/sparql/?default-graph-uri=&query=' + encodeURIComponent(query) + '&output=json';
  577. console.log(query);
  578. $.ajax({
  579. url: query_url + '&callback=?',
  580. dataType: "json",
  581. success: function (data) {
  582. query_handle_json(data);
  583. },
  584. error: function (e) {}
  585. });
  586. }
  587. function query_handle_json(json) {
  588. console.log(json);
  589. $('#query_results').text("");
  590. var i = 0;
  591. const first_row = [];
  592. $.each(
  593. json['head']['vars'],
  594. function (index, value) {
  595. first_row.push(value);
  596. });
  597. var t_head = '<div class="row t_head">';
  598. for (let k = 0; k < first_row.length; k++) {
  599. t_head += '<div class="col-auto">' + first_row[k] + '</div>';
  600. }
  601. t_head += '</div>';
  602. $('#query_results').append(t_head);
  603. $.each(
  604. json['results']['bindings'],
  605. function (index, value) {
  606. var object = "";
  607. var link = value['subject']['value'];
  608. var label = value['label']['value'];
  609. object += '<div class="row"><div class="col-auto">' + link + '</div><div class="col-auto">' + label + '</div>';
  610. if (value.hasOwnProperty('identifier')) {
  611. identifier = value['identifier']['value'];
  612. object += '<div class="col-auto">' + identifier + '</div>';
  613. }
  614. if (value.hasOwnProperty('dimension')) {
  615. dimension = value['dimension']['value'];
  616. object += '<div class="col-auto">' + dimension + '</div>';
  617. }
  618. if (value.hasOwnProperty('material')) {
  619. material = value['material']['value'];
  620. object += '<div class="col-auto">' + material + '</div>';
  621. }
  622. if (value.hasOwnProperty('location')) {
  623. location = value['location']['value'];
  624. object += '<div class="col-auto">' + location + '</div>';
  625. }
  626. if (value.hasOwnProperty('technique')) {
  627. technique = value['technique']['value'];
  628. object += '<div class="col-auto">' + technique + '</div>';
  629. }
  630. if (value.hasOwnProperty('artist')) {
  631. artist = value['artist']['value'];
  632. object += '<div class="col-auto">' + artist + '</div>';
  633. }
  634. if (value.hasOwnProperty('depiction')) {
  635. depiction = value['depiction']['value'];
  636. object += '<div class="col-auto">' + depiction + '</div>';
  637. }
  638. if (value.hasOwnProperty('title')) {
  639. title = value['title']['value'];
  640. object += '<div class="col-auto">' + title + '</div>';
  641. }
  642. if (value.hasOwnProperty('type')) {
  643. type = value['type']['value'];
  644. object += '<div class="col-auto">' + type + '</div>';
  645. }
  646. if (value.hasOwnProperty('note')) {
  647. note = value['note']['value'];
  648. object += '<div class="col-auto">' + note + '</div>';
  649. }
  650. if (value.hasOwnProperty('ref')) {
  651. ref = value['ref']['value'];
  652. object += '<div class="col-auto">' + ref + '</div>';
  653. }
  654. if (value.hasOwnProperty('givenName')) {
  655. givenName = value['givenName']['value'];
  656. object += '<div class="col-auto">' + givenName + '</div>';
  657. }
  658. if (value.hasOwnProperty('familyName')) {
  659. familyName = value['familyName']['value'];
  660. object += '<div class="col-auto">' + familyName + '</div>';
  661. }
  662. if (value.hasOwnProperty('patronymic')) {
  663. patronymic = value['patronymic']['value'];
  664. object += '<div class="col-auto">' + patronymic + '</div>';
  665. }
  666. if (value.hasOwnProperty('birthPlace')) {
  667. birthPlace = value['birthPlace']['value'];
  668. object += '<div class="col-auto">' + birthPlace + '</div>';
  669. }
  670. if (value.hasOwnProperty('deathPlace')) {
  671. deathPlace = value['deathPlace']['value'];
  672. object += '<div class="col-auto">' + deathPlace + '</div>';
  673. }
  674. if (value.hasOwnProperty('genere')) {
  675. genere = value['genere']['value'];
  676. object += '<div class="col-auto">' + genere + '</div>';
  677. }
  678. if (value.hasOwnProperty('Birth_TS')) {
  679. Birth_TS = value['Birth_TS']['value'];
  680. object += '<div class="col-auto">' + Birth_TS + '</div>';
  681. }
  682. if (value.hasOwnProperty('Death_TS')) {
  683. Death_TS = value['Death_TS']['value'];
  684. object += '<div class="col-auto">' + Death_TS + '</div>';
  685. }
  686. if (value.hasOwnProperty('qualification')) {
  687. qualification = value['qualification']['value'];
  688. object += '<div class="col-auto">' + qualification + '</div>';
  689. }
  690. if (value.hasOwnProperty('occupation')) {
  691. occupation = value['occupation']['value'];
  692. object += '<div class="col-auto">' + occupation + '</div>';
  693. }
  694. if (value.hasOwnProperty('group')) {
  695. group = value['group']['value'];
  696. object += '<div class="col-auto">' + group + '</div>';
  697. }
  698. if (value.hasOwnProperty('mittente')) {
  699. mittente = value['mittente']['value'];
  700. object += '<div class="col-auto">' + mittente + '</div>';
  701. }
  702. if (value.hasOwnProperty('destinatario')) {
  703. destinatario = value['destinatario']['value'];
  704. object += '<div class="col-auto">' + destinatario + '</div>';
  705. }
  706. if (value.hasOwnProperty('luogo_partenza')) {
  707. luogo_partenza = value['luogo_partenza']['value'];
  708. object += '<div class="col-auto">' + luogo_partenza + '</div>';
  709. }
  710. if (value.hasOwnProperty('luogo_arrivo')) {
  711. luogo_arrivo = value['luogo_arrivo']['value'];
  712. object += '<div class="col-auto">' + luogo_arrivo + '</div>';
  713. }
  714. if (value.hasOwnProperty('timeSpanSend')) {
  715. timeSpanSend = value['timeSpanSend']['value'];
  716. object += '<div class="col-auto">' + timeSpanSend + '</div>';
  717. }
  718. if (value.hasOwnProperty('timeSpanReceive')) {
  719. timeSpanReceive = value['timeSpanReceive']['value'];
  720. object += '<div class="col-auto">' + timeSpanReceive + '</div>';
  721. }
  722. if (value.hasOwnProperty('lingua')) {
  723. lingua = value['lingua']['value'];
  724. object += '<div class="col-auto">' + lingua + '</div>';
  725. }
  726. if (value.hasOwnProperty('area_linguistica')) {
  727. area_linguistica = value['area_linguistica']['value'];
  728. object += '<div class="col-auto">' + area_linguistica + '</div>';
  729. }
  730. if (value.hasOwnProperty('edizione')) {
  731. edizione = value['edizione']['value'];
  732. object += '<div class="col-auto">' + edizione + '</div>';
  733. }
  734. if (value.hasOwnProperty('toponimo')) {
  735. toponimo = value['toponimo']['value'];
  736. object += '<div class="col-auto">' + toponimo + '</div>';
  737. }
  738. if (value.hasOwnProperty('antroponimo')) {
  739. antroponimo = value['antroponimo']['value'];
  740. object += '<div class="col-auto">' + antroponimo + '</div>';
  741. }
  742. if (value.hasOwnProperty('date')) {
  743. date = value['date']['value'];
  744. object += '<div class="col-auto">' + date + '</div>';
  745. }
  746. object += '</div>';
  747. i++;
  748. /*onclick=copy__Text("' + value['link']['value'] + '")*/
  749. $('#query_results').append(object);
  750. });
  751. if (i==0) {
  752. var message = '<p>Nessun risultato trovato</p>';
  753. $('#query_results').append(message);
  754. }
  755. }