Skip to content

Commit

Permalink
Merge branch 'development' into feature/add-catalog-model
Browse files Browse the repository at this point in the history
  • Loading branch information
syphax-bouazzouni authored Feb 17, 2025
2 parents 7896d34 + 6ec7a72 commit e3a3f57
Show file tree
Hide file tree
Showing 31 changed files with 11,323 additions and 131 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/ruby-unit-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ jobs:
strategy:
fail-fast: false
matrix:
goo-slice: [ '20', '100', '500' ]
ruby-version: [ '2.7' ]
goo-slice: [ '100']
ruby-version: [ '3.2.0']
triplestore: [ 'fs', 'ag', 'vo', 'gb' ]
runs-on: ubuntu-latest
steps:
Expand All @@ -34,7 +34,7 @@ jobs:
# http://docs.codecov.io/docs/testing-with-docker
run: |
ci_env=`bash <(curl -s https://codecov.io/env)`
GOO_SLICES=${{ matrix.goo-slice }} bundle exec rake test:docker:${{ matrix.triplestore }} TESTOPTS="-v"
GOO_SLICES=${{ matrix.goo-slice }} RUBYOPT="-W0" bundle exec rake test:docker:${{ matrix.triplestore }} TESTOPTS="-v"
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v3
with:
Expand Down
15 changes: 10 additions & 5 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,25 @@ gem 'addressable', '~> 2.8'
gem 'bcrypt', '~> 3.0'
gem 'cube-ruby', require: 'cube'
gem 'faraday', '~> 1.9'
gem 'ffi', '~> 1.16.3'
gem 'ffi'
gem 'libxml-ruby'
gem 'minitest'
gem 'multi_json', '~> 1.0'
gem 'oj'
gem 'omni_logger'
gem 'pony'
gem 'rack', '~> 1.0'
gem 'rack-test', '~> 0.6'
gem 'rake', '~> 10.0'
gem 'rack'
gem 'rack-test'
gem 'rake'
gem 'rest-client'
gem 'rsolr', '~> 1.0'
gem 'rubyzip', '~> 1.0'
gem 'thin'
gem 'request_store'
gem 'jwt'
gem 'json-ld', '~> 3.0.2'
gem 'json-ld', '~> 3.2.0'
gem "parallel", "~> 1.24"
gem 'rdf-raptor', github:'ruby-rdf/rdf-raptor', ref: '6392ceabf71c3233b0f7f0172f662bd4a22cd534' # use version 3.3.0 when available


# Testing
Expand All @@ -42,3 +43,7 @@ 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'

gem 'net-ftp'
gem 'public_suffix', '~> 5.1.1'
gem 'net-imap', '~> 0.4.18'
83 changes: 54 additions & 29 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,15 @@ GIT
net-http-persistent (~> 4.0, >= 4.0.2)
rdf (~> 3.2, >= 3.2.11)

GIT
remote: https://github.com/ruby-rdf/rdf-raptor.git
revision: 6392ceabf71c3233b0f7f0172f662bd4a22cd534
ref: 6392ceabf71c3233b0f7f0172f662bd4a22cd534
specs:
rdf-raptor (3.3.0)
ffi (~> 1.15)
rdf (~> 3.3)

