Skip to content

Commit

Permalink
Merge pull request #607 from hubmapconsortium/Derek-Furst/fix-put-tri…
Browse files Browse the repository at this point in the history
…gger

Derek furst/fix put trigger
  • Loading branch information
yuanzhou authored Jan 31, 2024
2 parents 83de247 + 9c104ed commit 1551eba
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/schema/provenance_schema.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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."
Expand Down Expand Up @@ -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."
Expand Down
23 changes: 23 additions & 0 deletions src/schema/schema_validators.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down

0 comments on commit 1551eba

Please sign in to comment.