Skip to content

Commit

Permalink
Merge pull request #148 from ontoportal-lirmm/development
Browse files Browse the repository at this point in the history
Merge to master: Release 2.5.2
  • Loading branch information
syphax-bouazzouni authored Aug 5, 2024
2 parents e785635 + 552fbe5 commit 5f58b03
Show file tree
Hide file tree
Showing 13 changed files with 89 additions and 82 deletions.
5 changes: 2 additions & 3 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ gem 'addressable', '~> 2.8'
gem 'bcrypt', '~> 3.0'
gem 'cube-ruby', require: 'cube'
gem 'faraday', '~> 1.9'
gem 'ffi'
gem 'ffi', '~> 1.16.3'
gem 'libxml-ruby', '~> 2.0'
gem 'minitest'
gem 'multi_json', '~> 1.0'
gem 'oj', '~> 2.0'
gem 'oj'
gem 'omni_logger'
gem 'pony'
gem 'rack', '~> 1.0'
Expand Down Expand Up @@ -42,4 +42,3 @@ end
# NCBO gems (can be from a local dev path or from rubygems/git)
gem 'goo', github: 'ontoportal-lirmm/goo', branch: 'development'
gem 'sparql-client', github: 'ontoportal-lirmm/sparql-client', branch: 'development'

58 changes: 30 additions & 28 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
GIT
remote: https://github.com/ontoportal-lirmm/goo.git
revision: 8f0a9a5bddba03d9d660a363c4e6618da479db9f
revision: a95245b8c964431505ca6315907440996c59a00d
branch: development
specs:
goo (0.0.2)
Expand All @@ -18,7 +18,7 @@ GIT

GIT
remote: https://github.com/ontoportal-lirmm/sparql-client.git
revision: c96da3ad479724a31ccd6217ab9939dddfaca40e
revision: 59251e59346c9a69a67c88552ba55a1244eec602
branch: development
specs:
sparql-client (3.2.2)
Expand All @@ -34,16 +34,16 @@ GEM
multi_json (~> 1.3)
thread_safe (~> 0.1)
tzinfo (~> 0.3.37)
addressable (2.8.6)
public_suffix (>= 2.0.2, < 6.0)
addressable (2.8.7)
public_suffix (>= 2.0.2, < 7.0)
ansi (1.5.0)
ast (2.4.2)
base64 (0.2.0)
bcrypt (3.1.20)
bigdecimal (3.1.7)
builder (3.2.4)
bigdecimal (3.1.8)
builder (3.3.0)
coderay (1.1.3)
concurrent-ruby (1.2.3)
concurrent-ruby (1.3.3)
connection_pool (2.4.1)
crack (1.0.0)
bigdecimal
Expand Down Expand Up @@ -86,15 +86,15 @@ GEM
hashie (5.0.0)
htmlentities (4.3.4)
http-accept (1.7.0)
http-cookie (1.0.5)
http-cookie (1.0.6)
domain_name (~> 0.5)
i18n (0.9.5)
concurrent-ruby (~> 1.0)
json (2.7.2)
json-ld (3.0.2)
multi_json (~> 1.12)
rdf (>= 2.2.8, < 4.0)
jwt (2.8.1)
jwt (2.8.2)
base64
language_server-protocol (3.17.0.3)
launchy (2.5.2)
Expand All @@ -112,7 +112,7 @@ GEM
method_source (1.1.0)
mime-types (3.5.2)
mime-types-data (~> 3.2015)
mime-types-data (3.2024.0305)
mime-types-data (3.2024.0604)
mini_mime (1.1.5)
minitest (4.7.5)
minitest-reporters (0.14.24)
Expand All @@ -121,10 +121,10 @@ GEM
minitest (>= 2.12, < 5.0)
powerbar
multi_json (1.15.0)
multipart-post (2.4.0)
multipart-post (2.4.1)
net-http-persistent (4.0.2)
connection_pool (~> 2.2)
net-imap (0.4.10)
net-imap (0.4.14)
date
net-protocol
net-pop (0.1.2)
Expand All @@ -134,11 +134,12 @@ GEM
net-smtp (0.5.0)
net-protocol
netrc (0.11.0)
oj (2.18.5)
oj (3.16.4)
bigdecimal (>= 3.0)
omni_logger (0.1.4)
logger
parallel (1.24.0)
parser (3.3.1.0)
parallel (1.25.1)
parser (3.3.3.0)
ast (~> 2.4.1)
racc
pony (1.13.1)
Expand All @@ -148,8 +149,8 @@ GEM
pry (0.14.2)
coderay (~> 1.1)
method_source (~> 1.0)
public_suffix (5.0.5)
racc (1.7.3)
public_suffix (5.1.1)
racc (1.8.0)
rack (1.6.13)
rack-test (0.8.3)
rack (>= 1.0, < 3)
Expand All @@ -172,20 +173,21 @@ GEM
rexml (~> 3.2)
redis (5.2.0)
redis-client (>= 0.22.0)
redis-client (0.22.1)
redis-client (0.22.2)
connection_pool
regexp_parser (2.9.0)
request_store (1.6.0)
regexp_parser (2.9.2)
request_store (1.7.0)
rack (>= 1.4)
rest-client (2.1.0)
http-accept (>= 1.7.0, < 2.0)
http-cookie (>= 1.0.2, < 2.0)
mime-types (>= 1.16, < 4.0)
netrc (~> 0.8)
rexml (3.2.6)
rexml (3.3.1)
strscan
rsolr (1.1.2)
builder (>= 2.1.2)
rubocop (1.63.4)
rubocop (1.64.1)
json (~> 2.3)
language_server-protocol (>= 3.17.0)
parallel (~> 1.10)
Expand All @@ -210,6 +212,7 @@ GEM
simplecov (~> 0.19)
simplecov-html (0.12.3)
simplecov_json_formatter (0.1.4)
strscan (3.1.0)
systemu (2.6.5)
test-unit-minitest (0.9.1)
minitest (~> 4.7)
Expand All @@ -223,14 +226,13 @@ GEM
unicode-display_width (2.5.0)
uuid (2.3.9)
macaddr (~> 1.0)
webmock (3.23.0)
webmock (3.23.1)
addressable (>= 2.8.0)
crack (>= 0.3.2)
hashdiff (>= 0.4.0, < 2.0.0)

