Class: SequenceRelationshipsController

Inherits:
ApplicationController show all
Includes:
DataControllerConfiguration::ProjectDataControllerConfiguration
Defined in:
app/controllers/sequence_relationships_controller.rb

Instance Attribute Summary

Attributes inherited from ApplicationController

#is_data_controller, #is_task_controller, #meta_data, #meta_description, #meta_keywords, #meta_title, #page_title, #site_name

Instance Method Summary (collapse)

Methods included from DataControllerConfiguration::ProjectDataControllerConfiguration

#polymorphic_filter_params

Methods inherited from ApplicationController

#clear_project_and_user_variables, #digest_cookie, #digested_cookie_exists?, #disable_turbolinks, #intercept_api, #invalid_object, #is_data_controller?, #is_task_controller?, #log_user_recent_route, #notice_user, #project_matches, #record_not_found, #set_project_and_user_variables, #set_project_from_params, #token_authenticate

Methods included from ProjectsHelper

#project_link, #project_tag, #projects_list, #projects_search_form

Instance Method Details

- (Object) batch_load



79
80
# File 'app/controllers/sequence_relationships_controller.rb', line 79

def batch_load
end

- (Object) batch_params (private)



119
120
121
# File 'app/controllers/sequence_relationships_controller.rb', line 119

def batch_params
  params.permit(:name, :file, :import_level, :files => []).merge(user_id: sessions_current_user_id, project_id: sessions_current_project_id).symbolize_keys
end

- (Object) create

POST /sequence_relationships POST /sequence_relationships.json



33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'app/controllers/sequence_relationships_controller.rb', line 33

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

- (Object) create_primers_batch_load



93
94
95
96
97
98
99
100
101
102
103
104
105
106
# File 'app/controllers/sequence_relationships_controller.rb', line 93

def create_primers_batch_load
  if params[:file] && digested_cookie_exists?(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

- (Object) destroy

DELETE /sequence_relationships/1 DELETE /sequence_relationships/1.json



63
64
65
66
67
68
69
# File 'app/controllers/sequence_relationships_controller.rb', line 63

def destroy
  @sequence_relationship.destroy
  respond_to do |format|
    format.html { redirect_to sequence_relationships_url, notice: 'Sequence relationship was successfully destroyed.' }
    format.json { head :no_content }
  end
end

- (Object) edit

GET /sequence_relationships/1/edit



24
25
# File 'app/controllers/sequence_relationships_controller.rb', line 24

def edit
end

- (Object) index

GET /sequence_relationships GET /sequence_relationships.json



8
9
10
11
# 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

- (Object) list



27
28
29
# File 'app/controllers/sequence_relationships_controller.rb', line 27

def list
  @sequence_relationships = SequenceRelationship.with_project_id(sessions_current_project_id).page(params[:page])
end

- (Object) new

GET /sequence_relationships/new



19
20
21
# File 'app/controllers/sequence_relationships_controller.rb', line 19

def new
  @sequence_relationship = SequenceRelationship.new
end

- (Object) preview_primers_batch_load



82
83
84
85
86
87
88
89
90
91
# File 'app/controllers/sequence_relationships_controller.rb', line 82

def preview_primers_batch_load 
  if params[:file] 
    @result = BatchLoad::Import::SequenceRelationships::PrimersInterpreter.new(batch_params)
    digest_cookie(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

- (Object) search



71
72
73
74
75
76
77
# File 'app/controllers/sequence_relationships_controller.rb', line 71

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

- (Object) sequence_relationship_params (private)

Never trust parameters from the scary internet, only allow the white list through.



115
116
117
# File 'app/controllers/sequence_relationships_controller.rb', line 115

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

- (Object) set_sequence_relationship (private)

Use callbacks to share common setup or constraints between actions.



110
111
112
# File 'app/controllers/sequence_relationships_controller.rb', line 110

def set_sequence_relationship
  @sequence_relationship = SequenceRelationship.find(params[:id])
end

- (Object) show

GET /sequence_relationships/1 GET /sequence_relationships/1.json



15
16
# File 'app/controllers/sequence_relationships_controller.rb', line 15

def show
end

- (Object) update

PATCH/PUT /sequence_relationships/1 PATCH/PUT /sequence_relationships/1.json



49
50
51
52
53
54
55
56
57
58
59
# File 'app/controllers/sequence_relationships_controller.rb', line 49

def update
  respond_to do |format|
    if @sequence_relationship.update(sequence_relationship_params)
      format.html { redirect_to @sequence_relationship.metamorphosize, 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