| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326 |
- // 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("}{",",");
- }
- 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 owl: <http://www.w3.org/2002/07/owl#> \
- 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 ?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 ; \
- 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 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 . \
- ?uri_location rdfs:label ?location } \
- OPTIONAL { ?uri crm:P3_has_note ?uri_note . \
- ?uri_note rdfs:label ?note } \
- } "
- 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 ; \
- 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({
- url: queryURL,
- dataType: "json",
- success: function (data){
- handle_objectData(data);
- },
- error: function (e) {}
- });
- response_info = $.ajax({
- url: queryINF,
- dataType: "json",
- success: function (data){
- handle_objectInfo(data);
- },
- error: function (e) {}
- });
- response_info = $.ajax({
- url: queryOVI,
- dataType: "json",
- success: function (data){
- handle_oviLetter(data);
- },
- error: function (e) {}
- });
- function handle_objectData(json) {
- console.log(json['results']['bindings']);
- $.each(
- json['results']['bindings'],
- 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('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");
- condition = value['condition']['value'];
- }
- if (value.hasOwnProperty('material')) {
- $("#materia").css("display", "flex");
- materials = value['material']['value'];
- }
- if (value.hasOwnProperty('location')) {
- $("#localizzazione").css("display", "flex");
- current_location = value['location']['value'];
- }
- if (value.hasOwnProperty('note')) {
- $("#notes").css("display", "flex");
- description = value['note']['value'];
- }
- 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;
-
-
- });
-
- }
- 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) {
- console.log(json['results']['bindings']);
- $.each(
- json['results']['bindings'],
- function (index, value) {
- var title = "";
- var type = "";
- var subject = "";
-
- if (value.hasOwnProperty('titolo')) {
- $("#titolo").css("display", "flex");
- title = value['titolo']['value'];
- }
- if (value.hasOwnProperty('tipo')) {
- $("#tipo").css("display", "flex");
- type = value['tipo']['value'];
- }
- if (value.hasOwnProperty('ref')) {
- 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;
-
-
- });
-
- }
- 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) {
- var link = this.id;
- //alert(nome_autore);
- //$('#myModal').text("");
- window.open("Luogo.html?link="+this.id);
-
- });
- $(document).on("click", ".persona", function (ev) {
- var link = this.id;
- //alert(nome_autore);
- //$('#myModal').text("");
- window.open("Persona.html?link="+this.id);
-
- });
- function schedaASPO(info){
- window.open(info);
- }
|