Class: Api::V2::SpecificTubeCreationResource

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

Overview

Note:

the below example does not include the children as relationships, but via the child_purpose_uuids attribute. This is to be deprecated and should be replaced with the a relevant relationship.

For more information about JSON:API, see the JSON:API Specifications or refer to the JSONAPI::Resources package for Sequencescape’s implementation of the JSON:API standard.

Examples:

POST request with child purposes and parents specified by relationships

POST /api/v2/specific_tube_creations/
{
  "data": {
    "type": "specific_tube_creations",
    "attributes": {
      "child_purpose_uuids": [
          "40c0d714-fb53-11ef-bc6c-000000000000", "40c0d714-fb53-11ef-bc6c-000000000000"
      ],
      "tube_attributes": [{ "name": "Tube 1" }, { "name": "Tube 2" }]
    },
    "relationships": {
      "parents": {
        "data": [{ "type": "labware", "id": 3 }]
      },
      "user": {
        "data": { "type": "users", "id": 4 }
      }
    }
  }
}

GET request for all SpecificTubeCreation resources

GET /api/v2/specific_tube_creations/

GET request for a SpecificTubeCreation with ID 123

GET /api/v2/specific_tube_creations/123/

Instance Attribute Summary collapse

Method Summary

Methods inherited from BaseResource

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

Instance Attribute Details

#child_purpose_uuids=(value) ⇒ Void (writeonly)

TODO:

Update writeone to be write_once as resource is not updatable

TODO:

Deprecate - Create the child_purposes (or children) relationship instead. See Y25-236.

This is currently declared for convenience as child purposes do not appear to be set as a relationship. Setting this attribute alongside the relevant relationship shold prefer the relationship value.

Parameters:

  • value (Array<String>)

    Array of UUIDs for child purposes to use in the creation of tubes.

Returns:

  • (Void)


84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
# File 'app/resources/api/v2/specific_tube_creation_resource.rb', line 84

 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

#childrenArray<TubeResource> (readonly)

TODO:

fix this relationship as it currently appears to be broken See Y25-236.

Returns An array of tubes that were created.

Returns:

  • (Array<TubeResource>)

    An array of tubes that were created.



142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
# File 'app/resources/api/v2/specific_tube_creation_resource.rb', line 142

 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

#parent_uuids=(value) ⇒ Void (writeonly)

Deprecated.

Use the parents relationship instead. See Y25-236.

TODO:

Update writeone to be write_once as resource is not updatable

This is declared for convenience where the parent tubes are not available to set as a relationship. Setting this attribute alongside the parents relationship will prefer the relationship value.

Parameters:

  • value (Array<String>)

    The UUIDs of labware that will be the parents for all tubes created.

Returns:

  • (Void)

See Also:



99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
# File 'app/resources/api/v2/specific_tube_creation_resource.rb', line 99

 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

#parentsArray<LabwareResource>

Note:

This relationship is required.

Setting this relationship alongside the parent_uuids attribute will override the attribute value.

Returns:

  • (Array<LabwareResource>)

    An array of parent tubes for the created tubes.



148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
# File 'app/resources/api/v2/specific_tube_creation_resource.rb', line 148

 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

#tube_attributes=(value) ⇒ Void (writeonly)

TODO:

Update writeone to be write_once as resource is not updatable See Y25-236.

Parameters:

  • value (Array<Hash>)

    Array of attribute hashes to apply to each tube being created. This can be used to set custom properties, such as tube names.

Returns:

  • (Void)


111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
# File 'app/resources/api/v2/specific_tube_creation_resource.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

#userUserResource

Note:

This relationship is required.

Setting this relationship alongside the user_uuid attribute will override the attribute value.

Returns:

  • (UserResource)

    The user who initiated the creation of tubes.



154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
# File 'app/resources/api/v2/specific_tube_creation_resource.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

#user_uuid=(value) ⇒ Void (writeonly)

Deprecated.

Use the user relationship instead.

See Y25-236. This is declared for convenience where the user is not available to set as a relationship. Setting this attribute alongside the user relationship will prefer the relationship value.

Parameters:

  • value (String)

    The UUID of the user who initiated the creation of tubes.

Returns:

  • (Void)

See Also:



128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
# File 'app/resources/api/v2/specific_tube_creation_resource.rb', line 128

 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

#uuidString (readonly)

Note:

This identifier is automatically assigned upon creation and cannot be modified.

Returns The UUID of the specific tube creation event.

Returns:

  • (String)

    The UUID of the specific tube creation event.



74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
# File 'app/resources/api/v2/specific_tube_creation_resource.rb', line 74

 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