advanced_search.js 32 KB

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