Skip to content

Commit

Permalink
add submission diff endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
syphax-bouazzouni committed Sep 16, 2024
1 parent 41743a6 commit 5d56ebb
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,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
Expand Down
8 changes: 4 additions & 4 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ GIT

GIT
remote: https://github.com/ontoportal-lirmm/ontologies_linked_data.git
revision: 651d2f4226004c2311120e900a936101ee509865
branch: development
revision: d69ede0a0b3e3c5dee64fa75cb09cc6e16e0f4b5
branch: feature/parse-diff-files
specs:
ontologies_linked_data (0.0.1)
activesupport
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -231,7 +231,7 @@ 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)
Expand Down
19 changes: 19 additions & 0 deletions controllers/ontology_submissions_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 10 additions & 0 deletions test/controllers/test_ontology_submissions_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down

0 comments on commit 5d56ebb

Please sign in to comment.