advanced_searchBK.js 32 KB

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