PLATFORMS
x86_64-darwin-23
x86_64-linux
ruby

DEPENDENCIES
activesupport (~> 4)
Expand All @@ -239,15 +241,15 @@ DEPENDENCIES
cube-ruby
email_spec
faraday (~> 1.9)
ffi
ffi (~> 1.16.3)
goo!
json-ld (~> 3.0.2)
jwt
libxml-ruby (~> 2.0)
minitest
minitest-reporters (>= 0.5.0)
multi_json (~> 1.0)
oj (~> 2.0)
oj
omni_logger
parallel (~> 1.24)
pony
Expand All @@ -268,4 +270,4 @@ DEPENDENCIES
webmock

BUNDLED WITH
2.4.22
2.1.4
Original file line number Diff line number Diff line change
Expand Up @@ -46,31 +46,6 @@ def deprecated?(inst = self)
module Validators
include ValidatorsHelpers

def enforce_agent_type(values, type, attr)
Array(values).each do |aff|
error = ["is_#{type}", "`#{attr}` must contain only agents of type #{type.capitalize}"]

return error unless aff.is_a?(LinkedData::Models::Agent)

aff.bring(:agentType) if aff.bring?(:agentType)
return error unless aff.agentType&.eql?(type)
end
[]
end

def is_organization(inst, attr)
inst.bring(attr) if inst.bring?(attr)
affiliations = inst.send(attr)

enforce_agent_type(affiliations, 'organization', attr)
end

def is_person(inst, attr)
inst.bring(attr) if inst.bring?(attr)
persons = inst.send(attr)
enforce_agent_type(persons, 'person', attr)
end

def lexvo_language(inst, attr)
values = Array(attr_value(inst, attr))

Expand Down Expand Up @@ -290,7 +265,7 @@ def uri_lookup_default(sub)
end

def data_dump_default(sub)
RDF::URI.new("#{LinkedData.settings.rest_url_prefix}ontologies/#{sub.ontology.acronym}/download?download_format=rdf")
RDF::URI.new("#{LinkedData.settings.rest_url_prefix}ontologies/#{sub.ontology.acronym}/download")
end

def csv_dump_default(sub)
Expand All @@ -316,4 +291,3 @@ def default_hierarchy_property(sub)
end
end
end

