Class: SampleManifestExcel::Upload::Processor::OneDTube

Inherits:
Base
  • Object
show all
Defined in:
app/sample_manifest_excel/sample_manifest_excel/upload/processor/one_d_tube.rb

Overview

TODO: had to explicitly specify the namespace for Base here otherwise it picks up Upload::Base Processor to handle 1dtube uploads

Constant Summary

Constants inherited from Base

Base::MANDATORY_FIELDS

Instance Attribute Summary

Attributes inherited from Base

#upload

Instance Method Summary collapse

Methods inherited from Base

#aliquots_updated?, #create_samples_if_not_present, #downstream_aliquots_updated?, #initialize, #processed?, #run, #sample_manifest_updated?, #samples_updated?, #samples_valid?, #substitutions, #type, #update_sample_manifest, #update_samples_and_aliquots

Constructor Details

This class inherits a constructor from SampleManifestExcel::Upload::Processor::Base

Instance Method Details

#check_for_retention_instructionObject

rubocop:disable Metrics/CyclomaticComplexity, Metrics/AbcSize, Metrics/MethodLength



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'app/sample_manifest_excel/sample_manifest_excel/upload/processor/one_d_tube.rb', line 12

def check_for_retention_instruction
  upload.rows.each do |row|
    # ignore empty rows and skip if the retention column is not present
    next if row.columns.blank? || row.data.blank? || row.columns.extract(['retention_instruction']).count.zero?

    tube_barcode = row.value('sanger_tube_id')
    sample_id = row.value('sanger_sample_id')

    # ignore rows where primary sample fields have not been filled in
    next unless tube_barcode.present? && sample_id.present?

    # check the row retention instruction is valid
    err_msg = check_row_retention_value(row)
    next unless err_msg

    errors.add(
      :base,
      "Retention instruction checks failed at row: #{row.number}. #{err_msg}"
    )
    break
  end
end

#check_row_retention_value(row) ⇒ Object

rubocop:enable Metrics/CyclomaticComplexity, Metrics/AbcSize, Metrics/MethodLength



36
37
38
39
# File 'app/sample_manifest_excel/sample_manifest_excel/upload/processor/one_d_tube.rb', line 36

def check_row_retention_value(row)
  # if present the column is mandatory
  'Value cannot be blank.' if row.value('retention_instruction').nil?
end