Skip to content

Commit 024ace8

Browse files
authored
Merge pull request #772 from hubmapconsortium/Derek-Furst/add-intended-types
Derek furst/add intended types
2 parents 577ef93 + d699583 commit 024ace8

File tree

2 files changed

+40
-1
lines changed

2 files changed

+40
-1
lines changed

src/schema/provenance_schema.yaml

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1242,7 +1242,18 @@ ENTITIES:
12421242
- validate_in_admin_group
12431243
before_property_update_validators:
12441244
- validate_in_admin_group
1245-
1245+
intended_dataset_type:
1246+
type: string
1247+
indexed: true
1248+
description: The dataset type of the intended datasets that will be uploaded as part of the Upload.
1249+
before_property_create_validators:
1250+
- validate_intended_dataset_type
1251+
before_property_update_validators:
1252+
- validate_intended_dataset_type
1253+
intended_organ:
1254+
type: string
1255+
indexed: true
1256+
description: The organ code representing the organ type that the data contained in the upload will be registered/associated with.
12461257

12471258
############################################# EPICollection #############################################
12481259
Epicollection:

src/schema/schema_validators.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,34 @@ def validate_recognized_dataset_type(property_key, normalized_entity_type, reque
7373
raise ValueError(f"Proposed Dataset dataset_type '{proposed_dataset_type_prefix}'"
7474
f" is not recognized in the existing ontology."
7575
f" Valid values are: {str(target_list)}.")
76+
77+
78+
"""
79+
Validate the specified value for an Upload's intended_dataset_type is in the valueset UBKG recognizes.
80+
81+
Parameters
82+
----------
83+
property_key : str
84+
The target property key
85+
normalized_type : str
86+
Submission
87+
request: Flask request object
88+
The instance of Flask request passed in from application request
89+
existing_data_dict : dict
90+
A dictionary that contains all existing entity properties
91+
new_data_dict : dict
92+
The json data in request body, already after the regular validations
93+
"""
94+
def validate_intended_dataset_type(property_key, normalized_entity_type, request, existing_data_dict, new_data_dict):
95+
# If the proposed Upload intended_dataset_type ends with something in square brackets, anything inside
96+
# those square brackets are acceptable at the end of the string. Simply validate the start.
97+
proposed_dataset_type_prefix = re.sub(pattern='(\S)\s\[.*\]$', repl=r'\1', string=new_data_dict['intended_dataset_type'])
98+
target_list = schema_manager.get_dataset_type_valueset_list()
99+
100+
if proposed_dataset_type_prefix not in target_list:
101+
raise ValueError(f"Proposed Upload intended_dataset_type '{proposed_dataset_type_prefix}'"
102+
f" is not recognized in the existing ontology."
103+
f" Valid values are: {str(target_list)}.")
76104

77105

78106
"""

0 commit comments

Comments
 (0)