GEM
remote: https://rubygems.org/
specs:
Expand All @@ -39,6 +48,7 @@ GEM
ansi (1.5.0)
ast (2.4.2)
base64 (0.2.0)
bcp47_spec (0.2.1)
bcrypt (3.1.20)
bigdecimal (3.1.9)
builder (3.3.0)
Expand Down Expand Up @@ -83,7 +93,7 @@ GEM
faraday-patron (1.0.0)
faraday-rack (1.0.0)
faraday-retry (1.0.3)
ffi (1.16.3)
ffi (1.17.1)
hashdiff (1.1.2)
hashie (5.0.0)
htmlentities (4.3.4)
Expand All @@ -93,9 +103,14 @@ GEM
i18n (0.9.5)
concurrent-ruby (~> 1.0)
json (2.10.1)
json-ld (3.0.2)
multi_json (~> 1.12)
rdf (>= 2.2.8, < 4.0)
json-canonicalization (0.4.0)
json-ld (3.2.5)
htmlentities (~> 4.3)
json-canonicalization (~> 0.3, >= 0.3.2)
link_header (~> 0.0, >= 0.0.8)
multi_json (~> 1.15)
rack (>= 2.2, < 4)
rdf (~> 3.2, >= 3.2.10)
jwt (2.10.1)
base64
language_server-protocol (3.17.0.4)
Expand All @@ -105,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)
Expand All @@ -127,6 +143,9 @@ GEM
powerbar
multi_json (1.15.0)
multipart-post (2.4.1)
net-ftp (0.3.8)
net-protocol
time
net-http-persistent (4.0.5)
connection_pool (~> 2.2)
net-imap (0.4.19)
Expand Down Expand Up @@ -158,25 +177,24 @@ GEM
method_source (~> 1.0)
public_suffix (5.1.1)
racc (1.8.1)
rack (1.6.13)
rack-test (0.8.3)
rack (>= 1.0, < 3)
rack (2.2.11)
rack-test (2.2.0)
rack (>= 1.3)
rainbow (3.1.1)
rake (10.5.0)
rdf (3.2.12)
rake (13.2.1)
rdf (3.3.2)
bcp47_spec (~> 0.2)
bigdecimal (~> 3.1, >= 3.1.5)
link_header (~> 0.0, >= 0.0.8)
rdf-raptor (3.2.0)
ffi (~> 1.15)
rdf (~> 3.2)
rdf-rdfxml (3.2.2)
builder (~> 3.2)
rdf-rdfxml (3.3.0)
builder (~> 3.2, >= 3.2.4)
htmlentities (~> 4.3)
rdf (~> 3.2)
rdf-xsd (~> 3.2)
rdf-vocab (3.2.7)
rdf (~> 3.2, >= 3.2.4)
rdf-xsd (3.2.1)
rdf (~> 3.2)
rdf (~> 3.3)
rdf-xsd (~> 3.3)
rdf-vocab (3.3.2)
rdf (~> 3.3)
rdf-xsd (3.3.0)
rdf (~> 3.3)
rexml (~> 3.2)
redis (5.3.0)
redis-client (>= 0.22.0)
Expand All @@ -193,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)
Expand Down Expand Up @@ -225,6 +244,8 @@ GEM
eventmachine (~> 1.0, >= 1.0.4)
rack (>= 1, < 3)
thread_safe (0.3.6)
time (0.4.1)
date
timeout (0.4.3)
tzinfo (0.3.62)
unicode-display_width (3.1.4)
Expand All @@ -247,22 +268,26 @@ DEPENDENCIES
cube-ruby
email_spec
faraday (~> 1.9)
ffi (~> 1.16.3)
ffi
goo!
json-ld (~> 3.0.2)
json-ld (~> 3.2.0)
jwt
libxml-ruby
minitest
minitest-reporters (>= 0.5.0)
multi_json (~> 1.0)
net-ftp
net-imap (~> 0.4.18)
oj
omni_logger
parallel (~> 1.24)
pony
pry
rack (~> 1.0)
rack-test (~> 0.6)
rake (~> 10.0)
public_suffix (~> 5.1.1)
rack
rack-test
rake
rdf-raptor!
request_store
rest-client
rsolr (~> 1.0)
Expand All @@ -276,4 +301,4 @@ DEPENDENCIES
webmock

BUNDLED WITH
2.1.4
2.6.3
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def roots_by_query(query_body, page, paged, pagesize)
#needs to get cached
class_ids = []

Goo.sparql_query_client.query(root_skos, { graphs: [self.id] }).each_solution do |s|
Goo.sparql_query_client.query(root_skos, **{ graphs: [self.id] }).each_solution do |s|
class_ids << s[:root]
end

