Explorar o código

Aggiornati Oggetto e Persona

Alessia Spadi %!s(int64=2) %!d(string=hai) anos
pai
achega
0818aa41df
Modificáronse 6 ficheiros con 819 adicións e 35 borrados
  1. 22 0
      Persona.html
  2. 72 0
      css/pages.css
  3. 1 2
      js/lettera_query.js
  4. 390 6
      js/object.js
  5. 253 22
      js/people.js
  6. 81 5
      object.html

+ 22 - 0
Persona.html

@@ -176,6 +176,28 @@
 										<div class="col" id="tipologia"></div>
 									</div>
 
+									<div class="row mb-2" id="type_society" style="display:none;">
+										<div class="col-sm-4">
+											<span class="label">Tipo società:</span>
+										</div>
+										<div class="col" id="society"></div>
+									</div>
+
+									<div class="row mb-2" id="sede" style="display:none;">
+										<div class="col-sm-4">
+											<span class="label">Sede Operativa:</span>
+										</div>
+										<div class="col" id="workPlace"></div>
+										<div class="col-auto" id="workPlace_btn"></div>
+									</div>
+
+									<div class="row mb-2" id="stato" style="display:none;">
+										<div class="col-sm-4">
+											<span class="label">Status:</span>
+										</div>
+										<div class="col" id="status"></div>
+									</div>
+
 									<div class="row mb-2" id="card" style="display:none;">
 										<div class="col-sm-4">
 											<span class="label">Scheda anagrafica:</span>

+ 72 - 0
css/pages.css

@@ -285,4 +285,76 @@ tr:nth-child(2n+1) {
   font-size: 16px;
   text-transform: uppercase;
   font-weight: 600;
+}
+
+.nota_menzione {
+  font-size: small;
+  font-weight: 400;
+}
+
+.myMargin {
+  margin-bottom: 20px;
+}
+
+a {
+  word-wrap: break-word;
+} 
+
+.box_results {
+  margin-bottom: 35px;
+}
+
+.inner_results {
+  background-color: #ffffffa1;
+  border-radius: 6px;
+  overflow: hidden;
+  border: 1px solid;
+}
+
+.inner_results a:link {
+    color: #000;
+    background-color: transparent;
+    text-decoration: none;
+    font-weight: bold;
+}
+
+.res_list {
+  max-height: 400px;
+  overflow: auto;
+}
+
+.res_list .no-results {
+  padding-top: 10px;
+}
+
+.res_list .btn-icon {
+  font-size: 16px;
+}
+
+.def_res {
+  background-color: #3f4149;
+  color: #fff;
+  padding-top: 7px;
+  padding-bottom: 10px;
+  font-weight: 600;
+}
+
+.def_res .num_res {
+  display: flex;
+  justify-content: end;
+  align-items: end;
+}
+
+.def_res p {
+  margin-bottom: 0;
+}
+
+.res {
+  padding-top: 15px;
+  padding-bottom: 15px;
+  font-size: 14px;
+}
+
+.res:not(:last-child) {
+  border-bottom: 1px solid #000;
 }

+ 1 - 2
js/lettera_query.js

@@ -95,8 +95,7 @@ rdf:type crm:EL2_Send_Letter . \
 ?receive rdfs:subClassOf ?mov_ev ; \
 rdf:type crm:EL3_Receive_Letter . \
 \
-OPTIONAL {?subject crm:P54_has_current_permanent_location ?uriCurrentLocation . \
-?uriCurrentLocation rdfs:label ?currentLocation . } \
+OPTIONAL {?subject crm:P54_has_current_permanent_location ?currentLocation . } \
 OPTIONAL {?subject crm:P45_consist_of ?uriMaterial . \
 ?uriMaterial rdfs:label ?material . } \
 OPTIONAL {?subject crm:P43_has_dimension ?uriDimension . \

+ 390 - 6
js/object.js

@@ -47,7 +47,7 @@ PREFIX schema: <http://schema.org/> \
 PREFIX foaf: <http://xmlns.com/foaf/0.1/> \
 PREFIX person: <http://www.w3.org/ns/person#>"
 
-queryInfo = prefixes + " SELECT DISTINCT ?g AS ?graph ?uri ?label ?dimension ?consistency ?id (group_concat(distinct ?dimension ; separator='<br />') as ?dimensions) ?material ?location ?note \
+queryInfo = prefixes + " SELECT DISTINCT ?g AS ?graph ?uri ?label ?dimension ?consistency ?id ?sigla_registro (group_concat(distinct ?dimension ; separator='<br />') as ?dimensions) ?material (group_concat(distinct ?time_span ;separator='-') as ?time_span) ?location ?uri_owner ?owner ?note \
 WHERE { \
 VALUES ?uri {<" + thisUrlParams.link + ">} \
 GRAPH ?g { ?uri rdfs:label ?label } \
@@ -60,12 +60,19 @@ rdfs:label ?consistency } \
 OPTIONAL { ?uri crm:P43_has_dimension ?uri_dimension . \
 ?uri_dimension crm:P2_has_type 'Dimensioni' ; \
 rdfs:label ?dimension } \
+OPTIONAL { ?uri crm:P139_has_alternative_form ?uri_registro . \
+?uri_registro rdfs:label ?sigla_registro; \
+crm:P2_has_type 'Sigla registro' . } \
 OPTIONAL { ?uri crm:P45_consist_of ?uri_material . \
 ?uri_material rdfs:label ?material } \
-OPTIONAL { ?uri crm:P54_has_current_permanent_location ?uri_location . \
-?uri_location rdfs:label ?location } \
+OPTIONAL { ?uri crm:P52_has_current_owner ?uri_owner . \
+?uri_owner rdfs:label ?owner . } \
+OPTIONAL { ?uri crm:P54_has_current_permanent_location ?location } \
 OPTIONAL { ?uri crm:P3_has_note ?uri_note . \
 ?uri_note rdfs:label ?note } \
+OPTIONAL { ?uri crm:P92i_was_brought_into_existence_by ?creation . \
+?creation crm:P4_has_time-span ?uri_time_span . \
+?uri_time_span rdfs:label ?time_span . } \
 } "
 
 queryContent = prefixes + " SELECT DISTINCT ?g AS ?graph ?uri ?titolo ?tipo (group_concat(distinct ?ref ; separator='<br />') as ?ref) \
@@ -97,6 +104,45 @@ OPTIONAL { ?uri crm:P128_carries ?InfObj . \
 GRAPH <http://dev.restore.ovi.cnr.it:8890/ovi/datini> {?InfObj rdf:type crm:E73_Information_Object } } \
 } "
 
