Kaynağa Gözat

Aggiornamenti scheda Persona

Alessia Spadi 2 yıl önce
ebeveyn
işleme
3c4909f1a9
2 değiştirilmiş dosya ile 396 ekleme ve 29 silme
  1. 47 0
      Persona.html
  2. 349 29
      js/people.js

+ 47 - 0
Persona.html

@@ -169,6 +169,25 @@
 										<div class="col" id="alias"></div>
 									</div>
 
+									<div class="row mb-2" id="type" style="display:none;">
+										<div class="col-sm-4">
+											<span class="label">Tipo:</span>
+										</div>
+										<div class="col" id="tipologia"></div>
+									</div>
+
+									<div class="row mb-2" id="card" style="display:none;">
+										<div class="col-sm-4">
+											<span class="label">Scheda anagrafica:</span>
+										</div>
+										<div class="col" id="scheda_anagrafica"></div>
+										<div class="col-auto" id="btn_scheda"></div>
+									</div>
+
+									<div class="row mb-2" id="identifier" style="display:none;">
+										<!--Add info here-->	
+									</div>
+
 									<div class="row mb-2" id="BirthDate" style="display:none;">
 										<div class="col-sm-4">
 											<span class="label">Data di Nascita:</span>
@@ -225,6 +244,34 @@
 										<div class="col" id="ruoli"></div>
 									</div>
 
+									<div class="row mb-2" id="generic_event" style="display:none;">
+										<div class="col-sm-4">
+											<span class="label">Data:</span>
+										</div>
+										<div class="col" id="anno"></div>
+									</div>
+
+									<div class="row mb-2" id="find_event" style="display:none;">
+										<div class="col-sm-4">
+											<span class="label">Ritrovamento:</span>
+										</div>
+										<div class="col" id="ritrovamento"></div>
+									</div>
+
+									<div class="row mb-2" id="reunion_event" style="display:none;">
+										<div class="col-sm-4">
+											<span class="label">Ricongiungimento:</span>
+										</div>
+										<div class="col" id="ricongiungimento"></div>
+									</div>
+
+									<div class="row mb-2" id="adoption_event" style="display:none;">
+										<div class="col-sm-4">
+											<span class="label">Adozione:</span>
+										</div>
+										<div class="col" id="adozione"></div>
+									</div>
+
 									<div class="row mb-2" id="groups" style="display:none;">
 										<div class="col-sm-4">
 											<span class="label">Gruppi di appartenenza:</span>

+ 349 - 29
js/people.js

@@ -83,26 +83,30 @@ crm:P168_place_is_defined_by ?coordinates . \
   } \
 }"
 
-queryInfo = prefixes + " SELECT DISTINCT ?graph ?label ?identifier ?name ?givenName ?familyName ?alias (GROUP_CONCAT(DISTINCT CONCAT(?variant, '| ', ?otherName) ; SEPARATOR = ';') AS ?variants) ?gender ?Birth_Date ?Birth_Place ?Death_Date ?Death_Place ?patronymic ?occupation (group_concat(distinct ?relative1 ;separator=', ') as ?relatives) ?qualification ?group \
+queryInfo = prefixes + " SELECT DISTINCT ?graph ?label ?identifier ?id_type ?name ?givenName ?familyName ?relative2 ?relative3 ?alias ?provenienza (GROUP_CONCAT(DISTINCT CONCAT(?variant, '| ', ?otherName) ; SEPARATOR = ';') AS ?variants) ?gender ?Birth_Date ?Birth_Place ?Death_Date ?Death_Place ?patronymic ?occupation ?qualification ?group \
 WHERE { \
 VALUES ?uri {<" + thisUrlParams.link + ">} \
 GRAPH ?graph {?uri rdfs:label ?label} \
 ?uri foaf:name ?name . \
 OPTIONAL {?uri crm:P1_is_identified_by ?id . \
-?id rdfs:label ?identifier } \
+?id rdfs:label ?identifier ; \
+crm:P2_has_type ?id_type .} \
 OPTIONAL {?uri foaf:givenName ?givenName} \
 OPTIONAL {?uri foaf:familyName ?familyName} \
 OPTIONAL {?uri foaf:gender ?gender} \
 OPTIONAL {?uri person:patronymicName ?patronymic } \
