Class EntityDescriptorTemplate
All EntityDescriptors have a template for describing the columns that can be used for importing/exporting data automatically for the entity
The system automatically takes care of this for you from the properties, keys and relationships defined against your entity
However you can override this behaviour to provide custom properties and actions using EntityDescriptorTemplateExtender and IEntityDescriptorImportExtenderThe template is responsible for providing a list of all columns (EntityImportColDefinition) that can be used for importing/exporting
Implements
Inherited Members
Namespace: LemonEdge.API.Descriptors
Assembly: LemonEdge.API.dll
Syntax
public class EntityDescriptorTemplate : IEntityDescriptorTemplate
Constructors
EntityDescriptorTemplate(IFactoryInjector, IReflectionHelper, IDomainContextEventHandler, IEntityDescriptorFactory, ILogger<EntityDescriptorTemplate>)
Declaration
public EntityDescriptorTemplate(IFactoryInjector factory, IReflectionHelper reflector, IDomainContextEventHandler handler, IEntityDescriptorFactory descriptorFactory, ILogger<EntityDescriptorTemplate> logger)
Parameters
Type | Name | Description |
---|---|---|
IFactoryInjector | factory | |
IReflectionHelper | reflector | |
IDomainContextEventHandler | handler | |
IEntityDescriptorFactory | descriptorFactory | |
ILogger<EntityDescriptorTemplate> | logger |
Fields
ImportActionPropertyName
All import/export templates include system columns
This indicates if the row should be ignored, imported/updated, or found and deleted
Valid values are from EntityImportColumnActionDeclaration
public const string ImportActionPropertyName = "IMPORT_DATA_ACTION"
Field Value
Type | Description |
---|---|
string |
ImportDataType
This holds the SetName of the entity to be imported
If this is not provided you need to tell the system what it is you are importing, either via an IDataMapping, an IImportDefinition, or manually.
Declaration
public const string ImportDataType = "IMPORT_DATA_TYPE"
Field Value
Type | Description |
---|---|
string |
ImportExtendedPropertyPrefix
All entities can have their properties extended by other entity descriptors in the system
For each extending entity descriptor there is a set of properties that can be imported against the target descriptor by prefixing them with this string
Declaration
public const string ImportExtendedPropertyPrefix = "EXTENDED_"
Field Value
Type | Description |
---|---|
string |
ImportExternalDataSourcePrefix
All entities in the system can have external data source ids associated with them, and they can be imported/exported as part of the entitiy too.
For each IDataSourceType in the system there is a column for import/export prefixed with this string followed by _Name
Declaration
public const string ImportExternalDataSourcePrefix = "IMPORT_EXTERNAL_DATA_SOURCE"
Field Value
Type | Description |
---|---|
string |
ImportLinkItemPropUpdate
This holds an entity type, id, propname, and value to update a related item property at the same type in this import.
Format: SetName;;ID;;Imported;;True
i.e: Funds;;D89F02A8-8A96-4479-9300-B09400CA0247;;Imported;;TrueOr,: MigStagingTable;;{MigID};;ImportedItemID;;ID
Where ID refers to the property value of the current imported item, and {MigID} refers to a value in the import data from a column called MigIDDeclaration
public const string ImportLinkItemPropUpdate = "IMPORT_LINK_ITEM_PROP_UPDATE"
Field Value
Type | Description |
---|---|
string |
ImportPivotColumnNamePrefix
For entities (API.Entities.IGLAccount) that have pivot data associated with them, the system will create a import/export column for each PivotHeaderColumn prefixed with this string follwed by the PivotHeaderColumn label
Declaration
public const string ImportPivotColumnNamePrefix = "IMPORT_DATA_PIVOT"
Field Value
Type | Description |
---|---|
string |
Properties
Instance
Declaration
public static IEntityDescriptorTemplate Instance { get; set; }
Property Value
Type | Description |
---|---|
IEntityDescriptorTemplate |
Methods
AddPropertyRelationships(EntityImportColDefinition, List<EntityImportColDefinition>, EntityRelationship, ColumnDescriptor)
When a property is a relationship to another target entity in the system, we need to recursively add the key properties of that target entity (and any of its keys that are relationships to other entities)
This adds those properties as entity import column definitions to a list so the system provides a mechanism to refer to relationships through their keys
Declaration
public static void AddPropertyRelationships(EntityImportColDefinition parent, List<EntityImportColDefinition> properties, EntityRelationship relationship, ColumnDescriptor sourceCol)
Parameters
Type | Name | Description |
---|---|---|
EntityImportColDefinition | parent | The parent import column defintion that is a relationship to a target entity |
List<EntityImportColDefinition> | properties | The list of entity import column defintions to add the created properties to |
EntityRelationship | relationship | The this parent entity import column defintion is importing an id for |
ColumnDescriptor | sourceCol | The name of the source column that holds this value for the relationship on the source entity |
GetImportDefinitions(EntityDescriptor, IReadOnlyCache)
Returns a collection of EntityImportColDefinition for this entity descriptor.
These determine the properties that can be exported/imported by the system
If the entity descriptor has a EntityDescriptorTemplateExtender associated with it that is used to get the list of column definitionsOtherwise the system automatically generates them from the properties on the entity descriptor itself. It also uses the system ImportActionPropertyName and EntityImportColDefinition columns, and populates external data source and pivot columns automatically too
Declaration
public Task<IEnumerable<EntityImportColDefinition>> GetImportDefinitions(EntityDescriptor desc, IReadOnlyCache cache)
Parameters
Type | Name | Description |
---|---|---|
EntityDescriptor | desc | The entity descriptor to return a collection of valid EntityImportColDefinitions for |
IReadOnlyCache | cache | The local cache |
Returns
Type | Description |
---|---|
Task<IEnumerable<EntityImportColDefinition>> | A collection of EntityDescriptorTemplate for this entity descriptor. |
GetImportExtendedProperties(EntityDescriptor)
Declaration
public static IEnumerable<EntityImportColDefinition> GetImportExtendedProperties(EntityDescriptor desc)
Parameters
Type | Name | Description |
---|---|---|
EntityDescriptor | desc |
Returns
Type | Description |
---|---|
IEnumerable<EntityImportColDefinition> |
GetImportExternalDataSources(IReadOnlyCache)
Returns the standard list of all external data source import columns
Declaration
public static Task<IEnumerable<EntityImportColDefinition>> GetImportExternalDataSources(IReadOnlyCache cache)
Parameters
Type | Name | Description |
---|---|---|
IReadOnlyCache | cache | The local cache so all IDataSourceType can be loaded |
Returns
Type | Description |
---|---|
Task<IEnumerable<EntityImportColDefinition>> | The standard list of all external data source import columns |
GetImportHeaders(EntityDescriptor)
Returns the standard import headers for every entity descriptor, this consists of:
- ImportActionPropertyName: A column specifying whether to ignore, import or delete the data.
- ImportDataType: A column specifying the type of entty being imported/exported
- ImportPivotColumnNamePrefix: If this entity is marked as having pivot data ( EntityHasPivotAttribute) then automatically creates columns for each pivot header.
- ImportExternalDataSourcePrefix: Creates a column for each IDataSourceType defined in the system
Declaration
public static IEnumerable<EntityImportColDefinition> GetImportHeaders(EntityDescriptor desc)
Parameters
Type | Name | Description |
---|---|---|
EntityDescriptor | desc | The entity descriptor to return the default import column definitions for |
Returns
Type | Description |
---|---|
IEnumerable<EntityImportColDefinition> | The standard import headers for every entity descriptor |
GetImportProperties(EntityDescriptor)
Returns the import column definitions for each of the properties defined against the specified entity
This is the standard import/export properties dynamically created for every entity depending on the type of properties they have.
Declaration
public static IEnumerable<EntityImportColDefinition> GetImportProperties(EntityDescriptor desc)
Parameters
Type | Name | Description |
---|---|---|
EntityDescriptor | desc | The entity descriptor to return entity import column definitions for each of its properties |
Returns
Type | Description |
---|---|
IEnumerable<EntityImportColDefinition> | The import column definitions for each of the properties defined against the specified entity |
GetItem(Type, Guid?, IEnumerable<(object Value, EntityImportColDefinition Definition)>, IEntityRetriever, IReadOnlyCache, bool)
Returns the item being linked to from an import set of key values referring to it
Declaration
public Task<IBaseEntity> GetItem(Type itemType, Guid? subItemID, IEnumerable<(object Value, EntityImportColDefinition Definition)> keyIDs, IEntityRetriever retriever, IReadOnlyCache cache, bool addToCache)
Parameters
Type | Name | Description |
---|---|---|
Type | itemType | The globally unique id of the type of the entity to load |
Guid? | subItemID | Any sub id of the entity type if its a replicated entity descriptor |
IEnumerable<(object Value, EntityImportColDefinition Definition)> | keyIDs | A list of the key values needed to load the item being referred to through an import relationship |
IEntityRetriever | retriever | The current conext for loading the item |
IReadOnlyCache | cache | A local cache |
bool | addToCache | Specifies the item should be added to the |
Returns
Type | Description |
---|---|
Task<IBaseEntity> | The item being linked to from an import set of key values referring to it |
GetKeyValues(string, EntityDescriptor, IEntityRetriever, IReadOnlyCache)
Given a string key of the format:
Key1=Val1;;Key2=Val2;;Rel1_Key1=Val3;;Rel1_Key2
This function for a given entity descriptor returns all the values (parsed according to their type), and associated entity import column definitions for each key in the stringThis is required for key columns that can refer to any parent relationship as they have their multiple key values stored as above
Declaration
public Task<IEnumerable<(object Value, EntityImportColDefinition Col)>> GetKeyValues(string stringKey, EntityDescriptor desc, IEntityRetriever retriever, IReadOnlyCache cache)
Parameters
Type | Name | Description |
---|---|---|
string | stringKey | A string value of multiple key names and values, in the format Key1=Val1;;Key2=Val2;;Rel1_Key1=Val3;;Rel1_Key2 |
EntityDescriptor | desc | The entity descriptor for which we are loading the keys for |
IEntityRetriever | retriever | The current conext for loading possible values |
IReadOnlyCache | cache | A local cache |
Returns
Type | Description |
---|---|
Task<IEnumerable<(object Value, EntityImportColDefinition Col)>> | A list of entity column definitions and their associated parsed values for all keys in the string |
IsImportableCoreProp(string)
Declaration
public static bool IsImportableCoreProp(string propertyName)
Parameters
Type | Name | Description |
---|---|---|
string | propertyName |
Returns
Type | Description |
---|---|
bool |
TryGetTemplateExtender(EntityDescriptor, out EntityDescriptorTemplateExtender)
If this entitytype has a EntityDescriptorTemplateExtender defined for it, this will be returned, otherwise no extender will be returned
Declaration
public bool TryGetTemplateExtender(EntityDescriptor desc, out EntityDescriptorTemplateExtender extender)
Parameters
Type | Name | Description |
---|---|---|
EntityDescriptor | desc | The entitydescriptor to see if it has an extender defined for it |
EntityDescriptorTemplateExtender | extender | The out return value of the found extender |
Returns
Type | Description |
---|---|
bool | True if the entity descriptor has a defined template extender, false otherwise |