object.js 14 KB

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