Class: RKD::Query::Sparql
- Inherits:
-
Object
- Object
- RKD::Query::Sparql
- Defined in:
- lib/r_k_d/query/sparql.rb
Constant Summary collapse
- ENDPOINT =
"https://rkd.triply.cc/_api/datasets/rkd/RKD-Knowledge-Graph/services/SPARQL/sparql"- BASE_QUERY =
<<~SPARQL PREFIX rkd: <https://data.rkd.nl/def#> PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> PREFIX skos: <http://www.w3.org/2004/02/skos/core#> PREFIX crm: <http://www.cidoc-crm.org/cidoc-crm/> prefix la: <https://linked.art/ns/terms/> SELECT ?property ?propertyLabel ?value ?symbolicContent ?prefLabel ?tookPlaceAt ?tookPlaceAtTimeSpan ?tookPlaceAtTimeSpanBegin ?tookPlaceAtTimeSpanEnd ?placePoint ?placeLabel ?placeRef ?timeSpan ?start ?end ?domain ?range ?studyLabel ?studyReference ?referenceContent WHERE { <https://data.rkd.nl/artists/{{rkd_id}}> ?property ?value. FILTER ( !(?property in (crm:P67i_is_referred_to_by, crm:P1_is_identified_by, crm:P62i_is_depicted_by, la:member_of)) ) OPTIONAL { ?property rdfs:label ?propertyLabel. FILTER (lang(?propertyLabel) = "en") } OPTIONAL { ?value crm:P190_has_symbolic_content ?symbolicContent } OPTIONAL { ?value skos:prefLabel ?prefLabel FILTER (lang(?prefLabel) = "en") } OPTIONAL { ?value crm:P7_took_place_at ?tookPlaceAt. ?value crm:P4_has_time-span ?timeSpan. ?tookPlaceAt crm:P168_place_is_defined_by ?placePoint. ?tookPlaceAt rdfs:label ?placeLabel. ?tookPlaceAt skos:exactMatch ?placeRef. ?timeSpan crm:P82a_begin_of_the_begin ?start. ?timeSpan crm:P82b_end_of_the_end ?end. } OPTIONAL { ?value crm:P7_took_place_at ?tookPlaceAt. ?tookPlaceAt rdfs:label ?placeLabel. ?tookPlaceAt skos:exactMatch ?placeRef. } OPTIONAL { ?value crm:P01i_is_domain_of ?domain. ?domain crm:P02_has_range ?range. ?range skos:prefLabel ?studyLabel. } OPTIONAL { ?value crm:P01i_is_domain_of ?domain. ?domain crm:P02_has_range ?range. ?value crm:P67i_is_referred_to_by ?studyReference. ?studyReference crm:P190_has_symbolic_content ?referenceContent } OPTIONAL { ?value crm:P4_has_time-span ?tookPlaceAtTimeSpan. ?tookPlaceAtTimeSpan crm:P82a_begin_of_the_begin ?tookPlaceAtTimeSpanBegin. ?tookPlaceAtTimeSpan crm:P82b_end_of_the_end ?tookPlaceAtTimeSpanEnd. } } SPARQL
Class Method Summary collapse
Class Method Details
.find(id) ⇒ Object
67 68 69 70 71 72 73 |
# File 'lib/r_k_d/query/sparql.rb', line 67 def find id data = FileCache.cache("sparql-#{id}") do HTTP.post_json ENDPOINT, {query: query(id)} end JSON.parse(data) end |
.query(id) ⇒ Object
63 64 65 |
# File 'lib/r_k_d/query/sparql.rb', line 63 def query id BASE_QUERY.sub("{{rkd_id}}", id.to_i.to_s) end |