advanced_search.js 48 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296
  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 – Galleria Martini", "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. label = "?label bif:contains \"\' "+ params[i][1] + " \'\" . ";
  444. }
  445. if(params[i][0] == "Identificatore" && (params[i][1] != "")) {
  446. id = " ?identifier";
  447. identificatore = "FILTER (CONTAINS(?identifier, \'"+ params[i][1] +"\'))";
  448. }
  449. if(params[i][0] == "Dimensione" && (params[i][1] != "")) {
  450. dm = " ?dimension";
  451. dimensione = "?subject crm:P43_has_dimension ?uri_dimension . \
  452. ?uri_dimension rdfs:label ?dimension . \
  453. ?dimension bif:contains \"\'"+ params[i][1] +"\'\" ."
  454. }
  455. if(params[i][0] == "Materia" && (params[i][1] != "")) {
  456. mt = " ?material";
  457. materia = "?subject crm:P45_consists_of ?uri_material . \
  458. ?uri_material rdfs:label ?material . \
  459. ?material bif:contains \"\'"+ params[i][1] +"\'\" ."
  460. }
  461. if(params[i][0] == "Istituto di conservazione" && (params[i][1] != "")) {
  462. locl = " ?location";
  463. localizzazione = "?subject crm:P52_has_current_owner ?uri_location . \
  464. ?uri_location rdfs:label ?location . \
  465. ?location bif:contains \"\'"+ params[i][1] +"\'\" ."
  466. }
  467. if(params[i][0] == "Tecnica" && (params[i][1] != "")) {
  468. tec = " ?technique";
  469. tecnica = "?event ?pp ?subject . \
  470. ?event crm:P32_used_general_technique ?uri_technique . \
  471. ?uri_technique rdfs:label ?technique . \
  472. ?technique bif:contains \"\'"+ params[i][1] +"\'\" . "
  473. }
  474. if (params[i][0] == "Artista" && (params[i][1] != "")) {
  475. at = " ?artist";
  476. artista = "?subject rdfs:label ?label . \
  477. ?production crm:P108_has_produced ?subject . \
  478. ?pc crm:P01_has_domain ?production . \
  479. ?pc crm:P02_has_range ?range . \
  480. ?range rdfs:label ?artist . \
  481. ?artist bif:contains \"\'"+ params[i][1] +"\'\" ."
  482. }
  483. if (params[i][0] == "Soggetto" && (params[i][1] != "")) {
  484. sg = " ?depiction";
  485. soggetto = "?subject crm:P62_depicts ?uri_depiction . \
  486. ?uri_depiction rdfs:label ?depiction . \
  487. ?depiction bif:contains \"\'"+ params[i][1] +"\'\" ."
  488. }
  489. if (params[i][0] == "Titolo" && (params[i][1] != "")) {
  490. tt = " ?title";
  491. infObj = "?subject crm:P128_carries ?information_object .";
  492. titolo = "?information_object crm:P1_is_identified_by ?uri_title . \
  493. ?uri_title rdfs:label ?title . \
  494. ?title bif:contains \"\'"+ params[i][1] +"\'\" ."
  495. }
  496. if (params[i][0] == "Tipo di risorsa" && (params[i][1] != "")) {
  497. tp = " ?type";
  498. infObj = "?subject crm:P128_carries ?information_object .";
  499. tipo = "?information_object crm:P2_has_type ?uri_type . \
  500. ?uri_type rdfs:label ?type . \
  501. ?type bif:contains \"\'"+ params[i][1] +"\'\" ."
  502. }
  503. if (params[i][0] == "Note" && (params[i][1] != "")) {
  504. nt = " ?note";
  505. note = "?subject crm:P3_has_note ?uri_note . \
  506. ?uri_note rdfs:label ?note . \
  507. ?note bif:contains \"\'"+ params[i][1] +"\'\" .";
  508. }
  509. if (params[i][0] == "Riferimenti" && (params[i][1] != "")) {
  510. rf = " ?ref";
  511. riferimenti = "?subject crm:P67_refers_to ?uri_ref . \
  512. ?uri_ref rdfs:label ?ref . \
  513. ?ref bif:contains \"\'"+ params[i][1] +"\'\" . "
  514. }
  515. if (params[i][0] == "Nome proprio" && (params[i][1] != "")) {
  516. np = " ?givenName";
  517. nome_proprio = "?subject foaf:givenName ?givenName . \
  518. ?givenName bif:contains \"\'"+ params[i][1] +"\'\" . "
  519. }
  520. if (params[i][0] == "Nome di famiglia" && (params[i][1] != "")) {
  521. nf = " ?familyName";
  522. nome_di_famiglia = "?subject foaf:familyName ?familyName . \
  523. ?familyName bif:contains \"\'"+ params[i][1] +"\'\" . "
  524. }
  525. if (params[i][0] == "Patronimico" && (params[i][1] != "")) {
  526. pt = " ?patronymic";
  527. patronimico = "?subject person:patronymicName ?patronymic . \
  528. ?patronymic bif:contains \"\'"+ params[i][1] +"\'\" . "
  529. }
  530. if (params[i][0] == "Luogo di Nascita" && (params[i][1] != "")) {
  531. ln = " ?birthPlace";
  532. luogo_di_Nascita = "?subject crm:P98i_was_born ?Birth . \
  533. ?Birth crm:P7_took_place_at ?uri_birthPlace . \
  534. ?uri_birthPlace rdfs:label ?birthPlace . \
  535. ?birthPlace bif:contains \""+ params[i][1] +"\" . "
  536. }
  537. if (params[i][0] == "Luogo di Morte" && (params[i][1] != "")) {
  538. lm = " ?deathPlace";
  539. luogo_di_Morte = "?subject crm:P100i_died_in ?Death . \
  540. ?Death crm:P7_took_place_at ?uri_deathPlace . \
  541. ?uri_deathPlace rdfs:label ?deathPlace \
  542. ?deathPlace bif:contains \""+ params[i][1] +"\" . "
  543. }
  544. if (params[i][0] == "Genere" && (params[i][1] != "")) {
  545. gr = "?genere";
  546. genere = "?subject foaf:gender ?genere . \
  547. ?genere bif:contains \""+ params[i][1] +"\" . "
  548. }
  549. if (params[i][0] == "Data di Nascita" && (params[i][1] != "")) {
  550. dn = " ?Birth_TS";
  551. data_di_Nascita = "?subject crm:P98i_was_born ?Birth . \
  552. ?Birth crm:P4_has_time-span ?Birth_TS . \
  553. ?Birth_TS rdfs:label \""+ params[i][1] +"\" ."
  554. }
  555. if (params[i][0] == "Data di Morte" && (params[i][1] != "")) {
  556. dts = " ?Death_TS";
  557. data_di_Morte = "?subject crm:P100i_died_in ?Death . \
  558. ?Death crm:P4_has_time-span ?Death_TS . \
  559. ?Death_TS rdfs:label \""+ params[i][1] +"\" . "
  560. }
  561. if (params[i][0] == "Qualifica" && (params[i][1] != "")) {
  562. qf = " ?qualification";
  563. qualifica = "?subject schema:honorificPrefix ?qualification . \
  564. ?qualification bif:contains \"\'"+ params[i][1] +"\'\" . "
  565. }
  566. if (params[i][0] == "Occupazione" && (params[i][1] != "")) {
  567. oc = " ?occupation";
  568. occupazione = "?subject schema:hasOccupation ?uriOccupation . \
  569. ?uriOccupation rdf:type schema:Occupation; \
  570. rdfs:label ?occupation . \
  571. ?occupation bif:contains \"\'"+ params[i][1] +"\'\" . "
  572. }
  573. if (params[i][0] == "Gruppi di appartenenza" && (params[i][1] != "")) {
  574. ga = " ?group";
  575. gruppi_di_appartenenza = "?subject crm:P107i_is_current_or_former_member_of ?uriGroup . \
  576. ?uriGroup rdfs:label ?group . \
  577. ?group bif:contains \"\'"+ params[i][1] +"\'\" . "
  578. }
  579. if (params[i][0] == "Mittente" && (params[i][1] != "")) {
  580. mit = " ?mittente";
  581. letter_event = "?subject crm:P25i_moved_by ?mov_ev . \
  582. ?send rdfs:subClassOf ?mov_ev ; \
  583. rdf:type crm:EL2_Send_Letter . \
  584. ?receive rdfs:subClassOf ?mov_ev; \
  585. rdf:type crm:EL3_Receive_Letter . ";
  586. mittente = "?send crm:P01_has_domain ?pcS . \
  587. ?pcS crm:P02_has_range ?uriSender . \
  588. ?uriSender rdfs:label ?mittente . \
  589. ?mittente bif:contains \"\'"+ params[i][1] +"\'\" . "
  590. }
  591. if (params[i][0] == "Destinatario" && (params[i][1] != "")) {
  592. des = " ?destinatario";
  593. letter_event = "?subject crm:P25i_moved_by ?mov_ev . \
  594. ?send rdfs:subClassOf ?mov_ev ; \
  595. rdf:type crm:EL2_Send_Letter . \
  596. ?receive rdfs:subClassOf ?mov_ev; \
  597. rdf:type crm:EL3_Receive_Letter . ";
  598. destinatario = "?receive crm:P01_has_domain ?pcR . \
  599. ?pcR crm:P02_has_range ?uriReceiver . \
  600. ?uriReceiver rdfs:label ?destinatario . \
  601. ?destinatario bif:contains \"\'"+ params[i][1] +"\'\" . "
  602. }
  603. if (params[i][0] == "Luogo di Partenza" && (params[i][1] != "")) {
  604. lp = " ?luogo_partenza";
  605. letter_event = "?subject crm:P25i_moved_by ?mov_ev . \
  606. ?send rdfs:subClassOf ?mov_ev ; \
  607. rdf:type crm:EL2_Send_Letter . \
  608. ?receive rdfs:subClassOf ?mov_ev; \
  609. rdf:type crm:EL3_Receive_Letter . ";
  610. luogo_di_Partenza = "?send crm:P27_moved_from ?uriLuogoPartenza . \
  611. ?uriLuogoPartenza rdfs:label ?luogo_partenza . \
  612. ?luogo_partenza bif:contains \"\'"+ params[i][1] +"\'\" . "
  613. }
  614. if (params[i][0] == "Luogo di Arrivo" && (params[i][1] != "")) {
  615. la = " ?luogo_arrivo";
  616. letter_event = "?subject crm:P25i_moved_by ?mov_ev . \
  617. ?send rdfs:subClassOf ?mov_ev ; \
  618. rdf:type crm:EL2_Send_Letter . \
  619. ?receive rdfs:subClassOf ?mov_ev; \
  620. rdf:type crm:EL3_Receive_Letter . ";
  621. luogo_di_Arrivo = "?receive crm:P26_moved_to ?uriLuogoArrivo . \
  622. ?uriLuogoArrivo rdfs:label ?luogo_arrivo . \
  623. ?luogo_arrivo bif:contains \"\'"+ params[i][1] +"\'\" . "
  624. }
  625. if (params[i][0] == "Data partenza" && (params[i][1] != "")) {
  626. dp = " ?timeSpanSend";
  627. letter_event = "?subject crm:P25i_moved_by ?mov_ev . \
  628. ?send rdfs:subClassOf ?mov_ev ; \
  629. rdf:type crm:EL2_Send_Letter . \
  630. ?receive rdfs:subClassOf ?mov_ev; \
  631. rdf:type crm:EL3_Receive_Letter . ";
  632. data_partenza = "?send crm:P4_has_time-span ?time_spanS . \
  633. ?time_spanS rdfs:label ?timeSpanSend . \
  634. ?timeSpanSend bif:contains \"\'"+ params[i][1] +"\'\" . "
  635. }
  636. if (params[i][0] == "Data arrivo" && (params[i][1] != "")) {
  637. da = " ?timeSpanReceive";
  638. letter_event = "?subject crm:P25i_moved_by ?mov_ev . \
  639. ?send rdfs:subClassOf ?mov_ev ; \
  640. rdf:type crm:EL2_Send_Letter . \
  641. ?receive rdfs:subClassOf ?mov_ev; \
  642. rdf:type crm:EL3_Receive_Letter . ";
  643. data_arrivo = "?receive crm:P4_has_time-span ?time_spanR . \
  644. ?time_spanR rdfs:label ?timeSpanReceive .\
  645. ?timeSpanReceive bif:contains \"\'"+ params[i][1] +"\'\" . "
  646. }
  647. if (params[i][0] == "Lingua" && (params[i][1] != "")) {
  648. lin = " ?lingua";
  649. lingua = "?information_object crm:P72_has_language ?language . \
  650. ?language rdfs:label ?lingua . \
  651. ?lingua bif:contains \"\'"+ params[i][1] +"\'\" ."
  652. }
  653. if (params[i][0] == "Area linguistica" && (params[i][1] != "")) {
  654. alin = " ?area_linguistica";
  655. area_linguistica = "?information_object crm:P72_has_language ?language . \
  656. ?language crm:P3_has_note ?area . \
  657. ?area rdfs:label ?area_linguistica .\
  658. ?area_linguistica bif:contains \"\'"+ params[i][1] +"\'\" ."
  659. }
  660. if (params[i][0] == "Edizione" && (params[i][1] != "")) {
  661. ed = " ?edizione";
  662. edizione = "?edition crm:P70_documents ?information_object ; \
  663. crm:P1_is_identified_by ?edition_id . \
  664. ?edition_id rdfs:label ?edizione . \
  665. ?edizione bif:contains \"\'"+ params[i][1] +"\'\" ."
  666. }
  667. if (params[i][0] == "Lemma" && (params[i][1] != "")) {
  668. lem = " ?lemma";
  669. lemma = "?information_object crm:P67_refers_to ?link_lemma . \
  670. ?link_lemma rdfs:label ?lemma. \
  671. ?lemma bif:contains \"\'"+ params[i][1] +"\'\" ."
  672. }
  673. if (params[i][0] == "Testo libero" && (params[i][1] != "")) {
  674. ttx = " ?testo";
  675. testo = "?information_object crm:P190_has_symbolic_content ?testo . \
  676. ?testo bif:contains \"\'"+ params[i][1] +"\'\" ."
  677. }
  678. if (params[i][0] == "Data" && (params[i][1] != "")) {
  679. dt = " ?date";
  680. data = "?subject ?property ?event . \
  681. ?event crm:P4_has_time-span ?uri_date . \
  682. ?uri_date rdfs:label ?date . \
  683. ?date bif:contains \"\'"+ params[i][1] +"\'\" ."
  684. }
  685. if (params[i][0] == "Da" && (params[i][1] != "")) {
  686. st = " ?start";
  687. start = "?subject ?property ?event_start . \
  688. ?event_start crm:P4_has_time-span ?uri_date_start . \
  689. ?uri_date_start rdfs:label ?start ; \
  690. time:hasBeginning ?date_start . \
  691. FILTER (?date_start >= \""+ params[i][1] +"\"^^xsd:date)";
  692. }
  693. if (params[i][0] == "A" && (params[i][1] != "")) {
  694. fn = " ?end";
  695. finish = "?subject ?property ?event_end . \
  696. ?event_end crm:P4_has_time-span ?uri_date_end . \
  697. ?uri_date_end rdfs:label ?end ; \
  698. time:hasEnd ?date_end . \
  699. FILTER (?date_start <= \""+ params[i][1] +"\"^^xsd:date)";
  700. }
  701. if (params[i][0] == "Data partenza inizio" && (params[i][1] != "")) {
  702. dpi = " ?send_date";
  703. letter_event = "?subject crm:P25i_moved_by ?mov_ev . \
  704. ?send rdfs:subClassOf ?mov_ev ; \
  705. rdf:type crm:EL2_Send_Letter . \
  706. ?receive rdfs:subClassOf ?mov_ev; \
  707. rdf:type crm:EL3_Receive_Letter . ";
  708. data_partenza_inizio = "?send crm:P4_has_time-span ?uri_send_date . \
  709. ?uri_send_date rdfs:label ?send_date ; \
  710. time:hasBeginning ?time_send . \
  711. FILTER (?time_send >= \""+ params[i][1] +"\"^^xsd:date";
  712. }
  713. if (params[i][0] == "Data partenza fine" && (params[i][1] != "")) {
  714. data_partenza_fine = data_partenza_inizio + " && ?time_send <= \""+ params[i][1] +"\"^^xsd:date)";
  715. }
  716. if (params[i][0] == "Data arrivo inizio" && (params[i][1] != "")) {
  717. dai = " ?receive_date";
  718. letter_event = "?subject crm:P25i_moved_by ?mov_ev . \
  719. ?send rdfs:subClassOf ?mov_ev ; \
  720. rdf:type crm:EL2_Send_Letter . \
  721. ?receive rdfs:subClassOf ?mov_ev; \
  722. rdf:type crm:EL3_Receive_Letter . ";
  723. data_arrivo_inizio = "?receive crm:P4_has_time-span ?uri_receive_date . \
  724. ?uri_receive_date rdfs:label ?receive_date ; \
  725. time:hasEnd ?time_receive . \
  726. FILTER (?time_receive >= \""+ params[i][1] +"\"^^xsd:date";
  727. }
  728. if (params[i][0] == "Data arrivo fine" && (params[i][1] != "")) {
  729. data_arrivo_fine = data_arrivo_inizio + " && ?time_receive <= \""+ params[i][1] +"\"^^xsd:date)";
  730. }
  731. if (params[i][0] == "Data inizio opera" && (params[i][1] != "")) {
  732. diop = " ?time_start";
  733. data_opera_inizio = "?event_start ?pp ?subject ; \
  734. crm:P2_has_type 'Inizio'^^<http://www.w3.org/2001/XMLSchema#string> ; \
  735. crm:P4_has_time-span ?uri_time_start . \
  736. ?uri_time_start rdfs:label ?time_start; \
  737. time:year ?date_start . \
  738. FILTER (?date_start >= \""+ params[i][1] +"\"^^xsd:integer)";
  739. }
  740. if (params[i][0] == "Data fine opera" && (params[i][1] != "")) {
  741. data_opera_fine = "FILTER (?date_start <= \""+ params[i][1] +"\"^^xsd:integer)";
  742. }
  743. }
  744. prefixes = "PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> \
  745. PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> \
  746. PREFIX crm: <http://www.cidoc-crm.org/cidoc-crm/> \
  747. PREFIX owl: <http://www.w3.org/2002/07/owl#> \
  748. PREFIX schema: <http://schema.org/> \
  749. PREFIX foaf: <http://xmlns.com/foaf/0.1/> \
  750. PREFIX person: <http://www.w3.org/ns/person#> \
  751. PREFIX time: <https://www.w3.org/TR/owl-time#>"
  752. query = prefixes + " SELECT DISTINCT ?subject ?label ?identifier " + dm + mt + locl + tec + at
  753. + sg + tt + tp + nt + rf + np + nf + pt + ln + lm + gr + dn + dts + oc + qf + ga + mit
  754. + des + lp + la + dp + da + dpi + dai + diop + lin + alin + ed + lem + dt + st + ttx + " \
  755. WHERE {GRAPH " + search_graph + " {?subject ?property ?object } \
  756. ?subject rdfs:label ?label . "
  757. + search_identifier + infObj + letter_event + label + search_type + dimensione + materia + localizzazione + tecnica
  758. + artista + titolo + tipo + note + riferimenti + nome_proprio + nome_di_famiglia
  759. + patronimico + luogo_di_Nascita + luogo_di_Morte + genere + data_di_Nascita
  760. + data_di_Morte + qualifica + occupazione + gruppi_di_appartenenza + mittente + destinatario
  761. +luogo_di_Partenza + luogo_di_Arrivo + data_partenza_fine + data_arrivo_fine + data_opera_inizio + data_opera_fine + lingua
  762. + area_linguistica + edizione + lemma + data + identificatore + start + finish + testo + "}"
  763. var query_url = 'http://dev.restore.ovi.cnr.it:8890/sparql/?default-graph-uri=&query=' + encodeURIComponent(query) + '&output=json';
  764. console.log(query);
  765. $.ajax({
  766. url: query_url + '&callback=?',
  767. dataType: "json",
  768. success: function (data) {
  769. query_handle_json(data, choosen_type);
  770. },
  771. error: function (e) {}
  772. });
  773. }
  774. function query_handle_json(json, choosen_type) {
  775. console.log(json);
  776. var resulType = "";
  777. if (choosen_type == "Object") {
  778. resulType = "object";
  779. }
  780. if (choosen_type == "Letter") {
  781. resulType = "object";
  782. }
  783. if (choosen_type == "OA") {
  784. resulType = "artwork";
  785. }
  786. if (choosen_type == "Person") {
  787. resulType = "persona";
  788. }
  789. $('#query_results').text("");
  790. var i = 0;
  791. const first_row = [];
  792. $.each(
  793. json['head']['vars'],
  794. function (index, value) {
  795. first_row.push(value);
  796. });
  797. var t_head = '<div class="row t_head">';
  798. for (let k = 1; k < first_row.length; k++) {
  799. var param = renameCol(first_row[k]);
  800. t_head += '<div class="col-auto">' + param + '</div>';
  801. }
  802. t_head += '</div>';
  803. $('#query_results').append(t_head);
  804. $.each(
  805. json['results']['bindings'],
  806. function (index, value) {
  807. var object = "";
  808. var link = value['subject']['value'];
  809. var label = value['label']['value'];
  810. object += '<div class="row"><div id="' + link + '" class="col-auto link ' + resulType + '">' + label + '</div>';
  811. if (value.hasOwnProperty('identifier')) {
  812. identifier = value['identifier']['value'];
  813. object += '<div class="col-auto">' + identifier + '</div>';
  814. }
  815. if (value.hasOwnProperty('dimension')) {
  816. dimension = value['dimension']['value'];
  817. object += '<div class="col-auto">' + dimension + '</div>';
  818. }
  819. if (value.hasOwnProperty('material')) {
  820. material = value['material']['value'];
  821. object += '<div class="col-auto">' + material + '</div>';
  822. }
  823. if (value.hasOwnProperty('location')) {
  824. localization = value['location']['value'];
  825. object += '<div class="col-auto">' + localization + '</div>';
  826. }
  827. if (value.hasOwnProperty('technique')) {
  828. technique = value['technique']['value'];
  829. object += '<div class="col-auto">' + technique + '</div>';
  830. }
  831. if (value.hasOwnProperty('artist')) {
  832. artist = value['artist']['value'];
  833. object += '<div class="col-auto">' + artist + '</div>';
  834. }
  835. if (value.hasOwnProperty('depiction')) {
  836. depiction = value['depiction']['value'];
  837. object += '<div class="col-auto">' + depiction + '</div>';
  838. }
  839. if (value.hasOwnProperty('title')) {
  840. title = value['title']['value'];
  841. object += '<div class="col-auto">' + title + '</div>';
  842. }
  843. if (value.hasOwnProperty('type')) {
  844. type = value['type']['value'];
  845. object += '<div class="col-auto">' + type + '</div>';
  846. }
  847. if (value.hasOwnProperty('note')) {
  848. note = value['note']['value'];
  849. object += '<div class="col-auto">' + note + '</div>';
  850. }
  851. if (value.hasOwnProperty('ref')) {
  852. ref = value['ref']['value'];
  853. object += '<div class="col-auto">' + ref + '</div>';
  854. }
  855. if (value.hasOwnProperty('givenName')) {
  856. givenName = value['givenName']['value'];
  857. object += '<div class="col-auto">' + givenName + '</div>';
  858. }
  859. if (value.hasOwnProperty('familyName')) {
  860. familyName = value['familyName']['value'];
  861. object += '<div class="col-auto">' + familyName + '</div>';
  862. }
  863. if (value.hasOwnProperty('patronymic')) {
  864. patronymic = value['patronymic']['value'];
  865. object += '<div class="col-auto">' + patronymic + '</div>';
  866. }
  867. if (value.hasOwnProperty('birthPlace')) {
  868. birthPlace = value['birthPlace']['value'];
  869. object += '<div class="col-auto">' + birthPlace + '</div>';
  870. }
  871. if (value.hasOwnProperty('deathPlace')) {
  872. deathPlace = value['deathPlace']['value'];
  873. object += '<div class="col-auto">' + deathPlace + '</div>';
  874. }
  875. if (value.hasOwnProperty('genere')) {
  876. genere = value['genere']['value'];
  877. object += '<div class="col-auto">' + genere + '</div>';
  878. }
  879. if (value.hasOwnProperty('Birth_TS')) {
  880. Birth_TS = value['Birth_TS']['value'];
  881. object += '<div class="col-auto">' + Birth_TS + '</div>';
  882. }
  883. if (value.hasOwnProperty('Death_TS')) {
  884. Death_TS = value['Death_TS']['value'];
  885. object += '<div class="col-auto">' + Death_TS + '</div>';
  886. }
  887. if (value.hasOwnProperty('qualification')) {
  888. qualification = value['qualification']['value'];
  889. object += '<div class="col-auto">' + qualification + '</div>';
  890. }
  891. if (value.hasOwnProperty('occupation')) {
  892. occupation = value['occupation']['value'];
  893. object += '<div class="col-auto">' + occupation + '</div>';
  894. }
  895. if (value.hasOwnProperty('group')) {
  896. group = value['group']['value'];
  897. object += '<div class="col-auto">' + group + '</div>';
  898. }
  899. if (value.hasOwnProperty('mittente')) {
  900. mittente = value['mittente']['value'];
  901. object += '<div class="col-auto">' + mittente + '</div>';
  902. }
  903. if (value.hasOwnProperty('destinatario')) {
  904. destinatario = value['destinatario']['value'];
  905. object += '<div class="col-auto">' + destinatario + '</div>';
  906. }
  907. if (value.hasOwnProperty('luogo_partenza')) {
  908. luogo_partenza = value['luogo_partenza']['value'];
  909. object += '<div class="col-auto">' + luogo_partenza + '</div>';
  910. }
  911. if (value.hasOwnProperty('luogo_arrivo')) {
  912. luogo_arrivo = value['luogo_arrivo']['value'];
  913. object += '<div class="col-auto">' + luogo_arrivo + '</div>';
  914. }
  915. if (value.hasOwnProperty('timeSpanSend')) {
  916. timeSpanSend = value['timeSpanSend']['value'];
  917. object += '<div class="col-auto">' + timeSpanSend + '</div>';
  918. }
  919. if (value.hasOwnProperty('timeSpanReceive')) {
  920. timeSpanReceive = value['timeSpanReceive']['value'];
  921. object += '<div class="col-auto">' + timeSpanReceive + '</div>';
  922. }
  923. if (value.hasOwnProperty('lingua')) {
  924. lingua = value['lingua']['value'];
  925. object += '<div class="col-auto">' + lingua + '</div>';
  926. }
  927. if (value.hasOwnProperty('area_linguistica')) {
  928. area_linguistica = value['area_linguistica']['value'];
  929. object += '<div class="col-auto">' + area_linguistica + '</div>';
  930. }
  931. if (value.hasOwnProperty('edizione')) {
  932. edizione = value['edizione']['value'];
  933. object += '<div class="col-auto">' + edizione + '</div>';
  934. }
  935. if (value.hasOwnProperty('lemma')) {
  936. lemma = value['lemma']['value'];
  937. object += '<div class="col-auto">' + lemma + '</div>';
  938. }
  939. if (value.hasOwnProperty('testo')) {
  940. testo = value['testo']['value'];
  941. object += '<div class="col-auto">' + testo + '</div>';
  942. }
  943. if (value.hasOwnProperty('date')) {
  944. date = value['date']['value'];
  945. object += '<div class="col-auto">' + date + '</div>';
  946. }
  947. if (value.hasOwnProperty('start')) {
  948. start = value['start']['value'];
  949. object += '<div class="col-auto">' + start + '</div>';
  950. }
  951. if (value.hasOwnProperty('end')) {
  952. end = value['end']['value'];
  953. object += '<div class="col-auto">' + end + '</div>';
  954. }
  955. if (value.hasOwnProperty('send_date')) {
  956. send_date = value['send_date']['value'];
  957. object += '<div class="col-auto">' + send_date + '</div>';
  958. }
  959. if (value.hasOwnProperty('receive_date')) {
  960. receive_date = value['receive_date']['value'];
  961. object += '<div class="col-auto">' + receive_date + '</div>';
  962. }
  963. if (value.hasOwnProperty('time_start')) {
  964. opera_start = value['time_start']['value'];
  965. object += '<div class="col-auto">' + opera_start + '</div>';
  966. }
  967. object += '</div>';
  968. i++;
  969. /*onclick=copy__Text("' + value['link']['value'] + '")*/
  970. $('#query_results').append(object);
  971. });
  972. if (i==0) {
  973. var message = '<p>Nessun risultato trovato</p>';
  974. $('#query_results').append(message);
  975. }
  976. $('#Loader').css("display", "none");
  977. document.getElementById("n_res").innerHTML = i;
  978. }
  979. function populateSelGraph(graphType) {
  980. let y = graphArray.length;
  981. collection_selector.innerHTML = "";
  982. if (graphType != "General") {
  983. collection_selector.style.color = '#202122';
  984. collection_selector.style.cursor = 'pointer';
  985. collection_selector.style.backgroundColor = '#f8f9fa';
  986. collection_selector.style.backgroundImage = 'linear-gradient(to top, #fff, #fff 33%)';
  987. } else {
  988. collection_selector.style.color = '#a1a1a1';
  989. collection_selector.style.cursor = 'not-allowed';
  990. collection_selector.style.backgroundColor = '#eee';
  991. collection_selector.style.backgroundImage = 'linear-gradient(to top, #ddd, #eee 33%)';
  992. }
  993. var genOpt = document.createElement("option");
  994. genOpt.value= "";
  995. genOpt.innerHTML = "Tutte";
  996. collection_selector.add(genOpt);
  997. for(var i=0; i<y; i++) {
  998. if (graphType == graphArray[i][2]) {
  999. var opt = document.createElement("option");
  1000. opt.value= graphArray[i][1];
  1001. opt.innerHTML = graphArray[i][0]; // whatever property it has
  1002. // then append it to the select element
  1003. collection_selector.add(opt);
  1004. }
  1005. }
  1006. }
  1007. function renameCol(param) {
  1008. if (param == "label") {
  1009. return ("Denominazione");
  1010. }
  1011. else if (param == "identifier") {
  1012. return ("Identificatore");
  1013. }
  1014. else if (param == "dimension") {
  1015. return ("Dimensioni");
  1016. }
  1017. else if (param == "material") {
  1018. return ("Materiale");
  1019. }
  1020. else if (param == "location") {
  1021. return ("Istituto di conservazione");
  1022. }
  1023. else if (param == "technique") {
  1024. return ("Tecnica");
  1025. }
  1026. else if (param == "artist") {
  1027. return ("Artista");
  1028. }
  1029. else if (param == "depiction") {
  1030. return ("Soggetto");
  1031. }
  1032. else if (param == "title") {
  1033. return ("Titolo");
  1034. }
  1035. else if (param == "type") {
  1036. return ("Tipologia");
  1037. }
  1038. else if (param == "note") {
  1039. return ("Note");
  1040. }
  1041. else if (param == "ref") {
  1042. return ("Riferimenti");
  1043. }
  1044. else if (param == "givenName") {
  1045. return ("Nome proprio");
  1046. }
  1047. else if (param == "familyName") {
  1048. return ("Cognome");
  1049. }
  1050. else if (param == "birthPlace") {
  1051. return ("Luogo di Nascita");
  1052. }
  1053. else if (param == "deathPlace") {
  1054. return ("Luogo di morte");
  1055. }
  1056. else if (param == "genere") {
  1057. return ("Genere");
  1058. }
  1059. else if (param == "Birth_TS") {
  1060. return ("Data di nascita");
  1061. }
  1062. else if (param == "Death_TS") {
  1063. return ("Data di morte");
  1064. }
  1065. else if (param == "qualification") {
  1066. return ("Qualifica");
  1067. }
  1068. else if (param == "occupation") {
  1069. return ("Occupazione");
  1070. }
  1071. else if (param == "mittente") {
  1072. return ("Mittente");
  1073. }
  1074. else if (param == "destinatario") {
  1075. return ("Destinatario");
  1076. }
  1077. else if (param == "luogo_partenza") {
  1078. return ("Luogo di partenza");
  1079. }
  1080. else if (param == "luogo_arrivo") {
  1081. return ("Luogo di arrivo");
  1082. }
  1083. else if (param == "timeSpanSend") {
  1084. return ("Data partenza");
  1085. }
  1086. else if (param == "timeSpanReceive") {
  1087. return ("Data arrivo");
  1088. }
  1089. else if (param == "area_linguistica") {
  1090. return ("Area linguistica");
  1091. }
  1092. else if (param == "edizione") {
  1093. return ("Edizione");
  1094. }
  1095. else if (param == "lemma") {
  1096. return ("Lemma");
  1097. }
  1098. else if (param == "testo") {
  1099. return ("Testo");
  1100. }
  1101. else if (param == "date") {
  1102. return ("Data");
  1103. }
  1104. else if (param == "start") {
  1105. return ("Data");
  1106. }
  1107. else if (param == "end") {
  1108. return ("Fine");
  1109. }
  1110. else if (param == "send_date") {
  1111. return ("Data partenza");
  1112. }
  1113. else if (param == "receive_date") {
  1114. return ("Data arrivo");
  1115. }
  1116. else if (param == "time_start") {
  1117. return ("Data");
  1118. }
  1119. else {
  1120. return (param);
  1121. }
  1122. }
  1123. function download_table_as_csv(separator = ',') {
  1124. // Select rows from table_id
  1125. var rows = document.querySelectorAll('#query_results .row');
  1126. // Construct csv
  1127. var csv = [];
  1128. for (var i = 0; i < rows.length; i++) {
  1129. var row = [], cols = rows[i].querySelectorAll('.col-auto');
  1130. for (var j = 0; j < cols.length; j++) {
  1131. // Clean innertext to remove multiple spaces and jumpline (break csv)
  1132. var data = cols[j].innerText.replace(/(\r\n|\n|\r)/gm, '').replace(/(\s\s)/gm, ' ')
  1133. // Escape double-quote with double-double-quote (see https://stackoverflow.com/questions/17808511/properly-escape-a-double-quote-in-csv)
  1134. data = data.replace(/"/g, '""');
  1135. // Push escaped string
  1136. row.push('"' + data + '"');
  1137. }
  1138. csv.push(row.join(separator));
  1139. }
  1140. var csv_string = csv.join('\n');
  1141. // Download it
  1142. var filename = 'export_queryResults_' + new Date().toLocaleDateString() + '.csv';
  1143. var link = document.createElement('a');
  1144. link.style.display = 'none';
  1145. link.setAttribute('target', '_blank');
  1146. link.setAttribute('href', 'data:text/csv;charset=utf-8,' + encodeURIComponent(csv_string));
  1147. link.setAttribute('download', filename);
  1148. document.body.appendChild(link);
  1149. link.click();
  1150. document.body.removeChild(link);
  1151. }