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; /// /// Development ETL pipeline for the OrgHierarchy table. /// Schema from: Scripts/010_CreateOrgHierarchyTable.sql /// public static class OrgHierarchyDevEtl { public static readonly string TableName = "OrgHierarchy"; public static readonly string CacheFileName = "orghierarchy.json.zstd"; private static readonly JsonColumnSchema[] Schema = [ new("WorkCenterCode", typeof(string), IsNullable: false), new("BranchCode", typeof(string), IsNullable: false), new("ProfitCenterCode", typeof(string), IsNullable: false), 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(); } }