object.js 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406
  1. var link = thisUrlParams.link;
  2. prefixes = queryManager['prefixes']['all'];
  3. queryURL = prefixes + (queryManager['querySchedaOggetto']['queryInfo']).replace('{URI}', link);
  4. doJsonQuery(queryURL).done(function(data) { handle_objectData(data); });
  5. queryINF = prefixes + (queryManager['querySchedaOggetto']['queryContent']).replace('{URI}', link);
  6. doJsonQuery(queryINF).done(function(data) { handle_objectInfo(data); });
  7. queryOVI = prefixes + (queryManager['querySchedaOggetto']['queryOviLetter']).replace('{URI}', link);
  8. doJsonQuery(queryOVI).done(function(data) { handle_oviLetter(data); });
  9. queryPERS = prefixes + (queryManager['querySchedaOggetto']['queryPersone']).replace('{URI}', link);
  10. doJsonQuery(queryPERS).done(function(data) { handle_citedPeople(data); });
  11. queryLG = prefixes + (queryManager['querySchedaOggetto']['queryLuoghiGT']).replace('{URI}', link);
  12. doJsonQuery(queryLG).done(function(data) { handle_luoghiDocumento(data); });
  13. queryTR = prefixes + (queryManager['querySchedaOggetto']['queryTree']).replace('{URI}', link);
  14. doJsonQuery(queryTR).done(function(data) { handle_treeview(data, link); });
  15. function handle_objectData(json) {
  16. console.log(json['results']['bindings']);
  17. $.each(
  18. json['results']['bindings'],
  19. function (index, value) {
  20. var graph = value['graph']['value'];
  21. var label = value['label']['value'];
  22. var uri = value['uri']['value'];
  23. var siglaRegistro = "";
  24. var identifier = "";
  25. var dimensions = "";
  26. var consistence = "";
  27. var materials = "";
  28. var description = "";
  29. var button_ext = "";
  30. var button_owner = "";
  31. var current_owner = "";
  32. var uri_owner = "";
  33. var dates = "";
  34. var uri_composed = "";
  35. var composed = "";
  36. var button_doc = "";
  37. var treeList = "";
  38. var dataset = get_graph_name(graph);
  39. if (value.hasOwnProperty('id')) {
  40. $("#ID").css("display", "flex");
  41. identifier = value['id']['value'];
  42. }
  43. if (value.hasOwnProperty('dimension')) {
  44. $("#dimensione").css("display", "flex");
  45. dimensions = value['dimensions']['value'];
  46. }
  47. if (value.hasOwnProperty('consistency')) {
  48. $("#consistenza").css("display", "flex");
  49. consistence = value['consistency']['value'];
  50. }
  51. if (value.hasOwnProperty('sigla_registro')) {
  52. $("#IDreg").css("display", "flex");
  53. siglaRegistro = value['sigla_registro']['value'];
  54. }
  55. if (value.hasOwnProperty('condition')) {
  56. $("#STCC").css("display", "flex");
  57. condition = value['condition']['value'];
  58. }
  59. if (value.hasOwnProperty('material')) {
  60. $("#materia").css("display", "flex");
  61. materials = value['material']['value'];
  62. }
  63. if (value.hasOwnProperty('uri_owner')) {
  64. $("#current_owner").css("display", "flex");
  65. current_owner = value['owner']['value'];
  66. uri_owner = value['uri_owner']['value'];
  67. }
  68. if (value.hasOwnProperty('time_span')) {
  69. if (value['time_span']['value'] != ""){
  70. $("#time_span_object").css("display", "flex");
  71. dates = value['time_span']['value'];
  72. }
  73. }
  74. if (value.hasOwnProperty('note')) {
  75. $("#notes").css("display", "flex");
  76. description = value['note']['value'];
  77. }
  78. if (value.hasOwnProperty('uri_document')) {
  79. uri_composed = value['uri_document']['value'];
  80. }
  81. if (value.hasOwnProperty('document')) {
  82. //$("#composed").css("display", "flex");
  83. composed = value['document']['value'];
  84. }
  85. if (identifier != "") {
  86. button_ext = '<a title="Apri risorsa originale" href= "' + uri + '">' + identifier + '</a>';
  87. }
  88. if (uri_composed != "") {
  89. /*button_doc = '<button title="Apri risorsa di livello superiore" id="' + uri_composed + '" class="object btn btn-default" type="button" > \
  90. <i class="fa fa-book" aria-hidden="true"> <p class="btn-text">Livello superiore</p></i></button>';
  91. */
  92. treeList = '<li class="upLevel"><span id="' + uri_composed + '" class="object"><i class="fa fa-folder-open"></i>' +
  93. '<w class="link">' + composed + '</w></span><ul><li><span class="tree_label"><i class="fa fa-file-alt"></i>' + label + '<li></span><ul></li>'
  94. }
  95. if (owner != "") {
  96. button_owner = '<a title="Vai al sito dell\'Istituto" href= "' + uri_owner + '">' + current_owner + '</a>';
  97. }
  98. var Buttons = '<button title="Apri risorsa originale" class="btn btn-default" type="button" onclick="schedaASPO(\'' + uri + '\')"> \
  99. <i class="fas fa-external-link-alt" aria-hidden="true"></i></button> \
  100. <button title="Citazione" type="button" value="object" id="' + uri + '" class="cit btn btn-default" alt="scheda" title="Citazione"><i class="fa fa-quote-right"></i></button> \
  101. <button title="Permalink" type="button" value="object" id="' + uri + '" class="hyp btn btn-default" alt="scheda" title="Hyperlink"><i class="fa fa-link"></i></button> \
  102. <a href="http://dev.restore.ovi.cnr.it/lodlive/?' + uri + '" target="_blank"><button type="button" title="Naviga il grafo" class="btn btn-default info" alt="LOD" title="LodLive"><i class="fa fa-share-alt"></i></button></a></div></div>';
  103. document.getElementById("grafo").innerHTML = dataset;
  104. document.getElementById("nome_oggetto").innerHTML = label;
  105. document.getElementById("identifier").innerHTML = button_ext;
  106. document.getElementById("nota").innerHTML = description;
  107. document.getElementById("sigla_registro").innerHTML = siglaRegistro;
  108. document.getElementById("dimensions").innerHTML = dimensions;
  109. document.getElementById("materials").innerHTML = materials;
  110. document.getElementById("consistence").innerHTML = consistence;
  111. document.getElementById("owner").innerHTML = button_owner;
  112. document.getElementById("timeSpan").innerHTML = dates;
  113. document.getElementById("superDoc").innerHTML = composed;
  114. //document.getElementById("btn_superDoc").innerHTML = button_doc;
  115. document.getElementById("link_buttons").innerHTML = Buttons;
  116. document.getElementById("tree").innerHTML = treeList;
  117. });
  118. }
  119. function get_graph_name(graph) {
  120. var dataset = "Scheda Oggetto";
  121. if (graph == "http://dev.restore.ovi.cnr.it:8890/aspo/ospedale") {
  122. dataset = dataset + " / Ospedale";
  123. } else if (graph == "http://dev.restore.ovi.cnr.it:8890/aspo/datini") {
  124. dataset = dataset + " / Datini";
  125. } else if (graph == "http://dev.restore.ovi.cnr.it:8890/aspo/marcovaldi") {
  126. dataset = dataset + " / Marcovaldi";
  127. } else if (graph == "http://dev.restore.ovi.cnr.it:8890/aspo/gettatelli") {
  128. dataset = dataset + " / Gettatelli";
  129. } else {
  130. dataset = dataset;
  131. }
  132. return dataset;
  133. }
  134. function handle_objectInfo(json) {
  135. console.log(json['results']['bindings']);
  136. $.each(
  137. json['results']['bindings'],
  138. function (index, value) {
  139. var title = "";
  140. var type = "";
  141. var subject = "";
  142. if (value.hasOwnProperty('titolo')) {
  143. $("#titolo").css("display", "flex");
  144. title = value['titolo']['value'];
  145. }
  146. if (value.hasOwnProperty('tipo')) {
  147. $("#tipo").css("display", "flex");
  148. type = value['tipo']['value'];
  149. }
  150. if (value.hasOwnProperty('ref')) {
  151. if (value['ref']['value'] != "") {
  152. $("#argomento").css("display", "flex");
  153. subject = value['ref']['value'];
  154. }
  155. }
  156. document.getElementById("title").innerHTML = title;
  157. document.getElementById("type").innerHTML = type;
  158. document.getElementById("subject").innerHTML = subject;
  159. });
  160. }
  161. function handle_oviLetter(json) {
  162. console.log(json['results']['bindings']);
  163. $.each(
  164. json['results']['bindings'],
  165. function (index, value) {
  166. var other_id = "";
  167. var uri = "";
  168. var button_letter = "";
  169. if (value.hasOwnProperty('otherId')) {
  170. $("#IDbis").css("display", "flex");
  171. other_id = value['otherId']['value'];
  172. }
  173. if (value.hasOwnProperty('InfObj')) {
  174. uri = value['InfObj']['value'];
  175. }
  176. if (uri != "") {
  177. button_letter = '<button type="button" id="' + uri +
  178. '" class="lettera btn btn-default" alt="lettera"><i class="fa fa-envelope"></i><p class="btn-text">Scheda Lettera</p></button>';
  179. }
  180. document.getElementById("other_identifier").innerHTML = other_id;
  181. document.getElementById("btn_other_identifier").innerHTML = button_letter;
  182. });
  183. }
  184. function handle_citedPeople(json) {
  185. console.log(json);
  186. const people = [];
  187. $.each(
  188. json['results']['bindings'],
  189. function (index, value) {
  190. var uri = value['uri_person']['value'];
  191. var name = value['name']['value'];
  192. var tipo1 = "";
  193. var tipo2 = "";
  194. var nota = "";
  195. if (value.hasOwnProperty('types')) {
  196. if (value['types']['value'] != "") {
  197. tipo1 = value['types']['value'];
  198. }
  199. }
  200. if (value.hasOwnProperty('types2')) {
  201. if (value['types2']['value'] != "") {
  202. tipo2 = value['types2']['value'];
  203. }
  204. }
  205. if (value.hasOwnProperty('note')) {
  206. nota = value['note']['value'];
  207. }
  208. var tipo = "";
  209. if (tipo2 != "") {
  210. tipo = tipo2;
  211. } else {
  212. tipo = tipo1;
  213. }
  214. people.push([uri, name, tipo, nota]);
  215. });
  216. var Person = "";
  217. for (var i=0; i<people.length; i++) {
  218. var object = '<div class="col-8"><p><span id="' + people[i][0] + '" class="title_doc persona">'+ titleCase(people[i][1]) + '</span>';
  219. if (people[i][2] != "") {
  220. object = object + "<br />Ruoli documentati: " + people[i][2];
  221. }
  222. if (people[i][3] != "") {
  223. object = object + "<br />Nota: " + people[i][3];
  224. }
  225. object = object + '</p></div>';
  226. Person += '<div class="row res">' + object +
  227. '<div class="col d-flex align-items-start justify-content-end"><button type="button" id="' + people[i][0] + '" class="persona btn btn-default" alt="persona" title="' +
  228. people[i][1] + '"><i class="fa fa-user"></i><p class="btn-text">Persona</p></button>' +
  229. '<button type="button" value="Persona" id="' + people[i][0] + '" class="cit btn btn-default" alt="scheda" title="Info"><i class="fa fa-quote-right"></i><p class="btn-text">Citazione</p></button>' +
  230. '<button value="Persona" type="button" id="' + people[i][0] + '" class="hyp btn btn-default" alt="scheda" title="Info"><i class="fa fa-link"></i><p class="btn-text">Hyperlink</p></button>' +
  231. '<a href="http://dev.restore.ovi.cnr.it/lodlive/?' + people[i][0] + '" target="_blank"><button type="button" class="btn btn-default info" alt="LOD"><i class="fa fa-share-alt"></i><p class="btn-text">Lod</p></button></a></div></div>';
  232. }
  233. document.getElementById("n_pp").innerHTML = people.length;
  234. document.getElementById("cited_people").innerHTML = Person;
  235. if (people.length==0) {
  236. var messaggio = "<p class='no-results'>Questa ricerca non ha prodotto risultati</p>";
  237. document.getElementById("cited_people").innerHTML = messaggio;
  238. }
  239. }
  240. function handle_treeview(json, uri_subject) {
  241. console.log(json);
  242. var upLevel = "";
  243. var uri_up = "";
  244. var tree_doc = "";
  245. $.each(
  246. json['results']['bindings'],
  247. function (index, value) {
  248. upLevel = value['label']['value'];
  249. uri_up = value['uri']['value'];
  250. var uri = value['uri_document']['value'];
  251. var document = value['document']['value'];
  252. tree_doc += '<li><i class="fa fa-file-alt"></i><span id="' + uri + '" class="link object">' + document + '</span><li>'
  253. });
  254. if (tree_doc != "") {
  255. var tree_list = '<li class="upLevel"><span style="cursor:pointer;" class="caret"><i class="fa fa-folder-open"></i>' +
  256. '<w>' + upLevel + '</w></span><ul id="nested" style="display: none;">' + tree_doc + '</ul></li>';
  257. document.getElementById("treeView").innerHTML = tree_list;
  258. }
  259. }
  260. function handle_luoghiDocumento(json) {
  261. console.log(json);
  262. const places = [];
  263. $.each(
  264. json['results']['bindings'],
  265. function (index, value) {
  266. var uri = value['uri_place']['value'];
  267. var label = value['place']['value'];
  268. places.push([uri, label]);
  269. });
  270. var Luoghi = "";
  271. for (var i=0; i<places.length; i++) {
  272. var object = '<div class="col-8"><p><span id="' + places[i][0] + '" class="title_doc luogo">'+ places[i][1] + '</span></p></div>';
  273. var object_button = '<button type="button" id="' + places[i][0] +
  274. '" class="luogo btn btn-default" alt="oggetto" title="' + places[i][1] +
  275. '"><i class="fa fa-map"></i><p class="btn-text">luogo</p></button>';
  276. Luoghi += '<div class="row res">'+ object +
  277. '<div class="col d-flex align-items-start justify-content-end">' + object_button +
  278. '<button type="button" value="luogo" id="' + places[i][0] + '" class="cit btn btn-default" alt="scheda" title="Info"><i class="fa fa-quote-right"></i><p class="btn-text">Citazione</p></button>' +
  279. '<button type="button" value="luogo" id="' + places[i][0] + '" class="hyp btn btn-default" alt="scheda" title="Info"><i class="fa fa-link"></i><p class="btn-text">Hyperlink</p></button>' +
  280. '<a href="http://dev.restore.ovi.cnr.it/lodlive/?' + places[i][0] + '" target="_blank"><button type="button" class="btn btn-default info" alt="LOD"><i class="fa fa-share-alt"></i><p class="btn-text">Lod</p></button></a></div></div>';
  281. }
  282. document.getElementById("n_pl").innerHTML = places.length;
  283. document.getElementById("section_places").innerHTML = Luoghi;
  284. if (places.length==0) {
  285. var messaggio = "<p class='no-results'>Questa ricerca non ha prodotto risultati</p>";
  286. document.getElementById("section_places").innerHTML = messaggio;
  287. }
  288. }
  289. function createDivRelazione(type, id){
  290. htmlCode = '\
  291. <div class="row mb-2"> \
  292. <div class="col-sm-4"> \
  293. <span class="label"><RELATIONSHIP></span> \
  294. </div> \
  295. <div class="col record_box" id="<ID_RELATIONSHIP>"></div> \
  296. </div> \
  297. '.replace("<RELATIONSHIP>", type).replace("<ID_RELATIONSHIP>", id);
  298. return htmlCode;
  299. }
  300. function createColRelazione(text, link, tipo, fa, tab, decl) {
  301. htmlCode = '\
  302. <div class="row"> \
  303. <div class="col <CLASS>"><NAME></div> \
  304. <div class="col-auto"> \
  305. <button class="<TIPO> btn btn-default" type="button" id="<URI>">\
  306. <i class="<BUTTON>" aria-hidden="true">\
  307. <p class="btn-text"><TAB></p>\
  308. </i>\
  309. </button>\</div> \
  310. </div>\
  311. '.replace("<NAME>", text).replace("<URI>", link).replace("<TIPO>", tipo).replace("<BUTTON>", fa).replace("<TAB>", tab).replace("<CLASS>", decl);
  312. return htmlCode;
  313. }
  314. $(document).on("click", ".caret", function (ev) {
  315. $("#nested").toggle();
  316. //$("#nested").css("display", "block");
  317. });