Skip to content

Commit

Permalink
Format fixups
Browse files Browse the repository at this point in the history
  • Loading branch information
jas88 committed Jul 20, 2023
1 parent ff941e9 commit 1cd500a
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 34 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ protected override void WriteRows(DataTable toProcess, IDataLoadEventListener jo
{
return;
}

if(_request.IsBatchResume)
{
_destination.AllowLoadingPopulatedTables = true;
Expand Down Expand Up @@ -192,7 +192,7 @@ private DataTableUploadDestination PrepareDestination(IDataLoadEventListener lis
}

private void PrimeDestinationTypesBasedOnCatalogueTypes(IDataLoadEventListener listener, DataTable toProcess)
{
{
//if the extraction is of a Catalogue

if(_request is not IExtractDatasetCommand datasetCommand)
Expand Down Expand Up @@ -264,7 +264,7 @@ private string GetDestinationDatabaseType(ConcreteColumn col)
var intermediate = fromSyntax.TypeTranslater.GetDataTypeRequestForSQLDBType(col.ColumnInfo.Data_type);
return toSyntax.TypeTranslater.GetSQLDBTypeForCSharpType(intermediate);
}

return col.ColumnInfo.Data_type;
}

Expand All @@ -283,7 +283,7 @@ private string GetTableName(string suffix = null)

tblName = TableNamingPattern;
var project = _request.Configuration.Project;

tblName = tblName.Replace("$p", project.Name);
tblName = tblName.Replace("$n", project.ProjectNumber.ToString());
tblName = tblName.Replace("$c", _request.Configuration.Name);
Expand Down Expand Up @@ -387,7 +387,7 @@ public override void Abort(IDataLoadEventListener listener)
}
protected override void PreInitializeImpl(IExtractCommand value, IDataLoadEventListener listener)
{

}


Expand Down Expand Up @@ -441,20 +441,20 @@ protected override void TryExtractSupportingSQLTableImpl(SupportingSQLTable sqlT
using(var cmd = DatabaseCommandHelper.GetCommand(sqlTable.SQL, con))
using (var da = DatabaseCommandHelper.GetDataAdapter(cmd))
{
var sw = new Stopwatch();

sw.Start();
da.Fill(dt);
}
var sw = Stopwatch.StartNew();
dt.BeginLoadData();
da.Fill(dt);
dt.EndLoadData();
}

dt.TableName = GetTableName(_destinationDatabase.Server.GetQuerySyntaxHelper().GetSensibleEntityNameFromString(sqlTable.Name));
linesWritten = dt.Rows.Count;
dt.TableName = GetTableName(_destinationDatabase.Server.GetQuerySyntaxHelper().GetSensibleEntityNameFromString(sqlTable.Name));
linesWritten = dt.Rows.Count;

var destinationDb = GetDestinationDatabase(listener);
var tbl = destinationDb.ExpectTable(dt.TableName);
var destinationDb = GetDestinationDatabase(listener);
var tbl = destinationDb.ExpectTable(dt.TableName);

if(tbl.Exists())
tbl.Drop();
if(tbl.Exists())
tbl.Drop();

destinationDb.CreateTable(dt.TableName,dt);
destinationDescription = $"{TargetDatabaseServer.ID}|{GetDatabaseName()}|{dt.TableName}";
Expand All @@ -465,7 +465,7 @@ protected override void TryExtractLookupTableImpl(BundledLookupTable lookup, Dir
IExtractionConfiguration requestConfiguration,IDataLoadEventListener listener, out int linesWritten, out string destinationDescription)
{
using var dt = lookup.GetDataTable();

dt.TableName = GetTableName(_destinationDatabase.Server.GetQuerySyntaxHelper().GetSensibleEntityNameFromString(lookup.TableInfo.Name));

//describe the destination for the abstract base
Expand All @@ -474,7 +474,7 @@ protected override void TryExtractLookupTableImpl(BundledLookupTable lookup, Dir

var destinationDb = GetDestinationDatabase(listener);
var existing = destinationDb.ExpectTable(dt.TableName);

if(existing.Exists())
{
listener.OnNotify(this,new NotifyEventArgs(ProgressEventType.Warning,
Expand Down Expand Up @@ -575,7 +575,7 @@ public override void Check(ICheckNotifier notifier)
notifier.OnCheckPerformed(new CheckEventArgs(
$"Catalogue '{dsRequest.Catalogue}' does not have an Acronym but TableNamingPattern contains $a", CheckResult.Fail));
}

base.Check(notifier);

try
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,14 @@ public bool ConvertEmptyColumnInfo(Func<string, bool> shouldApplySql, ICheckNoti
var tbl = _tableInfo.Discover(DataAccessContext.DataLoad);

var rowcount = tbl.GetRowCount();

if(rowcount>0)
throw new NotSupportedException(
$"Table {_tableInfo} contains {rowcount} rows of data, you cannot use ColumnInfoToANOTableConverter.ConvertEmptyColumnInfo on this table");

using var con = tbl.Database.Server.GetConnection();
con.Open();

if (!IsOldColumnDroppable(con, notifier))
return false;

Expand All @@ -77,9 +77,9 @@ public bool ConvertFullColumnInfo(Func<string, bool> shouldApplySql, ICheckNotif
if (!IsOldColumnDroppable(con, notifier))
return false;

EnsureNoTriggerOnTable(tbl);
EnsureNoTriggerOnTable(tbl);

AddNewANOColumnInfo(shouldApplySql, con, notifier);
AddNewANOColumnInfo(shouldApplySql, con, notifier);

MigrateExistingData(shouldApplySql,con, notifier,tbl);

Expand All @@ -106,7 +106,7 @@ private void MigrateExistingData(Func<string, bool> shouldApplySql, DbConnection
{
var from = _colToNuke.GetRuntimeName(LoadStage.PostLoad);
var to = _newANOColumnInfo.GetRuntimeName(LoadStage.PostLoad);


//create an empty table for the anonymised data
using (var cmdCreateTempMap = DatabaseCommandHelper.GetCommand(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,11 +182,11 @@ private Dictionary<object, List<object>> GenerateAliasTable(int timeoutInSeconds
haveCheckedColumns = true;
}

var input = r[0];
var alias = r[1];
var input = r[0];
var alias = r[1];

if(input == null || input == DBNull.Value || alias == null || alias == DBNull.Value)
throw new AliasTableFetchException("Alias table contained nulls");
if(input == null || input == DBNull.Value || alias == null || alias == DBNull.Value)
throw new AliasTableFetchException("Alias table contained nulls");

if(input.Equals(alias))
throw new AliasTableFetchException("Alias table SQL should only return aliases not exact matches e.g. in the case of a simple alias X is Y, do not return 4 rows {X=X AND Y=Y AND Y=X AND X=Y}, only return 2 rows {X=Y and Y=X}");
Expand Down
7 changes: 2 additions & 5 deletions Rdmp.Core/Icons/IconProvision/CatalogueIconProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -250,10 +250,7 @@ public static RDMPConcept GetConceptForCollection(RDMPCollection rdmpCollection)
/// <returns></returns>
public static bool ConceptIs(Type t, object concept)
{
if (t.IsInstanceOfType(concept))
return true;

return concept is Type type && t.IsAssignableFrom(type);
return t.IsInstanceOfType(concept) || (concept is Type type && t.IsAssignableFrom(type));
}


Expand All @@ -278,7 +275,7 @@ public Dictionary<string, Image<Rgba32>> GetImageList(bool addFavouritesOverlayK
return imageList;
}

private Image<Rgba32> GetActualImage(Image<Rgba32> img, OverlayKind kind)
private static Image<Rgba32> GetActualImage(Image<Rgba32> img, OverlayKind kind)
{
return kind == OverlayKind.None ? img : IconOverlayProvider.GetOverlay(img, kind);
}
Expand Down
2 changes: 1 addition & 1 deletion Rdmp.Core/MapsDirectlyToDatabaseTable/TableRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -559,7 +559,7 @@ public IEnumerable<T> SelectAllWhere<T>(string selectQuery, string columnWithObj
return Enumerable.Empty<T>();


var toReturn = GetAllObjects<T>($"WHERE ID in ({string.Join(",", idsToReturn)})").ToList();
var toReturn = GetAllObjects<T>($"WHERE ID in ({string.Join(",", idsToReturn)})").ToList();

//this bit of hackery is if you're a crazy person who hates transparency and wants something like ColumnInfo.Missing to appear in the return list instead of an empty return list
if(dbNullSubstition != null)
Expand Down

0 comments on commit 1cd500a

Please sign in to comment.