object.js 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349
  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" title="Bene culturale" > \
  87. <i class="fa fa-book" aria-hidden="true"> <p class="btn-text">Bene culturale</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 tipo = "";
  186. var nota = "";
  187. if (value.hasOwnProperty('types')) {
  188. if (value['types']['value'] != "") {
  189. tipo = value['types']['value'];
  190. }
  191. }
  192. if (value.hasOwnProperty('note')) {
  193. nota = value['note']['value'];
  194. }
  195. people.push([uri, name, tipo, nota]);
  196. });
  197. var Person = "";
  198. for (var i=0; i<people.length; i++) {
  199. var object = '<div class="col-8"><p><span id="' + people[i][0] + '" class="title_doc persona">'+ people[i][1] + '</span>';
  200. if (people[i][2] != "") {
  201. object = object + "<br />Citazione nel ruolo di: " + people[i][2];
  202. }
  203. if (people[i][3] != "") {
  204. object = object + "<br />Nota: " + people[i][3];
  205. }
  206. object = object + '</p></div>';
  207. Person += '<div class="row res">' + object +
  208. '<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="' +
  209. people[i][1] + '"><i class="fa fa-user"></i><p class="btn-text">Scheda Persona</p></button>' +
  210. '<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>' +
  211. '<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>' +
  212. '<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>';
  213. }
  214. document.getElementById("n_pp").innerHTML = people.length;
  215. document.getElementById("cited_people").innerHTML = Person;
  216. if (people.length==0) {
  217. var messaggio = "<p class='no-results'>Questa ricerca non ha prodotto risultati</p>";
  218. document.getElementById("cited_people").innerHTML = messaggio;
  219. }
  220. }
  221. function handle_luoghiDocumento(json) {
  222. console.log(json);
  223. const places = [];
  224. $.each(
  225. json['results']['bindings'],
  226. function (index, value) {
  227. var uri = value['uri_place']['value'];
  228. var label = value['place']['value'];
  229. places.push([uri, label]);
  230. });
  231. var Luoghi = "";
  232. for (var i=0; i<places.length; i++) {
  233. var object = '<div class="col-8"><p><span id="' + places[i][0] + '" class="title_doc luogo">'+ places[i][1] + '</span></p></div>';
  234. var object_button = '<button type="button" id="' + places[i][0] +
  235. '" class="luogo btn btn-default" alt="oggetto" title="' + places[i][1] +
  236. '"><i class="fa fa-map"></i><p class="btn-text">luogo</p></button>';
  237. Luoghi += '<div class="row res">'+ object +
  238. '<div class="col d-flex align-items-start justify-content-end">' + object_button +
  239. '<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>' +
  240. '<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>' +
  241. '<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>';
  242. }
  243. document.getElementById("n_pl").innerHTML = places.length;
  244. document.getElementById("section_places").innerHTML = Luoghi;
  245. if (places.length==0) {
  246. var messaggio = "<p class='no-results'>Questa ricerca non ha prodotto risultati</p>";
  247. document.getElementById("section_places").innerHTML = messaggio;
  248. }
  249. }
  250. function createDivRelazione(type, id){
  251. htmlCode = '\
  252. <div class="row mb-2"> \
  253. <div class="col-sm-4"> \
  254. <span class="label"><RELATIONSHIP></span> \
  255. </div> \
  256. <div class="col record_box" id="<ID_RELATIONSHIP>"></div> \
  257. </div> \
  258. '.replace("<RELATIONSHIP>", type).replace("<ID_RELATIONSHIP>", id);
  259. return htmlCode;
  260. }
  261. function createColRelazione(text, link, tipo, fa, tab, decl) {
  262. htmlCode = '\
  263. <div class="row"> \
  264. <div class="col <CLASS>"><NAME></div> \
  265. <div class="col-auto"> \
  266. <button class="<TIPO> btn btn-default" type="button" id="<URI>">\
  267. <i class="<BUTTON>" aria-hidden="true">\
  268. <p class="btn-text"><TAB></p>\
  269. </i>\
  270. </button>\</div> \
  271. </div>\
  272. '.replace("<NAME>", text).replace("<URI>", link).replace("<TIPO>", tipo).replace("<BUTTON>", fa).replace("<TAB>", tab).replace("<CLASS>", decl);
  273. return htmlCode;
  274. }