advanced_search.js 48 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297
  1. const choiceArray = [
  2. ["Nome risorsa", "Object, OA", "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. ["Data", "Object", "date"],
  30. ["Date", "OA", "date_OA"],
  31. ["Lemma", "Letter", "lemma"],
  32. ["Testo libero", "Letter", "keyword"]
  33. ];
  34. const typeArray = [
  35. ["Oggetto", "Object"],
  36. ["Lettera", "Letter"],
  37. ["Opera d'Arte", "OA"],
  38. ["Persona", "Person"]
  39. ];
  40. const graphArray = [
  41. ["ASPO - Datini", "http://dev.restore.ovi.cnr.it:8890/aspo/datini", "Object"],
  42. ["ASPO - Ospedale", "http://dev.restore.ovi.cnr.it:8890/aspo/ospedale", "Object"],
  43. ["ASPO - Marcovaldi", "http://dev.restore.ovi.cnr.it:8890/aspo/marcovaldi", "Object"],
  44. ["ASPO - Onomastica Gettatelli", "http://dev.restore.ovi.cnr.it:8890/aspo/gettatelli", "Person"],
  45. ["ASPO - Onomastica Datini", "http://dev.restore.ovi.cnr.it:8890/aspo/onomastica", "Person"],
  46. ["MPP – Onomastica Artisti", "http://dev.restore.ovi.cnr.it:8890/mpp/autori", "Person"],
  47. ["MPP - Collezione Martini", "http://dev.restore.ovi.cnr.it:8890/mpp/martini", "Artwork"],
  48. ["MPP - Opere provenienti dall’Ospedale", "http://dev.restore.ovi.cnr.it:8890/mpp/ospedale", "Artwork"],
  49. ["MPP – Iconografia Datini", "http://dev.restore.ovi.cnr.it:8890/mpp/datini", "Artwork"],
  50. ["OVI - Lettere", "http://dev.restore.ovi.cnr.it:8890/ovi/datini", "Letter"]
  51. ];
  52. const objectArray = [];
  53. const personArray = [];
  54. const placeArray = [];
  55. const oaArray = [];
  56. const letterArray = [];
  57. $(document).ready(function () {
  58. //#######################################
  59. var type_selector = document.getElementById("type_selector");
  60. var collection_selector = document.getElementById("collection_selector");
  61. let x = typeArray.length;
  62. for(var i=0; i<x; i++) {
  63. var opt = document.createElement("option");
  64. opt.value= typeArray[i][1];
  65. opt.innerHTML = typeArray[i][0]; // whatever property it has
  66. // then append it to the select element
  67. type_selector.add(opt);
  68. }
  69. let z = choiceArray.length;
  70. for(var i=0; i<z; i++) {
  71. var cat = choiceArray[i][1];
  72. if (cat.includes("Object")) {
  73. objectArray.push(choiceArray[i]);
  74. }
  75. if (cat.includes("OA")) {
  76. oaArray.push(choiceArray[i]);
  77. }
  78. if (cat.includes("Person")) {
  79. personArray.push(choiceArray[i]);
  80. }
  81. if (cat.includes("Letter")) {
  82. letterArray.push(choiceArray[i]);
  83. }
  84. if (cat.includes("Place")) {
  85. placeArray.push(choiceArray[i]);
  86. }
  87. }
  88. $("#type_selector").change(function(){
  89. var selOpt = "";
  90. $(this).find("option:selected").each(function(){
  91. var optionValue = $(this).attr("value");
  92. selOpt = optionValue;
  93. if(optionValue){
  94. $(".box").not("." + optionValue).hide();
  95. $("." + optionValue).show();
  96. } else{
  97. $(".box").hide();
  98. }
  99. });
  100. $( ".container_choice" ).remove();
  101. if (selOpt == "Object") {
  102. addToListObject();
  103. populateSelGraph("Object");
  104. }
  105. else if (selOpt == "OA") {
  106. addToListOA();
  107. populateSelGraph("Artwork");
  108. }
  109. else if (selOpt == "Person") {
  110. addToListPerson();
  111. populateSelGraph("Person");
  112. }
  113. else if (selOpt == "Letter") {
  114. addToListLetter();
  115. populateSelGraph("Letter");
  116. }
  117. else {
  118. addToList();
  119. populateSelGraph("General");
  120. }
  121. }).change();
  122. /*$('[name=sel-parent]').on('change', function() {
  123. $(this).attr("id", 'example' + $(this).name());
  124. });*/
  125. });
  126. function populateOptions(selector, myArray) {
  127. var choice_selector = document.getElementById(selector);
  128. let k = myArray.length;
  129. for(var i=0; i<k; i++) {
  130. var opt = document.createElement("option");
  131. opt.value= myArray[i][1];
  132. opt.innerHTML = myArray[i][0]; // whatever property it has
  133. // then append it to the select element
  134. choice_selector.add(opt);
  135. }
  136. $('#' + selector).on( "change", function() {
  137. var numberId= selector.split("-")[1];
  138. var inputText= $( this ).find(":selected").text();
  139. var inp = "";
  140. if (inputText == "Genere") {
  141. inp = '<select class="advanced-form-select form-control" id="inputchoiceSelector_'+ numberId +'"> \
  142. <option>F</option> \
  143. <option>M</option> \
  144. </select>';
  145. } else if (inputText == "Materia"){
  146. inp = '<select class="advanced-form-select form-control" id="inputchoiceSelector_'+ numberId +'"> \
  147. <option>Tempera</option> \
  148. <option>Tavola</option> \
  149. <option>Stucco</option> \
  150. <option>Rame</option> \
  151. <option>Carta</option> \
  152. <option>Tela</option> \
  153. </select>';
  154. } else if (inputText == "Tecnica"){
  155. inp = '<select class="advanced-form-select form-control" id="inputchoiceSelector_'+ numberId +'"> \
  156. <option>Pittura a olio</option> \
  157. <option>Doratura</option> \
  158. </select>';
  159. } else if (inputText == "Tipo di risorsa"){
  160. inp = '<select class="advanced-form-select form-control" id="inputchoiceSelector_'+ numberId +'"> \
  161. <option>Documento</option> \
  162. <option>Carteggio</option> \
  163. <option>Lettera</option> \
  164. <option>Libro</option> \
  165. <option>Documenti diversi</option> \
  166. </select>';
  167. } else if (inputText == "Data"){
  168. var inp = '<div style="display:flex;"><div id="box_' + numberId + '_a" class="container_choice"><div class="choice_box">Da <select style="display:none;" id ="choice_selector-' + numberId + '_a" value=' + numberId + '_a" name="sel-parent" class="advanced-form-select form-control" aria-label="Default select example"> \
  169. <option selected value="0">Da</option> \
  170. <input type="number" id="inputchoiceSelector_'+ numberId +'_a" name="start" min="1000" max="2099" step="1" value="1300" /></div></div>\
  171. <div id="box_' + numberId + '_b" class="container_choice"><div class="choice_box">A <select style="display:none;" id ="choice_selector-' + numberId + '_b" value=' + numberId + '_b" name="sel-parent" class="advanced-form-select form-control" aria-label="Default select example"> \
  172. <option selected value="0">A</option> \
  173. <input type="number" id="inputchoiceSelector_'+ numberId +'_b" name="end" min="1000" max="2099" step="1" value="1900" /></div></div>\
  174. </select></div></div></div>';
  175. /*var inp = '<div style="display:flex;"><div id="box_' + numberId + '_a" class="container_choice"><div class="choice_box">Da <select style="display:none;" id ="choice_selector-' + numberId + '_a" value=' + numberId + '_a" name="sel-parent" class="advanced-form-select form-control" aria-label="Default select example"> \
  176. <option selected value="0">Da</option> \
  177. <input type="date" id="inputchoiceSelector_'+ numberId +'_a" name="start" value="1300-01-01"> \
  178. </select></div></div> \
  179. <div id="box_' + numberId + '_b" class="container_choice"><div class="choice_box">A <select style="display:none;" id ="choice_selector-' + numberId + '_b" value=' + numberId + '_b" name="sel-parent" class="advanced-form-select form-control" aria-label="Default select example"> \
  180. <option selected value="0">A</option> \
  181. <input type="date" id="inputchoiceSelector_'+ numberId +'_b" name="end" value="1900-12-31"> \
  182. </select></div></div></div>';*/
  183. }
  184. else if (inputText == "Date"){
  185. var inp = '<div style="display:flex;"><div id="box_' + numberId + '_a" class="container_choice"><div class="choice_box">Da <select style="display:none;" id ="choice_selector-' + numberId + '_a" value=' + numberId + '_a" name="sel-parent" class="advanced-form-select form-control" aria-label="Default select example"> \
  186. <option selected value="0">Data inizio opera</option> \
  187. <input type="number" id="inputchoiceSelector_'+ numberId +'_a" name="start" min="1000" max="2099" step="1" value="1300" /></div></div>\
  188. <div id="box_' + numberId + '_b" class="container_choice"><div class="choice_box">A <select style="display:none;" id ="choice_selector-' + numberId + '_b" value=' + numberId + '_b" name="sel-parent" class="advanced-form-select form-control" aria-label="Default select example"> \
  189. <option selected value="0">Data fine opera</option> \
  190. <input type="number" id="inputchoiceSelector_'+ numberId +'_b" name="end" min="1000" max="2099" step="1" value="1900" /></div></div>\
  191. </select></div></div></div>';
  192. /*var inp = '<div style="display:flex;"><div id="box_' + numberId + '_a" class="container_choice"><div class="choice_box">Da <select style="display:none;" id ="choice_selector-' + numberId + '_a" value=' + numberId + '_a" name="sel-parent" class="advanced-form-select form-control" aria-label="Default select example"> \
  193. <option selected value="0">Data inizio opera</option> \
  194. <input type="date" id="inputchoiceSelector_'+ numberId +'_a" name="start" value="1300-01-01"> \
  195. </select></div></div> \
  196. <div id="box_' + numberId + '_b" class="container_choice"><div class="choice_box">A <select style="display:none;" id ="choice_selector-' + numberId + '_b" value=' + numberId + '_b" name="sel-parent" class="advanced-form-select form-control" aria-label="Default select example"> \
  197. <option selected value="0">Data fine opera</option> \
  198. <input type="date" id="inputchoiceSelector_'+ numberId +'_b" name="end" value="1900-12-31"> \
  199. </select></div></div></div>';*/
  200. }
  201. else if (inputText == "Data partenza"){
  202. var inp = '<div style="display:flex;"><div id="box_' + numberId + '_a" class="container_choice"><div class="choice_box">Da <select style="display:none;" id ="choice_selector-' + numberId + '_a" value=' + numberId + '_a" name="sel-parent" class="advanced-form-select form-control" aria-label="Default select example"> \
  203. <option selected value="0">Data partenza inizio</option> \
  204. <input type="date" id="inputchoiceSelector_'+ numberId +'_a" name="start" value="1300-01-01"> \
  205. </select></div></div> \
  206. <div id="box_' + numberId + '_b" class="container_choice"><div class="choice_box">A <select style="display:none;" id ="choice_selector-' + numberId + '_b" value=' + numberId + '_b" name="sel-parent" class="advanced-form-select form-control" aria-label="Default select example"> \
  207. <option selected value="0">Data partenza fine</option> \
  208. <input type="date" id="inputchoiceSelector_'+ numberId +'_b" name="end" value="1900-12-31"> \
  209. </select></div></div></div>';
  210. }
  211. else if (inputText == "Data arrivo"){
  212. var inp = '<div style="display:flex;"><div id="box_' + numberId + '_a" class="container_choice"><div class="choice_box">Da <select style="display:none;" id ="choice_selector-' + numberId + '_a" value=' + numberId + '_a" name="sel-parent" class="advanced-form-select form-control" aria-label="Default select example"> \
  213. <option selected value="0">Data arrivo inizio</option> \
  214. <input type="date" id="inputchoiceSelector_'+ numberId +'_a" name="start" value="1300-01-01"> \
  215. </select></div></div> \
  216. <div id="box_' + numberId + '_b" class="container_choice"><div class="choice_box">A <select style="display:none;" id ="choice_selector-' + numberId + '_b" value=' + numberId + '_b" name="sel-parent" class="advanced-form-select form-control" aria-label="Default select example"> \
  217. <option selected value="0">Data arrivo fine</option> \
  218. <input type="date" id="inputchoiceSelector_'+ numberId +'_b" name="end" value="1900-12-31"> \
  219. </select></div></div></div>';
  220. }
  221. else {
  222. inp = '<input type="text" id="inputchoiceSelector_'+ numberId +'" class="selected_option form-control" placeholder="Enter search terms" aria-label="Enter search terms" aria-describedby="button-addon2">';
  223. }
  224. var sect = 'sect-' + String(numberId);
  225. var inDiv = document.getElementById(sect);
  226. inDiv.innerHTML = inp;
  227. console.log(selector);
  228. /*$('#inputchoiceSelector_' + numberId).val(inputText);
  229. $('#inputchoiceSelector_' + numberId).id(inputText);*/
  230. });
  231. }
  232. var val = 0;
  233. function addToList() {
  234. val = val+1;
  235. 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"> \
  236. <option selected value="0">Scegli un\'opzione</option> \
  237. </select><div id="sect-' + val + '"></div></div></div>';
  238. $('#drop-down-content').append(sel);
  239. var selector = 'choice_selector-' + val;
  240. //populateOptions(selector, choiceArray);
  241. }
  242. function addToListObject() {
  243. val = val+100;
  244. 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"> \
  245. <option selected value="0">Scegli un\'opzione</option> \
  246. </select><div id="sect-' + val + '"></div></div></div>';
  247. $('#drop-down-content-Object').append(sel);
  248. var selector = 'choice_selector-' + val;
  249. populateOptions(selector, objectArray);
  250. }
  251. function addToListOA() {
  252. val = val+200;
  253. 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"> \
  254. <option selected value="0">Scegli un\'opzione</option> \
  255. </select><div id="sect-' + val + '"></div></div></div>';
  256. $('#drop-down-content-OA').append(sel);
  257. var selector = 'choice_selector-' + val;
  258. populateOptions(selector, oaArray);
  259. }
  260. function addToListPerson() {
  261. val = val+300;
  262. 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"> \
  263. <option selected value="0">Scegli un\'opzione</option> \
  264. </select><div id="sect-' + val + '"></div></div></div>';
  265. $('#drop-down-content-Person').append(sel);
  266. var selector = 'choice_selector-' + val;
  267. populateOptions(selector, personArray);
  268. }
  269. function addToListLetter() {
  270. val = val+400;
  271. 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"> \
  272. <option selected value="0">Scegli un\'opzione</option> \
  273. </select><div id="sect-' + val + '"></div></div></div>';
  274. $('#drop-down-content-Letter').append(sel);
  275. var selector = 'choice_selector-' + val;
  276. populateOptions(selector, letterArray);
  277. }
  278. function addToListPlace() {
  279. val = val+500;
  280. 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"> \
  281. <option selected value="0">Scegli un\'opzione</option> \
  282. <input type="text" id="inputchoiceSelector_'+ val +'" class="selected_option form-control" placeholder="Enter search terms" aria-label="Enter search terms" aria-describedby="button-addon2"> \
  283. </select></div></div>';
  284. $('#drop-down-content-Place').append(sel);
  285. var selector = 'choice_selector-' + val;
  286. populateOptions(selector, placeArray);
  287. }
  288. //Get parameters from select and input options to build the query
  289. function getParameters() {
  290. $('#Loader').css("display", "block");
  291. $('#query_results').text("");
  292. var cc = document.getElementById("type_selector").value;
  293. if (cc != "General") {
  294. const arr = [];
  295. const collection = document.getElementsByClassName("advanced-form-select");
  296. for (let i = 0; i < collection.length; i++) {
  297. var x = collection[i].id;
  298. var t = document.getElementById(x);
  299. var e = t.options[t.selectedIndex].text;
  300. var numberId= x.split("-")[1]
  301. var inputId = "inputchoiceSelector_" + numberId;
  302. if (!!document.getElementById(inputId)) {
  303. var inputText = document.getElementById(inputId).value;
  304. var el = [e, inputText];
  305. console.log([inputText, el]);
  306. arr.push(el);
  307. }
  308. }
  309. constructQuery(arr);
  310. }
  311. else {
  312. alert("Seleziona una categoria")
  313. }
  314. /*$('#query_results').append(arr);
  315. testo = $('input#writeText').val();*/
  316. }
  317. function removeElement(id_element) {
  318. const element = document.getElementById(id_element);
  319. element.remove();
  320. }
  321. //Build query with harvested parametes
  322. function constructQuery(params) {
  323. var g = document.getElementById("collection_selector");
  324. var graph = g.value;
  325. var search_graph = "?g";
  326. if (graph != "") {
  327. search_graph = '<' + graph + '>';
  328. }
  329. var search_type = "";
  330. var ct = document.getElementById("type_selector");
  331. var choosen_type = ct.value;
  332. console.log(choosen_type);
  333. var search_identifier = "";
  334. if (choosen_type == "Object") {
  335. search_type = "?subject rdf:type crm:E22_Man-Made_Object . ";
  336. search_identifier = "?subject crm:P1_is_identified_by ?uri_identifier . \
  337. ?uri_identifier rdfs:label ?identifier ; \
  338. crm:P2_has_type 'Segnatura' .";
  339. }
  340. if (choosen_type == "Letter") {
  341. search_type = "?subject crm:P128_carries ?information_object . \
  342. ?information_object crm:P2_has_type ?uri_letter . \
  343. ?uri_letter rdfs:label 'lettera' ."
  344. search_identifier = "?subject crm:P1_is_identified_by ?uri_identifier . \
  345. ?uri_identifier rdfs:label ?identifier ; \
  346. crm:P2_has_type 'Segnatura' .";
  347. }
  348. if (choosen_type == "OA") {
  349. search_identifier = "?subject crm:P1_is_identified_by ?uri_identifier . \
  350. ?uri_identifier rdfs:label ?identifier ; \
  351. crm:P2_has_type 'Codice univoco del bene (NCT)' .";
  352. }
  353. if (choosen_type == "Person") {
  354. search_type = "?subject rdf:type crm:E21_Person . ";
  355. search_identifier = "?subject crm:P1_is_identified_by ?uri_identifier . \
  356. ?uri_identifier rdfs:label ?identifier .";
  357. }
  358. var label = ""; //
  359. var identificatore = ""; //
  360. var dimensione = ""; //
  361. var materia = ""; //
  362. var localizzazione = ""; //
  363. var tecnica = ""; //
  364. var artista = ""; //
  365. var soggetto = ""; //
  366. var titolo = ""; //
  367. var tipo = ""; //
  368. var note = ""; //
  369. var riferimenti = ""; //
  370. var nome_proprio = ""; //
  371. var nome_di_famiglia = ""; //
  372. var patronimico = ""; //
  373. var luogo_di_Nascita = ""; //
  374. var luogo_di_Morte = ""; //
  375. var genere = ""; //
  376. var data_di_Nascita = ""; //
  377. var data_di_Morte = ""; //
  378. var occupazione = ""; //
  379. var qualifica = ""; //
  380. var gruppi_di_appartenenza = ""; //
  381. var mittente = ""; //
  382. var destinatario = ""; //
  383. var luogo_di_Partenza = ""; //
  384. var luogo_di_Arrivo = ""; //
  385. var data_partenza_inizio = ""; //
  386. var data_partenza_fine = "";
  387. var data_arrivo_inizio = ""; //
  388. var data_arrivo_fine = "";
  389. var data_opera_inizio = ""; //
  390. var data_opera_fine = ""; //
  391. var lingua = ""; //
  392. var area_linguistica = ""; //
  393. var edizione = ""; //
  394. var lemma = ""; //
  395. var testo = ""; //
  396. var data = ""; //
  397. var start = "";
  398. var finish = "";
  399. var letter_event = ""; //
  400. var infObj = ""; //
  401. var id = ""; //
  402. var dm = ""; //
  403. var mt = ""; //
  404. var locl = ""; //
  405. var tec = ""; //
  406. var at = ""; //
  407. var sg = ""; //
  408. var tt = ""; //
  409. var tp = ""; //
  410. var nt = ""; //
  411. var rf = ""; //
  412. var np = ""; //
  413. var nf = ""; //
  414. var pt = ""; //
  415. var ln = ""; //
  416. var lm = ""; //
  417. var gr = ""; //
  418. var dn = ""; //
  419. var dts = ""; //
  420. var oc = ""; //
  421. var qf = ""; //
  422. var ga = ""; //
  423. var mit = ""; //
  424. var des = ""; //
  425. var lp = ""; //
  426. var la = ""; //
  427. var dp = ""; //
  428. var da = ""; //
  429. var lin = ""; //
  430. var alin = ""; //
  431. var ed = ""; //
  432. var lem = ""; //
  433. var ttx = ""; //
  434. var dt = ""; //
  435. var st = "";
  436. var fn = "";
  437. var dpi = "";
  438. var dai = "";
  439. var diop = "";
  440. var dfop = "";
  441. for (let i = 0; i < params.length; i++) {
  442. if(params[i][0] == "Nome risorsa" && (params[i][1] != "")) {
  443. var toSearch = params[i][1].replace("'", " ");
  444. label = "?label bif:contains \"\' "+ toSearch + " \'\" . ";
  445. }
  446. if(params[i][0] == "Identificatore" && (params[i][1] != "")) {
  447. id = " ?identifier";
  448. identificatore = "FILTER (CONTAINS(?identifier, \'"+ params[i][1] +"\'))";
  449. }
  450. if(params[i][0] == "Dimensione" && (params[i][1] != "")) {
  451. dm = " ?dimension";
  452. dimensione = "?subject crm:P43_has_dimension ?uri_dimension . \
  453. ?uri_dimension rdfs:label ?dimension . \
  454. ?dimension bif:contains \"\'"+ params[i][1] +"\'\" ."
  455. }
  456. if(params[i][0] == "Materia" && (params[i][1] != "")) {
  457. mt = " ?material";
  458. materia = "?subject crm:P45_consists_of ?uri_material . \
  459. ?uri_material rdfs:label ?material . \
  460. ?material bif:contains \"\'"+ params[i][1] +"\'\" ."
  461. }
  462. if(params[i][0] == "Istituto di conservazione" && (params[i][1] != "")) {
  463. locl = " ?location";
  464. localizzazione = "?subject crm:P52_has_current_owner ?uri_location . \
  465. ?uri_location rdfs:label ?location . \
  466. ?location bif:contains \"\'"+ params[i][1] +"\'\" ."
  467. }
  468. if(params[i][0] == "Tecnica" && (params[i][1] != "")) {
  469. tec = " ?technique";
  470. tecnica = "?event ?pp ?subject . \
  471. ?event crm:P32_used_general_technique ?uri_technique . \
  472. ?uri_technique rdfs:label ?technique . \
  473. ?technique bif:contains \"\'"+ params[i][1] +"\'\" . "
  474. }
  475. if (params[i][0] == "Artista" && (params[i][1] != "")) {
  476. at = " ?artist";
  477. artista = "?subject rdfs:label ?label . \
  478. ?production crm:P108_has_produced ?subject . \
  479. ?pc crm:P01_has_domain ?production . \
  480. ?pc crm:P02_has_range ?range . \
  481. ?range rdfs:label ?artist . \
  482. ?artist bif:contains \"\'"+ params[i][1] +"\'\" ."
  483. }
  484. if (params[i][0] == "Soggetto" && (params[i][1] != "")) {
  485. sg = " ?depiction";
  486. soggetto = "?subject crm:P62_depicts ?uri_depiction . \
  487. ?uri_depiction rdfs:label ?depiction . \
  488. ?depiction bif:contains \"\'"+ params[i][1] +"\'\" ."
  489. }
  490. if (params[i][0] == "Titolo" && (params[i][1] != "")) {
  491. tt = " ?title";
  492. infObj = "?subject crm:P128_carries ?information_object .";
  493. titolo = "?information_object crm:P1_is_identified_by ?uri_title . \
  494. ?uri_title rdfs:label ?title . \
  495. ?title bif:contains \"\'"+ params[i][1] +"\'\" ."
  496. }
  497. if (params[i][0] == "Tipo di risorsa" && (params[i][1] != "")) {
  498. tp = " ?type";
  499. infObj = "?subject crm:P128_carries ?information_object .";
  500. tipo = "?information_object crm:P2_has_type ?uri_type . \
  501. ?uri_type rdfs:label ?type . \
  502. ?type bif:contains \"\'"+ params[i][1] +"\'\" ."
  503. }
  504. if (params[i][0] == "Note" && (params[i][1] != "")) {
  505. nt = " ?note";
  506. note = "?subject crm:P3_has_note ?uri_note . \
  507. ?uri_note rdfs:label ?note . \
  508. ?note bif:contains \"\'"+ params[i][1] +"\'\" .";
  509. }
  510. if (params[i][0] == "Riferimenti" && (params[i][1] != "")) {
  511. rf = " ?ref";
  512. riferimenti = "?subject crm:P67_refers_to ?uri_ref . \
  513. ?uri_ref rdfs:label ?ref . \
  514. ?ref bif:contains \"\'"+ params[i][1] +"\'\" . "
  515. }
  516. if (params[i][0] == "Nome proprio" && (params[i][1] != "")) {
  517. np = " ?givenName";
  518. nome_proprio = "?subject foaf:givenName ?givenName . \
  519. ?givenName bif:contains \"\'"+ params[i][1] +"\'\" . "
  520. }
  521. if (params[i][0] == "Nome di famiglia" && (params[i][1] != "")) {
  522. nf = " ?familyName";
  523. nome_di_famiglia = "?subject foaf:familyName ?familyName . \
  524. ?familyName bif:contains \"\'"+ params[i][1] +"\'\" . "
  525. }
  526. if (params[i][0] == "Patronimico" && (params[i][1] != "")) {
  527. pt = " ?patronymic";
  528. patronimico = "?subject person:patronymicName ?patronymic . \
  529. ?patronymic bif:contains \"\'"+ params[i][1] +"\'\" . "
  530. }
  531. if (params[i][0] == "Luogo di Nascita" && (params[i][1] != "")) {
  532. ln = " ?birthPlace";
  533. luogo_di_Nascita = "?subject crm:P98i_was_born ?Birth . \
  534. ?Birth crm:P7_took_place_at ?uri_birthPlace . \
  535. ?uri_birthPlace rdfs:label ?birthPlace . \
  536. ?birthPlace bif:contains \""+ params[i][1] +"\" . "
  537. }
  538. if (params[i][0] == "Luogo di Morte" && (params[i][1] != "")) {
  539. lm = " ?deathPlace";
  540. luogo_di_Morte = "?subject crm:P100i_died_in ?Death . \
  541. ?Death crm:P7_took_place_at ?uri_deathPlace . \
  542. ?uri_deathPlace rdfs:label ?deathPlace \
  543. ?deathPlace bif:contains \""+ params[i][1] +"\" . "
  544. }
  545. if (params[i][0] == "Genere" && (params[i][1] != "")) {
  546. gr = "?genere";
  547. genere = "?subject foaf:gender ?genere . \
  548. ?genere bif:contains \""+ params[i][1] +"\" . "
  549. }
  550. if (params[i][0] == "Data di Nascita" && (params[i][1] != "")) {
  551. dn = " ?Birth_TS";
  552. data_di_Nascita = "?subject crm:P98i_was_born ?Birth . \
  553. ?Birth crm:P4_has_time-span ?Birth_TS . \
  554. ?Birth_TS rdfs:label \""+ params[i][1] +"\" ."
  555. }
  556. if (params[i][0] == "Data di Morte" && (params[i][1] != "")) {
  557. dts = " ?Death_TS";
  558. data_di_Morte = "?subject crm:P100i_died_in ?Death . \
  559. ?Death crm:P4_has_time-span ?Death_TS . \
  560. ?Death_TS rdfs:label \""+ params[i][1] +"\" . "
  561. }
  562. if (params[i][0] == "Qualifica" && (params[i][1] != "")) {
  563. qf = " ?qualification";
  564. qualifica = "?subject schema:honorificPrefix ?qualification . \
  565. ?qualification bif:contains \"\'"+ params[i][1] +"\'\" . "
  566. }
  567. if (params[i][0] == "Occupazione" && (params[i][1] != "")) {
  568. oc = " ?occupation";
  569. occupazione = "?subject schema:hasOccupation ?uriOccupation . \
  570. ?uriOccupation rdf:type schema:Occupation; \
  571. rdfs:label ?occupation . \
  572. ?occupation bif:contains \"\'"+ params[i][1] +"\'\" . "
  573. }
  574. if (params[i][0] == "Gruppi di appartenenza" && (params[i][1] != "")) {
  575. ga = " ?group";
  576. gruppi_di_appartenenza = "?subject crm:P107i_is_current_or_former_member_of ?uriGroup . \
  577. ?uriGroup rdfs:label ?group . \
  578. ?group bif:contains \"\'"+ params[i][1] +"\'\" . "
  579. }
  580. if (params[i][0] == "Mittente" && (params[i][1] != "")) {
  581. mit = " ?mittente";
  582. letter_event = "?subject crm:P25i_moved_by ?mov_ev . \
  583. ?send rdfs:subClassOf ?mov_ev ; \
  584. rdf:type crm:EL2_Send_Letter . \
  585. ?receive rdfs:subClassOf ?mov_ev; \
  586. rdf:type crm:EL3_Receive_Letter . ";
  587. mittente = "?send crm:P01_has_domain ?pcS . \
  588. ?pcS crm:P02_has_range ?uriSender . \
  589. ?uriSender rdfs:label ?mittente . \
  590. ?mittente bif:contains \"\'"+ params[i][1] +"\'\" . "
  591. }
  592. if (params[i][0] == "Destinatario" && (params[i][1] != "")) {
  593. des = " ?destinatario";
  594. letter_event = "?subject crm:P25i_moved_by ?mov_ev . \
  595. ?send rdfs:subClassOf ?mov_ev ; \
  596. rdf:type crm:EL2_Send_Letter . \
  597. ?receive rdfs:subClassOf ?mov_ev; \
  598. rdf:type crm:EL3_Receive_Letter . ";
  599. destinatario = "?receive crm:P01_has_domain ?pcR . \
  600. ?pcR crm:P02_has_range ?uriReceiver . \
  601. ?uriReceiver rdfs:label ?destinatario . \
  602. ?destinatario bif:contains \"\'"+ params[i][1] +"\'\" . "
  603. }
  604. if (params[i][0] == "Luogo di Partenza" && (params[i][1] != "")) {
  605. lp = " ?luogo_partenza";
  606. letter_event = "?subject crm:P25i_moved_by ?mov_ev . \
  607. ?send rdfs:subClassOf ?mov_ev ; \
  608. rdf:type crm:EL2_Send_Letter . \
  609. ?receive rdfs:subClassOf ?mov_ev; \
  610. rdf:type crm:EL3_Receive_Letter . ";
  611. luogo_di_Partenza = "?send crm:P27_moved_from ?uriLuogoPartenza . \
  612. ?uriLuogoPartenza rdfs:label ?luogo_partenza . \
  613. ?luogo_partenza bif:contains \"\'"+ params[i][1] +"\'\" . "
  614. }
  615. if (params[i][0] == "Luogo di Arrivo" && (params[i][1] != "")) {
  616. la = " ?luogo_arrivo";
  617. letter_event = "?subject crm:P25i_moved_by ?mov_ev . \
  618. ?send rdfs:subClassOf ?mov_ev ; \
  619. rdf:type crm:EL2_Send_Letter . \
  620. ?receive rdfs:subClassOf ?mov_ev; \
  621. rdf:type crm:EL3_Receive_Letter . ";
  622. luogo_di_Arrivo = "?receive crm:P26_moved_to ?uriLuogoArrivo . \
  623. ?uriLuogoArrivo rdfs:label ?luogo_arrivo . \
  624. ?luogo_arrivo bif:contains \"\'"+ params[i][1] +"\'\" . "
  625. }
  626. if (params[i][0] == "Data partenza" && (params[i][1] != "")) {
  627. dp = " ?timeSpanSend";
  628. letter_event = "?subject crm:P25i_moved_by ?mov_ev . \
  629. ?send rdfs:subClassOf ?mov_ev ; \
  630. rdf:type crm:EL2_Send_Letter . \
  631. ?receive rdfs:subClassOf ?mov_ev; \
  632. rdf:type crm:EL3_Receive_Letter . ";
  633. data_partenza = "?send crm:P4_has_time-span ?time_spanS . \
  634. ?time_spanS rdfs:label ?timeSpanSend . \
  635. ?timeSpanSend bif:contains \"\'"+ params[i][1] +"\'\" . "
  636. }
  637. if (params[i][0] == "Data arrivo" && (params[i][1] != "")) {
  638. da = " ?timeSpanReceive";
  639. letter_event = "?subject crm:P25i_moved_by ?mov_ev . \
  640. ?send rdfs:subClassOf ?mov_ev ; \
  641. rdf:type crm:EL2_Send_Letter . \
  642. ?receive rdfs:subClassOf ?mov_ev; \
  643. rdf:type crm:EL3_Receive_Letter . ";
  644. data_arrivo = "?receive crm:P4_has_time-span ?time_spanR . \
  645. ?time_spanR rdfs:label ?timeSpanReceive .\
  646. ?timeSpanReceive bif:contains \"\'"+ params[i][1] +"\'\" . "
  647. }
  648. if (params[i][0] == "Lingua" && (params[i][1] != "")) {
  649. lin = " ?lingua";
  650. lingua = "?information_object crm:P72_has_language ?language . \
  651. ?language rdfs:label ?lingua . \
  652. ?lingua bif:contains \"\'"+ params[i][1] +"\'\" ."
  653. }
  654. if (params[i][0] == "Area linguistica" && (params[i][1] != "")) {
  655. alin = " ?area_linguistica";
  656. area_linguistica = "?information_object crm:P72_has_language ?language . \
  657. ?language crm:P3_has_note ?area . \
  658. ?area rdfs:label ?area_linguistica .\
  659. ?area_linguistica bif:contains \"\'"+ params[i][1] +"\'\" ."
  660. }
  661. if (params[i][0] == "Edizione" && (params[i][1] != "")) {
  662. ed = " ?edizione";
  663. edizione = "?edition crm:P70_documents ?information_object ; \
  664. crm:P1_is_identified_by ?edition_id . \
  665. ?edition_id rdfs:label ?edizione . \
  666. ?edizione bif:contains \"\'"+ params[i][1] +"\'\" ."
  667. }
  668. if (params[i][0] == "Lemma" && (params[i][1] != "")) {
  669. lem = " ?lemma";
  670. lemma = "?information_object crm:P67_refers_to ?link_lemma . \
  671. ?link_lemma rdfs:label ?lemma. \
  672. ?lemma bif:contains \"\'"+ params[i][1] +"\'\" ."
  673. }
  674. if (params[i][0] == "Testo libero" && (params[i][1] != "")) {
  675. ttx = " ?testo";
  676. testo = "?information_object crm:P190_has_symbolic_content ?testo . \
  677. ?testo bif:contains \"\'"+ params[i][1] +"\'\" ."
  678. }
  679. if (params[i][0] == "Data" && (params[i][1] != "")) {
  680. dt = " ?date";
  681. data = "?subject ?property ?event . \
  682. ?event crm:P4_has_time-span ?uri_date . \
  683. ?uri_date rdfs:label ?date . \
  684. ?date bif:contains \"\'"+ params[i][1] +"\'\" ."
  685. }
  686. if (params[i][0] == "Da" && (params[i][1] != "")) {
  687. st = " ?start";
  688. start = "?subject ?property ?event_start . \
  689. ?event_start crm:P4_has_time-span ?uri_date_start . \
  690. ?uri_date_start rdfs:label ?start ; \
  691. time:hasBeginning ?date_start . \
  692. FILTER (?date_start >= \""+ params[i][1] +"\"^^xsd:date)";
  693. }
  694. if (params[i][0] == "A" && (params[i][1] != "")) {
  695. fn = " ?end";
  696. finish = "?subject ?property ?event_end . \
  697. ?event_end crm:P4_has_time-span ?uri_date_end . \
  698. ?uri_date_end rdfs:label ?end ; \
  699. time:hasEnd ?date_end . \
  700. FILTER (?date_start <= \""+ params[i][1] +"\"^^xsd:date)";
  701. }
  702. if (params[i][0] == "Data partenza inizio" && (params[i][1] != "")) {
  703. dpi = " ?send_date";
  704. letter_event = "?subject crm:P25i_moved_by ?mov_ev . \
  705. ?send rdfs:subClassOf ?mov_ev ; \
  706. rdf:type crm:EL2_Send_Letter . \
  707. ?receive rdfs:subClassOf ?mov_ev; \
  708. rdf:type crm:EL3_Receive_Letter . ";
  709. data_partenza_inizio = "?send crm:P4_has_time-span ?uri_send_date . \
  710. ?uri_send_date rdfs:label ?send_date ; \
  711. time:hasBeginning ?time_send . \
  712. FILTER (?time_send >= \""+ params[i][1] +"\"^^xsd:date";
  713. }
  714. if (params[i][0] == "Data partenza fine" && (params[i][1] != "")) {
  715. data_partenza_fine = data_partenza_inizio + " && ?time_send <= \""+ params[i][1] +"\"^^xsd:date)";
  716. }
  717. if (params[i][0] == "Data arrivo inizio" && (params[i][1] != "")) {
  718. dai = " ?receive_date";
  719. letter_event = "?subject crm:P25i_moved_by ?mov_ev . \
  720. ?send rdfs:subClassOf ?mov_ev ; \
  721. rdf:type crm:EL2_Send_Letter . \
  722. ?receive rdfs:subClassOf ?mov_ev; \
  723. rdf:type crm:EL3_Receive_Letter . ";
  724. data_arrivo_inizio = "?receive crm:P4_has_time-span ?uri_receive_date . \
  725. ?uri_receive_date rdfs:label ?receive_date ; \
  726. time:hasEnd ?time_receive . \
  727. FILTER (?time_receive >= \""+ params[i][1] +"\"^^xsd:date";
  728. }
  729. if (params[i][0] == "Data arrivo fine" && (params[i][1] != "")) {
  730. data_arrivo_fine = data_arrivo_inizio + " && ?time_receive <= \""+ params[i][1] +"\"^^xsd:date)";
  731. }
  732. if (params[i][0] == "Data inizio opera" && (params[i][1] != "")) {
  733. diop = " ?time_start";
  734. data_opera_inizio = "?event_start ?pp ?subject ; \
  735. crm:P2_has_type 'Inizio'^^<http://www.w3.org/2001/XMLSchema#string> ; \
  736. crm:P4_has_time-span ?uri_time_start . \
  737. ?uri_time_start rdfs:label ?time_start; \
  738. time:year ?date_start . \
  739. FILTER (?date_start >= \""+ params[i][1] +"\"^^xsd:integer)";
  740. }
  741. if (params[i][0] == "Data fine opera" && (params[i][1] != "")) {
  742. data_opera_fine = "FILTER (?date_start <= \""+ params[i][1] +"\"^^xsd:integer)";
  743. }
  744. }
  745. prefixes = "PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> \
  746. PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> \
  747. PREFIX crm: <http://www.cidoc-crm.org/cidoc-crm/> \
  748. PREFIX owl: <http://www.w3.org/2002/07/owl#> \
  749. PREFIX schema: <http://schema.org/> \
  750. PREFIX foaf: <http://xmlns.com/foaf/0.1/> \
  751. PREFIX person: <http://www.w3.org/ns/person#> \
  752. PREFIX time: <https://www.w3.org/TR/owl-time#>"
  753. query = prefixes + " SELECT DISTINCT ?subject ?label ?identifier " + dm + mt + locl + tec + at
  754. + sg + tt + tp + nt + rf + np + nf + pt + ln + lm + gr + dn + dts + oc + qf + ga + mit
  755. + des + lp + la + dp + da + dpi + dai + diop + lin + alin + ed + lem + dt + st + ttx + " \
  756. WHERE {GRAPH " + search_graph + " {?subject ?property ?object } \
  757. ?subject rdfs:label ?label . "
  758. + search_identifier + infObj + letter_event + label + search_type + dimensione + materia + localizzazione + tecnica
  759. + artista + titolo + tipo + note + riferimenti + nome_proprio + nome_di_famiglia
  760. + patronimico + luogo_di_Nascita + luogo_di_Morte + genere + data_di_Nascita
  761. + data_di_Morte + qualifica + occupazione + gruppi_di_appartenenza + mittente + destinatario
  762. +luogo_di_Partenza + luogo_di_Arrivo + data_partenza_fine + data_arrivo_fine + data_opera_inizio + data_opera_fine + lingua
  763. + area_linguistica + edizione + lemma + data + identificatore + start + finish + testo + "}"
  764. var query_url = 'http://dev.restore.ovi.cnr.it:8890/sparql/?default-graph-uri=&query=' + encodeURIComponent(query) + '&output=json';
  765. console.log(query);
  766. $.ajax({
  767. url: query_url + '&callback=?',
  768. dataType: "json",
  769. success: function (data) {
  770. query_handle_json(data, choosen_type);
  771. },
  772. error: function (e) {}
  773. });
  774. }
  775. function query_handle_json(json, choosen_type) {
  776. console.log(json);
  777. var resulType = "";
  778. if (choosen_type == "Object") {
  779. resulType = "object";
  780. }
  781. if (choosen_type == "Letter") {
  782. resulType = "object";
  783. }
  784. if (choosen_type == "OA") {
  785. resulType = "artwork";
  786. }
  787. if (choosen_type == "Person") {
  788. resulType = "persona";
  789. }
  790. $('#query_results').text("");
  791. var i = 0;
  792. const first_row = [];
  793. $.each(
  794. json['head']['vars'],
  795. function (index, value) {
  796. first_row.push(value);
  797. });
  798. var t_head = '<div class="row t_head">';
  799. for (let k = 1; k < first_row.length; k++) {
  800. var param = renameCol(first_row[k]);
  801. t_head += '<div class="col-auto">' + param + '</div>';
  802. }
  803. t_head += '</div>';
  804. $('#query_results').append(t_head);
  805. $.each(
  806. json['results']['bindings'],
  807. function (index, value) {
  808. var object = "";
  809. var link = value['subject']['value'];
  810. var label = value['label']['value'];
  811. object += '<div class="row"><div id="' + link + '" class="col-auto link ' + resulType + '">' + label + '</div>';
  812. if (value.hasOwnProperty('identifier')) {
  813. identifier = value['identifier']['value'];
  814. object += '<div class="col-auto">' + identifier + '</div>';
  815. }
  816. if (value.hasOwnProperty('dimension')) {
  817. dimension = value['dimension']['value'];
  818. object += '<div class="col-auto">' + dimension + '</div>';
  819. }
  820. if (value.hasOwnProperty('material')) {
  821. material = value['material']['value'];
  822. object += '<div class="col-auto">' + material + '</div>';
  823. }
  824. if (value.hasOwnProperty('location')) {
  825. localization = value['location']['value'];
  826. object += '<div class="col-auto">' + localization + '</div>';
  827. }
  828. if (value.hasOwnProperty('technique')) {
  829. technique = value['technique']['value'];
  830. object += '<div class="col-auto">' + technique + '</div>';
  831. }
  832. if (value.hasOwnProperty('artist')) {
  833. artist = value['artist']['value'];
  834. object += '<div class="col-auto">' + artist + '</div>';
  835. }
  836. if (value.hasOwnProperty('depiction')) {
  837. depiction = value['depiction']['value'];
  838. object += '<div class="col-auto">' + depiction + '</div>';
  839. }
  840. if (value.hasOwnProperty('title')) {
  841. title = value['title']['value'];
  842. object += '<div class="col-auto">' + title + '</div>';
  843. }
  844. if (value.hasOwnProperty('type')) {
  845. type = value['type']['value'];
  846. object += '<div class="col-auto">' + type + '</div>';
  847. }
  848. if (value.hasOwnProperty('note')) {
  849. note = value['note']['value'];
  850. object += '<div class="col-auto">' + note + '</div>';
  851. }
  852. if (value.hasOwnProperty('ref')) {
  853. ref = value['ref']['value'];
  854. object += '<div class="col-auto">' + ref + '</div>';
  855. }
  856. if (value.hasOwnProperty('givenName')) {
  857. givenName = value['givenName']['value'];
  858. object += '<div class="col-auto">' + givenName + '</div>';
  859. }
  860. if (value.hasOwnProperty('familyName')) {
  861. familyName = value['familyName']['value'];
  862. object += '<div class="col-auto">' + familyName + '</div>';
  863. }
  864. if (value.hasOwnProperty('patronymic')) {
  865. patronymic = value['patronymic']['value'];
  866. object += '<div class="col-auto">' + patronymic + '</div>';
  867. }
  868. if (value.hasOwnProperty('birthPlace')) {
  869. birthPlace = value['birthPlace']['value'];
  870. object += '<div class="col-auto">' + birthPlace + '</div>';
  871. }
  872. if (value.hasOwnProperty('deathPlace')) {
  873. deathPlace = value['deathPlace']['value'];
  874. object += '<div class="col-auto">' + deathPlace + '</div>';
  875. }
  876. if (value.hasOwnProperty('genere')) {
  877. genere = value['genere']['value'];
  878. object += '<div class="col-auto">' + genere + '</div>';
  879. }
  880. if (value.hasOwnProperty('Birth_TS')) {
  881. Birth_TS = value['Birth_TS']['value'];
  882. object += '<div class="col-auto">' + Birth_TS + '</div>';
  883. }
  884. if (value.hasOwnProperty('Death_TS')) {
  885. Death_TS = value['Death_TS']['value'];
  886. object += '<div class="col-auto">' + Death_TS + '</div>';
  887. }
  888. if (value.hasOwnProperty('qualification')) {
  889. qualification = value['qualification']['value'];
  890. object += '<div class="col-auto">' + qualification + '</div>';
  891. }
  892. if (value.hasOwnProperty('occupation')) {
  893. occupation = value['occupation']['value'];
  894. object += '<div class="col-auto">' + occupation + '</div>';
  895. }
  896. if (value.hasOwnProperty('group')) {
  897. group = value['group']['value'];
  898. object += '<div class="col-auto">' + group + '</div>';
  899. }
  900. if (value.hasOwnProperty('mittente')) {
  901. mittente = value['mittente']['value'];
  902. object += '<div class="col-auto">' + mittente + '</div>';
  903. }
  904. if (value.hasOwnProperty('destinatario')) {
  905. destinatario = value['destinatario']['value'];
  906. object += '<div class="col-auto">' + destinatario + '</div>';
  907. }
  908. if (value.hasOwnProperty('luogo_partenza')) {
  909. luogo_partenza = value['luogo_partenza']['value'];
  910. object += '<div class="col-auto">' + luogo_partenza + '</div>';
  911. }
  912. if (value.hasOwnProperty('luogo_arrivo')) {
  913. luogo_arrivo = value['luogo_arrivo']['value'];
  914. object += '<div class="col-auto">' + luogo_arrivo + '</div>';
  915. }
  916. if (value.hasOwnProperty('timeSpanSend')) {
  917. timeSpanSend = value['timeSpanSend']['value'];
  918. object += '<div class="col-auto">' + timeSpanSend + '</div>';
  919. }
  920. if (value.hasOwnProperty('timeSpanReceive')) {
  921. timeSpanReceive = value['timeSpanReceive']['value'];
  922. object += '<div class="col-auto">' + timeSpanReceive + '</div>';
  923. }
  924. if (value.hasOwnProperty('lingua')) {
  925. lingua = value['lingua']['value'];
  926. object += '<div class="col-auto">' + lingua + '</div>';
  927. }
  928. if (value.hasOwnProperty('area_linguistica')) {
  929. area_linguistica = value['area_linguistica']['value'];
  930. object += '<div class="col-auto">' + area_linguistica + '</div>';
  931. }
  932. if (value.hasOwnProperty('edizione')) {
  933. edizione = value['edizione']['value'];
  934. object += '<div class="col-auto">' + edizione + '</div>';
  935. }
  936. if (value.hasOwnProperty('lemma')) {
  937. lemma = value['lemma']['value'];
  938. object += '<div class="col-auto">' + lemma + '</div>';
  939. }
  940. if (value.hasOwnProperty('testo')) {
  941. testo = value['testo']['value'];
  942. object += '<div class="col-auto">' + testo + '</div>';
  943. }
  944. if (value.hasOwnProperty('date')) {
  945. date = value['date']['value'];
  946. object += '<div class="col-auto">' + date + '</div>';
  947. }
  948. if (value.hasOwnProperty('start')) {
  949. start = value['start']['value'];
  950. object += '<div class="col-auto">' + start + '</div>';
  951. }
  952. if (value.hasOwnProperty('end')) {
  953. end = value['end']['value'];
  954. object += '<div class="col-auto">' + end + '</div>';
  955. }
  956. if (value.hasOwnProperty('send_date')) {
  957. send_date = value['send_date']['value'];
  958. object += '<div class="col-auto">' + send_date + '</div>';
  959. }
  960. if (value.hasOwnProperty('receive_date')) {
  961. receive_date = value['receive_date']['value'];
  962. object += '<div class="col-auto">' + receive_date + '</div>';
  963. }
  964. if (value.hasOwnProperty('time_start')) {
  965. opera_start = value['time_start']['value'];
  966. object += '<div class="col-auto">' + opera_start + '</div>';
  967. }
  968. object += '</div>';
  969. i++;
  970. /*onclick=copy__Text("' + value['link']['value'] + '")*/
  971. $('#query_results').append(object);
  972. });
  973. if (i==0) {
  974. var message = '<p>Nessun risultato trovato</p>';
  975. $('#query_results').append(message);
  976. }
  977. $('#Loader').css("display", "none");
  978. document.getElementById("n_res").innerHTML = i;
  979. }
  980. function populateSelGraph(graphType) {
  981. let y = graphArray.length;
  982. collection_selector.innerHTML = "";
  983. if (graphType != "General") {
  984. collection_selector.style.color = '#202122';
  985. collection_selector.style.cursor = 'pointer';
  986. collection_selector.style.backgroundColor = '#f8f9fa';
  987. collection_selector.style.backgroundImage = 'linear-gradient(to top, #fff, #fff 33%)';
  988. } else {
  989. collection_selector.style.color = '#a1a1a1';
  990. collection_selector.style.cursor = 'not-allowed';
  991. collection_selector.style.backgroundColor = '#eee';
  992. collection_selector.style.backgroundImage = 'linear-gradient(to top, #ddd, #eee 33%)';
  993. }
  994. var genOpt = document.createElement("option");
  995. genOpt.value= "";
  996. genOpt.innerHTML = "Tutte";
  997. collection_selector.add(genOpt);
  998. for(var i=0; i<y; i++) {
  999. if (graphType == graphArray[i][2]) {
  1000. var opt = document.createElement("option");
  1001. opt.value= graphArray[i][1];
  1002. opt.innerHTML = graphArray[i][0]; // whatever property it has
  1003. // then append it to the select element
  1004. collection_selector.add(opt);
  1005. }
  1006. }
  1007. }
  1008. function renameCol(param) {
  1009. if (param == "label") {
  1010. return ("Denominazione");
  1011. }
  1012. else if (param == "identifier") {
  1013. return ("Identificatore");
  1014. }
  1015. else if (param == "dimension") {
  1016. return ("Dimensioni");
  1017. }
  1018. else if (param == "material") {
  1019. return ("Materiale");
  1020. }
  1021. else if (param == "location") {
  1022. return ("Istituto di conservazione");
  1023. }
  1024. else if (param == "technique") {
  1025. return ("Tecnica");
  1026. }
  1027. else if (param == "artist") {
  1028. return ("Artista");
  1029. }
  1030. else if (param == "depiction") {
  1031. return ("Soggetto");
  1032. }
  1033. else if (param == "title") {
  1034. return ("Titolo");
  1035. }
  1036. else if (param == "type") {
  1037. return ("Tipologia");
  1038. }
  1039. else if (param == "note") {
  1040. return ("Note");
  1041. }
  1042. else if (param == "ref") {
  1043. return ("Riferimenti");
  1044. }
  1045. else if (param == "givenName") {
  1046. return ("Nome proprio");
  1047. }
  1048. else if (param == "familyName") {
  1049. return ("Cognome");
  1050. }
  1051. else if (param == "birthPlace") {
  1052. return ("Luogo di Nascita");
  1053. }
  1054. else if (param == "deathPlace") {
  1055. return ("Luogo di morte");
  1056. }
  1057. else if (param == "genere") {
  1058. return ("Genere");
  1059. }
  1060. else if (param == "Birth_TS") {
  1061. return ("Data di nascita");
  1062. }
  1063. else if (param == "Death_TS") {
  1064. return ("Data di morte");
  1065. }
  1066. else if (param == "qualification") {
  1067. return ("Qualifica");
  1068. }
  1069. else if (param == "occupation") {
  1070. return ("Occupazione");
  1071. }
  1072. else if (param == "mittente") {
  1073. return ("Mittente");
  1074. }
  1075. else if (param == "destinatario") {
  1076. return ("Destinatario");
  1077. }
  1078. else if (param == "luogo_partenza") {
  1079. return ("Luogo di partenza");
  1080. }
  1081. else if (param == "luogo_arrivo") {
  1082. return ("Luogo di arrivo");
  1083. }
  1084. else if (param == "timeSpanSend") {
  1085. return ("Data partenza");
  1086. }
  1087. else if (param == "timeSpanReceive") {
  1088. return ("Data arrivo");
  1089. }
  1090. else if (param == "area_linguistica") {
  1091. return ("Area linguistica");
  1092. }
  1093. else if (param == "edizione") {
  1094. return ("Edizione");
  1095. }
  1096. else if (param == "lemma") {
  1097. return ("Lemma");
  1098. }
  1099. else if (param == "testo") {
  1100. return ("Testo");
  1101. }
  1102. else if (param == "date") {
  1103. return ("Data");
  1104. }
  1105. else if (param == "start") {
  1106. return ("Data");
  1107. }
  1108. else if (param == "end") {
  1109. return ("Fine");
  1110. }
  1111. else if (param == "send_date") {
  1112. return ("Data partenza");
  1113. }
  1114. else if (param == "receive_date") {
  1115. return ("Data arrivo");
  1116. }
  1117. else if (param == "time_start") {
  1118. return ("Data");
  1119. }
  1120. else {
  1121. return (param);
  1122. }
  1123. }
  1124. function download_table_as_csv(separator = ',') {
  1125. // Select rows from table_id
  1126. var rows = document.querySelectorAll('#query_results .row');
  1127. // Construct csv
  1128. var csv = [];
  1129. for (var i = 0; i < rows.length; i++) {
  1130. var row = [], cols = rows[i].querySelectorAll('.col-auto');
  1131. for (var j = 0; j < cols.length; j++) {
  1132. // Clean innertext to remove multiple spaces and jumpline (break csv)
  1133. var data = cols[j].innerText.replace(/(\r\n|\n|\r)/gm, '').replace(/(\s\s)/gm, ' ')
  1134. // Escape double-quote with double-double-quote (see https://stackoverflow.com/questions/17808511/properly-escape-a-double-quote-in-csv)
  1135. data = data.replace(/"/g, '""');
  1136. // Push escaped string
  1137. row.push('"' + data + '"');
  1138. }
  1139. csv.push(row.join(separator));
  1140. }
  1141. var csv_string = csv.join('\n');
  1142. // Download it
  1143. var filename = 'export_queryResults_' + new Date().toLocaleDateString() + '.csv';
  1144. var link = document.createElement('a');
  1145. link.style.display = 'none';
  1146. link.setAttribute('target', '_blank');
  1147. link.setAttribute('href', 'data:text/csv;charset=utf-8,' + encodeURIComponent(csv_string));
  1148. link.setAttribute('download', filename);
  1149. document.body.appendChild(link);
  1150. link.click();
  1151. document.body.removeChild(link);
  1152. }