Module: Submission::AccessionBehaviour

Included in:
Order
Defined in:
app/models/submission/accession_behaviour.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object



3
4
5
6
7
# File 'app/models/submission/accession_behaviour.rb', line 3

def self.included(base)
  base.class_eval do
    validate :check_data_release_and_accession_for_submission, if: :can_check_data_release_and_accession?
  end
end

Instance Method Details

#can_check_data_release_and_accession?Boolean

Returns:

  • (Boolean)


9
10
11
# File 'app/models/submission/accession_behaviour.rb', line 9

def can_check_data_release_and_accession?
  study.present? && request_types_require_accessioning?
end

#check_data_release_and_accession_for_submissionObject

rubocop:todo Metrics/AbcSize



17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'app/models/submission/accession_behaviour.rb', line 17

def check_data_release_and_accession_for_submission # rubocop:todo Metrics/AbcSize
  return if configatron.disable_accession_check == true

  if not study.valid_data_release_properties?
    errors.add(:study, "#{study.name}: Please fill in the study data release information")
  elsif study.accession_required?
    if not study.accession_number?
      errors.add(:study, "#{study.name} and all samples must have accession numbers")
    elsif not all_samples_have_accession_numbers?
      errors.add(:base, "The following samples are missing accession numbers: #{unaccessioned_samples}")
    end
  end
end

#request_types_require_accessioning?Boolean

Returns:

  • (Boolean)


13
14
15
# File 'app/models/submission/accession_behaviour.rb', line 13

def request_types_require_accessioning?
  RequestType.find(request_types).detect(&:accessioning_required?)
end