+queryPersone = prefixes + " SELECT DISTINCT ?uri_person ?name ?p_type ?note \
+WHERE { \
+VALUES ?uri {<" + thisUrlParams.link + ">} \
+{?uri crm:P46_is_composed_of ?card . \
+?card crm:P2_has_type 'Scheda anagrafica' . \
+?document crm:P141_assigned ?card ; \
+crm:P67_refers_to ?uri_person . \
+?uri_person foaf:name ?name ; \
+crm:P2_has_type ?person_type . \
+?person_type rdfs:label ?p_type . \
+} UNION { \
+?document crm:P141_assigned ?uri ; \
+crm:P67_refers_to ?uri_person . \
+?uri_person foaf:name ?name ; \
+crm:P2_has_type ?person_type . \
+?person_type rdfs:label ?p_type . \
+} UNION { \
+?uri crm:P92i_was_brought_into_existence_by ?creation . \
+?creation crm:P67_refers_to ?uri_person . \
+?uri_person foaf:name ?name ; \
+crm:P67.1_type ?person_type . \
+OPTIONAL {?uri_person crm:P3_has_note ?note } \
+?person_type rdfs:label ?p_type . \
+} \
+}"
+
+queryAssocDocs = prefixes + " SELECT DISTINCT ?card ?doc_type ?name_card \
+WHERE { \
+VALUES ?uri {<" + thisUrlParams.link + ">} \
+?uri crm:P46_is_composed_of ?card . \
+?card rdfs:label ?name_card . \
+OPTIONAL {?card crm:P2_has_type ?doc_type } \
+OPTIONAL {?document crm:P141_assigned ?card ; \
+crm:P67_refers_to ?uri_person . \
+?uri_person foaf:name ?name ; \
+crm:P2_has_type ?person_type . \
+?person_type rdfs:label ?type . \
+} \
+}"
 
 queryURL = prepareQueryURL(queryInfo);
 
@@ -104,6 +150,10 @@ queryINF = prepareQueryURL(queryContent);
 
 queryOVI = prepareQueryURL(queryOviLetter);
 
