You are viewing documentation for v1.1. Switch to current version โ†’

๐Ÿงฐ Schema Mapper

Short Description

The FGorgeousDataSchemaMapper class provides functionality to map data from a source snapshot to a target UObject based on a defined data schema mapping asset. It includes methods for applying the mapping, applying individual transforms, and resolving property paths on target objects.

Long Description

The FGorgeousDataSchemaMapper is a central component of the data schema mapping system, responsible for executing the mapping logic defined in UGorgeousDataSchemaMapping_DA assets. It provides a static interface for applying a source snapshot to a target object, which can be called from various contexts such as editor utilities, content browser actions, or runtime code.

The ApplySnapshotToObject method takes a source snapshot (which contains the extracted values from the source item), a target UObject to apply the data to, and a schema mapping asset that defines how to perform the mapping. It also provides output parameters for collecting any warnings or errors that occur during the mapping process.

The ApplyTransformDefinition method allows for applying individual transformations to source values based on the defined transform kind and parameters in the schema asset.

The private methods ResolvePropertyPath and ResolveStructPropertyPath are used internally to navigate through the target object's properties based on the specified target field paths in the schema mapping, allowing for dynamic assignment of values to nested properties.

Backup Your Data

When performing data migrations using the schema mapping system, it is highly recommended to backup your project and data before applying any mappings. While the system is designed to be robust and provides detailed error reporting, there is always a risk of unintended consequences when modifying large amounts of data, especially if there are misconfigurations in the schema asset. Always ensure you have a backup to restore from in case anything goes wrong during the migration process.

๐Ÿ—๏ธ Architecture Overview

graph TD
    A[UGorgeousDataSchemaMapping_DA] -->|Defines mapping| B[FGorgeousDataSchemaMapper]
    B -->|Applies mapping| C[Target UObject]
    A -->|Provides source snapshot| D[FGorgeousDataSchemaSourceSnapshot_S]
    B -->|Uses source snapshot| D
    B -->|Outputs warnings/errors| E[Mapping Diagnostics]

๐Ÿš€ Features

The Schema Mapper is the engine that executes the logic defined in your UGorgeousDataSchemaMapping_DA assets to perform data migrations. This class is C++ only and is not directly exposed to Blueprints.

ApplySnapshotToObject

This is the main function that takes a source snapshot, a target object, and a schema mapping asset, and applies the mapping logic to transfer data from the source to the target. It handles field mappings, applies any defined transformations, and collects warnings and errors that occur during the process.

The ApplySnapshotToObject function is responsible for executing the data mapping process based on the provided source snapshot and schema mapping asset. It iterates through the defined field mappings in the schema asset, retrieves the corresponding values from the source snapshot, applies any specified transformations, and assigns the values to the target object's properties according to the target field paths.

The function also collects any warnings or errors that occur during this process, such as missing required fields, transformation issues, or property assignment failures, and returns a boolean indicating whether the mapping was successful overall.

Type Description
FGorgeousDataSchemaSourceSnapshot_S A struct containing the extracted source data for a specific source item, including field paths and their corresponding values.
UObject* The target object to which the data should be applied. This is typically an instance of the class specified in the TargetDefinition of the schema asset.
UGorgeousDataSchemaMapping_DA* The data asset that defines the schema mapping, including source and target definitions, field mappings, and migration settings.
Type Description
TArray<FString>& An array to collect any warnings that occur during the mapping process, such as missing optional fields or transformation issues that do not cause migration to fail.
TArray<FString>& An array to collect any errors that occur during the mapping process, such as missing required fields or transformation errors that cause migration to fail.
bool Returns true if the mapping was successful (i.e., all required fields were present and successfully mapped), or false if it failed due to any issues.

ApplyTransformDefinition

This function applies a single transformation to a source value based on the specified transform definition in the schema asset. It handles various kinds of transformations, such as setting literal values, trimming whitespace, changing case, adding prefixes/suffixes, replacing text, performing numeric operations, and inverting booleans.

The ApplyTransformDefinition function takes a transform definition struct, a source value as a string, and applies the specified transformation to produce an output value. The behavior of the transformation depends on the TransformKind defined in the transform definition, which determines how the parameters are used to modify the source value.

The function also provides an output parameter for any error message if the transformation fails, such as when invalid parameters are provided for a specific transform kind.

Type Description
FGorgeousDataSchemaTransformDefinition_S A struct defining the kind of transformation to apply and its parameters.
FString The input source value to be transformed, provided as a string.
Type Description
FString& The output value after applying the transformation, returned as a string.
FString& An output parameter to receive any error message if the transformation fails.
bool Returns true if the transformation was successfully applied, or false if it failed due to invalid parameters or other issues.