Class: Accessionable::Base::Tag::FieldSerializer

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

Overview

Value serialization for accessioning XML generation It will return the same value without any changes and it applies to all tags

Direct Known Subclasses

FieldCollectionDate, FieldCountryOfOrigin

Constant Summary collapse

NOT_COLLECTED =
'not collected'
NOT_PROVIDED =
'not provided'
RESTRICTED_ACCESS =
'restricted access'
NOT_APPLICABLE_CONTROL_SAMPLE =
'not applicable: control sample'
NOT_APPLICABLE_SAMPLE_GROUP =
'not applicable: sample group'
MISSING_SYNTHETIC_CONSTRUCT =
'missing: synthetic construct'
MISSING_LAB_STOCK =
'missing: lab stock'
MISING_THIRD_PARTY_DATA =
'missing: third party data'
MISSING_DATA_AGGREEMENT_PRE2023 =
'missing: data agreement established pre-2023'
MISSING_ENDANGERED_SPECIES =
'missing: endangered species'
MISSING_HUMAN_IDENTIFIABLE =
'missing: human-identifiable'
MISSING_CONTROL_SAMPLE =
'missing: control sample'
MISSING_SAMPLE_GROUP =
'missing: sample group'
OTHER_DEFAULT_SETTINGS =
[
  NOT_COLLECTED,
  NOT_PROVIDED,
  RESTRICTED_ACCESS,
  NOT_APPLICABLE_CONTROL_SAMPLE,
  NOT_APPLICABLE_SAMPLE_GROUP,
  MISSING_SYNTHETIC_CONSTRUCT,
  MISSING_LAB_STOCK,
  MISING_THIRD_PARTY_DATA,
  MISSING_DATA_AGGREEMENT_PRE2023,
  MISSING_ENDANGERED_SPECIES,
  MISSING_HUMAN_IDENTIFIABLE,
  MISSING_CONTROL_SAMPLE,
  MISSING_SAMPLE_GROUP
].freeze

Instance Method Summary collapse

Instance Method Details

#applies_to?(_name) ⇒ Boolean

Returns:

  • (Boolean)


111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
# File 'app/models/accessionable/base.rb', line 111

 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

#incorrect_format_valueObject



115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
# File 'app/models/accessionable/base.rb', line 115

 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



107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
# File 'app/models/accessionable/base.rb', line 107

 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