-
Notifications
You must be signed in to change notification settings - Fork 55
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: 1878 copy cell lines #1923
Closed
Closed
Changes from all commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
af51e8e
feature: scaffhold of cell line sample copy created
FabianMauz caf9b08
feat: create empty CelllineSample when copy is executed.
c51fe20
feat: create new cell_line with copied attributes
6bd053a
refactor: add loading to copy test
FabianMauz 0a01175
feat: update short label and counter at copiing cell lines
FabianMauz 9cd9da9
feat: add rest endpoint for copy cell lines
FabianMauz 9996875
feat: add links to collections of copied cell lines
FabianMauz 4c302c9
merged with main
FabianMauz aa460fe
feat: add frontend ui for creating cell lines
FabianMauz 9cb2796
feat: add container update/creation
FabianMauz cfb18f7
test: add container to spec
FabianMauz c514055
refactor: extract api params to own file
FabianMauz 44e95bc
feat: reenabled ElementPolicy check
FabianMauz 8570333
feat: fixed element policy for cell lines
FabianMauz cc6997c
Merge branch 'main' into 1878-copy-cell-lines
9bee601
chore: remove accidentally doubled changelog information
7c2e475
Merge branch 'main' into 1878-copy-cell-lines
b931b80
Merge branch 'main' into 1878-copy-cell-lines
b9bb1c2
refactor: remove unnecessary space
7639ad4
Merge remote-tracking branch 'origin/main' into 1878-copy-cell-lines
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
# frozen_string_literal: true | ||
|
||
module CellLineApiParamsHelpers | ||
extend Grape::API::Helpers | ||
|
||
params :cell_line_get_params do | ||
optional :collection_id, type: Integer, desc: 'Collection id' | ||
optional :sync_collection_id, type: Integer, desc: 'SyncCollectionsUser id' | ||
optional :filter_created_at, type: Boolean, desc: 'filter by created at or updated at' | ||
optional :from_date, type: Integer, desc: 'created_date from in ms' | ||
optional :to_date, type: Integer, desc: 'created_date to in ms' | ||
end | ||
|
||
params :cell_line_creation_params do | ||
optional :organism, type: String, desc: 'name of the donor organism of the cell' | ||
optional :tissue, type: String, desc: 'tissue from which the cell originates' | ||
requires :amount, type: Integer, desc: 'amount of cells' | ||
requires :unit, type: String, desc: 'unit of cell amount' | ||
requires :passage, type: Integer, desc: 'passage of cells' | ||
optional :disease, type: String, desc: 'deasease of cells' | ||
requires :material_names, type: String, desc: 'names of cell line e.g. name1;name2' | ||
requires :collection_id, type: Integer, desc: 'Collection of the cell line sample' | ||
optional :cell_type, type: String, desc: 'type of cells' | ||
optional :biosafety_level, type: String, desc: 'biosafety_level of cells' | ||
optional :growth_medium, type: String, desc: 'growth medium of cells' | ||
optional :variant, type: String, desc: 'variant of cells' | ||
optional :optimal_growth_temp, type: Float, desc: 'optimal_growth_temp of cells' | ||
optional :cryo_pres_medium, type: String, desc: 'cryo preservation medium of cells' | ||
optional :gender, type: String, desc: 'gender of donor organism' | ||
optional :material_description, type: String, desc: 'description of cell line concept' | ||
optional :contamination, type: String, desc: 'contamination of a cell line sample' | ||
requires :source, type: String, desc: 'source of a cell line sample' | ||
optional :name, type: String, desc: 'name of a cell line sample' | ||
optional :mutation, type: String, desc: 'mutation of a cell line' | ||
optional :description, type: String, desc: 'description of a cell line sample' | ||
optional :short_label, type: String, desc: 'short label of a cell line sample' | ||
requires :container, type: Hash, desc: 'root Container of element' | ||
end | ||
|
||
params :cell_line_update_params do | ||
requires :cell_line_sample_id, type: String, desc: 'id of the cell line to update' | ||
optional :organism, type: String, desc: 'name of the donor organism of the cell' | ||
optional :mutation, type: String, desc: 'mutation of a cell line' | ||
optional :tissue, type: String, desc: 'tissue from which the cell originates' | ||
requires :amount, type: Integer, desc: 'amount of cells' | ||
requires :unit, type: String, desc: 'unit of amount of cells' | ||
optional :passage, type: Integer, desc: 'passage of cells' | ||
optional :disease, type: String, desc: 'deasease of cells' | ||
optional :material_names, type: String, desc: 'names of cell line e.g. name1;name2' | ||
optional :collection_id, type: Integer, desc: 'Collection of the cell line sample' | ||
optional :cell_type, type: String, desc: 'type of cells' | ||
optional :biosafety_level, type: String, desc: 'biosafety_level of cells' | ||
optional :variant, type: String, desc: 'variant of cells' | ||
optional :optimal_growth_temp, type: Float, desc: 'optimal_growth_temp of cells' | ||
optional :cryo_pres_medium, type: String, desc: 'cryo preservation medium of cells' | ||
optional :gender, type: String, desc: 'gender of donor organism' | ||
optional :material_description, type: String, desc: 'description of cell line concept' | ||
optional :contamination, type: String, desc: 'contamination of a cell line sample' | ||
optional :source, type: String, desc: 'source of a cell line sample' | ||
optional :name, type: String, desc: 'name of a cell line sample' | ||
optional :description, type: String, desc: 'description of a cell line sample' | ||
requires :container, type: Hash, desc: 'root Container of element' | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
# frozen_string_literal: true | ||
|
||
module Usecases | ||
module CellLines | ||
class Copy | ||
def initialize(cell_line_sample_to_copy, current_user, collection_id) | ||
@current_user = current_user | ||
@cell_line_sample_to_copy = cell_line_sample_to_copy | ||
@collection_id = collection_id | ||
end | ||
|
||
def execute! | ||
@current_user.increment_counter('celllines') # rubocop: disable Rails/SkipsModelValidations | ||
copied_cell_line_sample = copy_cellline_sample | ||
create_collection_links(copied_cell_line_sample.id) | ||
copied_cell_line_sample | ||
end | ||
|
||
private | ||
|
||
def copy_cellline_sample | ||
CelllineSample.create( | ||
cellline_material: @cell_line_sample_to_copy.cellline_material, | ||
creator: @current_user, | ||
amount: @cell_line_sample_to_copy[:amount], | ||
unit: @cell_line_sample_to_copy[:unit], | ||
passage: @cell_line_sample_to_copy[:passage], | ||
contamination: @cell_line_sample_to_copy[:contamination], | ||
name: @cell_line_sample_to_copy[:name], | ||
description: @cell_line_sample_to_copy[:description], | ||
short_label: create_short_label, | ||
) | ||
end | ||
|
||
def create_short_label | ||
"#{@current_user.name_abbreviation}-C#{@current_user.counters['celllines']}" | ||
end | ||
|
||
def create_collection_links(id) | ||
CollectionsCellline.create( | ||
collection: Collection.find(@collection_id), | ||
cellline_sample_id: id, | ||
) | ||
CollectionsCellline.create( | ||
collection: all_collection_of_current_user, | ||
cellline_sample_id: id, | ||
) | ||
end | ||
|
||
def all_collection_of_current_user | ||
Collection.get_all_collection_for_user(@current_user.id) | ||
end | ||
end | ||
end | ||
end |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should add a response to the user that something went wrong
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this an error that can occur normally or should it not actually fail? In the latter case, I think that logging is enough. Especially since all other operations in the
ElementAction
only log to the console in the case of an error. What do you think?