+OPTIONAL {?uri crm:P74_has_current_or_former_residence ?uri_provenienza . \
+?uri_provenienza crm:P2_has_type 'Provenienza'; \
+rdfs:label ?provenienza . } \
+OPTIONAL {?uri crm:P2_has_type ?uri_person_type . \
+?uri_person_type rdfs:label ?person_type } \
 OPTIONAL {?uri schema:hasOccupation ?uriOccupation . \
 ?uriOccupation rdf:type schema:Occupation; \
 rdfs:label ?occupation } \
 OPTIONAL {?uri schema:honorificPrefix ?qualification} \
-OPTIONAL {?uri schema:relatedTo ?uriRel1 . \
-?uriRel1 rdfs:label ?relative1} \
 OPTIONAL {?uri crm:P100i_died_in ?Death . \
 ?Death crm:P4_has_time-span ?Death_TS; \
-crm:P7_took_place_at ?Place_D .\
+crm:P7_took_place_at ?Place_D . \
 ?Death_TS rdfs:label ?Death_Date . \
 ?Place_D rdfs:label ?Death_Place } \
 OPTIONAL {?uri crm:P98i_was_born ?Birth . \
@@ -115,9 +119,44 @@ OPTIONAL {?uri crm:P107i_is_current_or_former_member_of ?uriGroup . \
 OPTIONAL {?uri schema:alternateName ?alias . } \
 OPTIONAL {?uri owl:sameAs ?variant . \
 ?variant foaf:name ?otherName . } \
+OPTIONAL {?relation2 crm:P141_assigned ?uri ; \
+crm:P42_assigned ?uri_rel_type2 . \
+?uri_rel_type2 rdfs:label 'Avo di secondo grado' . \
+?uri_relative2 crm:P141_assigned ?relation2; \
+rdfs:label ?relative2 .} \
+OPTIONAL {?relation3 crm:P141_assigned ?uri ; \
+crm:P42_assigned ?uri_rel_type3 . \
+?uri_rel_type3 rdfs:label 'Avo di terzo grado' . \
+?uri_relative3 crm:P141_assigned ?relation3; \
+rdfs:label ?relative3 .} \
 } \
-GROUP BY ?graph ?label ?identifier ?name ?givenName ?familyName ?alias ?gender ?Birth_Date ?Birth_Place ?Death_Date ?Death_Place ?patronymic ?occupation ?qualification ?group \
-LIMIT 1 "
+GROUP BY ?graph ?label ?identifier ?id_type ?name ?givenName ?familyName ?relative2 ?relative3 ?alias ?provenienza ?gender ?Birth_Date ?Birth_Place ?Death_Date ?Death_Place ?patronymic ?occupation ?qualification ?group \
+LIMIT 1  "
+
+queryInfoGettatelli = prefixes + " SELECT DISTINCT ?card ?uri_card \
+WHERE { \
+VALUES ?uri {<" + thisUrlParams.link + ">} \
+?documentation crm:P67_refers_to ?uri ; \
+crm:P141_assigned ?uri_card . \
+?uri_card rdfs:label ?card . \
+} "
+
+queryRelazioni = prefixes + " SELECT DISTINCT ?relation_type ?note ?uri_person ?name ?givenName ?familyName ?patronymic ?provenienza \
+WHERE { \
+VALUES ?uri {<" + thisUrlParams.link + ">} \
+?uri crm:P141_assigned ?relation . \
+?relation crm:P42_assigned ?uri_type ; \
+crm:P141_assigned ?uri_person . \
+?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 + "> . \
@@ -158,14 +197,25 @@ crm:P14.1_in_the_role_of ?uri_role . \
 GROUP BY ?document ?label ?id ?role "
 
 queryOtherDoc = prefixes + " SELECT DISTINCT ?document ?label ?id (group_concat(distinct ?time_span ;separator='-') as ?time_span) \
-WHERE {<" + thisUrlParams.link + "> rdf:type crm:E21_Person . \
-?creation crm:P67_refers_to <" + thisUrlParams.link + "> . \
-?document crm:P92i_was_brought_into_existence_by ?creation ; \
+WHERE { \
+VALUES ?uri {<" + thisUrlParams.link + ">} \
+?uri rdf:type crm:E21_Person . \
+?event crm:P67_refers_to ?uri . \
+{?document crm:P92i_was_brought_into_existence_by ?event ; \
+rdfs:label ?label ; \
+crm:P1_is_identified_by ?uri_id . \
+?uri_id rdfs:label ?id ; \
+crm:P2_has_type 'Segnatura' . } \
+UNION \
+{?documentation crm:P67_refers_to ?uri ; \
+crm:P141_assigned ?card . \
+?document crm:P46_is_composed_of ?card ; \
 rdfs:label ?label ; \
 crm:P1_is_identified_by ?uri_id . \
 ?uri_id rdfs:label ?id ; \
 crm:P2_has_type 'Segnatura' . \
-OPTIONAL {?creation crm:P4_has_time-span ?uri_time_span . \
+} \
+OPTIONAL {?event crm:P4_has_time-span ?uri_time_span . \
 ?uri_time_span rdfs:label ?time_span . } \
 } \
 GROUP BY ?document ?label ?id "
@@ -212,6 +262,16 @@ FILTER (?uri = <" + thisUrlParams.link + ">) \
 } \
 } ORDER BY DESC (?count)"
 
