Class: DescriptorsController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- DescriptorsController
- Defined in:
- app/controllers/descriptors_controller.rb
Constant Summary
Constants included from ProjectsHelper
ProjectsHelper::CLASSIFIER, ProjectsHelper::CLASSIFIER_ANNOTATION
Instance Method Summary collapse
-
#annotations ⇒ Object
TODO: remove for shared end point GET /annotations.
- #autocomplete ⇒ Object
- #batch_load ⇒ Object
- #batch_params ⇒ Object private
-
#create ⇒ Object
POST /descriptors POST /descriptors.json.
- #create_modify_gene_descriptor_batch_load ⇒ Object
- #create_qualitative_descriptor_batch_load ⇒ Object
- #descriptor_params ⇒ Object private
-
#destroy ⇒ Object
DELETE /descriptors/1 DELETE /descriptors/1.json.
-
#edit ⇒ Object
GET /descriptors/1/edit.
-
#index ⇒ Object
GET /descriptors GET /descriptors.json.
- #list ⇒ Object
-
#new ⇒ Object
GET /descriptors/new.
- #preview_modify_gene_descriptor_batch_load ⇒ Object
- #preview_qualitative_descriptor_batch_load ⇒ Object
- #search ⇒ Object
- #set_descriptor ⇒ Object private
-
#show ⇒ Object
GET /descriptors/1 GET /descriptors/1.json.
- #units ⇒ Object
-
#update ⇒ Object
PATCH/PUT /descriptors/1 PATCH/PUT /descriptors/1.json.
Methods included from DataControllerConfiguration::ProjectDataControllerConfiguration
Methods included from RedirectHelper
Methods included from RequestType
Methods included from LogRecent
Methods included from Cookies
#digest_cookie, #digested_cookie_exists?
Methods included from Whitelist
Methods included from ProjectsHelper
#cumulative_gb_per_year, #document_cumulative_gb_per_year, #document_gb_per_year, #gb_per_year, #image_cumulative_gb_per_year, #image_gb_per_year, #invalid_object, #project_classification, #project_link, #project_matches, #project_tag, #projects_list, #projects_search_form, #taxonworks_classification, #week_in_review_graphs
Methods included from Api::Intercept
Methods included from TokenAuthentication
#intercept_project, #intercept_user, #intercept_user_or_project, #project_token_authenticate, #token_authenticate
Instance Method Details
#annotations ⇒ Object
TODO: remove for shared end point GET /annotations
113 114 115 116 |
# File 'app/controllers/descriptors_controller.rb', line 113 def annotations @object = @descriptor render '/shared/data/all/annotations' end |
#autocomplete ⇒ Object
97 98 99 100 |
# File 'app/controllers/descriptors_controller.rb', line 97 def autocomplete @term = params[:term] @descriptors = Queries::Descriptor::Autocomplete.new(params.require(:term), project_id: sessions_current_project_id).all end |
#batch_load ⇒ Object
118 119 |
# File 'app/controllers/descriptors_controller.rb', line 118 def batch_load end |
#batch_params ⇒ Object (private)
199 200 201 202 203 |
# File 'app/controllers/descriptors_controller.rb', line 199 def batch_params params.permit(:file).merge( user_id: sessions_current_user_id, project_id: sessions_current_project_id).to_h.symbolize_keys end |
#create ⇒ Object
POST /descriptors POST /descriptors.json
47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'app/controllers/descriptors_controller.rb', line 47 def create @descriptor = Descriptor.new(descriptor_params) respond_to do |format| if @descriptor.save format.html { redirect_to url_for(@descriptor.), notice: 'Descriptor was successfully created.' } format.json { render :show, status: :created, location: @descriptor. } else format.html { render :new } format.json { render json: @descriptor..errors, status: :unprocessable_entity } end end end |
#create_modify_gene_descriptor_batch_load ⇒ Object
143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 |
# File 'app/controllers/descriptors_controller.rb', line 143 def create_modify_gene_descriptor_batch_load if params[:file] && ( params[:file].tempfile, :modify_gene_descriptor_batch_load_descriptors_md5) @result = BatchLoad::Import::Descriptors::ModifyGeneDescriptorInterpreter.new(**batch_params) if @result.create flash[:notice] = "Successfully proccessed file, #{@result.total_records_created} " \ 'Gene Descriptors were modified.' render 'descriptors/batch_load/modify_gene_descriptor/create' and return else flash[:alert] = 'Batch import failed.' end else flash[:alert] = 'File to batch upload must be supplied.' end render :batch_load end |
#create_qualitative_descriptor_batch_load ⇒ Object
162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 |
# File 'app/controllers/descriptors_controller.rb', line 162 def create_qualitative_descriptor_batch_load if params[:file] && ( params[:file].tempfile, :qualitative_descriptors_batch_load_md5) @result = BatchLoad::Import::Descriptors::QualitativeInterpreter.new(**batch_params) if @result.create flash[:notice] = "Successfully proccessed file, #{@result.total_records_created}." render 'descriptors/batch_load/qualitative_descriptor/create' and return else flash[:alert] = 'Batch import failed.' end else flash[:alert] = 'File to batch upload must be supplied.' end render :batch_load end |
#descriptor_params ⇒ Object (private)
190 191 192 193 194 195 196 197 |
# File 'app/controllers/descriptors_controller.rb', line 190 def descriptor_params params.require(:descriptor).permit( :name, :short_name, :key_name, :description_name, :description, :position, :type, :gene_attribute_logic, :default_unit, :weight, character_states_attributes: [:id, :descriptor_id, :_destroy, :label, :name, :position, :description_name, :key_name], gene_attributes_attributes: [:id, :_destroy, :sequence_id, :sequence_relationship_type, :controlled_vocabulary_term_id, :position ] ) end |
#destroy ⇒ Object
DELETE /descriptors/1 DELETE /descriptors/1.json
84 85 86 87 88 89 90 91 92 93 94 95 |
# File 'app/controllers/descriptors_controller.rb', line 84 def destroy @descriptor.destroy respond_to do |format| if @descriptor.destroyed? format.html { destroy_redirect @descriptor, notice: 'Descriptor was successfully destroyed.' } format.json { head :no_content } else format.html { destroy_redirect @descriptor, notice: 'Descriptor was not destroyed, ' + @descriptor.errors..join('; ') } format.json { render json: @descriptor.errors, status: :unprocessable_entity } end end end |
#edit ⇒ Object
GET /descriptors/1/edit
41 42 43 |
# File 'app/controllers/descriptors_controller.rb', line 41 def edit redirect_to new_descriptor_task_path(descriptor_id: @descriptor.id), notice: 'Editing in new interface.' end |
#index ⇒ Object
GET /descriptors GET /descriptors.json
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'app/controllers/descriptors_controller.rb', line 9 def index respond_to do |format| format.html do @recent_objects = Descriptor.recent_from_project_id(sessions_current_project_id) .order(updated_at: :desc).limit(10) render '/shared/data/all/index' end format.json { @descriptors = ::Queries::Descriptor::Filter.new(params).all .page(params[:page]) .per(params[:per]) .order('descriptors.name') } end end |
#list ⇒ Object
30 31 32 |
# File 'app/controllers/descriptors_controller.rb', line 30 def list @descriptor = Descriptor.with_project_id(sessions_current_project_id).page(params[:page]) end |
#new ⇒ Object
GET /descriptors/new
35 36 37 38 |
# File 'app/controllers/descriptors_controller.rb', line 35 def new @descriptor = Descriptor.new redirect_to new_descriptor_task_path(), notice: 'Using task interface.' end |
#preview_modify_gene_descriptor_batch_load ⇒ Object
121 122 123 124 125 126 127 128 129 130 |
# File 'app/controllers/descriptors_controller.rb', line 121 def preview_modify_gene_descriptor_batch_load if params[:file] @result = BatchLoad::Import::Descriptors::ModifyGeneDescriptorInterpreter.new(**batch_params) (params[:file].tempfile, :modify_gene_descriptor_batch_load_descriptors_md5) render 'descriptors/batch_load/modify_gene_descriptor/preview' else flash[:notice] = 'No file provided!' redirect_to action: :batch_load end end |
#preview_qualitative_descriptor_batch_load ⇒ Object
132 133 134 135 136 137 138 139 140 141 |
# File 'app/controllers/descriptors_controller.rb', line 132 def preview_qualitative_descriptor_batch_load if params[:file] @result = BatchLoad::Import::Descriptors::QualitativeInterpreter.new(**batch_params) (params[:file].tempfile, :qualitative_descriptors_batch_load_md5) render 'descriptors/batch_load/qualitative_descriptor/preview' else flash[:notice] = 'No file provided!' redirect_to action: :batch_load end end |
#search ⇒ Object
102 103 104 105 106 107 108 109 |
# File 'app/controllers/descriptors_controller.rb', line 102 def search if params[:id].blank? redirect_to descriptors_path, notice: 'You must select an item from the list with a click or ' \ 'tab press before clicking show.' else redirect_to descriptor_path(params[:id]) end end |
#set_descriptor ⇒ Object (private)
186 187 188 |
# File 'app/controllers/descriptors_controller.rb', line 186 def set_descriptor @descriptor = Descriptor.where(project_id: sessions_current_project_id).find(params[:id]) end |
#show ⇒ Object
GET /descriptors/1 GET /descriptors/1.json
27 28 |
# File 'app/controllers/descriptors_controller.rb', line 27 def show end |
#units ⇒ Object
180 181 182 |
# File 'app/controllers/descriptors_controller.rb', line 180 def units render json: UNITS end |
#update ⇒ Object
PATCH/PUT /descriptors/1 PATCH/PUT /descriptors/1.json
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'app/controllers/descriptors_controller.rb', line 63 def update respond_to do |format| begin if @descriptor.update(descriptor_params) format.html { redirect_to url_for(@descriptor.), notice: 'Descriptor was successfully updated.' } format.json { render :show, status: :ok, location: @descriptor. } else format.html { render :edit } format.json { render json: @descriptor..errors, status: :unprocessable_entity } end # Can not cascade destroy Observations rescue ActiveRecord::RecordNotDestroyed format.html { render :edit } format.json { render json: 'Could not destroy, do observations still exist?', status: :unprocessable_entity } end end end |