diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index e0b23263..d9af054d 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -69,7 +69,7 @@ jobs: - uses: actions/checkout@v3 - uses: ruby/setup-ruby@v1 with: - ruby-version: 2.7.6 # Not needed with a .ruby-version file + ruby-version: 2.7.8 # Not needed with a .ruby-version file bundler-cache: true # runs 'bundle install' and caches installed gems automatically - name: get-deployment-config uses: actions/checkout@v3 diff --git a/Gemfile b/Gemfile index 29f22d86..699fdb3a 100644 --- a/Gemfile +++ b/Gemfile @@ -19,7 +19,6 @@ gem 'json-ld' gem 'google-apis-core', '0.15.0' gem 'google-protobuf', '3.25.3' - # Rack middleware gem 'ffi' gem 'rack-accept', '~> 0.4' @@ -53,7 +52,7 @@ gem 'ncbo_cron', git: 'https://github.com/ontoportal-lirmm/ncbo_cron.git', branc gem 'ncbo_ontology_recommender', git: 'https://github.com/ncbo/ncbo_ontology_recommender.git', branch: 'master' gem 'goo', github: 'ontoportal-lirmm/goo', branch: 'development' gem 'sparql-client', github: 'ontoportal-lirmm/sparql-client', branch: 'development' -gem 'ontologies_linked_data', git: 'https://github.com/ontoportal-lirmm/ontologies_linked_data.git', branch: 'development' +gem 'ontologies_linked_data', git: 'https://github.com/ontoportal-lirmm/ontologies_linked_data.git', branch: 'feature/parse-diff-files' 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 3e72d61e..e6ee9482 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -57,8 +57,8 @@ GIT GIT remote: https://github.com/ontoportal-lirmm/ontologies_linked_data.git - revision: 9605eb44c4271c60bedda0520e85d8c3fa2513ac - branch: development + revision: d69ede0a0b3e3c5dee64fa75cb09cc6e16e0f4b5 + branch: feature/parse-diff-files specs: ontologies_linked_data (0.0.1) activesupport @@ -108,7 +108,7 @@ GEM multi_json (~> 1.0) addressable (2.8.7) public_suffix (>= 2.0.2, < 7.0) - airbrussh (1.5.2) + airbrussh (1.5.3) sshkit (>= 1.6.1, != 1.7.0) backports (3.25.0) base64 (0.2.0) @@ -178,7 +178,7 @@ GEM google-analytics-data (0.6.1) google-analytics-data-v1beta (>= 0.11, < 2.a) google-cloud-core (~> 1.6) - google-analytics-data-v1beta (0.13.0) + google-analytics-data-v1beta (0.13.1) gapic-common (>= 0.21.1, < 2.a) google-cloud-errors (~> 1.0) google-apis-analytics_v3 (0.16.0) @@ -202,7 +202,7 @@ GEM google-protobuf (>= 3.18, < 5.a) googleapis-common-protos-types (~> 1.7) grpc (~> 1.41) - googleapis-common-protos-types (1.15.0) + googleapis-common-protos-types (1.16.0) google-protobuf (>= 3.18, < 5.a) googleauth (1.11.0) faraday (>= 1.0, < 3.a) @@ -231,12 +231,12 @@ GEM rdf (>= 2.2.8, < 4.0) json-schema (2.8.1) addressable (>= 2.4) - jwt (2.8.2) + jwt (2.9.0) base64 kgio (2.11.4) libxml-ruby (5.0.3) link_header (0.0.8) - logger (1.6.0) + logger (1.6.1) macaddr (1.7.2) systemu (~> 2.6.5) mail (2.8.1) @@ -247,7 +247,7 @@ GEM method_source (1.1.0) mime-types (3.5.2) mime-types-data (~> 3.2015) - mime-types-data (3.2024.0820) + mime-types-data (3.2024.0903) mini_mime (1.1.5) minitest (4.7.5) minitest-stub_any_instance (1.0.3) @@ -255,9 +255,10 @@ GEM redis multi_json (1.15.0) multipart-post (2.4.1) - net-http-persistent (4.0.2) + mutex_m (0.2.0) + net-http-persistent (4.0.4) connection_pool (~> 2.2) - net-imap (0.4.14) + net-imap (0.4.16) date net-protocol net-pop (0.1.2) @@ -277,6 +278,7 @@ GEM omni_logger (0.1.4) logger os (1.1.4) + ostruct (0.6.0) parallel (1.26.3) parseconfig (1.1.2) pony (1.13.1) @@ -340,8 +342,7 @@ GEM mime-types (>= 1.16, < 4.0) netrc (~> 0.8) retriable (3.1.2) - rexml (3.3.6) - strscan + rexml (3.3.7) rsolr (2.6.0) builder (>= 2.1.2) faraday (>= 0.9, < 3, != 2.0.0) @@ -362,7 +363,7 @@ GEM simplecov-cobertura (2.1.0) rexml simplecov (~> 0.19) - simplecov-html (0.12.3) + simplecov-html (0.13.1) simplecov_json_formatter (0.1.4) sinatra (1.4.8) rack (~> 1.5) @@ -377,12 +378,12 @@ GEM rack-test sinatra (~> 1.4.0) tilt (>= 1.3, < 3) - sshkit (1.23.0) + sshkit (1.23.1) base64 net-scp (>= 1.1.2) net-sftp (>= 2.1.2) net-ssh (>= 2.8.0) - strscan (3.1.0) + ostruct systemu (2.6.5) temple (0.10.3) tilt (2.4.0) @@ -420,7 +421,6 @@ DEPENDENCIES faraday (~> 1.9) ffi goo! - google-apis-core (= 0.15.0) google-protobuf (= 3.25.3) haml (~> 5.2.2) json-ld diff --git a/controllers/ontology_submissions_controller.rb b/controllers/ontology_submissions_controller.rb index 0068a5f1..6b5818b5 100644 --- a/controllers/ontology_submissions_controller.rb +++ b/controllers/ontology_submissions_controller.rb @@ -140,6 +140,25 @@ class OntologySubmissionsController < ApplicationController end end + get '/:ontology_submission_id/diff' do + acronym = params["acronym"] + submission_attributes = [:submissionId, :submissionStatus, :diffFilePath] + ont = Ontology.find(acronym).include(:submissions => submission_attributes).first + error 422, "You must provide an existing `acronym` to download" if ont.nil? + ont.bring(:viewingRestriction) + check_access(ont) + ont_restrict_downloads = LinkedData::OntologiesAPI.settings.restrict_download + error 403, "License restrictions on download for #{acronym}" if ont_restrict_downloads.include? acronym + submission = ont.submission(params['ontology_submission_id'].to_i) + error 404, "There is no such submission for download" if submission.nil? + file_path = submission.diffFilePath + if File.readable? file_path + reply submission.parse_diff_report + else + error 500, "Cannot read submission diff file: #{file_path}" + end + end + ## # Download a submission diff file get '/:ontology_submission_id/download_diff' do diff --git a/test/controllers/test_ontology_submissions_controller.rb b/test/controllers/test_ontology_submissions_controller.rb index 095d0339..1e5014f6 100644 --- a/test/controllers/test_ontology_submissions_controller.rb +++ b/test/controllers/test_ontology_submissions_controller.rb @@ -474,6 +474,16 @@ def test_submissions_param_include test_submissions_custom_includes end + def test_submission_diff + num_onts_created, created_ont_acronyms, onts = create_ontologies_and_submissions(ont_count: 1, submission_count: 2, + process_submission: true, + process_options: { process_rdf: true, extract_metadata: false, diff: true} ) + + ont = onts.first + sub = ont.latest_submission(status: :any) + + get "/ontologies/#{ont.acronym}/submissions/#{sub.submissionId}/diff" + end private def submission_keys(sub) sub.to_hash.keys - %w[@id @type id]