Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 12 additions & 21 deletions src/schema/schema_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -417,10 +417,8 @@ def generate_triggered_data(trigger_type: TriggerTypeEnum, normalized_class, req
# Get the target trigger method defined in the schema_triggers.py module
trigger_method_to_call = getattr(schema_triggers, trigger_method_name)

if 'uuid' in existing_data_dict:
logger.info(f"To run {trigger_type.value}: {trigger_method_name} for {normalized_class} {existing_data_dict['uuid']}")
else:
logger.info(f"To run {trigger_type.value}: {trigger_method_name} for {normalized_class}")
target_uuid = existing_entity_dict['uuid'] if existing_entity_dict and 'uuid' in existing_entity_dict else '';
logger.info(f"To run {trigger_type.value}: {trigger_method_name} for {normalized_class} {target_uuid}")

# No return values for 'after_create_trigger' and 'after_update_trigger'
# because the property value is already set and stored in neo4j
Expand All @@ -443,11 +441,9 @@ def generate_triggered_data(trigger_type: TriggerTypeEnum, normalized_class, req
trigger_method_name = properties[key][trigger_type.value]
try:
trigger_method_to_call = getattr(schema_triggers, trigger_method_name)

if 'uuid' in existing_data_dict:
logger.info(f"To run {trigger_type.value}: {trigger_method_name} for {normalized_class} {existing_data_dict['uuid']}")
else:
logger.info(f"To run {trigger_type.value}: {trigger_method_name} for {normalized_class}")

target_uuid = existing_entity_dict['uuid'] if existing_entity_dict and 'uuid' in existing_entity_dict else '';
logger.info(f"To run {trigger_type.value}: {trigger_method_name} for {normalized_class} {target_uuid}")

# Will set the trigger return value as the property value by default
# Unless the return value is to be assigned to another property different target key
Expand Down Expand Up @@ -494,10 +490,8 @@ def generate_triggered_data(trigger_type: TriggerTypeEnum, normalized_class, req
try:
trigger_method_to_call = getattr(schema_triggers, trigger_method_name)

if 'uuid' in existing_data_dict:
logger.info(f"To run {trigger_type.value}: {trigger_method_name} for {normalized_class} {existing_data_dict['uuid']}")
else:
logger.info(f"To run {trigger_type.value}: {trigger_method_name} for {normalized_class}")
target_uuid = existing_entity_dict['uuid'] if existing_entity_dict and 'uuid' in existing_entity_dict else '';
logger.info(f"To run {trigger_type.value}: {trigger_method_name} for {normalized_class} {target_uuid}")

# Will set the trigger return value as the property value by default
# Unless the return value is to be assigned to another property different target key
Expand All @@ -512,6 +506,7 @@ def generate_triggered_data(trigger_type: TriggerTypeEnum, normalized_class, req
# within this dictionary and return it so it can be saved in the scope of this loop and
# passed to other 'updated_peripherally' triggers
if 'updated_peripherally' in properties[key] and properties[key]['updated_peripherally']:
# Such trigger methods get executed but really do nothing internally
trigger_generated_data_dict = trigger_method_to_call(key, normalized_class, request, user_token, existing_data_dict, new_data_dict, trigger_generated_data_dict)
else:
target_key, target_value = trigger_method_to_call(key, normalized_class, request, user_token, existing_data_dict, new_data_dict)
Expand Down Expand Up @@ -1042,10 +1037,8 @@ def execute_entity_level_validator(validator_type, normalized_entity_type, reque
# Get the target validator method defined in the schema_validators.py module
validator_method_to_call = getattr(schema_validators, validator_method_name)

if 'uuid' in existing_entity_dict:
logger.info(f"To run {validator_type}: {validator_method_name} for {normalized_entity_type} {existing_entity_dict['uuid']}")
else:
logger.info(f"To run {validator_type}: {validator_method_name} for {normalized_entity_type}")
target_uuid = existing_entity_dict['uuid'] if existing_entity_dict and 'uuid' in existing_entity_dict else '';
logger.info(f"To run {validator_type}: {validator_method_name} for {normalized_entity_type} {target_uuid}")

# Create a dictionary to hold data need by any entity validator, which must be populated
# with validator specific requirements when the method to be called is determined.
Expand Down Expand Up @@ -1110,10 +1103,8 @@ def execute_property_level_validators(validator_type, normalized_entity_type, re
# Get the target validator method defined in the schema_validators.py module
validator_method_to_call = getattr(schema_validators, validator_method_name)

if 'uuid' in existing_data_dict:
logger.info(f"To run {validator_type}: {validator_method_name} for {normalized_entity_type} {existing_data_dict['uuid']} on property {key}")
else:
logger.info(f"To run {validator_type}: {validator_method_name} for {normalized_entity_type} on property {key}")
target_uuid = existing_entity_dict['uuid'] if existing_entity_dict and 'uuid' in existing_entity_dict else '';
logger.info(f"To run {validator_type}: {validator_method_name} for {normalized_entity_type} {target_uuid} on property {key}")

validator_method_to_call(key, normalized_entity_type, request, existing_data_dict, new_data_dict)
except schema_errors.MissingApplicationHeaderException as e:
Expand Down
1 change: 1 addition & 0 deletions src/schema/schema_triggers.py
Original file line number Diff line number Diff line change
Expand Up @@ -2379,6 +2379,7 @@ def _commit_files(target_property_key, property_key, normalized_type, request, u
# For metadata files the property name is "metadata_files_to_add"
# But other may be used in the future
if (not property_key in new_data_dict) or (not new_data_dict[property_key]):
logger.info(f"Do nothing with the internal trigger method _commit_files() because {property_key} not found in request payload")
return generated_dict

#If POST or PUT where the target doesn't exist create the file info array
Expand Down