Documentation
¶
Index ¶
- func CreateChildEntitiesFromDelimitedString(objects []map[string]any, entityConfig *framework.EntityConfig, ...) []map[string]any
- func CreateChildEntitiesFromList(parentID string, fieldName string, values []string, ...) []any
- func GetUniqueIDValue(obj map[string]any, entityConfig *framework.EntityConfig) (string, bool)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CreateChildEntitiesFromDelimitedString ¶
func CreateChildEntitiesFromDelimitedString( objects []map[string]any, entityConfig *framework.EntityConfig, delimiter string, ) []map[string]any
CreateChildEntitiesFromDelimitedString transforms delimited string fields into child entity arrays. This is a generic function that works for any adapter with delimited values.
The function automatically extracts the parent unique ID from the entity configuration, so adapters don't need to manually find the unique ID attribute.
Parameters: - objects: The raw objects from the datasource - entityConfig: The entity configuration (contains both parent attributes and child entities) - delimiter: The delimiter used to separate values (e.g., ";", ",", "|")
Returns: - []map[string]any: Transformed objects with child entity arrays
Example:
objects := []map[string]any{
{"Id": "123", "Interests": "Sports;Music;Reading"},
}
entityConfig := &framework.EntityConfig{
Attributes: []*framework.AttributeConfig{
{ExternalId: "Id", UniqueId: true},
},
ChildEntities: []*framework.EntityConfig{
{
ExternalId: "Interests",
Attributes: []*framework.AttributeConfig{
{ExternalId: "id"}, {ExternalId: "value"},
},
},
},
}
transformed := CreateChildEntitiesFromDelimitedString(objects, entityConfig, ";")
func CreateChildEntitiesFromList ¶
func CreateChildEntitiesFromList( parentID string, fieldName string, values []string, childEntityConfig *framework.EntityConfig, ) []any
CreateChildEntitiesFromList creates an array of child entity objects from a list of values. The function automatically: - De-duplicates values (case-insensitive) - Trims whitespace - Filters out empty values - Generates deterministic IDs - Uses attribute names from the child entity config
Parameters: - parentID: The ID of the parent object (e.g., "003Hu000020yLuHIAU") - fieldName: The name of the field (e.g., "Interests__c") - values: A list of values to transform into child entities (may contain duplicates) - childEntityConfig: The child entity configuration defining the attributes
Returns: - []any: An array of child entity objects suitable for the framework
Expected child entity config attributes: - One attribute with ExternalId "id" for the unique identifier - One attribute with ExternalId "value" for the actual value
Example:
values := []string{"Sports", "Music", "Sports", " Reading "}
config := &framework.EntityConfig{
Attributes: []*framework.AttributeConfig{
{ExternalId: "id", Type: framework.AttributeTypeString},
{ExternalId: "value", Type: framework.AttributeTypeString},
},
}
childEntities := CreateChildEntitiesFromList("123", "Interests__c", values, config)
// Returns: []any{
// map[string]any{"id": "123_Interests__c_sports", "value": "Sports"},
// map[string]any{"id": "123_Interests__c_music", "value": "Music"},
// map[string]any{"id": "123_Interests__c_reading", "value": "Reading"}
// }
func GetUniqueIDValue ¶
GetUniqueIDValue extracts the unique ID value from an object based on the entity configuration. Returns the unique ID value and true if found, empty string and false otherwise.
Parameters: - obj: The object to extract the unique ID from - entityConfig: The entity configuration containing attribute metadata
Returns: - string: The unique ID value - bool: Whether the unique ID was found and is a string.
Types ¶
This section is empty.