Skip to content

Commit

Permalink
Merge branch 'feature/add-diff-parsing-endpoint' into test
Browse files Browse the repository at this point in the history
  • Loading branch information
syphax-bouazzouni committed Sep 16, 2024
2 parents db23cd8 + 5d56ebb commit 4fed9a3
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 9 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: 'feature/add-portal-config-model'
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
18 changes: 10 additions & 8 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: d893c08a2c2f11c743fad520873b7f98b0805240
branch: feature/add-portal-config-model
revision: 99b934317f303f9ea839413de4ff8a5638ac074f
branch: feature/parse-diff-files
specs:
ontologies_linked_data (0.0.1)
activesupport
Expand Down Expand Up @@ -204,7 +204,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 @@ -236,7 +236,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 All @@ -261,9 +261,9 @@ GEM
multi_json (1.15.0)
multipart-post (2.4.1)
mutex_m (0.2.0)
net-http-persistent (4.0.2)
net-http-persistent (4.0.4)
connection_pool (~> 2.2)
net-imap (0.4.15)
net-imap (0.4.16)
date
net-protocol
net-pop (0.1.2)
Expand All @@ -283,6 +283,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)
Expand Down Expand Up @@ -367,7 +368,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)
Expand All @@ -382,11 +383,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)
ostruct
systemu (2.6.5)
temple (0.10.3)
tilt (2.4.0)
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 4fed9a3

Please sign in to comment.