/// <summary> /// Returns the reason why <paramref name="table"/> is not refactorable e.g. if it's name is not properly qualified /// with database. Returns null if it is refactorable /// </summary> /// <param name="table"></param> /// <returns></returns> public string GetReasonNotRefactorable(ITableInfo table) { if (string.IsNullOrWhiteSpace(table.Name)) { return("Table has no Name property, this should be the fully qualified database table name"); } if (string.IsNullOrWhiteSpace(table.Database)) { return("Table does not have it's Database property set"); } //ensure database and Name match correctly var syntaxHelper = table.GetQuerySyntaxHelper(); var db = table.GetDatabaseRuntimeName(Curation.Data.DataLoad.LoadStage.PostLoad); if (!table.Name.StartsWith(syntaxHelper.EnsureWrapped(db))) { return(string.Format("Table with Name '{0}' has incorrect database propery '{1}'", table.Name, table.Database)); } if (table.Name != table.GetFullyQualifiedName()) { return(string.Format("Table name '{0}' did not match the expected fully qualified name '{1}'", table.Name, table.GetFullyQualifiedName())); } return(null); }
private void Add(PreLoadDiscardedColumn discardedColumn, ITableInfo tableInfo, string rawDbName) { var snip = new SubstringAutocompleteItem(discardedColumn.GetRuntimeName()); var colName = discardedColumn.GetRuntimeName(); snip.MenuText = colName; snip.Text = tableInfo.GetQuerySyntaxHelper().EnsureFullyQualified(rawDbName, null, tableInfo.GetRuntimeName(), colName); snip.Tag = discardedColumn; snip.ImageIndex = GetIndexFor(discardedColumn, RDMPConcept.ColumnInfo.ToString()); AddUnlessDuplicate(snip); }
public void Add(ITableInfo tableInfo, LoadStage loadStage) { //we already have it or it is not setup properly if (items.Any(i => i.Tag.Equals(tableInfo)) || string.IsNullOrWhiteSpace(tableInfo.Database) || string.IsNullOrWhiteSpace(tableInfo.Server)) { return; } var runtimeName = tableInfo.GetRuntimeName(loadStage); var dbName = tableInfo.GetDatabaseRuntimeName(loadStage); var syntaxHelper = tableInfo.GetQuerySyntaxHelper(); var fullSql = syntaxHelper.EnsureFullyQualified(dbName, null, runtimeName); var snip = new SubstringAutocompleteItem(tableInfo.GetRuntimeName()); snip.MenuText = runtimeName; //name of table snip.Text = fullSql; //full SQL snip.Tag = tableInfo; //record object for future reference snip.ImageIndex = GetIndexFor(tableInfo, RDMPConcept.TableInfo.ToString()); foreach (IHasStageSpecificRuntimeName o in tableInfo.GetColumnsAtStage(loadStage)) { var preDiscarded = o as PreLoadDiscardedColumn; var columnInfo = o as ColumnInfo; if (preDiscarded != null) { Add(preDiscarded, tableInfo, dbName); } else if (columnInfo != null) { Add(columnInfo, tableInfo, dbName, loadStage, syntaxHelper); } else { throw new Exception("Expected IHasStageSpecificRuntimeName returned by TableInfo.GetColumnsAtStage to return only ColumnInfos and PreLoadDiscardedColumns. It returned a '" + o.GetType().Name + "'"); } } AddUnlessDuplicate(snip); }
/// <summary> /// Creates a new collision resolver using the primary keys and resolution order of the supplied <see cref="TableInfo"/> /// </summary> /// <param name="tableInfo"></param> public PrimaryKeyCollisionResolver(ITableInfo tableInfo) { _tableInfo = tableInfo; _querySyntaxHelper = _tableInfo.GetQuerySyntaxHelper(); }