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
Inheritance
Inherited Members
Namespace: LemonEdge.Core.Descriptors
Assembly: API.dll
Syntax
public static class EntityDescriptorTemplate
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 |
---|---|
System.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 |
---|---|
System.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 |
---|---|
System.String |
ImportPivotColumnNamePrefix
For 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 |
---|---|
System.String |
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 |
System.Collections.Generic.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 ImportDataType columns, and populates external data source and pivot columns automatically too
Declaration
public static Task<IEnumerable<EntityImportColDefinition>> GetImportDefinitions(this 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 |
---|---|
System.Threading.Tasks.Task<System.Collections.Generic.IEnumerable<EntityImportColDefinition>> | A collection of EntityImportColDefinition for this entity descriptor. |
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 |
---|---|
System.Threading.Tasks.Task<System.Collections.Generic.IEnumerable<EntityImportColDefinition>> | The standard list of all external data source import columns |
GetImportHeaders(EntityDescriptor)
Returns the standard import headers for every entity descriptor, this concists 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(this EntityDescriptor desc)
Parameters
Type | Name | Description |
---|---|---|
EntityDescriptor | desc | The entity descriptor to return the default import column definitions for |
Returns
Type | Description |
---|---|
System.Collections.Generic.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(this 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 |
---|---|
System.Collections.Generic.IEnumerable<EntityImportColDefinition> | The import column definitions for each of the properties defined against the specified entity |
GetItem(Type, Nullable<Guid>, IEnumerable<(Object Value, EntityImportColDefinition Definition)>, IEntityRetriever, IReadOnlyCache, Boolean)
Returns the item being linked to from an import set of key values referring to it
Declaration
public static Task<IBaseEntity> GetItem(Type itemType, Guid? subItemID, IEnumerable<(object Value, EntityImportColDefinition Definition)> keyIDs, IEntityRetriever retriever, IReadOnlyCache cache, bool addToCache)
Parameters
Type | Name | Description |
---|---|---|
System.Type | itemType | The globally unique id of the type of the entity to load |
System.Nullable<System.Guid> | subItemID | Any sub id of the entity type if its a replicated entity descriptor |
System.Collections.Generic.IEnumerable<System.ValueTuple<System.Object, EntityImportColDefinition>> | 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 |
System.Boolean | addToCache | Specifies the item should be added to the |
Returns
Type | Description |
---|---|
System.Threading.Tasks.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 static Task<IEnumerable<(object Value, EntityImportColDefinition Col)>> GetKeyValues(string stringKey, EntityDescriptor desc, IEntityRetriever retriever, IReadOnlyCache cache)
Parameters
Type | Name | Description |
---|---|---|
System.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 |
---|---|
System.Threading.Tasks.Task<System.Collections.Generic.IEnumerable<System.ValueTuple<System.Object, EntityImportColDefinition>>> | A list of entity column definitions and their associated parsed values for all keys in the string |
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 static bool TryGetTemplateExtender(this 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 |
---|---|
System.Boolean | True if the entity descriptor has a defined template extender, false otherwise |