Federica 2 سال پیش
والد
کامیت
7fb1dba6e9
2فایلهای تغییر یافته به همراه148 افزوده شده و 20 حذف شده
  1. 122 15
      js/object.js
  2. 26 5
      object.html

+ 122 - 15
js/object.js

@@ -47,14 +47,19 @@ 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 ?id (group_concat(distinct ?dimension ; separator='<br />') as ?dimensions) ?material ?location ?note \
+queryInfo = prefixes + " SELECT DISTINCT ?g AS ?graph ?uri ?label ?dimension ?consistency ?id (group_concat(distinct ?dimension ; separator='<br />') as ?dimensions) ?material ?location ?note \
 WHERE { \
 VALUES ?uri {<" + thisUrlParams.link + ">} \
 GRAPH ?g { ?uri rdfs:label ?label } \
 OPTIONAL {?uri crm:P1_is_identified_by ?uri_id . \
-?uri_id rdfs:label ?id } \
+?uri_id rdfs:label ?id ; \
+crm:P2_has_type 'Segnatura' .} \
+OPTIONAL { ?uri crm:P43_has_dimension ?uri_consistency . \
+?uri_consistency crm:P2_has_type 'Consistenza carte' ; \
+rdfs:label ?consistency } \
 OPTIONAL { ?uri crm:P43_has_dimension ?uri_dimension . \
-?uri_dimension rdfs:label ?dimension } \
+?uri_dimension crm:P2_has_type 'Dimensioni' ; \
+rdfs:label ?dimension } \
 OPTIONAL { ?uri crm:P45_consist_of ?uri_material . \
 ?uri_material rdfs:label ?material } \
 OPTIONAL { ?uri crm:P54_has_current_permanent_location ?uri_location . \
@@ -63,24 +68,42 @@ OPTIONAL { ?uri crm:P3_has_note ?uri_note . \
 ?uri_note rdfs:label ?note } \
 } "
 
-queryContent = prefixes + " SELECT DISTINCT ?g AS ?graph ?uri ?titolo ?tipo ?ref \
+queryContent = prefixes + " SELECT DISTINCT ?g AS ?graph ?uri ?titolo ?tipo (group_concat(distinct ?ref ; separator='<br />') as ?ref) \
 WHERE { \
 VALUES ?object {<" + thisUrlParams.link + ">} \
 ?object crm:P128_carries ?uri . \
+?uri rdf:type crm:E73_Information_Object . \
 GRAPH ?g { ?uri rdfs:label ?label } \
 OPTIONAL {?uri crm:P1_is_identified_by ?uri_titolo . \
-?uri_titolo rdfs:label ?titolo . } \
+?uri_titolo rdfs:label ?titolo ; \
+rdf:type crm:E35_Title . } \
 OPTIONAL { ?uri crm:P2_has_type ?uri_tipo . \
 ?uri_tipo rdfs:label ?tipo . } \
 OPTIONAL { ?uri crm:P67_refers_to ?uri_ref . \
 ?uri_ref rdfs:label ?ref . } \
+FILTER NOT EXISTS {GRAPH <http://dev.restore.ovi.cnr.it:8890/ovi/datini> { ?uri rdfs:label ?label }}. \
 }"
 
+queryOviLetter = prefixes + " SELECT DISTINCT ?otherId ?InfObj \
+WHERE {  \
+VALUES ?uri {<" + thisUrlParams.link + ">}   \
+?uri crm:P1_is_identified_by ?uri_id .  \
+?uri_id crm:P2_has_type 'Segnatura' ; \
+crm:P139_has_alternative_form ?other_id . \
+?other_id crm:P2_has_type ?uri_type ; \
+rdfs:label ?otherId . \
+?uri_type rdfs:label 'Segnatura OVI' . \
+OPTIONAL { ?uri crm:P128_carries ?InfObj . \
+GRAPH <http://dev.restore.ovi.cnr.it:8890/ovi/datini> {?InfObj rdf:type crm:E73_Information_Object } } \
+} "
+
 
 queryURL = prepareQueryURL(queryInfo);
 
 queryINF = prepareQueryURL(queryContent);
 
