Alessia Spadi %!s(int64=2) %!d(string=hai) anos
pai
achega
7e27775265
Modificáronse 2 ficheiros con 87 adicións e 42 borrados
  1. 66 33
      js/map.js
  2. 21 9
      js/people.js

+ 66 - 33
js/map.js

@@ -109,23 +109,27 @@ crm:P4_has_time-span ?uri_ts . \
 ?uri_ts rdfs:label ?time_span . } \
 } "
 
-queryPersone = prefixes + " SELECT DISTINCT ?range ?label \
+queryPersone = prefixes + " SELECT DISTINCT ?role ?range ?label COUNT(?range) AS ?count \
 WHERE{ \
-  {?place owl:sameAs <" + thisUrlParams.link + "> .\
-  ?event_to crm:P26_moved_to ?place ;\
-  rdf:type crm:EL3_Receive_Letter ;\
-  crm:P01_has_domain ?domain .\
-  ?domain crm:P02_has_range ?range .\
-  ?range rdfs:label ?label .\
-} UNION {\
-  ?place owl:sameAs <" + thisUrlParams.link + "> .\
-  ?event_to crm:P27_moved_from ?place ;\
-  rdf:type crm:EL2_Send_Letter ;\
-  crm:P01_has_domain ?domain .\
-  ?domain crm:P02_has_range ?range .\
-  ?range rdfs:label ?label .\
-  }\
-}"
+  {?place owl:sameAs <" + thisUrlParams.link + "> . \
+  ?event_to crm:P26_moved_to ?place ; \
+  rdf:type crm:EL3_Receive_Letter ; \
+  crm:P01_has_domain ?domain . \
+  ?domain crm:P02_has_range ?range ; \
+  crm:P14.1_in_the_role_of ?uri_role . \
+  ?uri_role rdfs:label ?role . \
+  ?range rdfs:label ?label . \
+} UNION { \
+  ?place owl:sameAs <" + thisUrlParams.link + "> . \
+  ?event_to crm:P27_moved_from ?place ; \
+  rdf:type crm:EL2_Send_Letter ; \
+  crm:P01_has_domain ?domain . \
+  ?domain crm:P02_has_range ?range ; \
+  crm:P14.1_in_the_role_of ?uri_role . \
+  ?uri_role rdfs:label ?role . \
+  ?range rdfs:label ?label . \
+  } \
+} GROUP BY ?role ?range ?label"
 
 queryCount = prefixes + " SELECT ?place ?label COUNT(?label) AS ?Count \
 WHERE{ \
@@ -566,36 +570,65 @@ function handle_persons(json) {
 
   console.log(json);
 
-  const people = {};
-
-  var i=0;
+  const people = [];
+  const person_names = [];
+  const person_events = [];
+  var Person = "";
 
   $.each(
       json['results']['bindings'],
       function (index, value) {
-        key = value['range']['value'];
-        data = value['label']['value'];   
-        people[key] = data;  
-        i++;   
+        var uri = value['range']['value'];
+        var label = value['label']['value'];
+        var ruolo = value['role']['value']
+        var count = value['count']['value']
+        var evento = ruolo + ": " + count
+        person_events.push([uri, label, evento]);
+        if (!person_names.includes(uri)) {
+          person_names.push([uri, label]);
+        }
+        
       });
 
