Class: Accessionable::Base::Tag::FieldCollectionDate

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

Overview

Value serialization for collection date in accessioning XML generation It will return a valid collection date 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 NB: this regexp is defined in https://www.ebi.ac.uk/ena/browser/api/xml/ERC000011

Constant Summary collapse

REGEXP =

rubocop:disable Layout/LineLength

%r{(^[12][0-9]{3}(-(0[1-9]|1[0-2])(-(0[1-9]|[12][0-9]|3[01])(T[0-9]{2}:[0-9]{2}(:[0-9]{2})?Z?([+-][0-9]{1,2})?)?)?)?(/[0-9]{4}(-[0-9]{2}(-[0-9]{2}(T[0-9]{2}:[0-9]{2}(:[0-9]{2})?Z?([+-][0-9]{1,2})?)?)?)?)?$)}

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)


154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
# File 'app/models/accessionable/base.rb', line 154

 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

rubocop:enable Layout/LineLength



147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
# File 'app/models/accessionable/base.rb', line 147

 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