Class: Accessionable::Base::Tag::FieldCountryOfOrigin

Inherits:
FieldSerializer show all
Defined in:
app/models/accessionable/base.rb

Overview

Value serialization for country of origin in accessioning XML generation It will return a valid country of origin or 'not collected' if nothing provided or invalid It also allow other config settings for the XML service like the list defined inside OTHER_DEFAULT_SETTINGS

Constant Summary

Constants inherited from FieldSerializer

Accessionable::Base::Tag::FieldSerializer::MISING_THIRD_PARTY_DATA, Accessionable::Base::Tag::FieldSerializer::MISSING_CONTROL_SAMPLE, Accessionable::Base::Tag::FieldSerializer::MISSING_DATA_AGGREEMENT_PRE2023, Accessionable::Base::Tag::FieldSerializer::MISSING_ENDANGERED_SPECIES, Accessionable::Base::Tag::FieldSerializer::MISSING_HUMAN_IDENTIFIABLE, Accessionable::Base::Tag::FieldSerializer::MISSING_LAB_STOCK, Accessionable::Base::Tag::FieldSerializer::MISSING_SAMPLE_GROUP, Accessionable::Base::Tag::FieldSerializer::MISSING_SYNTHETIC_CONSTRUCT, Accessionable::Base::Tag::FieldSerializer::NOT_APPLICABLE_CONTROL_SAMPLE, Accessionable::Base::Tag::FieldSerializer::NOT_APPLICABLE_SAMPLE_GROUP, Accessionable::Base::Tag::FieldSerializer::NOT_COLLECTED, Accessionable::Base::Tag::FieldSerializer::NOT_PROVIDED, Accessionable::Base::Tag::FieldSerializer::OTHER_DEFAULT_SETTINGS, Accessionable::Base::Tag::FieldSerializer::RESTRICTED_ACCESS

Instance Method Summary collapse

Methods inherited from FieldSerializer

#incorrect_format_value

Instance Method Details

#applies_to?(name) ⇒ Boolean

Returns:

  • (Boolean)


131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
# File 'app/models/accessionable/base.rb', line 131

 do
  # NOTE: The following attribute is not required for Microarray Genotyping.
  # I think this might be broken and suggests that there should be separate classes for project: one for
  # next-gen sequencing that includes this attribute in it's metadata, and one for microarray genotyping
  # that doesn't.
  include ProjectManager::Associations
  include BudgetDivision::Associations

  custom_attribute(:project_cost_code, required: true)
  custom_attribute(:funding_comments)
  custom_attribute(:collaborators)
  custom_attribute(:external_funding_source)
  custom_attribute(:sequencing_budget_cost_centre)
  custom_attribute(:project_funding_model, in: PROJECT_FUNDING_MODELS)
  custom_attribute(:gt_committee_tracking_id)

  before_validation do |record|
    record.project_cost_code = nil if record.project_cost_code.blank?
    record.project_funding_model = nil if record.project_funding_model.blank?
  end
end

#value_for(value) ⇒ Object



124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
# File 'app/models/accessionable/base.rb', line 124

 do
  # NOTE: The following attribute is not required for Microarray Genotyping.
  # I think this might be broken and suggests that there should be separate classes for project: one for
  # next-gen sequencing that includes this attribute in it's metadata, and one for microarray genotyping
  # that doesn't.
  include ProjectManager::Associations
  include BudgetDivision::Associations

  custom_attribute(:project_cost_code, required: true)
  custom_attribute(:funding_comments)
  custom_attribute(:collaborators)
  custom_attribute(:external_funding_source)
  custom_attribute(:sequencing_budget_cost_centre)
  custom_attribute(:project_funding_model, in: PROJECT_FUNDING_MODELS)
  custom_attribute(:gt_committee_tracking_id)

  before_validation do |record|
    record.project_cost_code = nil if record.project_cost_code.blank?
    record.project_funding_model = nil if record.project_funding_model.blank?
  end
end