123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289 |
- // 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 ?graph ?identifier ?label ?title ?uriType ?type ?uriOwner ?current_owner ?current_location ?subject (group_concat(distinct ?dimension ; separator='<br />') as ?dimensions) (GROUP_CONCAT(DISTINCT CONCAT(?uriMaterial, '; ', ?material) ; SEPARATOR = '<br />') AS ?Materials) ?condition ?note \
- WHERE { \
- VALUES ?uri {<" + thisUrlParams.link + ">} \
- GRAPH ?graph {?uri rdfs:label ?label} \
- OPTIONAL {?uri crm:P3_has_note ?note } \
- ?uri crm:P128_carries ?Inf_Obj . \
- OPTIONAL {?Inf_Obj crm:P1_is_identified_by ?uriTitle . \
- ?uriTitle rdf:type crm:E35_Title; \
- rdfs:label ?title } \
- OPTIONAL {?Inf_Obj crm:P2_has_type ?uriType . \
- ?uriType rdfs:label ?type } \
- OPTIONAL {?uri crm:P43_has_dimension ?uriDimension . \
- ?uriDimension rdfs:label ?dimension } \
- OPTIONAL {?uri crm:P1_is_identified_by ?uriIdentifier . \
- ?uriIdentifier rdfs:label ?identifier } \
- OPTIONAL {?uri crm:P45_consists_of ?uriMaterial . \
- ?uriMaterial rdfs:label ?material } \
- OPTIONAL {?uri crm:P44_has_condition ?uriCondition . \
- ?uriCondition crm:P2_has_type ?condition} \
- OPTIONAL {?uri crm:P54_has_current_permanent_location ?current_location } \
- OPTIONAL {?uri crm:P62_depicts ?uriSubject . \
- ?uriSubject rdfs:label ?subject; \
- crm:P2_has_type 'Identificazione Iconografica' .} \
- OPTIONAL {?uri crm:P52_has_current_owner ?uriOwner . \
- ?uriOwner rdfs:label ?current_owner } \
- }"
- queryProduction = prefixes + " SELECT DISTINCT (GROUP_CONCAT(DISTINCT CONCAT(?uriPerson, '; ', ?person, '; ', ?role) ; SEPARATOR = '<br />') AS ?Partecipants) (group_concat(distinct ?time_span ;separator='-') as ?time) (GROUP_CONCAT(DISTINCT CONCAT(?uriTecne, '; ', ?technique) ; SEPARATOR = '<br />') AS ?techniques) \
- WHERE { \
- VALUES ?uri {<" + thisUrlParams.link + ">} \
- ?uri crm:P128_carries ?Information_Object . \
- ?Information_Object crm:P108i_was_produced_by ?Production . \
- OPTIONAL {?Production crm:P4_has_time-span ?uriTS ; \
- crm:P32_used_general_technique ?uriTecne . \
- ?uriTS rdfs:label ?time_span . \
- ?uriTecne rdfs:label ?technique} \
- OPTIONAL {?pc crm:P01_has_domain ?Production ; \
- crm:P02_has_range ?uriPerson ; \
- crm:P14.1_in_the_role_of ?uriRole . \
- ?uriPerson rdfs:label ?person . \
- ?uriRole rdfs:label ?role} \
- }"
- queryURL = prepareQueryURL(queryInfo);
- queryPro = prepareQueryURL(queryProduction);
- response = $.ajax({
- url: queryURL,
- dataType: "json",
- success: function (data){
- handle_OAdata(data);
- },
- error: function (e) {}
- });
- response_Pro = $.ajax({
- url: queryPro,
- dataType: "json",
- success: function (data){
- handle_Production(data);
- },
- error: function (e) {}
- });
- function handle_OAdata(json) {
- console.log(json['results']['bindings']);
- $.each(
- json['results']['bindings'],
- function (index, value) {
- var graph = value['graph']['value'];
- var label = value['label']['value'];
- var title = "";
- var type = "";
- var current_owner = "";
- var current_location = "";
- var subject = "";
- var dimensions = "";
- var materials = "";
- var condition = "";
- var note = "";
- var identifier = "";
-
- if (value.hasOwnProperty('title')) {
- $("#SGTT").css("display", "flex");
- title = value['title']['value'];
- }
- if (value.hasOwnProperty('identifier')) {
- $("#NCT").css("display", "flex");
- identifier = value['identifier']['value'];
- }
- if (value.hasOwnProperty('type')) {
- $("#OGTD").css("display", "flex");
- type = "<a href='" + value['uriType']['value'] + "'>" + value['type']['value'] + "</a>";
- }
- if (value.hasOwnProperty('current_owner')) {
- $("#LDCN").css("display", "flex");
- current_owner = "<a href='" + value['uriOwner']['value'] + "'>" + value['current_owner']['value'] + "</a>";
- }
- if (value.hasOwnProperty('current_location')) {
- $("#LDCS").css("display", "flex");
- current_location = value['current_location']['value'];
- }
- if (value.hasOwnProperty('subject')) {
- $("#SGTI").css("display", "flex");
- subject = value['subject']['value'];
- }
- if (value.hasOwnProperty('dimensions')) {
- if (value['dimensions']['value'] != "") {
- $("#MIS").css("display", "flex");
- dimensions = value['dimensions']['value'];
- }
- }
- if (value.hasOwnProperty('condition')) {
- $("#STCC").css("display", "flex");
- condition = value['condition']['value'];
- }
- if (value.hasOwnProperty('note')) {
- $("#NSC").css("display", "flex");
- note = value['note']['value'];
- }
- if (value.hasOwnProperty('Materials')) {
- if (value['Materials']['value'] != "") {
- $("#MTC").css("display", "flex");
- mm = value['Materials']['value'];
- mat = mm.split("<br />");
- for (i in mat) {
- slice = mat[i].split("; ");
- materials += "<a href='" + slice[0] + "'>" + slice[1] + "</a><br />";
- }
- }
- }
- document.getElementById("grafo").innerHTML = graph;
- document.getElementById("nome_oggetto").innerHTML = label;
- document.getElementById("title").innerHTML = title;
- document.getElementById("identifier").innerHTML = identifier;
- document.getElementById("type").innerHTML = type;
- document.getElementById("owner").innerHTML = current_owner;
- document.getElementById("location").innerHTML = current_location;
- document.getElementById("subject").innerHTML = subject;
- document.getElementById("dimensions").innerHTML = dimensions;
- document.getElementById("materials").innerHTML = materials;
- document.getElementById("condition").innerHTML = condition;
- document.getElementById("description").innerHTML = note;
-
- });
-
- }
- function handle_Production(json) {
- console.log(json['results']['bindings']);
- $.each(
- json['results']['bindings'],
- function (index, value) {
- var partecipants = "";
- var teche = "";
- var time = "";
- var client = "";
- var artist = "";
- var artist_name = "";
-
- if (value.hasOwnProperty('techniques')) {
- if (value['techniques']['value'] != "") {
- $("#MTC").css("display", "flex");
- tt = value['techniques']['value'];
- tec = tt.split("<br />");
- for (i in tec) {
- slice = tec[i].split("; ");
- teche += "<a href='" + slice[0] + "'>" + slice[1] + "</a><br />";
- }
- }
- }
- if (value.hasOwnProperty('Partecipants')) {
- pp = value['Partecipants']['value'];
- people = pp.split("<br />");
- for (i in people) {
- slice = people[i].split("; ");
- if (slice[2] == "Committente") {
- $("#CMM").css("display", "flex");
- client += slice[1];
- } else {
- $("#AUT").css("display", "flex");
- artist_name += slice[1];
- artist += "<div class='d-flex'><div class='mr-3'>" +
- slice[1] + "</div><div class='d-flex ml-auto'><div class='mr-3'><a target='_blank' href='" +
- slice[0] + "'><i class='fas fa-external-link-alt' aria-hidden='true'></i></a></div><div class='persona' id='" +
- slice[0] + "'><i class='fa fa-user' style='cursor:pointer'></i></div></div></div></div>";
- }
- }
- }
-
- if (value.hasOwnProperty('time')) {
- time = value['time']['value'];
- }
-
-
- document.getElementById("technique").innerHTML = teche;
- document.getElementById("time").innerHTML = time;
- document.getElementById("artist_name").innerHTML = artist_name;
- document.getElementById("artist").innerHTML = artist;
- document.getElementById("client").innerHTML = client;
-
- });
-
- }
- $(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);
-
- });
|