Skip to content

Commit

Permalink
Merge to master: Release 2.4.3 - New metadata model (#97)
Browse files Browse the repository at this point in the history
* fix  json serializer nil exception (#79)

if hash was missing @context key the json serializer throwed a nil exception

* Merge pull request #72 from ontoportal-lirmm/feature/migrate-attrbiutes-metadata-to-scheme-file

Feature: Update ontology submission model 2023 - Part 1  -  Update attributes validators and metadata

* Merge pull request #82 from ontoportal-lirmm/feature/embed-meterics-for-submissions

Feature: embed metrics for submission model

* Merge pull request #86 from ontoportal-lirmm/fix/read_restricted_based_on-nil

Fix: call to read_restricted?  only if instance_to_base_on not nil

* Merge pull request #90 from ontoportal-lirmm/feature/add-persons-and-organization-models

Feature: Update ontology submission model 2023 - Part 2 - Add person & organization models

* in tests no more use the reload argument in the exist? method

---------

Co-authored-by: Raimi Solorzano Niederhausen <44089477+RaimiSol@users.noreply.github.com>
  • Loading branch information
syphax-bouazzouni and RaimiSol committed Dec 5, 2023
1 parent aa5081d commit c20e1d3
Show file tree
Hide file tree
Showing 25 changed files with 2,257 additions and 649 deletions.
1 change: 0 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ end
group :development do
gem 'rubocop', require: false
end

# NCBO gems (can be from a local dev path or from rubygems/git)
gem 'goo', github: 'ontoportal-lirmm/goo', branch: 'master'
gem 'sparql-client', github: 'ontoportal-lirmm/sparql-client', branch: 'master'
1 change: 1 addition & 0 deletions config/config.rb.sample
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ LinkedData.config do |config|
config.purl_password = ""
config.purl_maintainers = ""
config.purl_target_url_prefix = "http://bioportal.bioontology.org"
config.sparql_endpoint_url = "http:://sparql_endpoint.com"
Goo.configure do |conf|
conf.main_languages = ['en']
end
Expand Down
1 change: 1 addition & 0 deletions config/config.test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,6 @@
config.ontology_analytics_redis_port = REDIS_PORT.to_i
config.search_server_url = SOLR_TERM_SEARCH_URL.to_s
config.property_search_server_url = SOLR_PROP_SEARCH_URL.to_s
config.sparql_endpoint_url = "http:://sparql_endpoint.com"
# config.enable_notifications = false
end
1,155 changes: 1,155 additions & 0 deletions config/schemes/ontology_submission.yml

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,12 @@ def extract_metadata(logger, user_params)
logger.error("Error while setting default metadata: #{e}")
end

self.save
if self.valid?
self.save
else
logger.error("Error while extracting additional metadata: #{self.errors}")
end

end

def extract_version
Expand Down Expand Up @@ -101,85 +106,6 @@ def extract_ontology_metadata(logger, user_params)
# Set some metadata to default values if nothing extracted
def set_default_metadata

self.identifier = uri.to_s if identifier.nil?

self.deprecated = status.eql?('retired') if deprecated.nil?

# Add the ontology hasDomain to the submission hasDomain metadata value
ontology_domain_list = []
ontology.bring(:hasDomain).hasDomain.each do |domain|
ontology_domain_list << domain.id
end

self.hasDomain = '' if !ontology_domain_list.empty? && hasDomain.nil?

self.hasDomain << ontology_domain_list.join(', ') unless hasDomain.nil?

# Only get the first view because the attribute is not a list
ontology_view = ontology.bring(:views).views.first
self.hasPart = ontology_view.id if hasPart.nil? && !ontology_view.nil?

# If no example identifier extracted: take the first class
self.exampleIdentifier = LinkedData::Models::Class.in(self).first.id if exampleIdentifier.nil?

# Metadata specific to BioPortal that have been removed:
#if self.hostedBy.nil?
# self.hostedBy = [ RDF::URI.new("http://#{LinkedData.settings.ui_host}") ]
#end

# Add the search endpoint URL
if openSearchDescription.nil?
self.openSearchDescription = RDF::URI.new("#{LinkedData.settings.rest_url_prefix}search?ontologies=#{ontology.acronym}&q=")
end

# Search allow to search by URI too
if uriLookupEndpoint.nil?
self.uriLookupEndpoint = RDF::URI.new("#{LinkedData.settings.rest_url_prefix}search?ontologies=#{ontology.acronym}&require_exact_match=true&q=")
end

# Add the dataDump URL
if dataDump.nil?
self.dataDump = RDF::URI.new("#{LinkedData.settings.rest_url_prefix}ontologies/#{ontology.acronym}/download?download_format=rdf")
end

if csvDump.nil?
self.csvDump = RDF::URI.new("#{LinkedData.settings.rest_url_prefix}ontologies/#{ontology.acronym}/download?download_format=csv")
end

# Add the previous submission as a prior version
if submissionId > 1
=begin
if prior_versions.nil?
prior_versions = []
else
prior_versions = self.hasPriorVersion.dup
end
prior_versions.push(RDF::URI.new("#{LinkedData.settings.rest_url_prefix}ontologies/#{self.ontology.acronym}/submissions/#{self.submissionId - 1}"))
self.hasPriorVersion = prior_versions
=end
self.hasPriorVersion = RDF::URI.new("#{LinkedData.settings.rest_url_prefix}ontologies/#{ontology.acronym}/submissions/#{submissionId - 1}")
end

if hasOntologyLanguage.umls?
self.hasOntologySyntax = 'http://www.w3.org/ns/formats/Turtle'
elsif hasOntologyLanguage.obo?
self.hasOntologySyntax = 'http://purl.obolibrary.org/obo/oboformat/spec.html'
end

# Define default properties for prefLabel, synonyms, definition, author:
if hasOntologyLanguage.owl?
self.prefLabelProperty = Goo.vocabulary(:skos)[:prefLabel] if prefLabelProperty.nil?
self.synonymProperty = Goo.vocabulary(:skos)[:altLabel] if synonymProperty.nil?
self.definitionProperty = Goo.vocabulary(:rdfs)[:comment] if definitionProperty.nil?
self.authorProperty = Goo.vocabulary(:dc)[:creator] if authorProperty.nil?
# Add also hierarchyProperty? Could not find any use of it
end

# Add the sparql endpoint URL
if endpoint.nil? && LinkedData.settings.sparql_endpoint_url
self.endpoint = RDF::URI.new(LinkedData.settings.sparql_endpoint_url)
end

end

def empty_value?(value)
Expand Down Expand Up @@ -284,7 +210,8 @@ def extract_each_metadata(ontology_uri, attr, prop_to_extract, logger)
value = sol[:extractedObject]
if enforce?(attr, :uri)
# If the attr is enforced as URI then it directly takes the URI
hash_results[value] = value if value.is_a?(RDF::URI)
uri_value = value ? RDF::URI.new(value.to_s.strip) : nil
hash_results[value] = uri_value if uri_value&.valid?
elsif enforce?(attr, :date_time)
begin
hash_results[value] = DateTime.iso8601(value.to_s)
Expand Down
Loading

0 comments on commit c20e1d3

Please sign in to comment.