Skip to content

Commit 0f3c374

Browse files
Added new property priority_project_list and accompanying validator
1 parent 53ca2a2 commit 0f3c374

File tree

3 files changed

+38
-0
lines changed

3 files changed

+38
-0
lines changed

src/schema/provenance_schema.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1282,6 +1282,16 @@ ENTITIES:
12821282
- validate_anticipated_dataset_count
12831283
before_property_update_validators:
12841284
- validate_anticipated_dataset_count
1285+
priority_project_list:
1286+
type: list
1287+
required: false
1288+
indexted: false
1289+
description: The list of priority projects that this Uploaded data will be used For
1290+
mutable: true
1291+
before_property_update_validators:
1292+
- validate_priority_project
1293+
before_property_create_validators:
1294+
- validate_priority_project
12851295

12861296
############################################# EPICollection #############################################
12871297
Epicollection:

src/schema/schema_constants.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ class SchemaConstants(object):
2626

2727
OMITTED_FIELDS = ['ingest_metadata', 'files']
2828

29+
ALLOWED_PRIORITY_PROJECTS = ['SWAT', 'MOSDEP']
30+
2931
# Define an enumeration to classify an entity's visibility, which can be combined with
3032
# authorization info when verify operations on a request.
3133
class DataVisibilityEnum(Enum):

src/schema/schema_validators.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -887,6 +887,32 @@ def verify_multi_assay_dataset_components(property_key, normalized_type, user_to
887887
# fall out successfully if no raise() occurred.
888888
return
889889

890+
891+
"""
892+
Validate the specified value for an Upload's priority_project_list is in a recognized value
893+
894+
Parameters
895+
----------
896+
property_key : str
897+
The target property key
898+
normalized_type : str
899+
Submission
900+
request: Flask request object
901+
The instance of Flask request passed in from application request
902+
existing_data_dict : dict
903+
A dictionary that contains all existing entity properties
904+
new_data_dict : dict
905+
The json data in request body, already after the regular validations
906+
"""
907+
def validate_priority_project(property_key, normalized_entity_type, request, existing_data_dict, new_data_dict):
908+
allowed_priority_projects = SchemaConstants.ALLOWED_PRIORITY_PROJECTS
909+
for priority_project in new_data_dict.get('priority_project_list'):
910+
if priority_project.upper() not in allowed_priority_projects:
911+
raise ValueError(f"Provided priority_project_list contains unrecognized value: {priority_project}. Allowed values are {', '.join(allowed_priority_projects)}")
912+
#Normalize the capitalization
913+
new_data_dict['priority_project_list'] = [project.upper() for project in new_data_dict['priority_project_list']]
914+
915+
890916
####################################################################################################
891917
## Internal Functions
892918
####################################################################################################

0 commit comments

Comments
 (0)