Class: SequenceRelationshipsController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- SequenceRelationshipsController
- Defined in:
- app/controllers/sequence_relationships_controller.rb
Constant Summary
Constants included from ProjectsHelper
ProjectsHelper::CLASSIFIER, ProjectsHelper::CLASSIFIER_ANNOTATION
Instance Method Summary collapse
- #batch_load ⇒ Object
- #batch_params ⇒ Object private
-
#create ⇒ Object
POST /sequence_relationships POST /sequence_relationships.json.
- #create_primers_batch_load ⇒ Object
-
#destroy ⇒ Object
DELETE /sequence_relationships/1 DELETE /sequence_relationships/1.json.
-
#edit ⇒ Object
GET /sequence_relationships/1/edit.
-
#index ⇒ Object
GET /sequence_relationships GET /sequence_relationships.json.
- #list ⇒ Object
-
#new ⇒ Object
GET /sequence_relationships/new.
- #preview_primers_batch_load ⇒ Object
- #search ⇒ Object
- #sequence_relationship_params ⇒ Object private
- #set_sequence_relationship ⇒ Object private
-
#show ⇒ Object
GET /sequence_relationships/1 GET /sequence_relationships/1.json.
-
#update ⇒ Object
PATCH/PUT /sequence_relationships/1 PATCH/PUT /sequence_relationships/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
#batch_load ⇒ Object
89 90 |
# File 'app/controllers/sequence_relationships_controller.rb', line 89 def batch_load end |
#batch_params ⇒ Object (private)
130 131 132 133 |
# File 'app/controllers/sequence_relationships_controller.rb', line 130 def batch_params params.permit(:name, :file, :import_level, files: []) .merge(user_id: sessions_current_user_id, project_id: sessions_current_project_id).to_h.symbolize_keys end |
#create ⇒ Object
POST /sequence_relationships POST /sequence_relationships.json
34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'app/controllers/sequence_relationships_controller.rb', line 34 def create @sequence_relationship = SequenceRelationship.new(sequence_relationship_params) respond_to do |format| if @sequence_relationship.save format.html { redirect_to sequence_relationship_path(@sequence_relationship), notice: 'Sequence relationship was successfully created.' } format.json { render :show, status: :created, location: @sequence_relationship } else format.html { render :new } format.json { render json: @sequence_relationship.errors, status: :unprocessable_entity } end end end |
#create_primers_batch_load ⇒ Object
103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 |
# File 'app/controllers/sequence_relationships_controller.rb', line 103 def create_primers_batch_load if params[:file] && (params[:file].tempfile, :Primers_sequences_md5) @result = BatchLoad::Import::SequenceRelationships::PrimersInterpreter.new(**batch_params) if @result.create! flash[:notice] = "Successfully proccessed file, #{@result.total_records_created} " \ 'sequence relationships were created.' render 'sequence_relationships/batch_load/primers/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 |
#destroy ⇒ Object
DELETE /sequence_relationships/1 DELETE /sequence_relationships/1.json
66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'app/controllers/sequence_relationships_controller.rb', line 66 def destroy @sequence_relationship.destroy respond_to do |format| if @sequence_relationship.destroyed? format.html { destroy_redirect @sequence_relationship, notice: 'Sequence relationship was successfully destroyed.' } format.json { head :no_content} else format.html { destroy_redirect @sequence_relationship, notice: 'Sequence relationship was not destroyed, ' + @sequence_relationship.errors..join('; ') } format.json { render json: @sequence_relationship.errors, status: :unprocessable_entity } end end end |
#edit ⇒ Object
GET /sequence_relationships/1/edit
25 26 |
# File 'app/controllers/sequence_relationships_controller.rb', line 25 def edit end |
#index ⇒ Object
GET /sequence_relationships GET /sequence_relationships.json
8 9 10 11 12 |
# File 'app/controllers/sequence_relationships_controller.rb', line 8 def index @recent_objects = SequenceRelationship.recent_from_project_id(sessions_current_project_id) .order(updated_at: :desc).limit(10) render '/shared/data/all/index' end |
#list ⇒ Object
28 29 30 |
# File 'app/controllers/sequence_relationships_controller.rb', line 28 def list @sequence_relationships = SequenceRelationship.with_project_id(sessions_current_project_id).page(params[:page]) end |
#new ⇒ Object
GET /sequence_relationships/new
20 21 22 |
# File 'app/controllers/sequence_relationships_controller.rb', line 20 def new @sequence_relationship = SequenceRelationship.new end |
#preview_primers_batch_load ⇒ Object
92 93 94 95 96 97 98 99 100 101 |
# File 'app/controllers/sequence_relationships_controller.rb', line 92 def preview_primers_batch_load if params[:file] @result = BatchLoad::Import::SequenceRelationships::PrimersInterpreter.new(**batch_params) (params[:file].tempfile, :Primers_sequences_md5) render 'sequence_relationships/batch_load/primers/preview' else flash[:notice] = 'No file provided!' redirect_to action: :batch_load end end |
#search ⇒ Object
80 81 82 83 84 85 86 87 |
# File 'app/controllers/sequence_relationships_controller.rb', line 80 def search if params[:id].blank? redirect_to sequence_relationships_path, notice: 'You must select an item from the list with a ' \ 'click or tab press before clicking show.' else redirect_to sequence_relationship_path(params[:id]) end end |
#sequence_relationship_params ⇒ Object (private)
125 126 127 128 |
# File 'app/controllers/sequence_relationships_controller.rb', line 125 def sequence_relationship_params params.require(:sequence_relationship).permit(:subject_sequence_id, :type, :object_sequence_id, :created_by_id, :updated_by_id, :project_id) end |
#set_sequence_relationship ⇒ Object (private)
121 122 123 |
# File 'app/controllers/sequence_relationships_controller.rb', line 121 def set_sequence_relationship @sequence_relationship = SequenceRelationship.where(project_id: sessions_current_project_id).find(params[:id]) end |
#show ⇒ Object
GET /sequence_relationships/1 GET /sequence_relationships/1.json
16 17 |
# File 'app/controllers/sequence_relationships_controller.rb', line 16 def show end |
#update ⇒ Object
PATCH/PUT /sequence_relationships/1 PATCH/PUT /sequence_relationships/1.json
51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'app/controllers/sequence_relationships_controller.rb', line 51 def update respond_to do |format| if @sequence_relationship.update(sequence_relationship_params) format.html { redirect_to url_for(@sequence_relationship.), notice: 'Sequence relationship was successfully updated.' } format.json { render :show, status: :ok, location: @sequence_relationship } else format.html { render :edit } format.json { render json: @sequence_relationship.errors, status: :unprocessable_entity } end end end |