Class: PlatesController
Constant Summary
FlashTruncation::STRING_OVERHEAD
Instance Method Summary
collapse
#block_api_access, #evil_parameter_hack!, #extract_header_info, #set_cache_disabled!
#max_flash_size, #truncate_flash, #truncate_flash_array
Instance Method Details
#create ⇒ Object
rubocop:todo Metrics/MethodLength
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
# File 'app/controllers/plates_controller.rb', line 24
def create @creator = plate_creator = Plate::Creator.find(params[:plates][:creator_id])
barcode_printer = BarcodePrinter.find(params[:plates][:barcode_printer])
source_plate_barcodes = params[:plates][:source_plates]
create_asset_group = params[:plates][:create_asset_group] == 'Yes'
scanned_user = User.find_with_barcode_or_swipecard_code(params[:plates][:user_barcode])
respond_to do |format|
if scanned_user.nil?
flash[:error] = 'Please scan your user barcode'
elsif tube_rack_sources?
plate_creator.create_plates_from_tube_racks!(tube_racks, barcode_printer, scanned_user, create_asset_group)
else
plate_creator.execute(
source_plate_barcodes,
barcode_printer,
scanned_user,
create_asset_group,
Plate::CreatorParameters.new(params[:plates])
)
end
flash[:notice] = 'Created plates successfully'
flash[:warning] = plate_creator.warnings if plate_creator.warnings.present?
format.html { render(new_plate_path) }
end
rescue StandardError => e
respond_to do |format|
flash[:error] = e.message
format.html { render(new_plate_path) }
end
end
|
#create_sample_tubes ⇒ Object
rubocop:todo Metrics/AbcSize, Metrics/MethodLength
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
|
# File 'app/controllers/plates_controller.rb', line 89
def create_sample_tubes barcode_printer = BarcodePrinter.find(params[:plates][:barcode_printer])
barcode_array = params[:plates][:source_plates].scan(/\w+/)
plates = Plate.with_barcode(barcode_array)
study = Study.find(params[:plates][:study])
respond_to do |format|
asset_group =
Plate::SampleTubeFactory.create_sample_tubes_asset_group_and_print_barcodes(plates, barcode_printer, study)
if asset_group
flash[:notice] = 'Created tubes and printed barcodes'
format.html { redirect_to(new_submission_path(study_id: asset_group.study.id)) }
format.xml { render xml: asset_group, status: :created }
format.json { render json: asset_group, status: :created }
else
flash[:error] = 'Failed to create sample tubes'
format.html { redirect_to(to_sample_tubes_plates_path) }
format.xml { render xml: flash.to_xml, status: :unprocessable_entity }
format.json { render json: flash.to_json, status: :unprocessable_entity }
end
end
end
|
#fluidigm_file ⇒ Object
114
115
116
117
118
119
120
|
# File 'app/controllers/plates_controller.rb', line 114
def fluidigm_file
if logged_in?
@plate = Plate.includes(wells: [{ samples: :sample_metadata }, :map]).find(params[:id])
@parents = @plate.parents
respond_to { |format| format.csv { render csv: @plate, content_type: 'text/csv' } }
end
end
|
#new ⇒ Object
15
16
17
18
19
20
21
|
# File 'app/controllers/plates_controller.rb', line 15
def new
respond_to do |format|
format.html
format.xml { render xml: @plate }
format.json { render json: @plate }
end
end
|
#set_barcode_printers ⇒ Object
63
64
65
66
|
# File 'app/controllers/plates_controller.rb', line 63
def set_barcode_printers
@barcode_printers = BarcodePrinterType96Plate.first.barcode_printers
@barcode_printers = BarcodePrinter.order('name asc') if @barcode_printers.blank?
end
|
#set_plate_creators ⇒ Object
rubocop:enable Metrics/MethodLength
59
60
61
|
# File 'app/controllers/plates_controller.rb', line 59
def set_plate_creators
@plate_creators = Plate::Creator.order(:name)
end
|
#show ⇒ Object
11
12
13
|
# File 'app/controllers/plates_controller.rb', line 11
def show
@plate = Plate.find(params[:id])
end
|
#to_sample_tubes ⇒ Object
84
85
86
87
|
# File 'app/controllers/plates_controller.rb', line 84
def to_sample_tubes
@barcode_printers = BarcodePrinter.all
@studies = Study.alphabetical
end
|
#tube_rack_barcodes ⇒ Object
68
69
70
71
72
|
# File 'app/controllers/plates_controller.rb', line 68
def tube_rack_barcodes
return [] unless params.dig(:plates, :source_plates)
params[:plates][:source_plates].split(/[\s,]+/)
end
|
#tube_rack_sources? ⇒ Boolean
74
75
76
77
78
|
# File 'app/controllers/plates_controller.rb', line 74
def tube_rack_sources?
return false if tube_rack_barcodes.empty?
tube_racks.count == tube_rack_barcodes.length
end
|
#tube_racks ⇒ Object
80
81
82
|
# File 'app/controllers/plates_controller.rb', line 80
def tube_racks
@tube_racks ||= TubeRack.joins(:barcodes).where(barcodes: { barcode: tube_rack_barcodes })
end
|