Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions entity-api-spec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,7 @@ components:
- block
- section
- suspension
description: 'A code representing the type of specimen. Must be an organ, block, section, or suspension'
description: 'A code representing the type of specimen. Must be an organ, block, section, or suspension, in all lower case.'
protocol_url:
type: string
description: 'The protocols.io doi url pointing the protocol under wich the sample was obtained and/or prepared.'
Expand Down Expand Up @@ -482,7 +482,7 @@ components:
- TR
- UR
- UT
description: 'Organ code specifier, only set if sample_category == organ. Valid values found in: [organ types](https://github.com/hubmapconsortium/search-api/blob/main/src/search-schema/data/definitions/enums/organ_types.yaml)'
description: 'Organ code specifier, only set if sample_category == organ. Valid values found in: [organ types](https://ontology.api.hubmapconsortium.org/organs/by-code?application_context=HUBMAP)'
organ_other:
type: string
description: The organ type provided by the user if "other" organ type is selected
Expand Down
12 changes: 10 additions & 2 deletions src/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -1272,7 +1272,15 @@ def create_multiple_samples(count):
# No need to log the validation errors
bad_request_error(str(e))

# `direct_ancestor_uuid` is required on create
try:
schema_manager.execute_property_level_validators('before_property_create_validators', normalized_entity_type, request, {}, json_data_dict)
# Currently only ValueError
except ValueError as e:
bad_request_error(e)
except schema_errors.UnimplementedValidatorException as uve:
internal_server_error(uve)

# `direct_ancestor_uuid` is required on create for a Sample.
# Check existence of the direct ancestor (either another Sample or Donor)
direct_ancestor_dict = query_target_entity(json_data_dict['direct_ancestor_uuid'], user_token)

Expand All @@ -1288,7 +1296,7 @@ def create_multiple_samples(count):
if ('organ' not in json_data_dict) or (not json_data_dict['organ']):
bad_request_error("A valid organ code is required since the direct ancestor is a Donor")

# Generate 'before_create_triiger' data and create the entity details in Neo4j
# Generate 'before_create_trigger' data and create the entity details in Neo4j
generated_ids_dict_list = create_multiple_samples_details(request, normalized_entity_type, user_token, json_data_dict, count)

# Also index the each new Sample node in elasticsearch via search-api
Expand Down
10 changes: 8 additions & 2 deletions src/schema/schema_validators.py
Original file line number Diff line number Diff line change
Expand Up @@ -564,8 +564,14 @@ def validate_sample_category(property_key, normalized_entity_type, request, exis
sample_category = new_data_dict[property_key].lower()

if sample_category not in defined_tissue_types:
raise ValueError(f"Invalid sample_category: {sample_category}")

raise ValueError(f"Invalid sample_category: {sample_category}."
f" Should be one of {', '.join(defined_tissue_types)}.")

# Given the sample_category is a defined_tissue_types element, assure the request has
# the proper case for storage
if new_data_dict[property_key] != sample_category:
raise ValueError(f"The case of sample_category '{new_data_dict[property_key]}'"
f" must be specified as '{sample_category}'.")

"""
Validate the provided value of Publication.publication_date is in the correct format against ISO 8601 Format:
Expand Down