From 09645da09177bd16033feb5f6e4db79432e8ac90 Mon Sep 17 00:00:00 2001 From: Imad Bourouche Date: Fri, 31 Jan 2025 10:38:49 +0100 Subject: [PATCH 1/5] get only public ontologies --- lib/ontologies_linked_data/models/mod/semantic_artefact.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/ontologies_linked_data/models/mod/semantic_artefact.rb b/lib/ontologies_linked_data/models/mod/semantic_artefact.rb index 98919381..b8aeb65d 100644 --- a/lib/ontologies_linked_data/models/mod/semantic_artefact.rb +++ b/lib/ontologies_linked_data/models/mod/semantic_artefact.rb @@ -192,9 +192,9 @@ def bring(*attributes) def self.all_artefacts(options = {}) onts = if options[:also_include_views] - Ontology.where.to_a + Ontology.where(viewingRestriction: 'public').to_a else - Ontology.where.filter(Goo::Filter.new(:viewOf).unbound).include(:acronym).to_a + Ontology.where(viewingRestriction: 'public').filter(Goo::Filter.new(:viewOf).unbound).include(:acronym).to_a end onts.map do |o| From 6538a0255eed466d242b99725a07dd902b1dd3c8 Mon Sep 17 00:00:00 2001 From: Imad Bourouche Date: Thu, 13 Feb 2025 16:20:04 +0100 Subject: [PATCH 2/5] add read_restriction_based_on based on ontology --- .../models/mod/semantic_artefact.rb | 12 +++++++----- .../models/mod/semantic_artefact_distribution.rb | 5 ++++- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/lib/ontologies_linked_data/models/mod/semantic_artefact.rb b/lib/ontologies_linked_data/models/mod/semantic_artefact.rb index b8aeb65d..944982ae 100644 --- a/lib/ontologies_linked_data/models/mod/semantic_artefact.rb +++ b/lib/ontologies_linked_data/models/mod/semantic_artefact.rb @@ -117,7 +117,7 @@ def attribute_mapped(name, **options) attribute_mapped :metrics, namespace: :mod, mapped_to: {model: :ontology_submission, attribute: :metrics} - attribute :ontology, type: :ontology + attribute :ontology, type: :ontology, enforce: [:existence] links_load :acronym link_to LinkedData::Hypermedia::Link.new("distributions", lambda {|s| "artefacts/#{s.acronym}/distributions"}, LinkedData::Models::SemanticArtefactDistribution.type_uri), @@ -132,7 +132,9 @@ def attribute_mapped(name, **options) LinkedData::Hypermedia::Link.new("collection", lambda {|s| "artefacts/#{s.acronym}/collections"}, LinkedData::Models::SKOS::Collection.uri_type), LinkedData::Hypermedia::Link.new("labels", lambda {|s| "artefacts/#{s.acronym}/labels"}, LinkedData::Models::SKOS::Label.uri_type) - + # Access control + read_restriction_based_on ->(artefct) { artefct.ontology } + serialize_default :acronym, :accessRights, :subject, :URI, :versionIRI, :creator, :identifier, :status, :language, :license, :rightsHolder, :description, :landingPage, :keyword, :bibliographicCitation, :contactPoint, :contributor, :publisher, :coverage, :createdWith, :accrualMethod, :accrualPeriodicity, @@ -157,7 +159,7 @@ def self.type_uri end def self.find(artefact_id) - ont = Ontology.find(artefact_id).include(:acronym).first + ont = Ontology.find(artefact_id).include(:acronym, :viewingRestriction, :administeredBy, :acl).first return nil unless ont new.tap do |sa| @@ -192,9 +194,9 @@ def bring(*attributes) def self.all_artefacts(options = {}) onts = if options[:also_include_views] - Ontology.where(viewingRestriction: 'public').to_a + Ontology.where().include(:acronym, :viewingRestriction, :administeredBy, :acl).to_a else - Ontology.where(viewingRestriction: 'public').filter(Goo::Filter.new(:viewOf).unbound).include(:acronym).to_a + Ontology.where().filter(Goo::Filter.new(:viewOf).unbound).include(:acronym, :viewingRestriction, :administeredBy, :acl).to_a end onts.map do |o| diff --git a/lib/ontologies_linked_data/models/mod/semantic_artefact_distribution.rb b/lib/ontologies_linked_data/models/mod/semantic_artefact_distribution.rb index 03583c66..e613a82a 100644 --- a/lib/ontologies_linked_data/models/mod/semantic_artefact_distribution.rb +++ b/lib/ontologies_linked_data/models/mod/semantic_artefact_distribution.rb @@ -60,6 +60,9 @@ def attribute_mapped(name, **options) # Attr special to SemanticArtefactDistribution attribute :submission, type: :ontology_submission + + # Access control + read_restriction_based_on ->(artefct_distribution) { artefct_distribution.submission.ontology } serialize_default :distributionId, :title, :hasRepresentationLanguage, :hasSyntax, :description, :created, :modified, :conformsToKnowledgeRepresentationParadigm, :usedEngineeringMethodology, :prefLabelProperty, @@ -80,7 +83,7 @@ def self.distribution_id_generator(ss) def initialize(sub) super() @submission = sub - @submission.bring(*[:submissionId, :ontology=>[:acronym]]) + @submission.bring(*[:submissionId, :ontology=>[:acronym, :administeredBy, :acl, :viewingRestriction]]) @distributionId = sub.submissionId end From 819ac7f01d5b2abc88cb3d9ae825dc2c54ea3f75 Mon Sep 17 00:00:00 2001 From: Imad Bourouche Date: Thu, 13 Feb 2025 16:35:41 +0100 Subject: [PATCH 3/5] update Gemfile.lock --- Gemfile.lock | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index fdc2b9a8..8e9c01c1 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,12 +1,12 @@ GIT remote: https://github.com/ontoportal-lirmm/goo.git - revision: 27300f28ca6c656c7e78af65013d88b792a6312f + revision: e48a2d13a65cc2dd1c12d116cfc9da9061106861 branch: development specs: goo (0.0.2) addressable (~> 2.8) pry - rdf (= 3.2.11) + rdf rdf-raptor rdf-rdfxml rdf-vocab @@ -18,7 +18,7 @@ GIT GIT remote: https://github.com/ontoportal-lirmm/sparql-client.git - revision: 4364d34e9e4c411f1dd0ea706bf052465bf0b467 + revision: 736b7650e28db3ce5e3e49511ac30f958a29e8f1 branch: development specs: sparql-client (3.2.2) @@ -92,19 +92,20 @@ GEM domain_name (~> 0.5) i18n (0.9.5) concurrent-ruby (~> 1.0) - json (2.9.1) + json (2.10.1) json-ld (3.0.2) multi_json (~> 1.12) rdf (>= 2.2.8, < 4.0) jwt (2.10.1) base64 - language_server-protocol (3.17.0.3) - launchy (3.0.1) + language_server-protocol (3.17.0.4) + launchy (3.1.0) addressable (~> 2.8) childprocess (~> 5.0) + logger (~> 1.6) libxml-ruby (5.0.3) link_header (0.0.8) - logger (1.6.5) + logger (1.6.6) macaddr (1.7.2) systemu (~> 2.6.5) mail (2.8.1) @@ -116,7 +117,7 @@ GEM mime-types (3.6.0) logger mime-types-data (~> 3.2015) - mime-types-data (3.2025.0107) + mime-types-data (3.2025.0204) mini_mime (1.1.5) minitest (4.7.5) minitest-reporters (0.14.24) @@ -128,14 +129,14 @@ GEM multipart-post (2.4.1) net-http-persistent (4.0.5) connection_pool (~> 2.2) - net-imap (0.4.18) + net-imap (0.4.19) date net-protocol net-pop (0.1.2) net-protocol net-protocol (0.2.2) timeout - net-smtp (0.5.0) + net-smtp (0.5.1) net-protocol netrc (0.11.0) oj (3.16.9) @@ -145,7 +146,7 @@ GEM logger ostruct (0.6.1) parallel (1.26.3) - parser (3.3.7.0) + parser (3.3.7.1) ast (~> 2.4.1) racc pony (1.13.1) @@ -162,7 +163,7 @@ GEM rack (>= 1.0, < 3) rainbow (3.1.1) rake (10.5.0) - rdf (3.2.11) + rdf (3.2.12) link_header (~> 0.0, >= 0.0.8) rdf-raptor (3.2.0) ffi (~> 1.15) @@ -192,17 +193,17 @@ GEM rexml (3.4.0) rsolr (1.1.2) builder (>= 2.1.2) - rubocop (1.70.0) + rubocop (1.71.2) json (~> 2.3) language_server-protocol (>= 3.17.0) parallel (~> 1.10) parser (>= 3.3.0.2) rainbow (>= 2.2.2, < 4.0) regexp_parser (>= 2.9.3, < 3.0) - rubocop-ast (>= 1.36.2, < 2.0) + rubocop-ast (>= 1.38.0, < 2.0) ruby-progressbar (~> 1.7) unicode-display_width (>= 2.4.0, < 4.0) - rubocop-ast (1.37.0) + rubocop-ast (1.38.0) parser (>= 3.3.1.0) ruby-progressbar (1.13.0) ruby2_keywords (0.0.5) @@ -231,7 +232,7 @@ GEM unicode-emoji (4.0.4) uuid (2.3.9) macaddr (~> 1.0) - webmock (3.24.0) + webmock (3.25.0) addressable (>= 2.8.0) crack (>= 0.3.2) hashdiff (>= 0.4.0, < 2.0.0) From 500f58663121fd2f4f2e91c26de7b8afa33aad82 Mon Sep 17 00:00:00 2001 From: Imad Bourouche Date: Thu, 13 Feb 2025 20:16:31 +0100 Subject: [PATCH 4/5] fix tests --- test/models/test_class.rb | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/test/models/test_class.rb b/test/models/test_class.rb index bd69bc33..1a37c7a8 100644 --- a/test/models/test_class.rb +++ b/test/models/test_class.rb @@ -42,9 +42,8 @@ def test_class_parents assert_equal(cls.parents[0].submission, os) # transitive - assert_raises ArgumentError do - cls.bring(:ancestors) - end + cls.bring(:ancestors) + assert_includes cls.loaded_attributes.to_a, :ancestors ancestors = cls.ancestors.dup ancestors.each do |a| assert !a.submission.nil? @@ -83,9 +82,8 @@ def test_class_children assert_equal(cls.children[0].submission, os) # transitive - assert_raises ArgumentError do - cls.bring(:descendants) - end + cls.bring(:descendants) + assert_includes cls.loaded_attributes.to_a, :descendants descendants = cls.descendants.dup descendants.map! { |a| a.id.to_s } data_descendants = ["http://bioportal.bioontology.org/ontologies/msotes#class_5", From 961e12ff19415c1e543204d84f91d12d520035f7 Mon Sep 17 00:00:00 2001 From: Imad Bourouche Date: Sat, 15 Feb 2025 22:50:06 +0100 Subject: [PATCH 5/5] update gemfile to use goo development branch --- Gemfile | 2 +- Gemfile.lock | 14 ++++++++------ 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/Gemfile b/Gemfile index c6f36f2d..82592b99 100644 --- a/Gemfile +++ b/Gemfile @@ -41,7 +41,7 @@ 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: 'feature/migrate-ruby-3.2' +gem 'goo', github: 'ontoportal-lirmm/goo', branch: 'development' gem 'sparql-client', github: 'ontoportal-lirmm/sparql-client', branch: 'development' gem 'net-ftp' diff --git a/Gemfile.lock b/Gemfile.lock index 010abf37..2415b8cd 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,7 +1,7 @@ GIT remote: https://github.com/ontoportal-lirmm/goo.git - revision: dd3ea6c0f583c2044622a9f872a0bd18e898bb79 - branch: feature/migrate-ruby-3.2 + revision: e48a2d13a65cc2dd1c12d116cfc9da9061106861 + branch: development specs: goo (0.0.2) addressable (~> 2.8) @@ -102,7 +102,7 @@ GEM domain_name (~> 0.5) i18n (0.9.5) concurrent-ruby (~> 1.0) - json (2.9.1) + json (2.10.1) json-canonicalization (0.4.0) json-ld (3.2.5) htmlentities (~> 4.3) @@ -120,6 +120,7 @@ GEM logger (~> 1.6) libxml-ruby (5.0.3) link_header (0.0.8) + lint_roller (1.1.0) logger (1.6.6) macaddr (1.7.2) systemu (~> 2.6.5) @@ -176,7 +177,7 @@ GEM method_source (~> 1.0) public_suffix (5.1.1) racc (1.8.1) - rack (2.2.10) + rack (2.2.11) rack-test (2.2.0) rack (>= 1.3) rainbow (3.1.1) @@ -210,9 +211,10 @@ GEM rexml (3.4.0) rsolr (1.1.2) builder (>= 2.1.2) - rubocop (1.71.2) + rubocop (1.72.1) json (~> 2.3) - language_server-protocol (>= 3.17.0) + language_server-protocol (~> 3.17.0.2) + lint_roller (~> 1.1.0) parallel (~> 1.10) parser (>= 3.3.0.2) rainbow (>= 2.2.2, < 4.0)