|
|
@@ -0,0 +1,189 @@
|
|
|
+
|
|
|
+// SPARQL Query text -- 'prefixes' and 'thisUrlParams' defined in people.js;
|
|
|
+queryLetters = prefixes +
|
|
|
+" SELECT DISTINCT ?type ?segnatura ?document_uri ?document_name ?time_span ?InfObj ?otherPerson" +
|
|
|
+" {" +
|
|
|
+ " VALUES ?uri {<" + thisUrlParams.link + ">} " +
|
|
|
+
|
|
|
+ " {?pc crm:P02_has_range ?uri .}" +
|
|
|
+ " UNION" +
|
|
|
+ " {?group crm:P107_has_current_or_former_member ?uri;" +
|
|
|
+ " crm:P2_has_type 'Gruppo scrittura lettera' ." +
|
|
|
+ " ?pc crm:P02_has_range ?group .}" +
|
|
|
+
|
|
|
+ " {?ev_move crm:P01_has_domain ?pc ;" +
|
|
|
+ " rdfs:label ?type ;" +
|
|
|
+ " rdfs:subClassOf ?event . FILTER regex(?type, 'Invio')" +
|
|
|
+ " ?event ^rdfs:subClassOf ?move_comp ." +
|
|
|
+ " ?move_comp rdfs:label 'Ricezione' ;" +
|
|
|
+ " crm:P01_has_domain ?cob_comp ." +
|
|
|
+ " ?cob_comp crm:P02_has_range ?uri_comp ." +
|
|
|
+ " ?uri_comp rdfs:label ?otherPerson. }" +
|
|
|
+ " UNION" +
|
|
|
+ " {?ev_move crm:P01_has_domain ?pc ;" +
|
|
|
+ " rdfs:label ?type ;" +
|
|
|
+ " rdfs:subClassOf ?event . FILTER regex(?type, 'Ricezione')" +
|
|
|
+ " ?event ^rdfs:subClassOf ?move_comp ." +
|
|
|
+ " ?move_comp rdfs:label 'Ricezione' ;" +
|
|
|
+ " crm:P01_has_domain ?cob_comp ." +
|
|
|
+ " ?cob_comp crm:P02_has_range ?uri_comp ." +
|
|
|
+ " ?uri_comp rdfs:label ?otherPerson. }" +
|
|
|
+
|
|
|
+ " ?document_uri crm:P25i_moved_by ?event ;" +
|
|
|
+ " rdfs:label ?document_name ." +
|
|
|
+ " ?document_uri crm:P1_is_identified_by ?uriSegnatura ." +
|
|
|
+ " ?uriSegnatura crm:P2_has_type 'Segnatura' ;" +
|
|
|
+ " rdfs:label ?segnatura ." +
|
|
|
+ " OPTIONAL" +
|
|
|
+ " {GRAPH <http://dev.restore.ovi.cnr.it:8890/ovi/datini>" +
|
|
|
+ " {?document_uri crm:P128_carries ?InfObj ." +
|
|
|
+ " ?InfObj rdf:type crm:E73_Information_Object} }." +
|
|
|
+ " OPTIONAL" +
|
|
|
+ " {?ev_move crm:P4_has_time-span ?uri_ts ." +
|
|
|
+ " ?uri_ts rdfs:label ?time_span . }" +
|
|
|
+" }"
|
|
|
+
|
|
|
+
|
|
|
+// 'prepareQueryURL' defined in people.js
|
|
|
+queryEx = prepareQueryURL(queryLetters);
|
|
|
+
|
|
|
+responseLet = $.ajax({
|
|
|
+
|
|
|
+ url: queryEx,
|
|
|
+ dataType: "json",
|
|
|
+ success: function (data){
|
|
|
+ handle_Letters(data);
|
|
|
+ },
|
|
|
+ error: function (e) {}
|
|
|
+});
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+function handle_Letters(json) {
|
|
|
+
|
|
|
+ console.log(json);
|
|
|
+
|
|
|
+ const send = [];
|
|
|
+ const receive = [];
|
|
|
+
|
|
|
+ var i=0;
|
|
|
+ var j=0;
|
|
|
+
|
|
|
+ $.each(
|
|
|
+ json['results']['bindings'],
|
|
|
+ function (index, value) {
|
|
|
+ type = value['type']['value'];
|
|
|
+ uri = value['document_uri']['value'];
|
|
|
+ title = value['document_name']['value'];
|
|
|
+ segnatura = value['segnatura']['value'];
|
|
|
+ var data = "";
|
|
|
+ var InfObj = "";
|
|
|
+ if (value.hasOwnProperty('time_span')) {
|
|
|
+ data = value['time_span']['value'];
|
|
|
+ }
|
|
|
+ if (value.hasOwnProperty('InfObj')) {
|
|
|
+ InfObj = value['InfObj']['value'];
|
|
|
+ }
|
|
|
+ if (type == "Invio") {
|
|
|
+ send.push([uri, title, segnatura, data, InfObj]);
|
|
|
+ i++;
|
|
|
+ } else {
|
|
|
+ receive.push([uri, title, segnatura, data, InfObj]);
|
|
|
+ j++;
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ var Send_Letters = "";
|
|
|
+ var Receive_Letters = "";
|
|
|
+
|
|
|
+ //POPULATE SEND LETTERS BOX
|
|
|
+
|
|
|
+ for (var i=0; i<send.length; i++) {
|
|
|
+ var letter = "";
|
|
|
+ var infObject_button = "";
|
|
|
+ var object_type = "";
|
|
|
+
|
|
|
+ if (send[i][4] != "") {
|
|
|
+ letter = '<div class="col-8"><p><span id="' + send[i][0] + '" class="title_doc lettera">'+ send[i][1] + '</span>';
|
|
|
+ object_type = "lettera";
|
|
|
+ infObject_button += '<button type="button" id="' + send[i][4] +
|
|
|
+ '" class="lettera btn btn-default" alt="lettera" ><i class="fa fa-envelope"></i><p class="btn-text">Scheda Lettera</p></button>';
|
|
|
+ } else {
|
|
|
+ letter = '<div class="col-8"><p><span id="' + send[i][0] + '" class="title_doc object">'+ send[i][1] + '</span>';
|
|
|
+ object_type = "object";
|
|
|
+ infObject_button += '<button type="button" id="' + send[i][0] +
|
|
|
+ '" class="object btn btn-default" alt="oggetto" title="' + send[i][1] +
|
|
|
+ '"><i class="fa fa-book"></i><p class="btn-text">Scheda Oggetto</p></button>';
|
|
|
+ }
|
|
|
+
|
|
|
+ if (send[i][2] != "") {
|
|
|
+ letter = letter + "<br />Segnatura: " + send[i][2];
|
|
|
+ }
|
|
|
+ if (send[i][3] != "") {
|
|
|
+ letter = letter + "<br />Data: " + send[i][3];
|
|
|
+ }
|
|
|
+
|
|
|
+ letter = letter + '</p></div>';
|
|
|
+
|
|
|
+ Send_Letters += '<div class="row res">'+ letter +
|
|
|
+ '<div class="col d-flex align-items-start justify-content-end">' + infObject_button +
|
|
|
+ '<button type="button" value="' + object_type + '" id="' + send[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>' +
|
|
|
+ '<button type="button" value="' + object_type + '" id="' + send[i][0] + '" class="hyp btn btn-default" alt="scheda" title="Info"><i class="fa fa-link"></i><p class="btn-text">Hyperlink</p></button>' +
|
|
|
+ '<a href="http://dev.restore.ovi.cnr.it/lodlive/?' + send[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>';
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ //POPULATE RECEIVE LETTERS BOX
|
|
|
+
|
|
|
+ for (var i=0; i<receive.length; i++) {
|
|
|
+ var letter = "";
|
|
|
+ var infObject_button = "";
|
|
|
+ var object_type = "";
|
|
|
+
|
|
|
+ if (receive[i][4] != "") {
|
|
|
+ letter = '<div class="col-8"><p><span id="' + receive[i][0] + '" class="title_doc lettera">'+ receive[i][1] + '</span>';
|
|
|
+ object_type = "lettera";
|
|
|
+ infObject_button += '<button type="button" id="' + receive[i][4] +
|
|
|
+ '" class="lettera btn btn-default" alt="lettera" ><i class="fa fa-envelope"></i><p class="btn-text">Scheda Lettera</p></button>';
|
|
|
+ } else {
|
|
|
+ letter = '<div class="col-8"><p><span id="' + receive[i][0] + '" class="title_doc object">'+ receive[i][1] + '</span>';
|
|
|
+ object_type = "object";
|
|
|
+ infObject_button += '<button type="button" id="' + receive[i][0] +
|
|
|
+ '" class="object btn btn-default" alt="oggetto" title="' + receive[i][1] +
|
|
|
+ '"><i class="fa fa-book"></i><p class="btn-text">Scheda Oggetto</p></button>';
|
|
|
+ }
|
|
|
+
|
|
|
+ if (receive[i][2] != "") {
|
|
|
+ letter = letter + "<br />Segnatura: " + receive[i][2];
|
|
|
+ }
|
|
|
+ if (receive[i][3] != "") {
|
|
|
+ letter = letter + "<br />Data: " + receive[i][3];
|
|
|
+ }
|
|
|
+
|
|
|
+ letter = letter + '</p></div>';
|
|
|
+
|
|
|
+ Receive_Letters += '<div class="row res">'+ letter +
|
|
|
+ '<div class="col d-flex align-items-start justify-content-end">' + infObject_button +
|
|
|
+ '<button type="button" value="' + object_type + '" id="' + receive[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>' +
|
|
|
+ '<button type="button" value="' + object_type + '" id="' + receive[i][0] + '" class="hyp btn btn-default" alt="scheda" title="Info"><i class="fa fa-link"></i><p class="btn-text">Hyperlink</p></button>' +
|
|
|
+ '<a href="http://dev.restore.ovi.cnr.it/lodlive/?' + receive[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>';
|
|
|
+ }
|
|
|
+
|
|
|
+ document.getElementById("l_send").innerHTML = send.length;
|
|
|
+ document.getElementById("l_receive").innerHTML = receive.length;
|
|
|
+ document.getElementById("letters_send").innerHTML = Send_Letters;
|
|
|
+ document.getElementById("letters_receive").innerHTML = Receive_Letters;
|
|
|
+
|
|
|
+ if (send.length==0) {
|
|
|
+ var messaggio = "<p class='no-results'>Nessun risultato trovato</p>";
|
|
|
+ document.getElementById("letters_send").innerHTML = messaggio;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (receive.length==0) {
|
|
|
+ var messaggio = "<p class='no-results'>Nessun risultato trovato</p>";
|
|
|
+ document.getElementById("letters_receive").innerHTML = messaggio;
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|