-  var myArray = "";
-
-  for (var key in people) {
-    myArray += "<div class='row res'><div class='col-10'>" + people[key] + "</div><div class='col d-flex align-items-center justify-content-end'><div class='persona' id='" + 
-    key + "'><i class='fa fa-user' style='cursor: pointer'></i></div></div></div>";
+  for (var k=0; k<person_names.length; k++) {
+    const tempArray = [];
+    var uri = person_names[k][0];
+    var nome = person_names[k][1]
+    tempArray.push(uri);
+    tempArray.push(nome);
+    for (var y=0; y<person_events.length; y++) {
+      var ev = person_events[y][2];
+      if (person_names[k][0] == person_events[y][0]) {
+        tempArray.push(ev);
+      }
+    }
+    people.push(tempArray);
   }
 
+  for (var i=0; i<people.length; i++) {
+
+      var info = "";
+      for (var h=2; h<people[i].length; h++) {
+        info += people[i][h] + ' occorrenze<br />';
+      }
+
+      Person += '<div class="row res"><div class="col-8">' +
+      '<a href=' + people[i][0] + ' target="_blank">' + people[i][1] + '</a><br />' + info + '</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_per").innerHTML = i;
-  document.getElementById("object_per").innerHTML = myArray;
+  document.getElementById("n_per").innerHTML = people.length;
+  document.getElementById("object_per").innerHTML = Person;
 
-  if (i==0) {
+  if (people.length==0) {
     var messaggio = "<p class='no-results'>Nessun risultato trovato</p>";
     document.getElementById("object_per").innerHTML = messaggio;
   }
-
-}
+} 
 
 function handle_count(json) {
   console.log(json);

+ 21 - 9
js/people.js

@@ -108,15 +108,17 @@ OPTIONAL {?uri schema:hasOccupation ?uriOccupation . \
 rdfs:label ?occupation } \
 OPTIONAL {?uri schema:honorificPrefix ?qualification} \
 OPTIONAL {?uri crm:P100i_died_in ?Death . \
-?Death crm:P4_has_time-span ?Death_TS; \
-crm:P7_took_place_at ?Place_D . \
-?Death_TS rdfs:label ?Death_Date . \
+OPTIONAL {?Death crm:P4_has_time-span ?Death_TS . \
+?Death_TS rdfs:label ?Death_Date . } \
+OPTIONAL {?Death crm:P7_took_place_at ?Place_D .  \
 ?Place_D rdfs:label ?Death_Place } \
+} \
 OPTIONAL {?uri crm:P98i_was_born ?Birth . \
-?Birth crm:P4_has_time-span ?Birth_TS; \
-crm:P7_took_place_at ?Place_B . \
-?Birth_TS rdfs:label ?Birth_Date . \
+OPTIONAL {?Birth crm:P4_has_time-span ?Birth_TS . \
+?Birth_TS rdfs:label ?Birth_Date . } \
+OPTIONAL {?Birth crm:P7_took_place_at ?Place_B . \
 ?Place_B rdfs:label ?Birth_Place } \
+} \
 OPTIONAL {?uri crm:P107i_is_current_or_former_member_of ?uriGroup . \
 ?uriGroup rdfs:label ?group } \
 OPTIONAL {?uri schema:alternateName ?alias . } \
@@ -169,7 +171,7 @@ 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:name ?name } \
 OPTIONAL {?uri_person foaf:givenName ?givenName} \
 OPTIONAL {?uri_person foaf:familyName ?familyName}  \
 OPTIONAL {?uri_person person:patronymicName ?patronymic } \
@@ -179,7 +181,14 @@ rdfs:label ?provenienza . } \
 } "
 
 queryLetters = prefixes + " SELECT DISTINCT ?type ?segnatura ?document_uri ?document_name ?time_span ?InfObj \
-WHERE {?pc crm:P02_has_range <" + thisUrlParams.link + "> . \
+WHERE { \
+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 . \
@@ -818,13 +827,16 @@ function handle_RelazioniInverse(json) {
     function (index, value) {
       var tipo = value['relation_type']['value'];
       var uri_person = value['uri_person']['value'];
-      var nome = value['name']['value'];
+      var nome = "";
       var principale = "";
       var givenName = "";
       var familyName = "";
       var patronymic = "";
       var provenence = "";
       
+      if (value.hasOwnProperty('name')) {
+        nome = value['name']['value'];
+      }
       if (value.hasOwnProperty('givenName')) {
         givenName = value['givenName']['value'];
       }