forked from ontoportal/ontologies_linked_data
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
merged PR #153 that adds the ontology IRI metadata attribute
- Loading branch information
Showing
3 changed files
with
48 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
lib/ontologies_linked_data/concerns/ontology_submissions/submission_metadata_extractor.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
module LinkedData | ||
module Concerns | ||
module OntologySubmission | ||
module MetadataExtractor | ||
|
||
def extract_metadata | ||
version_info = extract_version | ||
ontology_iri = extract_ontology_iri | ||
|
||
self.version = version_info if version_info | ||
self.uri = ontology_iri if ontology_iri | ||
|
||
end | ||
|
||
def extract_version | ||
query = Goo.sparql_query_client.select(:versionInfo).distinct | ||
.from(self.id) | ||
.where([RDF::URI.new('http://bioportal.bioontology.org/ontologies/versionSubject'), | ||
RDF::URI.new('http://www.w3.org/2002/07/owl#versionInfo'), | ||
:versionInfo]) | ||
|
||
sol = query.each_solution.first || {} | ||
sol[:versionInfo]&.to_s | ||
end | ||
|
||
def extract_ontology_iri | ||
query = Goo.sparql_query_client.select(:uri).distinct | ||
.from(self.id) | ||
.where([:uri, | ||
RDF::URI.new('http://www.w3.org/1999/02/22-rdf-syntax-ns#type'), | ||
RDF::URI.new('http://www.w3.org/2002/07/owl#Ontology')]) | ||
sol = query.each_solution.first || {} | ||
sol[:uri]&.to_s | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters