81b07ce027
- Create JdeScoping.DataSync.Dev for sandbox testing ETL code - Create JdeScoping.DataSync.Dev.Tests for associated tests - Move 22 source files and 8 test files - Update namespaces from DevEtl to Dev - Add both projects to solution
42 lines
1.6 KiB
C#
42 lines
1.6 KiB
C#
using JdeScoping.DataAccess.Interfaces;
|
|
using JdeScoping.DataSync.Etl.Destinations;
|
|
using JdeScoping.DataSync.Etl.Models;
|
|
using JdeScoping.DataSync.Etl.Pipeline;
|
|
using JdeScoping.DataSync.Etl.Sources;
|
|
|
|
namespace JdeScoping.DataSync.Dev;
|
|
|
|
/// <summary>
|
|
/// Development ETL pipeline for the Item table.
|
|
/// Schema from: Scripts/008_CreateItemTable.sql
|
|
/// </summary>
|
|
public static class ItemDevEtl
|
|
{
|
|
public static readonly string TableName = "Item";
|
|
public static readonly string CacheFileName = "item.json.zstd";
|
|
|
|
private static readonly JsonColumnSchema[] Schema =
|
|
[
|
|
new("ShortItemNumber", typeof(long), IsNullable: false),
|
|
new("ItemNumber", typeof(string), IsNullable: false),
|
|
new("Description", typeof(string), IsNullable: true),
|
|
new("PlanningFamily", typeof(string), IsNullable: true),
|
|
new("StockingType", typeof(string), IsNullable: true),
|
|
new("LastUpdateDT", typeof(DateTime), IsNullable: false),
|
|
];
|
|
|
|
public static EtlPipeline Create(IDbConnectionFactory connectionFactory, string cacheFilePath)
|
|
{
|
|
ArgumentNullException.ThrowIfNull(connectionFactory);
|
|
|
|
if (string.IsNullOrWhiteSpace(cacheFilePath))
|
|
throw new ArgumentException("Cache file path is required.", nameof(cacheFilePath));
|
|
|
|
return new EtlPipelineBuilder()
|
|
.WithName($"{TableName}_Dev")
|
|
.WithSource(new JsonZstdFileSource(cacheFilePath, Schema))
|
|
.WithDestination(new DbBulkImportDestination(connectionFactory, TableName))
|
|
.Build();
|
|
}
|
|
}
|