+queryPERS = prepareQueryURL(queryPersone);
+
+queryDOC = prepareQueryURL(queryAssocDocs);
+
 
 response = $.ajax({
 
@@ -135,6 +185,26 @@ response_info = $.ajax({
     error: function (e) {}
 });
 
+response_people = $.ajax({
+
+  url: queryPERS,
+  dataType: "json",
+  success: function (data){
+    handle_citedPeople(data);
+  },
+  error: function (e) {}
+});
+
+response_documents = $.ajax({
+
+  url: queryDOC,
+  dataType: "json",
+  success: function (data){
+    handle_associatedDocuments(data);
+  },
+  error: function (e) {}
+});
+
 
 function handle_objectData(json) {
 
@@ -153,6 +223,11 @@ function handle_objectData(json) {
         var current_location = "";
         var description = "";
         var button_ext = "";
+        var button_owner = "";
+        var registro = "";
+        var current_owner = "";
+        var uri_owner = "";
+        var dates = "";
 
         var dataset = get_graph_name(graph);
 
@@ -176,10 +251,25 @@ function handle_objectData(json) {
           $("#materia").css("display", "flex");
           materials = value['material']['value'];
         }
+        if (value.hasOwnProperty('uri_owner')) {
+          $("#current_owner").css("display", "flex");
+          current_owner = value['owner']['value'];
+          uri_owner = value['uri_owner']['value'];
+        }
         if (value.hasOwnProperty('location')) {
-          $("#localizzazione").css("display", "flex");
+          $("#conservazione").css("display", "flex");
           current_location = value['location']['value'];
         }
+        if (value.hasOwnProperty('time_span')) {
+          if (value['time_span']['value'] != ""){
+            $("#time_span_object").css("display", "flex");
+            dates = value['time_span']['value'];
+          }
+        }
+        if (value.hasOwnProperty('sigla_registro')) {
+          $("#IDreg").css("display", "flex");
+          registro = value['sigla_registro']['value'];
+        }
         if (value.hasOwnProperty('note')) {
           $("#notes").css("display", "flex");
           description = value['note']['value'];
@@ -190,15 +280,24 @@ function handle_objectData(json) {
           <i class="fa fa-link" aria-hidden="true">	<p class="btn-text">Link</p></i></button>';
         }
 
+        if (owner != "") {
+          button_owner = '<button class="btn btn-default" type="button" onclick="schedaASPO(\'' + uri_owner + '\')"> \
+          <i class="fa fa-link" aria-hidden="true">	<p class="btn-text">Link</p></i></button>';
+        }
+
         document.getElementById("grafo").innerHTML = dataset;
         document.getElementById("nome_oggetto").innerHTML = label;
         document.getElementById("identifier").innerHTML = identifier;
         document.getElementById("btn_identifier").innerHTML = button_ext;
-        document.getElementById("location").innerHTML = current_location;
+        document.getElementById("current_location").innerHTML = current_location;
         document.getElementById("nota").innerHTML = description;
         document.getElementById("dimensions").innerHTML = dimensions;
-        document.getElementById("consistence").innerHTML = consistence;
         document.getElementById("materials").innerHTML = materials;
+        document.getElementById("consistence").innerHTML = consistence;
+        document.getElementById("registry").innerHTML = registro;
+        document.getElementById("owner").innerHTML = current_owner;
+        document.getElementById("btn_owner").innerHTML = button_owner;
+        document.getElementById("timeSpan").innerHTML = dates;
        
         
       });
@@ -292,6 +391,281 @@ function handle_oviLetter(json) {
 
 }
 
+/*
+function handle_citedPeople(json) {
+  
+  console.log(json);
+
+  var Relazioni = "";
+  const myArray = []
+
+  $.each(
+    json['results']['bindings'],
+    function (index, value) {
+        var uri_person = value['uri_person']['value'];
+        var name = value['name']['value'];
+        var tipo = "";
+        var nota = "";
+      
+        if (value.hasOwnProperty('p_type')) {
+          tipo = value['p_type']['value'];
+        }
+        if (value.hasOwnProperty('note')) {
+          nota = "<br /><span class='nota_menzione'><i>" + value['note']['value'] + "</i></span>";
+        }
+      
+      var string = name + nota; 
+
+      myArray.push([tipo, string, uri_person, nota]);
+   
+    });
+
+  if (myArray.length == 0) {
+    $("#placeholder_people").css("display", "none");
+  }
+
+  const checkRel = [];
+
+  for (var i=0; i<myArray.length; i++) {
+      var key = myArray[i][0];
+      checkRel.push(key);
+  }
+
+  var params = [];
+  $.each(checkRel, function(i, el){
+    if($.inArray(el, params) === -1) params.push(el);
+  });
+
+  for (var i=0; i<params.length; i++) {
+    var par = params[i];
+    var par_id = par.replaceAll(" ", "_");
+    var rel = createDivRelazione(par, par_id);
+    Relazioni = Relazioni + rel;
+  }
+
+  $(Relazioni).insertAfter( "#placeholder_people" );
+
+  for (var j=0; j<params.length; j++) {
+      var el = params[j];
+      var par = el.replaceAll(" ", "_");
+      var Colums = ""; 
+      for (var i=0; i<myArray.length; i++) {
+          var text = myArray[i][1];
+          var link = myArray[i][2];
+          var declaration = "" 
+          if (myArray[i][3] != "") {
+            declaration = "myMargin";
+          }
+          var rel = myArray[i][0].replaceAll(" ", "_");
+          if (par == rel) {
+              var col = createColRelazione(text, link, "persona", "fa fa-user", "Scheda Persona", declaration);
+              Colums = Colums + col;
+          }
+      }
+      document.getElementById(par).innerHTML = Colums;
+  }
+
+}
+
+function handle_associatedDocuments(json) {
+  
+  console.log(json);
+
+  var Sezioni = "";
+  const myArray = []
+
+  $.each(
+    json['results']['bindings'],
+    function (index, value) {
+        var uri = value['card']['value'];
+        var name = value['name_card']['value'];
+        var tipo = "";
+      
+        if (value.hasOwnProperty('doc_type')) {
+          tipo = value['doc_type']['value'];
+        }
+        
+      myArray.push([tipo, name, uri]);
+   
+    });
+
+  if (myArray.length == 0) {
+    $("#placeholder_documents").css("display", "none");
+  }
+
+  const checkRel = [];
+
+  for (var i=0; i<myArray.length; i++) {
+      var key = myArray[i][0];
+      checkRel.push(key);
+  }
+
+  var params = [];
+  $.each(checkRel, function(i, el){
+    if($.inArray(el, params) === -1) params.push(el);
+  });
+
+  for (var i=0; i<params.length; i++) {
+    var par = params[i];
+    var par_id = par.replaceAll(" ", "_");
+    var rel = createDivRelazione(par, par_id);
+    Sezioni = Sezioni + rel;
+  }
+
+  $(Sezioni).insertAfter( "#placeholder_documents" );
+
+  for (var j=0; j<params.length; j++) {
+      var el = params[j];
+      var par = el.replaceAll(" ", "_");
+      var Colums = ""; 
+      for (var i=0; i<myArray.length; i++) {
+          var text = myArray[i][1];
+          var link = myArray[i][2];
+          var rel = myArray[i][0].replaceAll(" ", "_");
+          if (par == rel) {
+              var col = createColRelazione(text, link, "object", "fa fa-book", "Scheda Oggetto", "");
+              Colums = Colums + col;
+          }
+      }
+      document.getElementById(par).innerHTML = Colums;
+  }
+
+} */
+
+function handle_citedPeople(json) {
+
+  console.log(json);
+
+  const people = [];
+
+  $.each(
+    json['results']['bindings'],
+    function (index, value) {
+        var uri = value['uri_person']['value'];
+        var name = value['name']['value'];
+        var tipo = "";
+        var nota = "";
+      
+        if (value.hasOwnProperty('p_type')) {
+          tipo = value['p_type']['value'];
+        }
+        if (value.hasOwnProperty('note')) {
+          nota = value['note']['value'];
+        } 
+
+      people.push([uri, name, tipo, nota]);
+      
+    });
+
+    var Person = "";
+
+    for (var i=0; i<people.length; i++) {
+      var object = '<a href=' + people[i][0] + ' target="_blank">' + people[i][1] + '</a>';
+      if (people[i][2] != "") {
+        object = object + "<br />Tipo: " + people[i][2];
+      }
+      if (people[i][3] != "") {
+        object = object + "<br />Nota: " + people[i][3];
+      }
+    
+    Person += /*INIZIO DIV*/ '<div class="row res"><div class="col-8">' +
+      object + '</div>' +
+      '<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="' +
+      people[i][1] + '"><i class="fa fa-user"></i><p class="btn-text">Scheda Persona</p></button>' +
+      '<button type="button" 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>' +
+      /*DA QUI HYPERLINK ->*/'<button 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>' +
+      /*DA QUI LOD ->*/'<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>';
+
+      
+    }
+  
+    document.getElementById("n_pp").innerHTML = people.length;
+    document.getElementById("cited_people").innerHTML = Person;
+  
+    if (people.length==0) {
+      var messaggio = "<p class='no-results'>Nessun risultato trovato</p>";
+      document.getElementById("cited_people").innerHTML = messaggio;
+    }
+
+}
+
+function handle_associatedDocuments(json) {
+
+  console.log(json);
+
+  const docs = [];
+
+  $.each(
+      json['results']['bindings'],
+      function (index, value) {
+        var uri = value['card']['value'];
+        var label = value['name_card']['value'];
+        var tipo = "";
+      
+        if (value.hasOwnProperty('doc_type')) {
+          tipo = value['doc_type']['value'];
+        }
+
+        docs.push([uri, label, tipo]);
+        
+      });
+
+  var Docs = "";
+
+  for (var i=0; i<docs.length; i++) {
+    var object = '<a href=' + docs[i][0] + ' target="_blank">' + docs[i][1] + '</a>';
+    if (docs[i][2] != "") {
+      object = object + "<br />Documento: " + docs[i][2];
+    }
+
+    var object_button  = '<button type="button" id="' + docs[i][0] + 
+      '" class="object btn btn-default" alt="oggetto" title="' + docs[i][1] + 
+      '"><i class="fa fa-book"></i><p class="btn-text">Scheda Oggetto</p></button>';
+
+      Docs += '<div class="row res"><div class="col-8"><p>'+ object +'</p></div>' + 
+    '<div class="col d-flex align-items-start justify-content-end">' + object_button +
+    '<button type="button" id="' + docs[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" id="' + docs[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/?' + docs[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("n_sec").innerHTML = docs.length;
+  document.getElementById("section_documents").innerHTML = Docs;
+
+  if (docs.length==0) {
+    var messaggio = "<p class='no-results'>Nessun risultato trovato</p>";
+    document.getElementById("section_documents").innerHTML = messaggio;
+  }
+  
+}
+
+function createDivRelazione(type, id){
+	htmlCode = '\
+      <div class="row mb-2"> \
+      <div class="col-sm-4"> \
+        <span class="label"><RELATIONSHIP></span> \
+      </div> \
+      <div class="col record_box" id="<ID_RELATIONSHIP>"></div> \
+    </div> \
+		'.replace("<RELATIONSHIP>", type).replace("<ID_RELATIONSHIP>", id);
+	return htmlCode;
+}
+
+function createColRelazione(text, link, tipo, fa, tab, decl) {
+  htmlCode = '\
+    <div class="row"> \
+        <div class="col <CLASS>"><NAME></div> \
+        <div class="col-auto"> \
+            <button class="<TIPO> btn btn-default" type="button" id="<URI>">\
+	            	<i class="<BUTTON>" aria-hidden="true">\
+			              <p class="btn-text"><TAB></p>\
+	        	    </i>\
+		          </button>\</div> \
+    </div>\
+		'.replace("<NAME>", text).replace("<URI>", link).replace("<TIPO>", tipo).replace("<BUTTON>", fa).replace("<TAB>", tab).replace("<CLASS>", decl);
+	return htmlCode;
+}
+
 $(document).on("click", ".lettera", function (ev) {
 
     var link = this.id;
@@ -319,6 +693,16 @@ $(document).on("click", ".persona", function (ev) {
     window.open("Persona.html?link="+this.id);
     
 
+  });
+
+  $(document).on("click", ".object", function (ev) {
+
+    var link = this.id;
+    //alert(nome_autore);
+    //$('#myModal').text("");
+    window.open("object.html?link="+this.id);
+    
+  
   });
 
   function schedaASPO(info){

+ 253 - 22
js/people.js

@@ -47,34 +47,37 @@ PREFIX schema: <http://schema.org/> \
 PREFIX foaf: <http://xmlns.com/foaf/0.1/> \
 PREFIX person: <http://www.w3.org/ns/person#>"
 
-query = prefixes + " SELECT DISTINCT ?place ?label ?coordinates \
+query = prefixes + " SELECT DISTINCT ?place ?label ?tipo ?coordinates COUNT(?pc) AS ?count \
 WHERE { \
-{?pc crm:P02_has_range <" + thisUrlParams.link + "> . \
+VALUES ?uri {<" + thisUrlParams.link + ">} \
+{?pc crm:P02_has_range ?uri . \
 ?event_from crm:P01_has_domain ?pc ; \
 rdf:type crm:EL3_Receive_Letter; \
+rdfs:label ?tipo ; \
 crm:P26_moved_to ?place_from . \
 ?place_from rdf:type crm:E53_Place ; \
 owl:sameAs ?place . \
 ?place rdfs:label ?label ; \
 crm:P168_place_is_defined_by ?coordinates . \
 } UNION { \
-?pc crm:P02_has_range <" + thisUrlParams.link + "> . \
+?pc crm:P02_has_range ?uri . \
 ?event_from crm:P01_has_domain ?pc ; \
 rdf:type crm:EL2_Send_Letter; \
+rdfs:label ?tipo ; \
 crm:P27_moved_from ?place_from . \
 ?place_from rdf:type crm:E53_Place ; \
 owl:sameAs ?place . \
 ?place rdfs:label ?label ; \
 crm:P168_place_is_defined_by ?coordinates . \
 } UNION { \
-  <" + thisUrlParams.link + "> crm:P100i_died_in ?uri_death . \
+  ?uri crm:P100i_died_in ?uri_death . \
   ?uri_death crm:P7_took_place_at ?uri_place . \
   ?uri_place rdf:type crm:E53_Place ; \
   owl:sameAs ?place .  \
   ?place rdfs:label ?label ;  \
   crm:P168_place_is_defined_by ?coordinates . \
   } UNION { \
-    <" + thisUrlParams.link + "> crm:P98i_was_born ?uri_birth . \
+    ?uri crm:P98i_was_born ?uri_birth . \
   ?uri_birth crm:P7_took_place_at ?uri_place . \
   ?uri_place rdf:type crm:E53_Place ; \
   owl:sameAs ?place . \
@@ -158,6 +161,23 @@ OPTIONAL {?uri_person crm:P74_has_current_or_former_residence ?uri_provenienza .
 rdfs:label ?provenienza . } \
 } "
 
+queryRelazioniInverse = prefixes + " SELECT DISTINCT ?relation_type ?note ?uri_person SAMPLE(?name) AS ?name ?givenName ?familyName ?patronymic ?provenienza \
+WHERE { \
+VALUES ?uri {<" + thisUrlParams.link + ">} \
+?relation crm:P141_assigned ?uri; \
+crm:P42_assigned ?uri_type . \
+?uri_person crm:P141_assigned ?relation . \
+?uri_type rdfs:label ?relation_type . \
+OPTIONAL {?uri_type crm:P3_has_note ?note } \
+?uri_person foaf:name ?name . \
+OPTIONAL {?uri_person foaf:givenName ?givenName} \
+OPTIONAL {?uri_person foaf:familyName ?familyName}  \
+OPTIONAL {?uri_person person:patronymicName ?patronymic } \
+OPTIONAL {?uri_person crm:P74_has_current_or_former_residence ?uri_provenienza . \
+?uri_provenienza crm:P2_has_type 'Provenienza'; \
+rdfs:label ?provenienza . } \
+} "
+
 queryLetters = prefixes + " SELECT DISTINCT ?type ?segnatura ?document_uri ?document_name ?time_span ?InfObj \
 WHERE {?pc crm:P02_has_range <" + thisUrlParams.link + "> . \
 ?ev_move crm:P01_has_domain ?pc ; \
@@ -272,6 +292,20 @@ crm:P4_has_time-span ?uri_time_span . \
 ?uri_event_type rdfs:label ?event_type . \
 } "
 
+queryCompagnia = prefixes + " SELECT DISTINCT ?denomination ?occupation ?uri_sede ?uri_place ?sede \
+WHERE { \
+VALUES ?uri {<" + thisUrlParams.link + ">} \
+?uri rdf:type crm:E74_Group . \
+?uri crm:P2_has_type ?denomination . \
+OPTIONAL {?uri schema:hasOccupation ?uri_Occupation . \
+?uri_Occupation rdfs:label ?occupation .} \
+OPTIONAL {?uri crm:P74_has_current_or_former_residence ?uri_sede . \
+?uri_sede rdfs:label ?sede . \
+OPTIONAL {?uri_sede owl:sameAs ?uri_place . \
+?uri_place crm:P168_place_is_defined_by ?coords .} \
+} \
+}"
+
 queryURL = prepareQueryURL(query);
 
 queryNet = prepareQueryURL(queryNetwork);
@@ -292,6 +326,10 @@ queryInfoGt = prepareQueryURL(queryInfoGettatelli);
 
 queryRel = prepareQueryURL(queryRelazioni);
 
+queryRelIn = prepareQueryURL(queryRelazioniInverse);
+
+queryCom = prepareQueryURL(queryCompagnia);
+
 response = $.ajax({
 
     url: query,
@@ -392,6 +430,26 @@ responseRel = $.ajax({
   error: function (e) {}
 });
 
+responseRel = $.ajax({
+
+  url: queryRelIn,
+  dataType: "json",
+  success: function (data){
+    handle_RelazioniInverse(data);
+  },
+  error: function (e) {}
+});
+
+responseRel = $.ajax({
+
+  url: queryCom,
+  dataType: "json",
+  success: function (data){
+    handle_Compagnia(data);
+  },
+  error: function (e) {}
+});
+
 
 var labelName = "";
 
@@ -675,23 +733,19 @@ function handle_Relazioni(json) {
       var provenence = "";
       
       if (value.hasOwnProperty('givenName')) {
-        $("#givenName").css("display", "flex");
         givenName = value['givenName']['value'];
       }
       if (value.hasOwnProperty('note')) {
         principale = " principale";
       }
       if (value.hasOwnProperty('familyName')) {
-        $("#familyName").css("display", "flex");
         familyName = value['familyName']['value'].toLowerCase();
         familyName = familyName.charAt(0).toUpperCase() + familyName.slice(1)
       }
       if (value.hasOwnProperty('patronymic')) {
-        $("#patronymic").css("display", "flex");
         patronymic = value['patronymic']['value'];
       }
       if (value.hasOwnProperty('provenienza')) {
-        $("#PlaceProvenence").css("display", "flex");
         provenence = value['provenienza']['value'];
       } 
 
@@ -752,6 +806,103 @@ function handle_Relazioni(json) {
 
 }
 
+function handle_RelazioniInverse(json) {
+  
+  console.log(json);
+
+  var Relazioni = "";
+  const myArray = []
+
+  $.each(
+    json['results']['bindings'],
+    function (index, value) {
+      var tipo = value['relation_type']['value'];
+      var uri_person = value['uri_person']['value'];
+      var nome = value['name']['value'];
+      var principale = "";
+      var givenName = "";
+      var familyName = "";
+      var patronymic = "";
+      var provenence = "";
+      
+      if (value.hasOwnProperty('givenName')) {
+        givenName = value['givenName']['value'];
+      }
+      if (value.hasOwnProperty('note')) {
+        principale = " principale";
+      }
+      if (value.hasOwnProperty('familyName')) {
+        familyName = value['familyName']['value'].toLowerCase();
+        familyName = familyName.charAt(0).toUpperCase() + familyName.slice(1)
+      }
+      if (value.hasOwnProperty('patronymic')) {
+        patronymic = value['patronymic']['value'];
+      }
+      if (value.hasOwnProperty('provenienza')) {
+        provenence = value['provenienza']['value'];
+      } 
+
+      var type = tipo.charAt(0).toUpperCase() + tipo.slice(1) + principale + " di";
+
+      if (type == "Socio di") {
+        type = "Soci";
+      }
+
+      if (type == "Socio principale di") {
+        type = "Intestatario principale";
+      }
+
+      var first_name = "";
+
+      if ((givenName != "") || (patronymic != "") || (familyName != "") || (provenence != "")) {
+        first_name = givenName + " " + patronymic + " " + familyName + " " + provenence;
+      } else {
+        first_name = nome;
+      }
+
+      myArray.push([type, first_name, uri_person]);
+   
+    });
+
+  const checkRel = [];
+
+  for (var i=0; i<myArray.length; i++) {
+      var key = myArray[i][0];
+      checkRel.push(key);
+  }
+
+  var params = [];
+  $.each(checkRel, function(i, el){
+    if($.inArray(el, params) === -1) params.push(el);
+  });
+
+  for (var i=0; i<params.length; i++) {
+    var par = params[i];
+    var par_id = par.replaceAll(" ", "_");
+    var rel = createDivRelazione(par, par_id);
+    Relazioni = Relazioni + rel;
+  }
+
+  $(Relazioni).insertAfter( "#groups" );
+
+  for (var j=0; j<params.length; j++) {
+      var el = params[j];
+      var par = el.replaceAll(" ", "_");
+      var Colums = ""; 
+      for (var i=0; i<myArray.length; i++) {
+          var text = myArray[i][1];
+          var link = myArray[i][2];
+          var rel = myArray[i][0].replaceAll(" ", "_");
+          if (par == rel) {
+              var col = createColRelazione(text, link);
+              Colums = Colums + col;
+          }
+      }
+      document.getElementById(par).innerHTML = Colums;
+  }
+
+}
+
 function createDivRelazione(type, id){
 	htmlCode = '\
       <div class="row mb-2"> \
@@ -779,6 +930,53 @@ function createColRelazione(text, link) {
 	return htmlCode;
 }
 
+function handle_Compagnia(json) {
+  
+  console.log(json);
+
+  var denominazione = "";
+  var sede = "";
+  var uri_sede = "";
+  var uri_place = "";
+
+  $.each(
+    json['results']['bindings'],
+    function (index, value) {
+      if (value.hasOwnProperty('denomination')) {
+        $("#type_society").css("display", "flex");
+        denominazione = value['denomination']['value'];
+      }
+      if (value.hasOwnProperty('uri_place')) {
+        $("#sede").css("display", "flex");
+        uri_place = value['uri_place']['value'];
+      }
+      if (value.hasOwnProperty('uri_sede')) {
+        $("#sede").css("display", "flex");
+        uri_sede = value['uri_sede']['value'];
+      }
+      if (value.hasOwnProperty('sede')) {
+        sede = value['sede']['value'];
+      }
+
+  });
+      
+
+  var workPlace_button = "";
+
+  if (uri_place != "") {
+    workPlace_button = '<button type="button" id="' + uri_place + 
+    '" class="luogo btn btn-default" alt="luogo" ><i class="far fa-map"></i><p class="btn-text">Scheda Luogo</p></button>';
+  } else {
+    workPlace_button = '<button class="btn btn-default" type="button" onclick="schedaASPO(' + uri_sede 
+    + ')"><i class="fa fa-link" aria-hidden="true">	<p class="btn-text">Link</p></i></button>';
+  }
+
+  document.getElementById("society").innerHTML = denominazione;
+  document.getElementById("workPlace").innerHTML = sede;
+  document.getElementById("workPlace_btn").innerHTML = workPlace_button;
+      
+}
+
 function handle_Letters(json) {
 
   console.log(json);
@@ -1055,6 +1253,8 @@ function handle_map(json) {
 
   const locations = [];
   const place_names = [];
+  const place_events = [];
+  const luoghi = [];
 
   var lat = 0;
   var long = 0;
@@ -1068,19 +1268,46 @@ function handle_map(json) {
         var uri = value['place']['value'];
         var label = value['label']['value'];
         var coord = value['coordinates']['value'];
-        const coordinates = coord.split(", ");
-        loc.push(label);
-        myPlaces += "<div class='item-place-person'><div class='clickPlace item-place-person-label' data-point='"+ coordinates + "'>" + label + "</div><div class='item-place-person-action'><div class='luogo' id='" + 
-    uri + "'><i class='far fa-map' style='cursor:pointer'></i></div></div></div>";
-        loc.push(coordinates[0]);
-        lat += parseInt(coordinates[0]);
-        loc.push(coordinates[1]);
-        long += parseInt(coordinates[1].replace(/^(\.)/,"0.").replace("-.", "-0."));
-        locations.push(loc);
-        i++;
+        var evento = value['tipo']['value']
+        var count = value['count']['value']
+        place_events.push([uri, evento, count]);
+        if (!place_names.includes(uri)) {
+          place_names.push(uri);
+          const coordinates = coord.split(", ");
+          loc.push(uri);
+          loc.push(label);
+          myPlaces += "<div class='item-place-person'><div class='clickPlace item-place-person-label' data-point='"+ coordinates + "'>" + label + "</div><div class='item-place-person-action'><div class='luogo' id='" + 
+      uri + "'><i class='far fa-map' style='cursor:pointer'></i></div></div></div>";
+          loc.push(coordinates[0]);
+          lat += parseInt(coordinates[0]);
+          loc.push(coordinates[1]);
+          long += parseInt(coordinates[1].replace(/^(\.)/,"0.").replace("-.", "-0."));
+          locations.push(loc);
+          i++;
+        }
         
       });
 
+  for (var k=0; k<locations.length; k++) {
+    const tempArray = [];
+    var nomeLuogo = locations[k][1];
+    var lt = locations[k][2];
+    var lg = locations[k][3];
+    tempArray.push(nomeLuogo);
+    tempArray.push(lt);
+    tempArray.push(lg);
+    for (var y=0; y<place_events.length; y++) {
+      var ev = place_events[y][1];
+      var number = place_events[y][2]
+      var dict = ev + ": " + number;
+      if (locations[k][0] == place_events[y][0]) {
+        tempArray.push(dict);
+      }
+    }
+    luoghi.push(tempArray);
+  }
+    
+  console.log(luoghi);
   var latitude = lat/i;
   var longitude = long/i;
 
@@ -1118,9 +1345,13 @@ function handle_map(json) {
     }).addTo(map);
 
   function populate() {
-    for (var i = 0; i < locations.length; i++) {
-      var a = locations[i];
-      var title = a[0];
+    for (var i = 0; i < luoghi.length; i++) {
+      var a = luoghi[i];
+      var len = a.length;
+      var title = "<b>" + a[0] + "</b>";
+      for (var k=3; k<len; k++) {
+        title = title + "<br />" + a[k];
+      }
       var marker = new L.Marker(new L.LatLng(a[1], a[2]), { title: title });
       marker.bindPopup(title);
       markers.addLayer(marker);

+ 81 - 5
object.html

@@ -134,19 +134,33 @@
 											<div class="col-auto" id="btn_other_identifier"></div>
 										</div>
 
+										<div class="row mb-2" id="IDreg" style="display:none;">
+											<div class="col-sm-4">
+												<span class="label">Sigla registro:</span>
+											</div>
+											<div class="col" id="registry"></div>
+										</div>
 
 										<div class="row mb-2" id="conservazione" style="display:none;">
 											<div class="col-sm-4">
-												<span class="label">Localizzazione:</span>
+												<span class="label">Luogo di conservazione:</span>
+											</div>
+											<div class="col" id="current_location"></div>
+										</div>
+
+										<div class="row mb-2" id="current_owner" style="display:none;">
+											<div class="col-sm-4">
+												<span class="label">Responsabile dell'oggetto:</span>
 											</div>
 											<div class="col" id="owner"></div>
+											<div class="col-auto" id="btn_owner"></div>
 										</div>
 
-										<div class="row mb-2" id="localizzazione" style="display:none;">
+										<div class="row mb-2" id="time_span_object" style="display:none;">
 											<div class="col-sm-4">
-												<span class="label">Luogo di conservazione:</span>
+												<span class="label">Date:</span>
 											</div>
-											<div class="col" id="location"></div>
+											<div class="col" id="timeSpan"></div>
 										</div>
 
 										<div class="row mb-2" id="persone" style="display:none;">
@@ -186,7 +200,7 @@
 									</div>
 								</div>
 
-								<div class="col-12">
+								<div class="col-12" style="margin-bottom: 25px;">
 									<div id="placeholder_contenuti">
 										<h2 class="section_box">Contenuti informativi</h2>
 									</div>
@@ -225,7 +239,69 @@
 										</div>
 									</div>
 								</div>
+
+								<!--<div class="col-12">
+									<div id="placeholder_documents" style="margin-bottom: 25px;">
+										<h2 class="section_box">Sezioni documentate</h2>
+									</div>
+
+								</div>
+
+								<div class="col-12">
+									<div id="placeholder_people">
+										<h2 class="section_box">Persone citate nel documento</h2>
+									</div>
+
+								</div> -->
+							</div>
+
+							<div class="placeholder_container">
+								<div id="placeholder_documenti" class="row" id="references_documents">
+									<p class="section_box col-12">Risorse collegate <span id="nome3" class="font-italic PN"></span></p>
+									
+									<div class="box_results col-12" id="documents">
+										<div class="inner_results container-fluid">
+                                          
+                                          	<!-- Scheda -->
+											<div id="myTab" class="tab"></div>
+                                          
+											<div class="row def_res">
+												<div class="col">
+													<b>Sezioni documentate <span id="nome_au" class="PN"></span></b>
+												</div>
+												<div class="col num_res">
+													<span><span id="n_sec"></span> risultati</span>
+												</div>
+											</div>
+											<div class="row res_list">
+												<div class="container-fluid" id="section_documents"></div>
+											</div>
+										</div>
+									</div>
+
+									<div class="box_results col-12" id="sent">
+										<div class="inner_results container-fluid">
+                                          
+                                          	<!-- Scheda -->
+											<div id="myTab" class="tab"></div>
+                                          
+											<div class="row def_res">
+												<div class="col">
+													<b>Persone citate nel documento <span id="nome_au" class="PN"></span></b>
+												</div>
+												<div class="col num_res">
+													<span><span id="n_pp"></span> risultati</span>
+												</div>
+											</div>
+											<div class="row res_list">
+												<div class="container-fluid" id="cited_people"></div>
+											</div>
+										</div>
+									</div>
+									
+								</div>
 							</div>
+						</div>
 
 							<!-- <div class="d-flex justify-content-end" id="map_buttons">
 								<a href="#placeholder_luoghi">