// Raccatto i parametri dall'URL -- mi aspetto un parametro di nome 'link'! thisUrlParams = {}; window.location.href.replace(/[?&]+([^=&]+)=([^&]*)/gi, function(m,key,value) { thisUrlParams[key] = value; }); console.log('URL get params: ', thisUrlParams); // Funzioni per eseguire le queries function prepareQueryURL(query){ sparqlEndpoint = 'http://dev.restore.ovi.cnr.it:8890/sparql/'; sparqlUrlParams = '?default-graph-uri=&query=' + encodeURIComponent(query) + '&output=json&callback=?'; return sparqlEndpoint + sparqlUrlParams; } function doJsonQuery(query){ queryURL = prepareQueryURL(query); response = $.ajax({//OGGETTO url: queryURL, dataType: "json", success: function (data){}, error: function (e) {} }); return response; } // Funzioni per raccattare + stringhificare l'output queryStringOutput = ""; function stringifyResponse(val){ resultArray = val['results']['bindings']; out = ""; for(i = 0; i < resultArray.length; i++){ out = out + JSON.stringify(resultArray[i]) } queryStringOutput = (queryStringOutput + out).replace("}{",","); } //////////////////// // TESTI DELLE QUERY //////////////////// prefixes = "PREFIX rdfs: \ PREFIX rdf: \ PREFIX crm: \ PREFIX dat: \ PREFIX mpp: \ PREFIX aut: " query1 = prefixes + " SELECT DISTINCT ?mittente ?destinatario ?data_partenza ?data_arrivo ?luogo_partenza ?luogo_arrivo \ WHERE {?subject crm:P128_carries <" + thisUrlParams.link + "> \ GRAPH {?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 . \ ?placeA rdfs:label ?luogo_partenza . \ ?sender crm:P02_has_range ?mittente . \ \ ?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 . \ ?placeB rdfs:label ?luogo_arrivo . \ ?receiver crm:P02_has_range ?destinatario . \ }" 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 \ }" 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'. \ }"