kora %!s(int64=2) %!d(string=hai) anos
pai
achega
cd9265f6a2
Modificáronse 2 ficheiros con 112 adicións e 46 borrados
  1. 30 12
      js/lettera.js
  2. 82 34
      js/lettera_query.js

+ 30 - 12
js/lettera.js

@@ -52,20 +52,35 @@ function myFunction_b(value, index, array) {
   list_b += "<li>" + value + "</li>";
 }
 
-
-doJsonQuery(query1)
-    .then(val => tempfunc(val))
-    .then(() => console.log(queryStringOutput))
-    .then(() => doThat());
-
+async function fillPageContents(){
+	val = await doJsonQuery(query1);
+	stringifyResponse(val);
+	val = await doJsonQuery(queryAreaLinguistica);
+	stringifyResponse(val);
+	val = await doJsonQuery(queryDescrizione);
+	stringifyResponse(val);
+	val = await doJsonQuery(queryTipo);
+	stringifyResponse(val);
+	val = await doJsonQuery(querySiglaOVI);
+	stringifyResponse(val);
+	val = await doJsonQuery(queryTitolo);
+	stringifyResponse(val);
+	val = await doJsonQuery(queryTestoLemmatizzato);
+	stringifyResponse(val);
+	val = await doJsonQuery(queryEdizione);
+	stringifyResponse(val);
+	val = await doJsonQuery(queryRaccolta);
+	stringifyResponse(val);	
+	doThat();
+}
 
 function doThat(){
-	console.log("AHIA", queryStringOutput);
+	console.log("Stringified Response:", queryStringOutput);
 	queryOutput = JSON.parse(queryStringOutput);
-	document.getElementById("title").innerHTML = "MM - " + title;
+	document.getElementById("title").innerHTML = queryOutput.titolo.value;
 	document.getElementById("mittente_id").innerHTML = queryOutput.mittente.value;
 	document.getElementById("destinatario_id").innerHTML = queryOutput.destinatario.value;
-	document.getElementById("descrizione_id").innerHTML = "MM - " + informazioni_lettera.descrizione;
+	document.getElementById("descrizione_id").innerHTML = queryOutput.descrizione.value;
 	document.getElementById("luogo_partenza_id").innerHTML = queryOutput.luogo_partenza.value;
 	document.getElementById("luogo_arrivo_id").innerHTML = queryOutput.luogo_arrivo.value;
 	document.getElementById("data_partenza_id").innerHTML = queryOutput.data_partenza.value;
@@ -73,9 +88,12 @@ function doThat(){
 	document.getElementById("supporto_id").innerHTML = "MM - " + informazioni_lettera.supporto;
 	document.getElementById("segnatura_id").innerHTML = "MM - " + informazioni_lettera.segnatura;
 	document.getElementById("lingua_id").innerHTML = "MM - " + informazioni_lettera.lingua;
-	document.getElementById("area_linguistica_id").innerHTML = "MM - " + informazioni_lettera.area_linguistica;
-	document.getElementById("edizione_id").innerHTML = "MM - " + informazioni_lettera.edizione;
-	document.getElementById("trascrizione_id").innerHTML = "MM - " + informazioni_lettera.trascrizione;
+	document.getElementById("area_linguistica_id").innerHTML = queryOutput.area_linguistica.value;
+	document.getElementById("edizione_id").innerHTML = queryOutput.edizione.value;
+	document.getElementById("trascrizione_id").innerHTML = queryOutput.testo_lemmatizzato.value;
 	document.getElementById("antroponimi").innerHTML = "<li>MM</li>" + list_a;
 	document.getElementById("toponimi").innerHTML = "<li>MM</li>" + list_b;
 }
+
+
+fillPageContents();

+ 82 - 34
js/lettera_query.js

@@ -1,8 +1,3 @@
-var jsonprova = {
-    nome: "Nonmolto",
-    cognome: "Furbo",
-    descrizione: "Che ci volete fa'?"
-}
 
 thisUrlParams = {};
 window.location.href.replace(/[?&]+([^=&]+)=([^&]*)/gi, function(m,key,value) {
@@ -16,6 +11,8 @@ function prepareQueryURL(query){
     return sparqlEndpoint + sparqlUrlParams;
 }
 
+queryStringOutput = "";
+
 function doJsonQuery(query){
 
     queryURL = prepareQueryURL(query);
@@ -32,45 +29,96 @@ function doJsonQuery(query){
 
 }
 
-query1 = "PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>\n\
-PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>\n\
-PREFIX crm: <http://www.cidoc-crm.org/cidoc-crm/>\n\
-PREFIX dat: <http://datini.archiviodistato.prato.it/la-ricerca/scheda/>\n\
-PREFIX mpp: <http://palazzopretorio.comune.prato.it/it/le-opere/alcuni-capolavori/>\n\
-PREFIX aut: <http://palazzopretorio.comune.prato.it/it/opere/autori/>\n\
-SELECT DISTINCT ?mittente ?destinatario ?data_partenza ?data_arrivo ?luogo_partenza ?luogo_arrivo\n\
+prefixes = "PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> \
+PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> \
+PREFIX crm: <http://www.cidoc-crm.org/cidoc-crm/> \
+PREFIX dat: <http://datini.archiviodistato.prato.it/la-ricerca/scheda/> \
+PREFIX mpp: <http://palazzopretorio.comune.prato.it/it/le-opere/alcuni-capolavori/> \
+PREFIX aut: <http://palazzopretorio.comune.prato.it/it/opere/autori/>"
+
+query1 = prefixes + " SELECT DISTINCT ?mittente ?destinatario ?data_partenza ?data_arrivo ?luogo_partenza ?luogo_arrivo \
 WHERE {?subject crm:P128_carries <" + thisUrlParams.link + "> \
-GRAPH <http://dev.restore.ovi.cnr.it:8890/ovi/datini/ex> {?subject crm:P25i_moved_by ?mov_ev .}\n\
-?send rdfs:subClassOf ?mov_ev ;\n\
-rdf:type crm:EL2_Send_Letter ;\n\
-crm:P4_has_time-span ?time_spanA;\n\
-crm:P27_moved_from ?placeA;\n\
-crm:P01_has_domain ?sender .\n\
+GRAPH <http://dev.restore.ovi.cnr.it:8890/ovi/datini/ex> {?subject crm:P25i_moved_by ?mov_ev .} \
+?send rdfs:subClassOf ?mov_ev ; \
+rdf:type crm:EL2_Send_Letter ; \
+crm:P4_has_time-span ?time_spanA; \
+crm:P27_moved_from ?placeA; \
+crm:P01_has_domain ?sender . \
 \
-?time_spanA rdfs:label ?data_partenza .\n\
-?placeA rdfs:label ?luogo_partenza .\n\
-?sender crm:P02_has_range ?mittente .\n\
+?time_spanA rdfs:label ?data_partenza . \
+?placeA rdfs:label ?luogo_partenza . \
+?sender crm:P02_has_range ?mittente . \
  \
-?receive rdfs:subClassOf ?mov_ev;\n\
-rdf:type crm:EL3_Receive_Letter ;\n\
-crm:P4_has_time-span ?time_spanB;\n\
-crm:P26_moved_to ?placeB;\n\
-crm:P01_has_domain ?receiver .\n\
+?receive rdfs:subClassOf ?mov_ev; \
+rdf:type crm:EL3_Receive_Letter ; \
+crm:P4_has_time-span ?time_spanB; \
+crm:P26_moved_to ?placeB; \
+crm:P01_has_domain ?receiver . \
  \
-?time_spanB rdfs:label ?data_arrivo .\n\
-?placeB rdfs:label ?luogo_arrivo .\n\
-?receiver crm:P02_has_range ?destinatario .\n\
+?time_spanB rdfs:label ?data_arrivo . \
+?placeB rdfs:label ?luogo_arrivo . \
+?receiver crm:P02_has_range ?destinatario . \
 }"
 
-console.log("Query: " + query1);
+queryAreaLinguistica = prefixes + " SELECT DISTINCT ?lingua ?area_linguistica \
+WHERE {<" + thisUrlParams.link + "> crm:P72_has_language ?language . \
+?language crm:P3_has_note ?area ; \
+rdfs:label ?lingua . \
+?area rdfs:label ?area_linguistica \
+}"
 
-queryStringOutput = "";
 
-function tempfunc(val){
+queryDescrizione = prefixes + " SELECT DISTINCT ?descrizione \
+WHERE {<" + thisUrlParams.link + "> crm:P3_has_note ?description . \
+?description rdfs:label ?descrizione \
+}"
+
+queryTipo = prefixes + " SELECT DISTINCT ?tipologia \
+WHERE {<" + thisUrlParams.link + "> crm:P2_has_type ?type . \
+?type rdf:type crm:E55_Type; \
+rdfs:label ?tipologia . \
+}"
+
+querySiglaOVI = prefixes + " SELECT DISTINCT ?sigla_OVI \
+WHERE {<" + thisUrlParams.link + "> crm:P1_is_identified_by ?id . \
+?id rdf:type crm:E42_Identifier; \
+crm:P2_has_type ?type ; \
+rdfs:label ?sigla_OVI . \
+?type rdfs:label 'Sigla OVI'. \
+}"
+
+queryTitolo = prefixes + " SELECT DISTINCT ?titolo \
+WHERE {<" + thisUrlParams.link + "> crm:P1_is_identified_by ?title . \
+?title rdf:type crm:E35_Title; \
+rdfs:label ?titolo . \
+}"
+
+queryTestoLemmatizzato = prefixes + " SELECT DISTINCT ?testo_lemmatizzato \
+WHERE {<" + thisUrlParams.link + "> crm:P190_has_symbolic_content ?testo_lemmatizzato . \
+}"
+
+queryEdizione = prefixes + " SELECT DISTINCT ?edizione ?edizione_abbreviata \
+WHERE {?edition crm:P70_documents <" + thisUrlParams.link + "> ; \
+crm:P1_is_identified_by ?edition_id . \
+?edition_id rdfs:label ?edizione; \
+crm:P139_has_alternative_form ?ed_abbr . \
+?ed_abbr rdfs:label ?edizione_abbreviata \
+}"
+
+queryRaccolta = prefixes + " SELECT DISTINCT ?raccolta \
+WHERE {?racc crm:P148_has_component <" + thisUrlParams.link + "> ; \
+crm:P2_has_type ?racc_type ; \
+rdfs:label ?raccolta . \
+?racc_type rdfs:label 'Raccolta'. \
+}"
+
+
+
+function stringifyResponse(val){
     resultArray = val['results']['bindings'];
     out = "";
     for(i = 0; i < resultArray.length; i++){
         out = out + JSON.stringify(resultArray[i])
     }
-    queryStringOutput = out;
-}
+    queryStringOutput = (queryStringOutput + out).replace("}{",",");
+}