diff --git a/src/schema/provenance_schema.yaml b/src/schema/provenance_schema.yaml index ce3ef892..fec94cf5 100644 --- a/src/schema/provenance_schema.yaml +++ b/src/schema/provenance_schema.yaml @@ -363,6 +363,7 @@ ENTITIES: - validate_no_duplicates_in_list before_property_update_validators: - validate_no_duplicates_in_list + - validate_not_invalid_creation_action transient: true exposed: false description: "The uuids of source entities from which this new entity is derived. Used to pass source entity ids in on POST or PUT calls used to create the linkages." @@ -633,6 +634,7 @@ ENTITIES: - validate_no_duplicates_in_list before_property_update_validators: - validate_no_duplicates_in_list + - validate_not_invalid_creation_action transient: true exposed: false description: "The uuids of source entities from which this new entity is derived. Used to pass source entity ids in on POST or PUT calls used to create the linkages." diff --git a/src/schema/schema_validators.py b/src/schema/schema_validators.py index 25773dfd..17ad3cf6 100644 --- a/src/schema/schema_validators.py +++ b/src/schema/schema_validators.py @@ -540,6 +540,29 @@ def validate_creation_action(property_key, normalized_entity_type, request, exis raise ValueError(f"The property {property_key} cannot be empty, when specified.") +""" +Validate the provided value of the activity creation action before updating direct ancestors. Certain values prohibited +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_not_invalid_creation_action(property_key, normalized_entity_type, request, existing_data_dict, new_data_dict): + prohibited_creation_action_values = ["Central Process", "Multi-Assay Split"] + entity_uuid = existing_data_dict.get('uuid') + creation_action = schema_neo4j_queries.get_entity_creation_action_activity(schema_manager.get_neo4j_driver_instance(), entity_uuid) + if creation_action and creation_action in prohibited_creation_action_values: + raise ValueError("Cannot update {} value if creation_action of parent activity is {}".format(property_key, ", ".join(prohibited_creation_action_values))) + + """ Validate that the user is in Hubmap-Data-Admin before creating or updating field 'assigned_to_group_name'