+queryGettatelliEv = prefixes + " SELECT DISTINCT ?event_type ?time_span \
+WHERE { \
+VALUES ?uri {<" + thisUrlParams.link + ">} \
+?uri crm:P12i_was_present_at ?event . \
+?event crm:P2_has_type ?uri_event_type ; \
+crm:P4_has_time-span ?uri_time_span . \
+?uri_time_span rdfs:label ?time_span . \
+?uri_event_type rdfs:label ?event_type . \
+} "
+
 queryURL = prepareQueryURL(query);
 
 queryNet = prepareQueryURL(queryNetwork);
@@ -226,6 +286,12 @@ query = prepareQueryURL(queryInfo);
 
 queryEx = prepareQueryURL(queryLetters);
 
+queryGt = prepareQueryURL(queryGettatelliEv);
+
+queryInfoGt = prepareQueryURL(queryInfoGettatelli);
+
+queryRel = prepareQueryURL(queryRelazioni);
+
 response = $.ajax({
 
     url: query,
@@ -296,6 +362,38 @@ responseDoc = $.ajax({
   error: function (e) {}
 });
 
+responseDoc = $.ajax({
+
+  url: queryGt,
+  dataType: "json",
+  success: function (data){
+    handle_Gettatelli(data);
+  },
+  error: function (e) {}
+});
+
+responseDoc = $.ajax({
+
+  url: queryInfoGt,
+  dataType: "json",
+  success: function (data){
+    handle_InfoGettatelli(data);
+  },
+  error: function (e) {}
+});
+
+responseRel = $.ajax({
+
+  url: queryRel,
+  dataType: "json",
+  success: function (data){
+    handle_Relazioni(data);
+  },
+  error: function (e) {}
+});
+
+
+var labelName = "";
 
 function handle_data(json) {
 
@@ -321,18 +419,26 @@ function handle_data(json) {
         var gender = "";
         var patronymic = "";
         var occupation = "";
-        var relative = "";
+        var relative2 = "";
+        var relative3 = "";
         var identifier = "";
+        var id_type = "";
         var birth_date = "";
         var birth_place = "";
         var death_date = "";
         var death_place = "";
         var qualification = "";
         var group = "";
+        var type = "";
+        var provenence = "";
 
         var variants = "";
 
-
+        if ((value.hasOwnProperty('identifier')) && (value.hasOwnProperty('id_type'))) {
+          $("#identifier").css("display", "flex");
+          identifier = value['identifier']['value'];
+          id_type = value['id_type']['value'];
+        }
         if (value.hasOwnProperty('givenName')) {
           $("#givenName").css("display", "flex");
           givenName = value['givenName']['value'];
@@ -340,7 +446,7 @@ function handle_data(json) {
         if (value.hasOwnProperty('familyName')) {
           $("#familyName").css("display", "flex");
           familyName = value['familyName']['value'].toLowerCase();
-          familyName = familyName.charAt(0).toUpperCase() + familyName.slice(1)
+          familyName = familyName.charAt(0).toUpperCase() + familyName.slice(1);
         }
         if (value.hasOwnProperty('alias')) {
           $("#aliasName").css("display", "flex");
@@ -354,19 +460,28 @@ function handle_data(json) {
           $("#patronymic").css("display", "flex");
           patronymic = value['patronymic']['value'];
         }
+        if (value.hasOwnProperty('provenienza')) {
+          $("#PlaceProvenence").css("display", "flex");
+          provenence = value['provenienza']['value'];
+        }
         if (value.hasOwnProperty('occupation')) {
           $("#occupation").css("display", "flex");
           occupation = value['occupation']['value'];
         }
-        if (value.hasOwnProperty('relatives')) {
-          if (value['relatives']['value'] != "") {
-            relative = value['relatives']['value'];
-          }
+        if (value.hasOwnProperty('relative2')) {
+          relative2 = value['relative2']['value'];
+        }
+        if (value.hasOwnProperty('relative3')) {
+          relative3 = value['relative3']['value'];
         }
         if (value.hasOwnProperty('qualification')) {
           $("#honorific").css("display", "flex");
           qualification = value['qualification']['value'];
         }
+        if (value.hasOwnProperty('person_type')) {
+          $("#type").css("display", "flex");
+          type = value['person_type']['value'];
+        }
         if (value.hasOwnProperty('Birth_Date')) {
           $("#BirthDate").css("display", "flex");
           birth_date = value['Birth_Date']['value'];
@@ -397,16 +512,18 @@ function handle_data(json) {
         }
         
         var dataset = get_dataset_name(graph);
-        var second_name = patronymic + " " + relative;
+        var second_name = patronymic + " " + relative2 + " " + relative3;
 
         var first_name = "";
 
-        if ((givenName != "") || (second_name != " ") || (familyName != "")) {
-          first_name = givenName + " " + second_name + " " + familyName;
+        if ((givenName != "") || (second_name != "  ") || (familyName != "") || (provenence != "")) {
+          first_name = givenName + " " + second_name + " " + familyName + " " + provenence;
         } else {
           first_name = name;
         }
 
+        first_name = first_name.replace(",", "");
+        
         var name_string = "";
 
         if (variants.length>0) {
@@ -416,11 +533,11 @@ function handle_data(json) {
           }
         }
 
+        labelName = first_name;
+
         console.log(variants);
 
-        /*for (var i=0; i<l; i++) {
-          names_string = names_string + "<a href='" + variants[i][0] + "'>" + variants[i][1] + "</a>";
-        }*/
+        var id_snippet = "<div class='col-sm-4'><span class='label'>" + id_type + ":</span></div><div class='col' id='identificatore'>" + identifier + "</div>";
 
         document.getElementById("grafo").innerHTML = dataset;
         document.getElementById("nome_persona").innerHTML = first_name;
@@ -428,7 +545,10 @@ function handle_data(json) {
         document.getElementById("genere").innerHTML = gender;
         document.getElementById("nome_proprio").innerHTML = givenName;
         document.getElementById("nome_famiglia").innerHTML = familyName;
+        document.getElementById("provenienza").innerHTML = provenence;
+        document.getElementById("identifier").innerHTML = id_snippet;
         document.getElementById("alias").innerHTML = alias;
+        document.getElementById("tipologia").innerHTML = type;
         document.getElementById("variants").innerHTML = name_string;
         document.getElementById("patronimico").innerHTML = second_name;
         document.getElementById("qualifica").innerHTML = qualification;
@@ -462,6 +582,201 @@ function get_dataset_name(graph) {
   return (string);
 }
 
+function handle_InfoGettatelli(json) {
+  
+  console.log(json);
+
+  var card = "";
+  var uri_card = "";
+
+  $.each(
+      json['results']['bindings'],
+      function (index, value) {
+
+        if ((value.hasOwnProperty('uri_card')) && (value.hasOwnProperty('card'))) {
+          $("#card").css("display", "flex");
+          uri_card = value['uri_card']['value'];
+          card = value['card']['value'];
+        }
+        
+      });
+
+  var button_obj = "";
+
+  if (uri_card != "") {
+    button_obj = '<button type="button" id="' + uri_card + 
+    '" class="object btn btn-default" alt="oggetto" title="' + uri_card + 
+    '"><i class="fa fa-book"></i><p class="btn-text">Scheda Oggetto</p></button>';
+  }
+
+  document.getElementById("scheda_anagrafica").innerHTML = card;
+  document.getElementById("btn_scheda").innerHTML = button_obj;
+
+}
+
+function handle_Gettatelli(json) {
+  
+  console.log(json);
+
+  var generic = "";
+  var find = "";
+  var reunite = "";
+  var adoption = "";
+
+  $.each(
+      json['results']['bindings'],
+      function (index, value) {
+        var event_type = value['event_type']['value'];
+        var data = value['time_span']['value'];
+
+        if (event_type == "Evento generico") {
+          $("#generic_event").css("display", "flex");
+          generic = data;
+        } 
+        else if (event_type == "Ritrovamento") {
+          $("#find_event").css("display", "flex");
+          find = data;
+        } 
+        else if (event_type == "Ricongiungimento") {
+          $("#reunion_event").css("display", "flex");
+          reunite = data;
+        } 
+        else if (event_type == "Adozione") {
+          $("#adoption_event").css("display", "flex");
+          adoption = data;
+        } 
+        
+      });
+
+  document.getElementById("anno").innerHTML = generic;
+  document.getElementById("ritrovamento").innerHTML = find;
+  document.getElementById("ricongiungimento").innerHTML = reunite;
+  document.getElementById("adozione").innerHTML = adoption;
+
+}
+
+function handle_Relazioni(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").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'];
+      } 
+
+      var type = tipo.charAt(0).toUpperCase() + tipo.slice(1) + principale;
+
+      if ((type == "Socio") || (type == "Socio principale")) {
+        type = type + " di";
+      }
+
+      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 rel = createDivRelazione(par);
+    Relazioni = Relazioni + rel;
+  }
+
+  $(Relazioni).insertAfter( "#groups" );
+
+  for (var j=0; j<params.length; j++) {
+      var par = params[j];
+      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];
+          if (par == rel) {
+              var col = createColRelazione(text, link);
+              Colums = Colums + col;
+          }
+      }
+      document.getElementById(par).innerHTML = Colums;
+  }
+
+}
+
+function createDivRelazione(type){
+	htmlCode = '\
+      <div class="row mb-2"> \
+      <div class="col-sm-4"> \
+        <span class="label"><RELATIONSHIP></span> \
+      </div> \
+      <div class="col" id="<ID_RELATIONSHIP>"></div> \
+    </div> \
+		'.replace("<RELATIONSHIP>", type).replace("<ID_RELATIONSHIP>", type);
+	return htmlCode;
+}
+
+function createColRelazione(text, link) {
+  htmlCode = '\
+    <div class="row"> \
+        <div class="col"><NAME></div> \
+        <div class="col-auto" id="gruppi_appartenenza"> \
+            <button class="persona btn btn-default" type="button" id="<URI>">\
+	            	<i class="fa fa-user" aria-hidden="true">\
+			              <p class="btn-text">Scheda Persona</p>\
+	        	    </i>\
+		          </button>\</div> \
+    </div>\
+		'.replace("<NAME>", text).replace("<URI>", link);
+	return htmlCode;
+}
+
 function handle_Letters(json) {
 
   console.log(json);
@@ -656,7 +971,7 @@ function handle_Documents(json) {
     if (docs[i][3] != "") {
       object = object + "<br />Data: " + docs[i][3];
     }
-    object = object + "<br /><span class='PN'></span> nel ruolo di " + docs[i][4];
+    object = object + "<br /><span>" + labelName + "</span> nel ruolo di " + docs[i][4];
 
     var object_button  = '<button type="button" id="' + docs[i][0] + 
       '" class="object btn btn-default" alt="opera d\'arte" title="' + docs[i][1] + 
@@ -671,6 +986,11 @@ function handle_Documents(json) {
 
   document.getElementById("n_dc").innerHTML = docs.length;
   document.getElementById("written_documents").innerHTML = Docs;
+
+  if (docs.length==0) {
+    var messaggio = "<p class='no-results'>Nessun risultato trovato</p>";
+    document.getElementById("written_documents").innerHTML = messaggio;
+  }
   
 }
 
@@ -686,12 +1006,14 @@ function handle_Other_Documents(json) {
       function (index, value) {
         uri = value['document']['value'];
         label = value['label']['value'];
-        id = value['id']['value'];
         var data = "";
-        
+        var id = "";
         if (value.hasOwnProperty('time_span')) {
             data = value['time_span']['value'];
         }
+        if (value.hasOwnProperty('id')) {
+            id = value['id']['value'];
+        }
 
         doc.push([uri, label, id, data]);
         
@@ -986,8 +1308,6 @@ $(document).on("click", ".luogo", function (ev) {
 $(document).on("click", ".persona", function (ev) {
 
     var link = this.id;
-    //alert(nome_autore);
-    //$('#myModal').text("");
     window.open("Persona.html?link="+this.id);