2 changes: 1 addition & 1 deletion lib/ontologies_linked_data/models/class.rb
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ def index_doc(to_set=nil)
if cur_val.is_a?(Hash) # Multi language
if multi_language_fields.include?(att)
doc[att] = cur_val.values.flatten # index all values of each language
cur_val.each { |lang, values| doc["#{att}_#{lang}".to_sym] = values } # index values per language
cur_val.each { |lang, values| doc["#{att}_#{lang.to_s.gsub('@', '')}".to_sym] = values } # index values per language
else
doc[att] = cur_val.values.flatten.first
end
Expand Down
6 changes: 4 additions & 2 deletions lib/ontologies_linked_data/models/ontology.rb
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ class OntologyAnalyticsError < StandardError; end
LinkedData::Hypermedia::Link.new("download", lambda {|s| "ontologies/#{s.acronym}/download"}, self.type_uri),
LinkedData::Hypermedia::Link.new("views", lambda {|s| "ontologies/#{s.acronym}/views"}, self.type_uri),
LinkedData::Hypermedia::Link.new("analytics", lambda {|s| "ontologies/#{s.acronym}/analytics"}, "#{Goo.namespaces[:metadata].to_s}Analytics"),
LinkedData::Hypermedia::Link.new("agents", lambda {|s| "ontologies/#{s.acronym}/agents"}, LinkedData::Models::Agent.uri_type),
LinkedData::Hypermedia::Link.new("ui", lambda {|s| "http://#{LinkedData.settings.ui_host}/ontologies/#{s.acronym}"}, self.uri_type)

# Access control
Expand Down Expand Up @@ -304,17 +305,18 @@ def property_roots(sub=nil, extra_include=[])
LinkedData::Models::OntologyProperty.sort_properties(all_roots)
end

def property(prop_id, sub=nil)
def property(prop_id, sub=nil, display_all_attributes: false)
p = nil
sub ||= latest_submission(status: [:rdf])
self.bring(:acronym) if self.bring?(:acronym)
raise ParsedSubmissionError, "The properties of ontology #{self.acronym} cannot be retrieved because it has not been successfully parsed" unless sub
prop_classes = [LinkedData::Models::ObjectProperty, LinkedData::Models::DatatypeProperty, LinkedData::Models::AnnotationProperty]

prop_classes.each do |c|
p = c.find(prop_id).in(sub).include(:label, :definition, :parents).first
p = c.find(prop_id).in(sub).include(:label, :definition, :parents,:domain, :range).first

unless p.nil?
p.bring(:unmapped) if display_all_attributes
p.load_has_children
parents = p.parents.nil? ? [] : p.parents.dup
c.in(sub).models(parents).include(:label, :definition).all()
Expand Down
10 changes: 5 additions & 5 deletions lib/ontologies_linked_data/models/ontology_submission.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class OntologySubmission < LinkedData::Models::Base
attribute :classType, type: :uri
attribute :hierarchyProperty, type: :uri, default: ->(s) { default_hierarchy_property(s) }
attribute :obsoleteProperty, type: :uri, default: ->(s) { Goo.vocabulary(:owl)[:deprecated] }
attribute :obsoleteParent, type: :uri, default: ->(s) { RDF::URI.new("http://www.geneontology.org/formats/oboInOwl#ObsoleteClass") }
attribute :obsoleteParent, type: :uri
attribute :createdProperty, type: :uri, default: ->(s) { Goo.vocabulary(:dc)[:created] }
attribute :modifiedProperty, type: :uri, default: ->(s) { Goo.vocabulary(:dc)[:modified] }

Expand Down Expand Up @@ -81,12 +81,12 @@ class OntologySubmission < LinkedData::Models::Base

# Person and organizations metadata
attribute :contact, type: %i[contact list], enforce: [:existence]
attribute :hasCreator, namespace: :omv, type: %i[list Agent], enforce: [:is_person]
attribute :hasContributor, namespace: :omv, type: %i[list Agent], enforce: [:is_person]
attribute :hasCreator, namespace: :omv, type: %i[list Agent]
attribute :hasContributor, namespace: :omv, type: %i[list Agent]
attribute :curatedBy, namespace: :pav, type: %i[list Agent]
attribute :publisher, namespace: :dct, type: %i[list Agent]
attribute :fundedBy, namespace: :foaf, type: %i[list Agent], enforce: [:is_organization]
attribute :endorsedBy, namespace: :omv, type: %i[list Agent], enforce: [:is_organization]
attribute :fundedBy, namespace: :foaf, type: %i[list Agent]
attribute :endorsedBy, namespace: :omv, type: %i[list Agent]
attribute :translator, namespace: :schema, type: %i[list Agent]

