Class: Api::V2::VolumeUpdateResource

Inherits:
BaseResource
  • Object
show all
Defined in:
app/resources/api/v2/volume_update_resource.rb

Overview

Note:

Access this resource via the /api/v2/volume_updates/ endpoint.

Note:

Updates are not allowed on this resource @see self.updatable_fields

Provides a JSON:API representation of VolumeUpdate for the tracking of volume changes associated with labware.

Performs a change of volume on a resource Primarily created on plates via Assets Audits application to indicate reduced volume on, eg. working dilution creation. No records exist on 29/05/2019 due to no volumes configured for processes

For more information about JSON:API, see the JSON:API Specifications or look at the JSONAPI::Resources package for Sequencescape's implementation of the JSON:API standard.

Examples:

POST request to create a volume update

POST /api/v2/volume_updates/
{
  "data": {
    "type": "volume_updates",
    "attributes": {
      "created_by": "me",
      "target_uuid": "9dc5f262-f524-11ef-8842-000000000000",
      "volume_change": -2.345
    }
  }
}

GET request for all VolumeUpdate resources

GET /api/v2/volume_updates/

GET request for a specific VolumeUpdate resource with ID 123

GET /api/v2/volume_updates/123/

Instance Attribute Summary collapse

Class Method Summary collapse

Methods inherited from BaseResource

apply_includes, creatable_fields, default_includes, #fetchable_fields, inclusions, resolve_relationship_names_to_relations

Instance Attribute Details

#created_byString

TODO:

This can be any string, update to use a user relationship See Y25-236.

Note:

This attribute is required.

The user who created the volume update.

Returns:

  • (String)

    the UUID of the user who created the volume update.



50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# File 'app/resources/api/v2/volume_update_resource.rb', line 50

 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

#target_uuidString

Transforms the target Labware into its UUID when generating an API query response.

Returns:

  • (String)

    the UUID of the associated target labware.



56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# File 'app/resources/api/v2/volume_update_resource.rb', line 56

 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

#volume_changeFloat

Note:

This attribute is required.

The amount of volume change that occurred on the target labware.

Returns:

  • (Float)

    the volume change value (e.g., 5.0 for an increase of 5 units).



62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
# File 'app/resources/api/v2/volume_update_resource.rb', line 62

 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

Class Method Details

.updatable_fields(_context) ⇒ Array<Symbol>

TODO:

Use except: %i[update] in routes.rb or the access restrictions instead of this approach See Y25-236.

Gets the list of fields which are updatable on an existing VolumeUpdate.

Parameters:

  • _context (JSONAPI::Resource::Context)

    not used.

Returns:

  • (Array<Symbol>)

    the list of updatable fields (empty in this case as updates are not allowed).



93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
# File 'app/resources/api/v2/volume_update_resource.rb', line 93

 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