advanced_search.js 46 KB

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