From 031888fd3de5be3cb4c410181a7447f2f206ceb7 Mon Sep 17 00:00:00 2001 From: Alex Skrenchuk Date: Sun, 1 Dec 2024 23:01:06 -0800 Subject: [PATCH 1/2] Remove BPIDResolver Addresses https://github.com/ncbo/bioportal_web_ui/issues/337 --- app/controllers/application_controller.rb | 28 ----------------------- app/controllers/concepts_controller.rb | 9 -------- app/controllers/notes_controller.rb | 6 ----- app/controllers/ontologies_controller.rb | 14 +----------- app/controllers/search_controller.rb | 3 --- app/models/bpid_resolver.rb | 6 ----- config/initializers/zeitwerk.rb | 1 - config/routes.rb | 2 -- 8 files changed, 1 insertion(+), 68 deletions(-) delete mode 100644 app/models/bpid_resolver.rb diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 7e1b0acbe..2f7853f03 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -231,34 +231,6 @@ def redirect_to_home # Redirect to Home Page redirect_to "/" end - def redirect_new_api(class_view = false) - # Hack to make ontologyid and conceptid work in addition to id and ontology params - params[:ontology] = params[:ontology].nil? ? params[:ontologyid] : params[:ontology] - # Error checking - if params[:ontology].nil? || params[:id] && params[:ontology].nil? - @error = "Please provide an ontology id or concept id with an ontology id." - return - end - acronym = BPIDResolver.id_to_acronym(params[:ontology]) - not_found unless acronym - if class_view - @ontology = LinkedData::Client::Models::Ontology.find_by_acronym(acronym).first - @submission = get_ontology_submission_ready(@ontology) - concept = get_class(params, @submission).first.to_s - redirect_to "/ontologies/#{acronym}?p=classes#{params_string_for_redirect(params, prefix: "&")}", :status => :moved_permanently - else - redirect_to "/ontologies/#{acronym}#{params_string_for_redirect(params)}", :status => :moved_permanently - end - end - - def params_cleanup_new_api - params = @_params - if params[:ontology] && params[:ontology].to_i > 0 - params[:ontology] = BPIDResolver.id_to_acronym(params[:ontology]) - end - - params - end def params_string_for_redirect(params, options = {}) prefix = options[:prefix] || "?" diff --git a/app/controllers/concepts_controller.rb b/app/controllers/concepts_controller.rb index 44a4eef34..94478c537 100644 --- a/app/controllers/concepts_controller.rb +++ b/app/controllers/concepts_controller.rb @@ -2,7 +2,6 @@ class ConceptsController < ApplicationController include MappingsHelper - before_action :redirect_new_api, except: [:show, :biomixer] layout 'ontology' @@ -113,14 +112,6 @@ def biomixer render partial: 'biomixer', layout: false end - def redirect_new_api - return unless params[:ontology].to_i.positive? - - params_cleanup_new_api - redirect_to "#{request.path}#{params_string_for_redirect(params, stop_words: %w[controller action])}", - status: :moved_permanently - end - private # Load data for a concept or retrieve a concept's children, depending on the value of the :callback parameter. diff --git a/app/controllers/notes_controller.rb b/app/controllers/notes_controller.rb index 875e3138e..8bf72d0c4 100644 --- a/app/controllers/notes_controller.rb +++ b/app/controllers/notes_controller.rb @@ -115,12 +115,6 @@ def archive end end - def show_concept_list - params[:p] = 'classes' - params[:t] = 'notes' - redirect_new_api - end - private def note_params diff --git a/app/controllers/ontologies_controller.rb b/app/controllers/ontologies_controller.rb index 6fc48fa41..60cc259c0 100644 --- a/app/controllers/ontologies_controller.rb +++ b/app/controllers/ontologies_controller.rb @@ -245,17 +245,9 @@ def show return end - if params[:ontology].to_i > 0 - acronym = BPIDResolver.id_to_acronym(params[:ontology]) - if acronym - redirect_new_api - return - end - end - # Note: find_by_acronym includes ontology views @ontology = LinkedData::Client::Models::Ontology.find_by_acronym(params[:ontology], include: 'all').first - not_found if @ontology.nil? + not_found if @ontology.nil? || @ontology.errors # Handle the case where an ontology is converted to summary only. # See: https://github.com/ncbo/bioportal_web_ui/issues/133. @@ -361,10 +353,6 @@ def update end end - def virtual - redirect_new_api - end - def widgets if request.xhr? render :partial => 'widgets', :layout => false diff --git a/app/controllers/search_controller.rb b/app/controllers/search_controller.rb index 70a235c76..32a3b8279 100644 --- a/app/controllers/search_controller.rb +++ b/app/controllers/search_controller.rb @@ -96,9 +96,6 @@ def check_params_ontologies(params) else params[:ontologies] = [params[:ontologies]] end - if params[:ontologies].first.to_i > 0 - params[:ontologies].map! {|o| BPIDResolver.id_to_acronym(o)} - end params[:ontologies] = params[:ontologies].join(",") end end diff --git a/app/models/bpid_resolver.rb b/app/models/bpid_resolver.rb deleted file mode 100644 index db73b4b7e..000000000 --- a/app/models/bpid_resolver.rb +++ /dev/null @@ -1,6 +0,0 @@ -# frozen_string_literal: true - -class BPIDResolver - # deprecated; see https://github.com/ncbo/bioportal_web_ui/issues/337 - nil -end diff --git a/config/initializers/zeitwerk.rb b/config/initializers/zeitwerk.rb index 5e278416f..edc750f48 100644 --- a/config/initializers/zeitwerk.rb +++ b/config/initializers/zeitwerk.rb @@ -3,7 +3,6 @@ Rails.autoloaders.each do |autoloader| autoloader.inflector = Zeitwerk::Inflector.new autoloader.inflector.inflect( - 'bpid_resolver' => 'BPIDResolver', 'kgcl' => 'KGCL' ) end diff --git a/config/routes.rb b/config/routes.rb index 8377a8c98..6421b1c73 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -65,7 +65,6 @@ get '/robots.txt' => 'robots#index' # Ontologies - get '/ontologies/virtual/:ontology' => 'ontologies#virtual', :as => :ontology_virtual get '/ontologies/success/:id' => 'ontologies#submit_success' match '/ontologies/:acronym' => 'ontologies#update', via: [:get, :post] match '/ontologies/:acronym/submissions/:id' => 'submissions#update', via: [:get, :post] @@ -93,7 +92,6 @@ get '/ajax/json_class' => 'ajax_proxy#json_class' get '/ajax/loading_spinner' => 'ajax_proxy#loading_spinner' get '/ajax/notes/delete' => 'notes#destroy' - get '/ajax/notes/concept_list' => 'notes#show_concept_list' get '/ajax/classes/label' => 'concepts#show_label' get '/ajax/classes/definition' => 'concepts#show_definition' get '/ajax/classes/treeview' => 'concepts#show_tree' From 13a25c3c299d380d1a0c45a72c6b529afa585deb Mon Sep 17 00:00:00 2001 From: Alex Skrenchuk Date: Mon, 2 Dec 2024 09:16:12 -0800 Subject: [PATCH 2/2] Revert change: to be addressed in a separate PR --- app/controllers/ontologies_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/ontologies_controller.rb b/app/controllers/ontologies_controller.rb index 60cc259c0..05b138c25 100644 --- a/app/controllers/ontologies_controller.rb +++ b/app/controllers/ontologies_controller.rb @@ -247,7 +247,7 @@ def show # Note: find_by_acronym includes ontology views @ontology = LinkedData::Client::Models::Ontology.find_by_acronym(params[:ontology], include: 'all').first - not_found if @ontology.nil? || @ontology.errors + not_found if @ontology.nil? # Handle the case where an ontology is converted to summary only. # See: https://github.com/ncbo/bioportal_web_ui/issues/133.