Class: Api::V2::Sapio::StudyResource
- Inherits:
-
BaseResource
- Object
- JSONAPI::Resource
- BaseResource
- Api::V2::Sapio::StudyResource
- Includes:
- StudySearchQuery
- Defined in:
- app/resources/api/v2/sapio/study_resource.rb
Overview
The reference_genome relationship on studies is not accurate and not exposed in this
resource. Use the reference_genome relationship on study_metadata instead.
Access this resource via the /api/v2/sapio/studies/ endpoint.
Requires the :y26_172_enable_externally_managed_study_restrictions feature flag to
be enabled. Returns 404 Not Found otherwise.
Requests that modify data require a valid Integration Hub API key. If this key is not provided, the request will return a 403 Forbidden response. See the examples for more details.
It does not subclass Api::V2::StudyResource to decouple it from the default Study
resource, which is used by other API consumers.
When the y26_245_sapio_study_upsert feature flag is enabled,
this method behaves as an upsert based on the supplied uuid: if
Sequencescape does not already have a Study with that uuid, a new
Study is created as described above; if it already has one, that
Study is instead marked externally_managed (if not already) and
broadcast to mlwarehouse, rather than raising a conflict. No other
attributes on the existing Study are changed by this. This means
the method CAN be used to transfer an existing Sequencescape study
to the external LIMS, once this flag is enabled. When this feature
flag is disabled, this method is intended exclusively for creating
new studies that originate in an external LIMS, and should NOT be
used to transfer an existing Sequencescape study to the external
LIMS - supplying a uuid that already exists will return a
409 Conflict instead.
Sapio-specific Study resource for Integration Hub consumers.
Indexing and Searching
For index requests, this resource supports only filtering by name, and it does not allow listing studies without a filter.
Creating a New Externally Managed Study
The POST method creates a new Study that is managed externally, granting ownership to the requesting user.
If a UUID is not provided, one will be generated automatically.
Updating an Existing Study
Existing studies can be updated using the PATCH method. Only studies that have been marked
as externally_managed can be updated via this endpoint. Attempts to update a study that is
not externally managed will return a 423 Locked response.
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.
Constant Summary
Constants included from StudySearchQuery
Api::V2::Sapio::StudySearchQuery::MAX_RESULTS
Instance Attribute Summary collapse
-
#blocked ⇒ Boolean
readonly
Whether the study is blocked.
-
#created_at ⇒ String
readonly
Timestamp when the study was created.
-
#enforce_accessioning ⇒ Boolean
readonly
Whether accessioning enforcement is enabled.
-
#enforce_data_release ⇒ Boolean
readonly
Whether data release enforcement is enabled.
-
#ethically_approved ⇒ Boolean
readonly
Whether ethical approval is set.
-
#externally_managed ⇒ Boolean
readonly
Whether the study is managed by an external LIMS.
-
#name ⇒ String
readonly
The name of the study.
-
#state ⇒ String
The state of the study (pending, active, or inactive).
-
#study_metadata ⇒ StudyMetadataResource
readonly
The metadata associated with this study, containing additional details like faculty sponsor.
-
#updated_at ⇒ String
readonly
Timestamp when the study was last updated.
-
#user ⇒ UserResource?
readonly
The user associated with this study.
-
#uuid ⇒ String
A version 1 UUID that uniquely identifies the study.
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
#blocked ⇒ Boolean (readonly)
All rows in production have this column set to false.
Returns Whether the study is blocked.
188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 |
# File 'app/resources/api/v2/sapio/study_resource.rb', line 188 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 |
#created_at ⇒ String (readonly)
Returns Timestamp when the study was created.
177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 |
# File 'app/resources/api/v2/sapio/study_resource.rb', line 177 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 |
#enforce_accessioning ⇒ Boolean (readonly)
Returns Whether accessioning enforcement is enabled.
209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 |
# File 'app/resources/api/v2/sapio/study_resource.rb', line 209 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 |
#enforce_data_release ⇒ Boolean (readonly)
Returns Whether data release enforcement is enabled.
205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 |
# File 'app/resources/api/v2/sapio/study_resource.rb', line 205 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 |
#ethically_approved ⇒ Boolean (readonly)
Returns Whether ethical approval is set.
201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 |
# File 'app/resources/api/v2/sapio/study_resource.rb', line 201 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 |
#externally_managed ⇒ Boolean (readonly)
Cannot be updated after creation.
Returns Whether the study is managed by an external LIMS.
197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 |
# File 'app/resources/api/v2/sapio/study_resource.rb', line 197 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 |
#name ⇒ String (readonly)
This attribute is required when creating a new study.
Cannot be updated after creation.
Maximum length is 200 characters.
Must be unique across all studies.
Returns The name of the study.
161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 |
# File 'app/resources/api/v2/sapio/study_resource.rb', line 161 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 |
#state ⇒ String
Returns The state of the study (pending, active, or inactive).
192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 |
# File 'app/resources/api/v2/sapio/study_resource.rb', line 192 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 |
#study_metadata ⇒ StudyMetadataResource (readonly)
Returns The metadata associated with this study, containing additional details like faculty sponsor.
145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 |
# File 'app/resources/api/v2/sapio/study_resource.rb', line 145 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 |
#updated_at ⇒ String (readonly)
study_metadata association specifies touch: true, so updated_at will reflect changes to the study_metadata as well.
Returns Timestamp when the study was last updated.
183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 |
# File 'app/resources/api/v2/sapio/study_resource.rb', line 183 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 ⇒ UserResource? (readonly)
Returns The user associated with this study.
149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 |
# File 'app/resources/api/v2/sapio/study_resource.rb', line 149 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 |
#uuid ⇒ String
Cannot be updated after creation.
A version 1 UUID that uniquely identifies the study.
167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 |
# File 'app/resources/api/v2/sapio/study_resource.rb', line 167 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 |