Class: Api::V2::WorkCompletionResource

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

Overview

Note:

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

Note:

This resource cannot be modified after creation: its endpoint will not accept PATCH requests.

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 WorkCompletion (by uuids - deprecated)

POST /api/v2/work_completions/
{
  "data": {
    "type": "work_completions",
    "attributes": {
      "submission_uuids": ["11111111-2222-3333-4444-555555666666"],
      "target_uuid": "33333333-4444-5555-6666-777777888888",
      "user_uuid": "99999999-0000-1111-2222-333333444444"
    }
  }
}

POST request to create a WorkCompletion using relationships

POST /api/v2/work_completions/
{
  "data": {
    "type": "work_completions",
    "relationships": {
      "submissions": {
          "data": [
            { "type": "submissions", "id": 1 }
          ]
      },
      "target": {
          "data": { "type": "labware", "id": 1 }
      },
      "user": {
          "data": { "type": "users", "id": 4 }
      }
    }
  }
}

GET request for all WorkCompletion resources

GET /api/v2/work_completions/

GET request for a WorkCompletion with ID 123

GET /api/v2/work_completions/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

#submission_uuids=(value) ⇒ Void (writeonly)

Deprecated.

Use the submissions relationship instead. See Y25-236.

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

Parameters:

  • value (Array<String>)

    The UUIDs of the Submissions related to this WorkCompletion.

Returns:

  • (Void)

See Also:



70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
# File 'app/resources/api/v2/work_completion_resource.rb', line 70

 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

#submissionsArray<SubmissionResource>

Note:

This relationship is required.

An array of submissions which will be passed (although this is done through the request ids on the aliquots, not directly through the submissions). Setting this relationship alongside the submission_uuids attribute will override the attribute value.

Returns:



113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
# File 'app/resources/api/v2/work_completion_resource.rb', line 113

 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

#targetLabwareResource

Note:

This relationship is required.

The labware on which the library has been completed. Setting this relationship alongside the target_uuid attribute will override the attribute value.

Returns:

  • (LabwareResource)

    The Labware which this WorkCompletion is associated with.



120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
# File 'app/resources/api/v2/work_completion_resource.rb', line 120

 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_uuid=(value) ⇒ Void (writeonly)

Deprecated.

Use the target relationship instead.

This is declared for convenience where the target Labware is not available to set as a relationship. Setting this attribute alongside the target relationship will prefer the relationship value.

Parameters:

  • value (String)

    The UUID of the Labware that this work completion targets.

Returns:

  • (Void)

See Also:



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

 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.

The user performing the action Setting this relationship alongside the user_uuid attribute will override the attribute value.

Returns:

  • (UserResource)

    The User who initiated this WorkCompletion.



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

 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 this work completion.

Returns:

  • (Void)

See Also:



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

 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