Class: DescriptorsController
Constant Summary
ProjectsHelper::CLASSIFIER, ProjectsHelper::CLASSIFIER_ANNOTATION
Instance Method Summary
collapse
#annotator_params
#set_time_zone
#destroy_redirect
#json_request?
Methods included from LogRecent
#log_user_recent_route
Methods included from Cookies
#digest_cookie, #digested_cookie_exists?
Methods included from Whitelist
#whitelist_constantize
#cumulative_gb_per_year, #cumulative_projects_created_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_initials, #project_link, #project_login_link, #project_matches, #project_tag, #projects_list, #projects_search_form, #sound_cumulative_gb_per_year, #sound_gb_per_year, #taxonworks_classification, #week_in_review_graphs
#intercept_api
#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
117
118
119
120
|
# File 'app/controllers/descriptors_controller.rb', line 117
def annotations
@object = @descriptor
render '/shared/data/all/annotations'
end
|
#autocomplete ⇒ Object
101
102
103
104
|
# File 'app/controllers/descriptors_controller.rb', line 101
def autocomplete
@term = params[:term]
@descriptors = Queries::Descriptor::Autocomplete.new(params.require(:term), project_id: sessions_current_project_id).all
end
|
#batch_load ⇒ Object
122
123
|
# File 'app/controllers/descriptors_controller.rb', line 122
def batch_load
end
|
#batch_params ⇒ Object
209
210
211
212
213
|
# File 'app/controllers/descriptors_controller.rb', line 209
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
51
52
53
54
55
56
57
58
59
60
61
62
63
|
# File 'app/controllers/descriptors_controller.rb', line 51
def create
@descriptor = Descriptor.new(descriptor_params)
respond_to do |format|
if @descriptor.save
format.html { redirect_to url_for(@descriptor.metamorphosize),
notice: 'Descriptor was successfully created.' }
format.json { render :show, status: :created, location: @descriptor.metamorphosize }
else
format.html { render :new }
format.json { render json: @descriptor.metamorphosize.errors, status: :unprocessable_content }
end
end
end
|
#create_modify_gene_descriptor_batch_load ⇒ Object
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
|
# File 'app/controllers/descriptors_controller.rb', line 147
def create_modify_gene_descriptor_batch_load
if params[:file] && digested_cookie_exists?(
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
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
|
# File 'app/controllers/descriptors_controller.rb', line 166
def create_qualitative_descriptor_batch_load
if params[:file] && digested_cookie_exists?(
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
200
201
202
203
204
205
206
207
|
# File 'app/controllers/descriptors_controller.rb', line 200
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
88
89
90
91
92
93
94
95
96
97
98
99
|
# File 'app/controllers/descriptors_controller.rb', line 88
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.full_messages.join('; ') }
format.json { render json: @descriptor.errors, status: :unprocessable_content }
end
end
end
|
#edit ⇒ Object
45
46
47
|
# File 'app/controllers/descriptors_controller.rb', line 45
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
24
25
26
27
|
# 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')
if helpers.extend_response_with('observation_matrices')
@descriptors = @descriptors.includes(:observation_matrices)
end
}
end
end
|
#list ⇒ Object
34
35
36
|
# File 'app/controllers/descriptors_controller.rb', line 34
def list
@descriptor = Descriptor.with_project_id(sessions_current_project_id).page(params[:page])
end
|
#new ⇒ Object
39
40
41
42
|
# File 'app/controllers/descriptors_controller.rb', line 39
def new
@descriptor = Descriptor.new
redirect_to new_descriptor_task_path(), notice: 'Using task interface.'
end
|
#preview_modify_gene_descriptor_batch_load ⇒ Object
125
126
127
128
129
130
131
132
133
134
|
# File 'app/controllers/descriptors_controller.rb', line 125
def preview_modify_gene_descriptor_batch_load
if params[:file]
@result = BatchLoad::Import::Descriptors::ModifyGeneDescriptorInterpreter.new(**batch_params)
digest_cookie(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
136
137
138
139
140
141
142
143
144
145
|
# File 'app/controllers/descriptors_controller.rb', line 136
def preview_qualitative_descriptor_batch_load
if params[:file]
@result = BatchLoad::Import::Descriptors::QualitativeInterpreter.new(**batch_params)
digest_cookie(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
106
107
108
109
110
111
112
113
|
# File 'app/controllers/descriptors_controller.rb', line 106
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
196
197
198
|
# File 'app/controllers/descriptors_controller.rb', line 196
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
31
32
|
# File 'app/controllers/descriptors_controller.rb', line 31
def show
end
|
#sort ⇒ Object
PATCH /descriptors/sort.json?ids=1&ids=2
189
190
191
192
|
# File 'app/controllers/descriptors_controller.rb', line 189
def sort
Descriptor.sort(params.require(:ids), sessions_current_project_id)
head :no_content
end
|
#units ⇒ Object
184
185
186
|
# File 'app/controllers/descriptors_controller.rb', line 184
def units
render json: UNITS
end
|
#update ⇒ Object
PATCH/PUT /descriptors/1
PATCH/PUT /descriptors/1.json
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
|
# File 'app/controllers/descriptors_controller.rb', line 67
def update
respond_to do |format|
begin
if @descriptor.update(descriptor_params)
format.html { redirect_to url_for(@descriptor.metamorphosize),
notice: 'Descriptor was successfully updated.' }
format.json { render :show, status: :ok, location: @descriptor.metamorphosize }
else
format.html { render :edit }
format.json { render json: @descriptor.metamorphosize.errors, status: :unprocessable_content }
end
rescue ActiveRecord::RecordNotDestroyed
format.html { render :edit }
format.json { render json: 'Could not destroy, do observations still exist?', status: :unprocessable_content }
end
end
end
|