Skip to content
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

added new fields uploads.intended_dataset_type, and uploads.intended_… #773

Merged
merged 1 commit into from
Dec 12, 2024
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
13 changes: 12 additions & 1 deletion src/schema/provenance_schema.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1191,7 +1191,18 @@ ENTITIES:
- validate_in_admin_group
before_property_update_validators:
- validate_in_admin_group

intended_dataset_type:
type: string
indexed: true
description: The dataset type of the intended datasets that will be uploaded as part of the Upload.
before_property_create_validators:
- validate_intended_dataset_type
before_property_update_validators:
- validate_intended_dataset_type
intended_organ:
type: string
indexed: true
description: The organ code representing the organ type that the data contained in the upload will be registered/associated with.

############################################# EPICollection #############################################
Epicollection:
Expand Down
28 changes: 28 additions & 0 deletions src/schema/schema_validators.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,34 @@ def validate_recognized_dataset_type(property_key, normalized_entity_type, reque
raise ValueError(f"Proposed Dataset dataset_type '{proposed_dataset_type_prefix}'"
f" is not recognized in the existing ontology."
f" Valid values are: {str(target_list)}.")


"""
Validate the specified value for an Upload's intended_dataset_type is in the valueset UBKG recognizes.

Parameters
----------
property_key : str
The target property key
normalized_type : str
Submission
request: Flask request object
The instance of Flask request passed in from application request
existing_data_dict : dict
A dictionary that contains all existing entity properties
new_data_dict : dict
The json data in request body, already after the regular validations
"""
def validate_intended_dataset_type(property_key, normalized_entity_type, request, existing_data_dict, new_data_dict):
# If the proposed Upload intended_dataset_type ends with something in square brackets, anything inside
# those square brackets are acceptable at the end of the string. Simply validate the start.
proposed_dataset_type_prefix = re.sub(pattern='(\S)\s\[.*\]$', repl=r'\1', string=new_data_dict['intended_dataset_type'])
target_list = schema_manager.get_dataset_type_valueset_list()

if proposed_dataset_type_prefix not in target_list:
raise ValueError(f"Proposed Upload intended_dataset_type '{proposed_dataset_type_prefix}'"
f" is not recognized in the existing ontology."
f" Valid values are: {str(target_list)}.")


"""
Expand Down
Loading