Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: show multiple languages #8

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -43,4 +43,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'

71 changes: 30 additions & 41 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,11 +121,10 @@ GEM
minitest (>= 2.12, < 5.0)
powerbar
multi_json (1.15.0)
multi_xml (0.6.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 @@ -135,18 +134,12 @@ GEM
net-smtp (0.5.0)
net-protocol
netrc (0.11.0)
oauth2 (2.0.9)
faraday (>= 0.17.3, < 3.0)
jwt (>= 1.0, < 3.0)
multi_xml (~> 0.5)
rack (>= 1.2, < 4)
snaky_hash (~> 2.0)
version_gem (~> 1.1)
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 @@ -156,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 @@ -180,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 @@ -218,9 +212,7 @@ GEM
simplecov (~> 0.19)
simplecov-html (0.12.3)
simplecov_json_formatter (0.1.4)
snaky_hash (2.0.1)
hashie
version_gem (~> 1.1, >= 1.1.1)
strscan (3.1.0)
systemu (2.6.5)
test-unit-minitest (0.9.1)
minitest (~> 4.7)
Expand All @@ -234,15 +226,13 @@ GEM
unicode-display_width (2.5.0)
uuid (2.3.9)
macaddr (~> 1.0)
version_gem (1.1.4)
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 @@ -251,16 +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)
oauth2 (~> 2.0)
oj (~> 2.0)
oj
omni_logger
parallel (~> 1.24)
pony
Expand All @@ -281,4 +270,4 @@ DEPENDENCIES
webmock

BUNDLED WITH
2.4.22
2.1.4
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
7 changes: 4 additions & 3 deletions lib/ontologies_linked_data/models/users/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,11 @@ def save(*args)
OntologySubmission.cache_collection_invalidate
end

if args.include?(:send_notifications) && args[:send_notifications]
if args.first&.dig(:send_notifications)
begin
LinkedData::Utils::Notifications.new_user(user)
rescue Exception => e
LinkedData::Utils::Notifications.new_user(self)
rescue StandardError => e
puts "Error on user creation notification: #{e.message}"
end
end

Expand Down
9 changes: 4 additions & 5 deletions lib/ontologies_linked_data/utils/notifications.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,10 @@ 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)
if LinkedData.settings.replace_url_prefix == true
note_url = "http://#{LinkedData.settings.ui_host}/notes/#{CGI.escape(note.id.to_s.gsub("http://data.bioontology.org", LinkedData.settings.rest_url_prefix))}"
else
note_url = "http://#{LinkedData.settings.ui_host}/notes/#{CGI.escape(note.id.to_s)}"
end

note_hash = note.id.to_s.split('/').last
note_url = "http://#{LinkedData.settings.ui_host}/notes/#{note_hash}"

subject = "[#{LinkedData.settings.ui_name} Notes] [#{ontologies}] #{note.subject}"
body = NEW_NOTE.gsub("%username%", note.creator.username)
.gsub("%ontologies%", ontologies)
Expand Down
13 changes: 11 additions & 2 deletions test/models/test_class_request_lang.rb
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,15 @@ def test_requested_language_not_found
assert_empty properties.select { |x| x.to_s['prefLabel'] }.values
end

def test_request_multiple_languages

cls = get_class_by_lang('http://opendata.inrae.fr/thesaurusINRAE/c_22817',
requested_lang: [:EN, :FR])
pref_label_all_languages = { en: 'industrialization', fr: 'industrialisation' }
assert_includes pref_label_all_languages.values, cls.prefLabel
assert_equal pref_label_all_languages, cls.prefLabel(include_languages: true)
end

def test_request_all_languages

cls = get_class_by_lang('http://opendata.inrae.fr/thesaurusINRAE/c_22817',
Expand All @@ -86,9 +95,9 @@ def test_request_all_languages

properties = cls.properties(include_languages: true)

assert_equal synonym_all_languages.stringify_keys,
assert_equal synonym_all_languages,
properties.select { |x| x.to_s['altLabel'] }.values.first.transform_values{|v| v.map(&:object)}
assert_equal pref_label_all_languages.stringify_keys,
assert_equal pref_label_all_languages,
properties.select { |x| x.to_s['prefLabel'] }.values.first.transform_values{|v| v.first.object}
end

Expand Down
9 changes: 6 additions & 3 deletions test/models/test_ontology.rb
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,8 @@ def test_ontology_properties
ont.bring(:submissions)
sub = ont.submissions[0]
props = ont.properties()
assert_equal 83, props.length
#assert_equal 83, props.length
assert_equal 79, props.length

# verify sorting
assert_equal "http://bioontology.org/ontologies/BiomedicalResourceOntology.owl#AlgorithmPurpose", props[0].id.to_s
Expand Down Expand Up @@ -192,7 +193,8 @@ def test_ontology_properties

# test property roots
pr = ont.property_roots(sub, extra_include=[:hasChildren, :children])
assert_equal 62, pr.length
#assert_equal 62, pr.length
assert_equal 58, pr.length

# verify sorting
assert_equal "http://bioontology.org/ontologies/BiomedicalResourceOntology.owl#AlgorithmPurpose", pr[0].id.to_s
Expand All @@ -206,7 +208,8 @@ def test_ontology_properties
assert_equal 33, dpr.length
# count annotation properties
apr = pr.select { |p| p.class == LinkedData::Models::AnnotationProperty }
assert_equal 11, apr.length
#assert_equal 11, apr.length
assert_equal 7, apr.length
# check for non-root properties
assert_empty pr.select { |p| ["http://www.w3.org/2004/02/skos/core#broaderTransitive",
"http://www.w3.org/2004/02/skos/core#topConceptOf",
Expand Down
5 changes: 3 additions & 2 deletions test/models/test_ontology_submission.rb
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,8 @@ def test_index_properties
"./test/data/ontology_files/BRO_v3.5.owl", 1,
process_rdf: true, extract_metadata: false, index_properties: true)
res = LinkedData::Models::OntologyProperty.search("*:*", {:fq => "submissionAcronym:\"BRO\"", :start => 0, :rows => 80})
assert_includes [81, 52] , res["response"]["numFound"] # if 81 if owlapi import skos properties
#assert_equal 81, res["response"]["numFound"] # if 81 if owlapi import skos properties
assert_equal 77, res["response"]["numFound"] # if 81 if owlapi import skos properties
found = 0

res["response"]["docs"].each do |doc|
Expand Down Expand Up @@ -1149,4 +1150,4 @@ def test_submission_delete_remove_files
sub.delete
assert !Dir.exist?(data_folder)
end
end
end
Loading
Loading