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 e8f2516a..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,7 +120,8 @@ GEM logger (~> 1.6) libxml-ruby (5.0.3) link_header (0.0.8) - logger (1.6.5) + lint_roller (1.1.0) + logger (1.6.6) macaddr (1.7.2) systemu (~> 2.6.5) mail (2.8.1) @@ -147,7 +148,7 @@ GEM time 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) @@ -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) @@ -251,7 +253,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) diff --git a/lib/ontologies_linked_data/models/mod/semantic_artefact.rb b/lib/ontologies_linked_data/models/mod/semantic_artefact.rb index 7c8c2328..17388c20 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,7 +194,7 @@ def bring(*attributes) def self.all_artefacts(attributes, page, pagesize) all_count = Ontology.where.count - onts = Ontology.where.include(:acronym).page(page, pagesize).page_count_set(all_count).all + onts = Ontology.where.include(:acronym, :viewingRestriction, :administeredBy, :acl).page(page, pagesize).page_count_set(all_count).all all_artefacts = onts.map do |o| new.tap do |sa| sa.ontology = 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 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",