diff --git a/Gemfile b/Gemfile index 8832064f..393bb442 100644 --- a/Gemfile +++ b/Gemfile @@ -46,9 +46,8 @@ gem 'ncbo_annotator', github: 'ncbo/ncbo_annotator', branch: 'develop' gem 'ncbo_cron', github: 'ncbo/ncbo_cron', branch: 'develop' gem 'ncbo_ontology_recommender', github: 'ncbo/ncbo_ontology_recommender', branch: 'develop' gem 'sparql-client', github: 'ncbo/sparql-client', branch: 'develop' -gem 'goo', github: 'ncbo/goo', branch: 'multilingual_preflabels' -gem 'ontologies_linked_data', github: 'ncbo/ontologies_linked_data', branch: 'develop' - +gem 'goo', github: 'ncbo/goo', branch: 'develop' +gem 'ontologies_linked_data', github: 'ncbo/ontologies_linked_data', branch: 'multilingual_preflabels' group :development do # bcrypt_pbkdf and ed35519 is required for capistrano deployments when using ed25519 keys; see https://github.com/miloserdow/capistrano-deploy/issues/42 diff --git a/Gemfile.lock b/Gemfile.lock index 524508ed..26e296d3 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,7 +1,7 @@ GIT remote: https://github.com/ncbo/goo.git - revision: a27d6ca79d47eb045b1bdfe311531827428aa504 - branch: multilingual_preflabels + revision: 35721855ba808517698d8b94eb38d4553001c4b6 + branch: develop specs: goo (0.0.2) addressable (~> 2.8) @@ -27,7 +27,7 @@ GIT GIT remote: https://github.com/ncbo/ncbo_cron.git - revision: a9e8bf81b314b0a5f8a32ed814f1b6943496c1ee + revision: 9d1b6ba54019cac2eeeb5c173e452b4eebbeaa3a branch: develop specs: ncbo_cron (0.0.1) @@ -45,7 +45,7 @@ GIT GIT remote: https://github.com/ncbo/ncbo_ontology_recommender.git - revision: 084cfc74a78b1c6334f3b74e228ddbf80d36e30a + revision: f92a42f660635522eb8709e618ff2e641aef0d17 branch: develop specs: ncbo_ontology_recommender (0.0.1) @@ -56,8 +56,8 @@ GIT GIT remote: https://github.com/ncbo/ontologies_linked_data.git - revision: 3aadf69fa004886b8e08830003788d09e9d550d5 - branch: develop + revision: 0598b9f6e8a37a42938f1db8648ff1b3355be519 + branch: multilingual_preflabels specs: ontologies_linked_data (0.0.1) activesupport @@ -153,9 +153,8 @@ GEM net-http (>= 0.5.0) faraday-retry (2.2.1) faraday (~> 2.0) - ffi (1.17.0-aarch64-linux-gnu) + ffi (1.17.0) ffi (1.17.0-arm64-darwin) - ffi (1.17.0-x86_64-linux-gnu) gapic-common (0.23.0) faraday (>= 1.9, < 3.a) faraday-retry (>= 1.0, < 3.a) @@ -235,7 +234,7 @@ GEM mime-types-data (~> 3.2015) mime-types-data (3.2024.1105) mini_mime (1.1.5) - minitest (5.25.1) + minitest (5.25.2) minitest-hooks (1.5.2) minitest (> 5.3) minitest-stub_any_instance (1.0.3) @@ -260,7 +259,7 @@ GEM net-protocol net-ssh (7.3.0) netrc (0.11.0) - newrelic_rpm (9.15.0) + newrelic_rpm (9.16.0) oj (3.16.7) bigdecimal (>= 3.0) ostruct (>= 0.2) @@ -399,6 +398,7 @@ GEM PLATFORMS aarch64-linux arm64-darwin-22 + arm64-darwin-23 x86_64-linux DEPENDENCIES @@ -456,4 +456,4 @@ DEPENDENCIES webrick BUNDLED WITH - 2.5.7 + 2.5.11 diff --git a/test/controllers/test_classes_controller.rb b/test/controllers/test_classes_controller.rb index 69ae98a0..838385d7 100644 --- a/test/controllers/test_classes_controller.rb +++ b/test/controllers/test_classes_controller.rb @@ -106,8 +106,7 @@ def test_all_class_pages assert last_response.ok? count_terms = count_terms + page_response["collection"].length end while page_response["nextPage"] - #bnodes thing got fixed. changed to 486. - assert_equal 486, count_terms + assert_equal 487, count_terms #one more page should bring no results call = "/ontologies/#{ont.acronym}/classes" @@ -295,42 +294,43 @@ def test_descendants_for_cls descendants_data = {} descendants_data['http://bioontology.org/ontologies/ResearchArea.owl#Area_of_Research'] =[ "http://bioontology.org/ontologies/ResearchArea.owl#Behavioral_Science", - "http://bioontology.org/ontologies/ResearchArea.owl#Bioinformatics", - "http://bioontology.org/ontologies/ResearchArea.owl#Biostatistics", - "http://bioontology.org/ontologies/ResearchArea.owl#Clinical_Studies", - "http://bioontology.org/ontologies/ResearchArea.owl#Computational_Biology", - "http://bioontology.org/ontologies/ResearchArea.owl#Epidemiology", - "http://bioontology.org/ontologies/ResearchArea.owl#Genomics", - "http://bioontology.org/ontologies/ResearchArea.owl#Metabolomics", - "http://bioontology.org/ontologies/ResearchArea.owl#Nursing", - "http://bioontology.org/ontologies/ResearchArea.owl#Outcomes_Research", - "http://bioontology.org/ontologies/ResearchArea.owl#Pathology", - "http://bioontology.org/ontologies/ResearchArea.owl#Pediatrics", - "http://bioontology.org/ontologies/ResearchArea.owl#Pharmacokinetics_Pharmacodynamics", - "http://bioontology.org/ontologies/ResearchArea.owl#Physiology", - "http://bioontology.org/ontologies/ResearchArea.owl#Preclinical", - "http://bioontology.org/ontologies/ResearchArea.owl#Proteomics", - "http://bioontology.org/ontologies/ResearchArea.owl#Psychometrics", - "http://bioontology.org/ontologies/ResearchArea.owl#Research_IT", - "http://bioontology.org/ontologies/ResearchArea.owl#Toxicology"] + "http://bioontology.org/ontologies/ResearchArea.owl#Bioinformatics", + "http://bioontology.org/ontologies/ResearchArea.owl#Biostatistics", + "http://bioontology.org/ontologies/ResearchArea.owl#Clinical_Studies", + "http://bioontology.org/ontologies/ResearchArea.owl#Computational_Biology", + "http://bioontology.org/ontologies/ResearchArea.owl#Epidemiology", + "http://bioontology.org/ontologies/ResearchArea.owl#Genomics", + "http://bioontology.org/ontologies/ResearchArea.owl#Metabolomics", + "http://bioontology.org/ontologies/ResearchArea.owl#Nursing", + "http://bioontology.org/ontologies/ResearchArea.owl#Outcomes_Research", + "http://bioontology.org/ontologies/ResearchArea.owl#Pathology", + "http://bioontology.org/ontologies/ResearchArea.owl#Pediatrics", + "http://bioontology.org/ontologies/ResearchArea.owl#Pharmacokinetics_Pharmacodynamics", + "http://bioontology.org/ontologies/ResearchArea.owl#Physiology", + "http://bioontology.org/ontologies/ResearchArea.owl#Preclinical", + "http://bioontology.org/ontologies/ResearchArea.owl#Proteomics", + "http://bioontology.org/ontologies/ResearchArea.owl#Psychometrics", + "http://bioontology.org/ontologies/ResearchArea.owl#Research_IT", + "http://bioontology.org/ontologies/ResearchArea.owl#Toxicology"] descendants_data['http://bioontology.org/ontologies/Activity.owl#Activity'] = ["http://bioontology.org/ontologies/Activity.owl#Biospecimen_Management", - "http://bioontology.org/ontologies/Activity.owl#Community_Engagement", - "http://bioontology.org/ontologies/Activity.owl#Gene_Therapy", - "http://bioontology.org/ontologies/Activity.owl#Health_Services", - "http://bioontology.org/ontologies/Activity.owl#IRB", - "http://bioontology.org/ontologies/Activity.owl#Medical_Device_Development", - "http://bioontology.org/ontologies/Activity.owl#Regulatory_Compliance", - "http://bioontology.org/ontologies/Activity.owl#Research_Funding", - "http://bioontology.org/ontologies/Activity.owl#Research_Lab_Management", - "http://bioontology.org/ontologies/Activity.owl#Resource_Inventory", - "http://bioontology.org/ontologies/Activity.owl#Small_Molecule", - "http://bioontology.org/ontologies/Activity.owl#Social_Networking", - "http://bioontology.org/ontologies/Activity.owl#Software_Development", - "http://bioontology.org/ontologies/Activity.owl#Surgical_Procedure", - "http://bioontology.org/ontologies/Activity.owl#Therapeutics", - "http://bioontology.org/ontologies/Activity.owl#Training"] + "http://bioontology.org/ontologies/Activity.owl#Catalog", + "http://bioontology.org/ontologies/Activity.owl#Community_Engagement", + "http://bioontology.org/ontologies/Activity.owl#Gene_Therapy", + "http://bioontology.org/ontologies/Activity.owl#Health_Services", + "http://bioontology.org/ontologies/Activity.owl#IRB", + "http://bioontology.org/ontologies/Activity.owl#Medical_Device_Development", + "http://bioontology.org/ontologies/Activity.owl#Regulatory_Compliance", + "http://bioontology.org/ontologies/Activity.owl#Research_Funding", + "http://bioontology.org/ontologies/Activity.owl#Research_Lab_Management", + "http://bioontology.org/ontologies/Activity.owl#Resource_Inventory", + "http://bioontology.org/ontologies/Activity.owl#Small_Molecule", + "http://bioontology.org/ontologies/Activity.owl#Social_Networking", + "http://bioontology.org/ontologies/Activity.owl#Software_Development", + "http://bioontology.org/ontologies/Activity.owl#Surgical_Procedure", + "http://bioontology.org/ontologies/Activity.owl#Therapeutics", + "http://bioontology.org/ontologies/Activity.owl#Training"] clss_ids = [ 'http://bioontology.org/ontologies/Activity.owl#Activity', "http://bioontology.org/ontologies/ResearchArea.owl#Area_of_Research" ] @@ -514,8 +514,7 @@ def test_class_page_with_metric_count assert last_response.ok? count_terms = count_terms + page_response["collection"].length end while page_response["nextPage"] - #bnodes thing got fixed. changed to 486. - assert_equal 486, count_terms + assert_equal 487, count_terms #one more page should bring no results call = "/ontologies/#{ont.acronym}/classes" @@ -526,7 +525,7 @@ def test_class_page_with_metric_count assert page_response["collection"].length == 0 end - def test_default_multilingual + def test_multilingual ont = Ontology.find("TEST-ONT-0").include(:acronym).first sub = ont.latest_submission sub.bring_remaining @@ -561,10 +560,54 @@ def test_default_multilingual assert last_response.ok? page_response = MultiJson.load(last_response.body) # show french value as specified in submission naturalLanguage - assert_equal 'Biospecimen Management', page_response["prefLabel"] + assert_equal 'Gestion des échantillons biologiques', page_response["prefLabel"] sub.naturalLanguage = [] sub.save + + # prefLabel NOT present, rdfs:label is defined in multiple languages, default portal language + get "/ontologies/#{ont.acronym}/classes/#{CGI.escape('http://bioontology.org/ontologies/Activity.owl#Catalog')}?lang=all" + assert last_response.ok? + page_response = MultiJson.load(last_response.body) + assert_equal 'Catalog', page_response["prefLabel"]["en"] + assert_equal 'Catalogo', page_response["prefLabel"]["it"] + assert_equal 'Catalogue', page_response["prefLabel"]["fr"] + assert_equal 'Catálogo', page_response["prefLabel"]["es"] + assert_equal 'カタログ', page_response["prefLabel"]["ja"] + + # prefLabel NOT present, rdfs:label is defined in multiple languages, + # portal language is set to one of the defined languages + sub.naturalLanguage = ['ja'] + sub.save + get "/ontologies/#{ont.acronym}/classes/#{CGI.escape('http://bioontology.org/ontologies/Activity.owl#Catalog')}" + assert last_response.ok? + page_response = MultiJson.load(last_response.body) + # show Japanese value as specified in submission naturalLanguage + assert_equal 'カタログ', page_response["prefLabel"] + + sub.naturalLanguage = [] + sub.save + + # prefLabel NOT present, multiple rdfs:label(s) are defined with no language designation + get "/ontologies/#{ont.acronym}/classes/#{CGI.escape('http://bioontology.org/ontologies/Activity.owl#Regulatory_Compliance')}" + assert last_response.ok? + page_response = MultiJson.load(last_response.body) + assert_equal 'Regulatory Compliance', page_response["prefLabel"] + + # prefLabel is defined in a non-language format as well as in French and Italian - default check with no language requested + get "/ontologies/#{ont.acronym}/classes/#{CGI.escape('http://bioontology.org/ontologies/Activity.owl#Research_Lab_Management')}" + assert last_response.ok? + page_response = MultiJson.load(last_response.body) + assert_equal 'Research Lab Management', page_response["prefLabel"] + + # prefLabel is defined in a non-language format as well as in French and Italian - all languages are requested + get "/ontologies/#{ont.acronym}/classes/#{CGI.escape('http://bioontology.org/ontologies/Activity.owl#Research_Lab_Management')}?lang=all" + assert last_response.ok? + page_response = MultiJson.load(last_response.body) + + assert_equal 'Research Lab Management', page_response["prefLabel"]["none"] + assert_equal 'Gestion du laboratoire de recherche', page_response["prefLabel"]["fr"] + assert_equal 'Gestione del laboratorio di ricerca', page_response["prefLabel"]["it"] end end diff --git a/test/controllers/test_metrics_controller.rb b/test/controllers/test_metrics_controller.rb index 0d8b547d..8031d967 100644 --- a/test/controllers/test_metrics_controller.rb +++ b/test/controllers/test_metrics_controller.rb @@ -9,15 +9,15 @@ def before_suite end OntologySubmission.all.each {|s| s.delete } Ontology.all.each {|o| o.delete } - @@data = {"classes"=>486, - "averageChildCount"=>5, - "maxChildCount"=>65, - "classesWithOneChild"=>14, - "classesWithMoreThan25Children"=>2, - "classesWithNoDefinition"=>11, - "individuals"=>124, - "properties"=>63, - "maxDepth"=> 7 } + @@data = {"classes" => 487, + "averageChildCount" => 5, + "maxChildCount" => 65, + "classesWithOneChild" => 14, + "classesWithMoreThan25Children" => 2, + "classesWithNoDefinition" => 11, + "individuals" => 124, + "properties" => 63, + "maxDepth" => 7 } @@options = { ont_count: 2, submission_count: 3, submissions_to_process: [1, 2], @@ -35,8 +35,8 @@ def test_all_metrics #TODO: improve this test and test for two different ontologies #though this is tested in LD metrics.each do |m| - @@data.each do |k,v| - assert_equal(m[k], v) + @@data.each do |k, v| + assert_equal(v, m[k]) end assert m["@id"] == m["submission"].first + "/metrics" end @@ -49,27 +49,29 @@ def test_single_metrics metrics = MultiJson.load(last_response.body) @@data.each do |k,v| - assert_equal(metrics[k], v) + assert_equal(v, metrics[k]) end end def test_metrics_with_submission_id ontology = 'TEST-ONT-0' - get "/ontologies/#{ontology}/submissions/1/metrics" + get "/ontologies/#{ontology}/submissions/2/metrics" assert last_response.ok? metrics = MultiJson.load(last_response.body) + @@data.each do |k,v| - assert_equal(metrics[k], v) + assert_equal(v, metrics[k]) end end def test_metrics_with_submission_id_as_param ontology = 'TEST-ONT-0' - get "/ontologies/#{ontology}/metrics?submissionId=1" + get "/ontologies/#{ontology}/metrics?ontology_submission_id=2" assert last_response.ok? metrics = MultiJson.load(last_response.body) + @@data.each do |k,v| - assert_equal(metrics[k], v) + assert_equal(v, metrics[k]) end end