+queryOVI = prepareQueryURL(queryOviLetter);
+
 
 response = $.ajax({
 
@@ -102,6 +125,16 @@ response_info = $.ajax({
     error: function (e) {}
 });
 
+response_info = $.ajax({
+
+    url: queryOVI,
+    dataType: "json",
+    success: function (data){
+      handle_oviLetter(data);
+    },
+    error: function (e) {}
+});
+
 
 function handle_objectData(json) {
 
@@ -112,22 +145,28 @@ function handle_objectData(json) {
       function (index, value) {
         var graph = value['graph']['value'];
         var label = value['label']['value'];
+        var uri = value['uri']['value'];
         var identifier = "";
         var dimensions = "";
+        var consistence = "";
         var materials = "";
         var current_location = "";
         var description = "";
+        var button_ext = "";
+
+        var dataset = get_graph_name(graph);
 
-        
         if (value.hasOwnProperty('id')) {
           $("#ID").css("display", "flex");
           identifier = value['id']['value'];
         }
-        if (value.hasOwnProperty('dimensions')) {
-          if (value['dimensions']['value'] != "") {
-            $("#consistenza").css("display", "flex");
+        if (value.hasOwnProperty('dimension')) {
+            $("#dimensione").css("display", "flex");
             dimensions = value['dimensions']['value'];
-          }
+        }
+        if (value.hasOwnProperty('consistency')) {
+            $("#consistenza").css("display", "flex");
+            consistence = value['consistency']['value'];
         }
         if (value.hasOwnProperty('condition')) {
           $("#STCC").css("display", "flex");
@@ -145,14 +184,20 @@ function handle_objectData(json) {
           $("#notes").css("display", "flex");
           description = value['note']['value'];
         }
-        
 
-        document.getElementById("grafo").innerHTML = graph;
+        if (identifier != "") {
+          button_ext = '<button class="btn btn-default" type="button" onclick="schedaASPO(\'' + uri + '\')"> \
+          <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("nota").innerHTML = description;
         document.getElementById("dimensions").innerHTML = dimensions;
+        document.getElementById("consistence").innerHTML = consistence;
         document.getElementById("materials").innerHTML = materials;
        
         
@@ -160,6 +205,22 @@ function handle_objectData(json) {
   
 }
 
+function get_graph_name(graph) {
+  var dataset = "Scheda Oggetto";
+
+  if (graph == "http://dev.restore.ovi.cnr.it:8890/aspo/ospedale") {
+    dataset = dataset + " / Ospedale";
+  } else if (graph == "http://dev.restore.ovi.cnr.it:8890/aspo/datini") {
+    dataset = dataset + " / Datini";
+  } else if (graph == "http://dev.restore.ovi.cnr.it:8890/aspo/marcovaldi") {
+    dataset = dataset + " / Marcovaldi";
+  } else if (graph == "http://dev.restore.ovi.cnr.it:8890/aspo/gettatelli") {
+    dataset = dataset + " / Gettatelli";
+  } else {
+    dataset = dataset;
+  }
+  return dataset;
+}
 
 function handle_objectInfo(json) {
 
@@ -182,12 +243,14 @@ function handle_objectInfo(json) {
           $("#tipo").css("display", "flex");
           type = value['tipo']['value'];
         }
+
         if (value.hasOwnProperty('ref')) {
-          $("#argomento").css("display", "flex");
-          subject = value['ref']['value'];
+          if (value['ref']['value'] != "") {
+            $("#argomento").css("display", "flex");
+            subject = value['ref']['value'];
+          }
         }
         
-        
         document.getElementById("title").innerHTML = title;
         document.getElementById("type").innerHTML = type;
         document.getElementById("subject").innerHTML = subject;
@@ -197,6 +260,46 @@ function handle_objectInfo(json) {
   
 }
 
+function handle_oviLetter(json) {
+
+  console.log(json['results']['bindings']);
+
+  $.each(
+      json['results']['bindings'],
+      function (index, value) {
+
+        var other_id = "";
+        var uri = "";
+        var button_letter = "";
+
+        if (value.hasOwnProperty('otherId')) {
+          $("#IDbis").css("display", "flex");
+          other_id = value['otherId']['value'];
+        }
+        if (value.hasOwnProperty('InfObj')) {
+          uri = value['InfObj']['value'];
+        }
+
+        if (uri != "") {
+          button_letter = '<button type="button" id="' + uri + 
+					'" class="lettera btn btn-default" alt="lettera"><i class="fa fa-envelope"></i><p class="btn-text">Scheda Lettera</p></button>';
+        }
+        
+        document.getElementById("other_identifier").innerHTML = other_id;
+        document.getElementById("btn_other_identifier").innerHTML = button_letter;
+        
+      });
+
+}
+
+$(document).on("click", ".lettera", function (ev) {
+
+    var link = this.id;
+    //alert(nome_autore);
+    //$('#myModal').text("");
+    window.open("lettera.html?link="+this.id);
+    
+  });
 
 $(document).on("click", ".luogo", function (ev) {
 
@@ -217,3 +320,7 @@ $(document).on("click", ".persona", function (ev) {
     
 
   });
+
+  function schedaASPO(info){
+    window.open(info);
+  }

+ 26 - 5
object.html

@@ -120,11 +120,21 @@
 									<div id="info_oggetto">
 										<div class="row mb-2" id="ID" style="display:none;">
 											<div class="col-sm-4">
-												<span class="label">Identificatore:</span>
+												<span class="label">Segnatura:</span>
 											</div>
 											<div class="col" id="identifier"></div>
+											<div class="col-auto" id="btn_identifier"></div>
 										</div>
 
+										<div class="row mb-2" id="IDbis" style="display:none;">
+											<div class="col-sm-4">
+												<span class="label">Segnatura alternativa:</span>
+											</div>
+											<div class="col" id="other_identifier"></div>
+											<div class="col-auto" id="btn_other_identifier"></div>
+										</div>
+
+
 										<div class="row mb-2" id="conservazione" style="display:none;">
 											<div class="col-sm-4">
 												<span class="label">Localizzazione:</span>
@@ -146,13 +156,20 @@
 											<div class="col" id="author"></div>
 										</div>
 
-										<div class="row mb-2" id="consistenza" style="display:none;">
+										<div class="row mb-2" id="dimensione" style="display:none;">
 											<div class="col-sm-4">
 												<span class="label">Dimensioni:</span>
 											</div>
 											<div class="col" id="dimensions"></div>
 										</div>
 
+										<div class="row mb-2" id="consistenza" style="display:none;">
+											<div class="col-sm-4">
+												<span class="label">Consistenza carte:</span>
+											</div>
+											<div class="col" id="consistence"></div>
+										</div>
+
 										<div class="row mb-2" id="materia" style="display:none;">
 											<div class="col-sm-4">
 												<span class="label">Materiale:</span>
@@ -177,14 +194,14 @@
 									<div id="info_oggetto">
 										<div class="row mb-2" id="titolo" style="display:none;">
 											<div class="col-sm-4">
-												<span class="label">Titolo:</span>
+												<span class="label">Descrizione:</span>
 											</div>
 											<div class="col" id="title"></div>
 										</div>
 
 										<div class="row mb-2" id="tipo" style="display:none;">
 											<div class="col-sm-4">
-												<span class="label">Oggetto:</span>
+												<span class="label">Tipo:</span>
 											</div>
 											<div class="col" id="type"></div>
 										</div>
@@ -198,10 +215,14 @@
 
 										<div class="row mb-2" id="NSC" style="display:none;">
 											<div class="col-sm-4">
-												<span class="label">Notizie Storico Critiche:</span>
+												<span class="label">Note:</span>
 											</div>
 											<div class="col" id="description"></div>
 										</div>
+
+										<div class="row mb-2" id="OVI" style="display:none;">
+											<div class="col" id="letterOVI"></div>
+										</div>
 									</div>
 								</div>
 							</div>