# Community metadata
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,12 @@ class AnnotationProperty < LinkedData::Models::OntologyProperty
attribute :children, namespace: :rdfs, inverse: { on: :annotation_property, :attribute => :parents }
attribute :ancestors, namespace: :rdfs, property: :subPropertyOf, handler: :retrieve_ancestors
attribute :descendants, namespace: :rdfs, property: :subPropertyOf, handler: :retrieve_descendants
# attribute :domain
# attribute :range
attribute :domain, namespace: :rdfs
attribute :range, namespace: :rdfs

serialize_default :label, :labelGenerated, :definition, :matchType, :ontologyType, :propertyType, :parents, :children, :hasChildren # some of these attributes are used in Search (not shown out of context)
serialize_default :label, :labelGenerated, :definition, :matchType, :ontologyType, :propertyType, :parents, :children, :hasChildren,:domain, :range # some of these attributes are used in Search (not shown out of context)
aggregates childrenCount: [:count, :children]
serialize_methods :properties
# this command allows the children to be serialized in the output
embed :children

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,12 @@ class DatatypeProperty < LinkedData::Models::OntologyProperty
attribute :children, namespace: :rdfs, inverse: { on: :datatype_property, :attribute => :parents }
attribute :ancestors, namespace: :rdfs, property: :subPropertyOf, handler: :retrieve_ancestors
attribute :descendants, namespace: :rdfs, property: :subPropertyOf, handler: :retrieve_descendants
# attribute :domain
# attribute :range
attribute :domain, namespace: :rdfs
attribute :range, namespace: :rdfs

serialize_default :label, :labelGenerated, :definition, :matchType, :ontologyType, :propertyType, :parents, :children, :hasChildren # some of these attributes are used in Search (not shown out of context)
serialize_default :label, :labelGenerated, :definition, :matchType, :ontologyType, :propertyType, :parents, :children, :hasChildren, :domain, :range # some of these attributes are used in Search (not shown out of context)
aggregates childrenCount: [:count, :children]
serialize_methods :properties
# this command allows the children to be serialized in the output
embed :children

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,12 @@ class ObjectProperty < LinkedData::Models::OntologyProperty
attribute :children, namespace: :rdfs, inverse: { on: :object_property, :attribute => :parents }
attribute :ancestors, namespace: :rdfs, property: :subPropertyOf, handler: :retrieve_ancestors
attribute :descendants, namespace: :rdfs, property: :subPropertyOf, handler: :retrieve_descendants
# attribute :domain
# attribute :range
attribute :domain, namespace: :rdfs
attribute :range, namespace: :rdfs

serialize_default :label, :labelGenerated, :definition, :matchType, :ontologyType, :propertyType, :parents, :children, :hasChildren # some of these attributes are used in Search (not shown out of context)
serialize_default :label, :labelGenerated, :definition, :matchType, :ontologyType, :propertyType, :parents, :children, :hasChildren, :domain, :range # some of these attributes are used in Search (not shown out of context)
aggregates childrenCount: [:count, :children]
serialize_methods :properties
# this command allows the children to be serialized in the output
embed :children

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@ def self.index_schema(schema_generator)
index_schema(schema_generator)
end


def properties
self.unmapped
end

def retrieve_ancestors
retrieve_ancestors_descendants(:ancestors)
Expand Down
8 changes: 4 additions & 4 deletions lib/ontologies_linked_data/utils/notifications.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ def self.new_note(note)
note.relatedOntology.each { |o| o.bring(:name) if o.bring?(:name); o.bring(:subscriptions) if o.bring?(:subscriptions) }
ontologies = note.relatedOntology.map { |o| o.name }.join(", ")
# Fix the note URL when using replace_url_prefix (in another VM than NCBO)

note_hash = note.id.to_s.split('/').last
note_url = "http://#{LinkedData.settings.ui_host}/notes/#{note_hash}"
note_url = "http://#{LinkedData.settings.ui_host}/ontologies/#{note.relatedOntology.first.acronym}?p=notes&noteid=#{note_hash}"


subject = "[#{LinkedData.settings.ui_name} Notes] [#{ontologies}] #{note.subject}"
body = NEW_NOTE.gsub("%username%", note.creator.username)
Expand Down Expand Up @@ -201,8 +201,8 @@ def self.obofoundry_sync(missing_onts, obsolete_onts)
EOS

REST_PASSWORD = <<~HTML
Someone has requested a password reset for user %username% . If this was
you, please click on the link below to reset your password. Otherwise, please
Someone has requested a password reset for user %username% . If this was
you, please click on the link below to reset your password. Otherwise, please
ignore this email.<br/><br/>
<a href="%password_url%">%password_url%</a><br/><br/>
Expand Down
Loading

0 comments on commit 5f58b03

Please sign in to comment.