public Table GetRejectedTable(DexihHub hub, Connection connection, TransformSettings transformSettings) { var table = GetTable(hub, connection, transformSettings); return(table.GetRejectedTable(RejectedTableName)); }
public Table GetTable(DexihHub hub, Connection connection, InputColumn[] inputColumns, TransformSettings transformSettings, string referenceTableAlias = null) { Table table; if (connection == null) { table = new Table(); } else { EConnectionCategory category; if (connection is ConnectionFlatFile) { category = EConnectionCategory.File; } else { var connectionReference = Connections.GetConnection(connection.GetType()); category = connectionReference.ConnectionCategory; } switch (category) { case EConnectionCategory.File: table = new FlatFile(); if (FileFormatKey == null) { ((FlatFile)table).FileConfiguration = new FileConfiguration(); } else { var fileFormat = hub.DexihFileFormats.SingleOrDefault(f => f.IsValid && f.Key == FileFormatKey); if (fileFormat == null) { throw new RepositoryException( $"The file format for the table {Name} with key {FileFormatKey} could not be found."); } ((FlatFile)table).FileConfiguration = fileFormat?.GetFileFormat(); } break; case EConnectionCategory.WebService: table = new WebService(); break; default: table = new Table(); break; } } // create a temporary copy and exclude the fileFormat (which is different between DexihTable & Table) this.CopyProperties(table, false); switch (table) { case FlatFile flatFile: if (transformSettings.HasVariables()) { flatFile.FileIncomingPath = transformSettings.InsertHubVariables(flatFile.FileIncomingPath); flatFile.FileMatchPattern = transformSettings.InsertHubVariables(flatFile.FileMatchPattern); flatFile.FileOutgoingPath = transformSettings.InsertHubVariables(flatFile.FileOutgoingPath); flatFile.FileProcessedPath = transformSettings.InsertHubVariables(flatFile.FileProcessedPath); flatFile.FileRejectedPath = transformSettings.InsertHubVariables(flatFile.FileRejectedPath); flatFile.FileRootPath = transformSettings.InsertHubVariables(flatFile.FileRootPath); } break; case WebService restFunction: if (transformSettings.HasVariables()) { restFunction.RestfulUri = transformSettings.InsertHubVariables(restFunction.RestfulUri); restFunction.RowPath = transformSettings.InsertHubVariables(restFunction.RowPath); } break; } foreach (var dbColumn in DexihTableColumns.Where(c => c.IsValid && c.DeltaType != EDeltaType.IgnoreField).OrderBy(c => c.Position)) { table.Columns.Add(dbColumn.GetTableColumn(inputColumns, referenceTableAlias)); } foreach (var dbIndex in DexihTableIndexes.Where(c => c.IsValid)) { table.Indexes.Add(new TableIndex() { Name = dbIndex.Name, Columns = dbIndex.Columns.Select(ti => { var column = DexihTableColumns.SingleOrDefault(c => c.Key == ti.ColumnKey); if (column != null) { return(new TableIndexColumn(column.Name, ti.Direction)); } return(null); }).Where(c => c != null).ToList() }); } return(table); }
public Table GetTable(DexihHub hub, Connection connection, TransformSettings transformSettings, string referenceTableAlias = null) { return(GetTable(hub, connection, (InputColumn[])null, transformSettings, referenceTableAlias)); }
public Table GetTable(DexihHub hub, Connection connection, IEnumerable <DexihColumnBase> inputColumns, TransformSettings transformSettings, string referenceTableAlias = null) { var inputs = inputColumns.Select(c => c.ToInputColumn()).ToArray(); return(GetTable(hub, connection, inputs, transformSettings, referenceTableAlias)); }
/// <summary> /// Retrieves all source tables for the datalink, including from dependent datalink, and joins. /// </summary> /// <returns></returns> public IEnumerable <DexihTable> GetAllSourceTables(DexihHub hub, HashSet <long> ignoreDatalinks = null) { var tables = new Dictionary <long, DexihTable>(); // check previously used datalinks to avoid infinite recursion. if (ignoreDatalinks == null) { ignoreDatalinks = new HashSet <long>(); } if (ignoreDatalinks.Contains(Key)) { return(tables.Values); } ignoreDatalinks.Add(Key); if (SourceDatalinkTable?.SourceTableKey != null) { var table = hub.GetTableFromKey(SourceDatalinkTable.SourceTableKey.Value); if (table != null) { tables.Add(table.Key, table); } } if (SourceDatalinkTable?.SourceDatalinkKey != null) { var datalink = hub.DexihDatalinks.SingleOrDefault(d => d.IsValid && d.Key == SourceDatalinkTable.SourceDatalinkKey); if (datalink != null) { var sourceTables = datalink.GetAllSourceTables(hub); foreach (var table in sourceTables) { if (!tables.ContainsKey(table.Key)) { tables.Add(table.Key, table); } } } } foreach (var transform in DexihDatalinkTransforms) { if (transform.JoinDatalinkTable?.SourceTableKey != null) { var table = hub.GetTableFromKey(transform.JoinDatalinkTable.SourceTableKey.Value); if (table != null && !tables.ContainsKey(table.Key)) { tables.Add(table.Key, table); } } if (transform.JoinDatalinkTable?.SourceDatalinkKey != null) { var datalink = hub.DexihDatalinks.SingleOrDefault(d => d.IsValid && d.Key == transform.JoinDatalinkTable.SourceDatalinkKey); if (datalink != null) { var sourceTables = datalink.GetAllSourceTables(hub); foreach (var table in sourceTables) { if (!tables.ContainsKey(table.Key)) { tables.Add(table.Key, table); } } } } } return(tables.Values); }