Expand Down
5 changes: 2 additions & 3 deletions lib/ontologies_linked_data/diff/bubastis_diff.rb
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ def setup_environment
if (not Dir.exist?(@output_repo))
begin
FileUtils.mkdir_p(@output_repo)
rescue SystemCallError => e
rescue SystemCallError
raise MkdirException, "Output folder #{@output_repo} folder cannot be created."
end
end
Expand Down Expand Up @@ -116,8 +116,7 @@ def call_bubastis_java_cmd
Diff.logger.info(stdout)
end
if not File.exist?(@file_diff_path)
raise Diff::BubastisDiffException, "Bubastis diff command exited with status=#{status.exitstatus}. " +\
"Output file #{@file_diff_path} cannot be found."
raise Diff::BubastisDiffException, "Bubastis diff command exited with status=#{status.exitstatus}. " + "Output file #{@file_diff_path} cannot be found."
else
Diff.logger.info("Output size #{File.stat(@file_diff_path).size} in `#{@file_diff_path}`")
end
Expand Down
3 changes: 1 addition & 2 deletions lib/ontologies_linked_data/mappings/mappings.rb
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ def self.mapping_ontologies_count(sub1, sub2, reload_cache = false)
eos
group_count = sub2.nil? ? {} : nil
count = 0
latest_sub_ids = self.retrieve_latest_submission_ids
epr = Goo.sparql_query_client(:main)

mapping_predicates().each do |_source, mapping_predicate|
Expand Down Expand Up @@ -698,7 +697,7 @@ def self.mappings_ont_build_query(class_id, page, size, sub1, sub2)
def self.mappings_union_template(class_id, sub1, sub2, predicate, bind)
class_id_subject = class_id.nil? ? '?s1' : "<#{class_id.to_s}>"
target_graph = sub2.nil? ? '?g' : "<#{sub2.to_s}>"
union_template = <<-eos
return <<-eos
{
GRAPH <#{sub1.to_s}> {
#{class_id_subject} <#{predicate}> ?o .
Expand Down
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 @@ -447,7 +447,7 @@ def retrieve_descendants(page=nil, size=nil)
total_size = ids.length
if !page.nil?
ids = ids.to_a.sort
rstart = (page -1) * size
rstart = (page - 1) * size
rend = (page * size) -1
ids = ids[rstart..rend]
end
Expand Down
2 changes: 1 addition & 1 deletion lib/ontologies_linked_data/models/metric.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def self.ontology_submission_links(m)
ont.bring(:acronym) if ont.bring?(:acronym)
acronym_link = "ontologies/#{ont.acronym}"
submission_link = "/submissions/#{m.submission.first.submissionId}"
rescue Exception => e
rescue Exception
acronym_link = ""
submission_link = ""
end
Expand Down
25 changes: 11 additions & 14 deletions lib/ontologies_linked_data/models/mod/semantic_artefact.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand All @@ -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,
Expand All @@ -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|
Expand Down Expand Up @@ -190,20 +192,17 @@ def bring(*attributes)
end
end

def self.all_artefacts(options = {})
onts = if options[:also_include_views]
Ontology.where.to_a
else
Ontology.where.filter(Goo::Filter.new(:viewOf).unbound).include(:acronym).to_a
end

onts.map do |o|
def self.all_artefacts(attributes, page, pagesize)
all_count = Ontology.where.count
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
sa.acronym = o.acronym
sa.bring(*options[:includes]) if options[:includes]
sa.bring(*attributes) if attributes
end
end
Goo::Base::Page.new(page, pagesize, all_count, all_artefacts)
end

def latest_distribution(status)
Expand All @@ -217,7 +216,6 @@ def distribution(dist_id)
end

def all_distributions(options = {})
status = options[:status]
to_bring = options[:includes]
@ontology.bring(:submissions)

Expand All @@ -235,4 +233,3 @@ def analytics
end
end
end

Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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

Expand Down
3 changes: 1 addition & 2 deletions lib/ontologies_linked_data/models/ontology.rb
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,6 @@ def next_submission_id
end

def highest_submission_id(options = {})
reload = options[:reload] || false
status = options[:status] || :ready

LinkedData::Models::Ontology.where.models([self])
Expand All @@ -215,7 +214,7 @@ def highest_submission_id(options = {})

begin
subs = self.submissions
rescue Exception => e
rescue Exception
i = 0
num_calls = LinkedData.settings.num_retries_4store
subs = nil
Expand Down
Loading

0 comments on commit e3a3f57

Please sign in to comment.