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


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

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)

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

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

#check_data_release_and_accession_for_submissionObject


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

def check_data_release_and_accession_for_submission
  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 not study.ena_accession_required?
    # Nothing to do here because the study does not require ENA accessioning
  elsif 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

#request_types_require_accessioning?Boolean

Returns:

  • (Boolean)

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

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