Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Small code refactor to reuse replace url prefix #100

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ gem 'goo', github: 'ncbo/goo', branch: 'master'
gem 'ncbo_annotator', github: 'ncbo/ncbo_annotator', branch: 'master'
gem 'ncbo_cron', github: 'ncbo/ncbo_cron', branch: 'master'
gem 'ncbo_ontology_recommender', github: 'ncbo/ncbo_ontology_recommender', branch: 'master'
gem 'ontologies_linked_data', github: 'ncbo/ontologies_linked_data', branch: 'master'
gem 'ontologies_linked_data', github: 'ontoportal-lirmm/ontologies_linked_data', branch: 'pr/fix/get-rest-mapping-with-prefix-url'
gem 'sparql-client', github: 'ncbo/sparql-client', branch: 'master'

group :development do
Expand Down
39 changes: 20 additions & 19 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,19 @@ GIT
redis

GIT
remote: https://github.com/ncbo/ontologies_linked_data.git
revision: 8196bf34b45c75f8104bb76dfcba1db0f2c048e4
remote: https://github.com/ncbo/sparql-client.git
revision: fb4a89b420f8eb6dda5190a126b6c62e32c4c0c9
branch: master
specs:
sparql-client (1.0.1)
json_pure (>= 1.4)
net-http-persistent (= 2.9.4)
rdf (>= 1.0)

GIT
remote: https://github.com/ontoportal-lirmm/ontologies_linked_data.git
revision: 4cbb5b3e87a91fdcf073f93db733602726405427
branch: pr/fix/get-rest-mapping-with-prefix-url
specs:
ontologies_linked_data (0.0.1)
activesupport
Expand All @@ -71,16 +81,6 @@ GIT
rsolr
rubyzip

GIT
remote: https://github.com/ncbo/sparql-client.git
revision: fb4a89b420f8eb6dda5190a126b6c62e32c4c0c9
branch: master
specs:
sparql-client (1.0.1)
json_pure (>= 1.4)
net-http-persistent (= 2.9.4)
rdf (>= 1.0)

GIT
remote: https://github.com/palexander/rack-post-body-to-params.git
revision: 0fd30e710386d0cb8a3a6833d9549d7b655d5398
Expand All @@ -103,8 +103,8 @@ GEM
activesupport (3.2.22.5)
i18n (~> 0.6, >= 0.6.4)
multi_json (~> 1.0)
addressable (2.8.0)
public_suffix (>= 2.0.2, < 5.0)
addressable (2.8.1)
public_suffix (>= 2.0.2, < 6.0)
airbrussh (1.4.1)
sshkit (>= 1.6.1, != 1.7.0)
backports (3.23.0)
Expand All @@ -131,7 +131,7 @@ GEM
docile (1.4.0)
domain_name (0.5.20190701)
unf (>= 0.0.5, < 1.0.0)
faraday (1.10.1)
faraday (1.10.2)
faraday-em_http (~> 1.0)
faraday-em_synchrony (~> 1.0)
faraday-excon (~> 1.1)
Expand Down Expand Up @@ -188,7 +188,7 @@ GEM
json-schema (2.8.1)
addressable (>= 2.4)
json_pure (2.6.2)
jwt (2.4.1)
jwt (2.5.0)
kgio (2.11.4)
libxml-ruby (3.2.3)
logger (1.5.1)
Expand All @@ -213,7 +213,7 @@ GEM
net-ssh (>= 2.6.5)
net-ssh (7.0.1)
netrc (0.11.0)
newrelic_rpm (8.9.0)
newrelic_rpm (8.10.0)
oj (2.18.5)
omni_logger (0.1.4)
logger
Expand All @@ -224,7 +224,7 @@ GEM
pry (0.14.1)
coderay (~> 1.1)
method_source (~> 1.0)
public_suffix (4.0.7)
public_suffix (5.0.0)
rack (1.6.13)
rack-accept (0.4.5)
rack (>= 0.4)
Expand All @@ -246,7 +246,7 @@ GEM
rdf (1.0.8)
addressable (>= 2.2)
redcarpet (3.5.1)
redis (4.7.1)
redis (4.8.0)
redis-activesupport (5.3.0)
activesupport (>= 3, < 8)
redis-store (>= 1.3, < 2)
Expand Down Expand Up @@ -325,6 +325,7 @@ GEM
webrick (1.7.0)

PLATFORMS
x86_64-darwin-21
x86_64-linux

DEPENDENCIES
Expand Down
3 changes: 1 addition & 2 deletions helpers/application_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -344,8 +344,7 @@ def uri_as_needed(id)
# If the setting is enabled, replace the URL prefix with the proper id prefix
# EX: http://stagedata.bioontology.org/ontologies/BRO would become http://data.bioontology.org/ontologies/BRO
def replace_url_prefix(id)
id = id.sub(LinkedData.settings.rest_url_prefix, LinkedData.settings.id_url_prefix) if LinkedData.settings.replace_url_prefix && id.start_with?(LinkedData.settings.rest_url_prefix)
id
LinkedData::Models::Base.replace_url_prefix_to_id(id)
end

def retrieve_latest_submissions(options = {})
Expand Down
10 changes: 3 additions & 7 deletions helpers/batch_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,8 @@ def batch_class_lookup(class_id_by_ontology, goo_include)
class_id_to_ontology = Hash.new
class_id_by_ontology.keys.each do |ont_id_orig|
ont_id = ont_id_orig
if LinkedData.settings.replace_url_prefix && ont_id_orig.to_s.start_with?(LinkedData.settings.rest_url_prefix)
ont_id = ont_id_orig.sub(LinkedData.settings.rest_url_prefix, LinkedData.settings.id_url_prefix)
end
ont_id = LinkedData::Models::Base.replace_url_prefix_to_id(ont_id_orig.to_s)

if all_latest_by_id[ont_id]
latest_submissions << all_latest_by_id[ont_id]
all_class_ids << class_id_by_ontology[ont_id_orig]
Expand All @@ -43,10 +42,7 @@ def batch_class_lookup(class_id_by_ontology, goo_include)
ont_classes.each do |cls|
if class_id_to_ontology[cls.id.to_s]
ont_id_orig = class_id_to_ontology[cls.id.to_s]
ont_id = ont_id_orig
if LinkedData.settings.replace_url_prefix && ont_id_orig.to_s.start_with?(LinkedData.settings.rest_url_prefix)
ont_id = ont_id_orig.sub(LinkedData.settings.rest_url_prefix, LinkedData.settings.id_url_prefix)
end
ont_id = LinkedData::Models::Base.replace_url_prefix_to_id(ont_id_orig.to_s)
if all_latest_by_id[ont_id]
cls.submission = all_latest_by_id[ont_id]
to_reply << cls
Expand Down