advanced_search.js 46 KB

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