object.js 14 KB

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