Skip to content

Commit b7cb172

Browse files
Updated validate_creation_action to preclude publications from using external process. Also cause a rejection for external process when any of the direct ancestors are not datasets
1 parent 0731c1f commit b7cb172

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/schema/schema_validators.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -585,7 +585,16 @@ def validate_creation_action(property_key, normalized_entity_type, request, exis
585585
raise ValueError("Invalid {} value. Accepted values are: {}".format(property_key, ", ".join(accepted_creation_action_values)))
586586
if creation_action == '':
587587
raise ValueError(f"The property {property_key} cannot be empty, when specified.")
588-
588+
if creation_action == 'external process':
589+
if normalized_entity_type.lower() != "dataset":
590+
raise ValueError(f"Only datasets are allowed to have creation_action of 'external_process'. Provided entity is a {normalized_entity_type}")
591+
direct_ancestor_uuids = new_data_dict.get('direct_ancestor_uuids')
592+
for ancestor_uuid in direct_ancestor_uuids:
593+
ancestor = schema_neo4j_queries.get_entity(schema_manager.get_neo4j_driver_instance(), ancestor_uuid)
594+
ancestor_type = ancestor['entity_type']
595+
if ancestor_type.lower() != "dataset":
596+
raise ValueError(f"If creation_action is 'external process', all direct ancesotrs must be of type 'dataset'. Ancestor with uuid {ancestor_uuid} has entity type of '{ancestor_type}'")
597+
589598

590599
"""
591600
Validate the provided value of the activity creation action before updating direct ancestors. Certain values prohibited

0 commit comments

Comments
 (0)