Skip to content

Commit

Permalink
Disused usings; make S3 uploads less blocking
Browse files Browse the repository at this point in the history
  • Loading branch information
jas88 committed Nov 22, 2024
1 parent 057db78 commit 2b12494
Show file tree
Hide file tree
Showing 33 changed files with 194 additions and 268 deletions.
1 change: 1 addition & 0 deletions HIC.DataManagementPlatform.sln.DotSettings
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<s:Boolean x:Key="/Default/CodeInspection/CodeAnnotations/NamespacesWithAnnotations/=SciStore_002EAnnotations/@EntryIndexedValue">True</s:Boolean>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=ANO/@EntryIndexedValue">ANO</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=AWS/@EntryIndexedValue">AWS</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=AWSS/@EntryIndexedValue">AWSS</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=CTS/@EntryIndexedValue">CTS</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=DISTINCT/@EntryIndexedValue">DISTINCT</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=DQE/@EntryIndexedValue">DQE</s:String>
Expand Down
12 changes: 6 additions & 6 deletions Rdmp.Core.Tests/Curation/Integration/MEFCheckerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

namespace Rdmp.Core.Tests.Curation.Integration;

public class MEFCheckerTests : UnitTests
public sealed class MEFCheckerTests : UnitTests
{
[Test]
public void FindClass_WrongCase_FoundAnyway()
Expand All @@ -24,23 +24,23 @@ public void FindClass_WrongCase_FoundAnyway()
[Test]
public void FindClass_EmptyString()
{
var m = new MEFChecker("", s => Assert.Fail());
var m = new MEFChecker("", static _ => Assert.Fail());
var ex = Assert.Throws<Exception>(() => m.Check(ThrowImmediatelyCheckNotifier.Quiet));
Assert.That(
ex.Message, Is.EqualTo("MEFChecker was asked to check for the existence of an Export class but the _classToFind string was empty"));
ex?.Message, Is.EqualTo("MEFChecker was asked to check for the existence of an Export class but the _classToFind string was empty"));
}

[Test]
public void FindClass_CorrectNamespace()
{
var m = new MEFChecker("Rdmp.Core.DataLoad.Modules.Attachers.AnySeparatorFileAttacher", s => Assert.Fail());
var m = new MEFChecker("Rdmp.Core.DataLoad.Modules.Attachers.AnySeparatorFileAttacher", static _ => Assert.Fail());
m.Check(ThrowImmediatelyCheckNotifier.Quiet);
}

[Test]
public void FindClass_WrongNamespace()
{
var m = new MEFChecker("CatalogueLibrary.AnySeparatorFileAttacher", s => Assert.Pass());
var m = new MEFChecker("CatalogueLibrary.AnySeparatorFileAttacher", static _ => Assert.Pass());
m.Check(new AcceptAllCheckNotifier());

Assert.Fail("Expected the class not to be found but to be identified under the correct namespace (above)");
Expand All @@ -49,7 +49,7 @@ public void FindClass_WrongNamespace()
[Test]
public void FindClass_NonExistent()
{
var m = new MEFChecker("CatalogueLibrary.UncleSam", s => Assert.Fail());
var m = new MEFChecker("CatalogueLibrary.UncleSam", static _ => Assert.Fail());
var ex = Assert.Throws<Exception>(() => m.Check(ThrowImmediatelyCheckNotifier.Quiet));
Assert.That(
ex?.Message, Does.Contain("Could not find MEF class called CatalogueLibrary.UncleSam in LoadModuleAssembly.GetAllTypes() and couldn't even find any with the same basic name"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
using FAnsi.Discovery;
using FAnsi.Discovery.TableCreation;
using NUnit.Framework;
using Rdmp.Core.CommandExecution;
using Rdmp.Core.Curation.Data;
using Rdmp.Core.Curation.Data.DataLoad;
using Rdmp.Core.Curation.Data.Defaults;
Expand Down Expand Up @@ -132,15 +131,15 @@ public void Load(DatabaseType databaseType, TestCase testCase)
blk.Upload(dt);
}

Assert.That(tbl.DiscoverColumns().Count(c =>
c.GetRuntimeName().Equals("ID", StringComparison.CurrentCultureIgnoreCase)), Is.EqualTo(1),
Assert.That(tbl.DiscoverColumns().Count(static c =>
c.GetRuntimeName().Equals("ID", StringComparison.OrdinalIgnoreCase)), Is.EqualTo(1),
"Table created did not contain ID column");
break;
}
case TestCase.AllPrimaryKeys:
dt.PrimaryKey = dt.Columns.Cast<DataColumn>().ToArray();
tbl = db.CreateTable("MyTable", dt, new[] { nameCol }); //upload the column as is
Assert.That(tbl.DiscoverColumns().All(c => c.IsPrimaryKey));
Assert.That(tbl.DiscoverColumns().All(static c => c.IsPrimaryKey));
break;
default:
tbl = db.CreateTable("MyTable", dt, new[]
Expand Down Expand Up @@ -192,9 +191,9 @@ public void Load(DatabaseType databaseType, TestCase testCase)

Assert.Multiple(() =>
{
Assert.That(tbl.DiscoverColumns().Select(c => c.GetRuntimeName()).Contains(SpecialFieldNames.DataLoadRunID), Is.EqualTo(testCase != TestCase.NoTrigger),
$"When running with NoTrigger there shouldn't be any additional columns added to table. Test case was {testCase}");
Assert.That(tbl.DiscoverColumns().Select(c => c.GetRuntimeName()).Contains(SpecialFieldNames.ValidFrom), Is.EqualTo(testCase != TestCase.NoTrigger),
Assert.That(tbl.DiscoverColumns().Select(static c => c.GetRuntimeName()).Contains(SpecialFieldNames.DataLoadRunID), Is.EqualTo(testCase != TestCase.NoTrigger),
$"When running with NoTrigger there shouldn't be any additional columns added to table. Test case was {testCase}");
Assert.That(tbl.DiscoverColumns().Select(static c => c.GetRuntimeName()).Contains(SpecialFieldNames.ValidFrom), Is.EqualTo(testCase != TestCase.NoTrigger),
$"When running with NoTrigger there shouldn't be any additional columns added to table. Test case was {testCase}");
});

Expand Down Expand Up @@ -240,22 +239,22 @@ public void Load(DatabaseType databaseType, TestCase testCase)

//frank should be updated to like Neon instead of Orange
Assert.That(tbl.GetRowCount(), Is.EqualTo(3));
var frankOld = tbl.GetDataTable().Rows.Cast<DataRow>().Single(r => (string)r["Name"] == "Frank");
var frankOld = tbl.GetDataTable().Rows.Cast<DataRow>().Single(static r => (string)r["Name"] == "Frank");
Assert.That(frankOld["FavouriteColour"], Is.EqualTo("Orange"));
Assert.Pass();
}

//frank should be updated to like Neon instead of Orange
Assert.That(tbl.GetRowCount(), Is.EqualTo(3));
var result = tbl.GetDataTable();
var frank = result.Rows.Cast<DataRow>().Single(r => (string)r["Name"] == "Frank");
var frank = result.Rows.Cast<DataRow>().Single(static r => (string)r["Name"] == "Frank");
Assert.That(frank["FavouriteColour"], Is.EqualTo("Neon"));

if (testCase != TestCase.NoTrigger)
AssertHasDataLoadRunId(frank);

//MrMurder is a new person who likes Yella
var mrmurder = result.Rows.Cast<DataRow>().Single(r => (string)r["Name"] == "MrMurder");
var mrmurder = result.Rows.Cast<DataRow>().Single(static r => (string)r["Name"] == "MrMurder");
Assert.Multiple(() =>
{
Assert.That(mrmurder["FavouriteColour"], Is.EqualTo("Yella"));
Expand All @@ -266,7 +265,7 @@ public void Load(DatabaseType databaseType, TestCase testCase)
AssertHasDataLoadRunId(mrmurder);

//bob should be untouched (same values as before and no dataloadrunID)
var bob = result.Rows.Cast<DataRow>().Single(r => (string)r["Name"] == "Bob");
var bob = result.Rows.Cast<DataRow>().Single(static r => (string)r["Name"] == "Bob");
Assert.Multiple(() =>
{
Assert.That(bob["FavouriteColour"], Is.EqualTo("Pink"));
Expand All @@ -284,9 +283,9 @@ public void Load(DatabaseType databaseType, TestCase testCase)

Assert.Multiple(() =>
{
Assert.That(tbl.DiscoverColumns().Select(c => c.GetRuntimeName()).Contains(SpecialFieldNames.DataLoadRunID), Is.EqualTo(testCase != TestCase.NoTrigger),
$"When running with NoTrigger there shouldn't be any additional columns added to table. Test case was {testCase}");
Assert.That(tbl.DiscoverColumns().Select(c => c.GetRuntimeName()).Contains(SpecialFieldNames.ValidFrom), Is.EqualTo(testCase != TestCase.NoTrigger),
Assert.That(tbl.DiscoverColumns().Select(static c => c.GetRuntimeName()).Contains(SpecialFieldNames.DataLoadRunID), Is.EqualTo(testCase != TestCase.NoTrigger),
$"When running with NoTrigger there shouldn't be any additional columns added to table. Test case was {testCase}");
Assert.That(tbl.DiscoverColumns().Select(static c => c.GetRuntimeName()).Contains(SpecialFieldNames.ValidFrom), Is.EqualTo(testCase != TestCase.NoTrigger),
$"When running with NoTrigger there shouldn't be any additional columns added to table. Test case was {testCase}");
});
}
Expand Down Expand Up @@ -358,7 +357,8 @@ public void DLELoadTwoTables(DatabaseType databaseType)
var args = new CreateTableArgs(
db,
"Child",
null,
// ReSharper disable once NullableWarningSuppressionIsUsed - FAnsi should know schema is often null
null!,
dtChild,
false,
new Dictionary<DatabaseColumnRequest, DiscoveredColumn>
Expand Down Expand Up @@ -437,23 +437,23 @@ public void DLELoadTwoTables(DatabaseType databaseType)
Assert.That(parentTbl.GetRowCount(), Is.EqualTo(2));
});
var result = parentTbl.GetDataTable();
var dave = result.Rows.Cast<DataRow>().Single(r => (string)r["Name"] == "Dave");
var dave = result.Rows.Cast<DataRow>().Single(static r => (string)r["Name"] == "Dave");
Assert.That(dave["Height"], Is.EqualTo(3.2f)); //should now be only 3.2 inches high
AssertHasDataLoadRunId(dave);

//should be 3 children (Child1 who gets updated to be called UpdC1) and NewC1
Assert.That(childTbl.GetRowCount(), Is.EqualTo(3));
result = childTbl.GetDataTable();

var updC1 = result.Rows.Cast<DataRow>().Single(r => (string)r["Name"] == "UpdC1");
var updC1 = result.Rows.Cast<DataRow>().Single(static r => (string)r["Name"] == "UpdC1");
Assert.Multiple(() =>
{
Assert.That(updC1["Parent_ID"], Is.EqualTo(1));
Assert.That(updC1["ChildNumber"], Is.EqualTo(1));
});
AssertHasDataLoadRunId(updC1);

var newC1 = result.Rows.Cast<DataRow>().Single(r => (string)r["Name"] == "NewC1");
var newC1 = result.Rows.Cast<DataRow>().Single(static r => (string)r["Name"] == "NewC1");
Assert.Multiple(() =>
{
Assert.That(newC1["Parent_ID"], Is.EqualTo(2));
Expand Down Expand Up @@ -481,7 +481,7 @@ public void DLELoadTwoTables(DatabaseType databaseType)
}
}

internal class CustomINameDatabasesAndTablesDuringLoads : INameDatabasesAndTablesDuringLoads
internal sealed class CustomINameDatabasesAndTablesDuringLoads : INameDatabasesAndTablesDuringLoads
{
public string GetDatabaseName(string rootDatabaseName, LoadBubble convention)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
using System.IO;
using System.Linq;
using NUnit.Framework;
using Rdmp.Core.CommandExecution;
using Rdmp.Core.Curation.Data;
using Rdmp.Core.Curation.Data.DataLoad;
using Rdmp.Core.Curation.Data.Defaults;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
using Rdmp.Core.Providers;
using Rdmp.Core.Repositories.Construction;
using Rdmp.Core.ReusableLibraryCode.Icons.IconProvision;
using Rdmp.Core.Setting;
using SixLabors.ImageSharp;
using SixLabors.ImageSharp.PixelFormats;

Expand All @@ -23,7 +22,7 @@ namespace Rdmp.Core.CommandExecution.AtomicCommands.CohortCreationCommands;
/// <summary>
/// Generates and runs an SQL query based on a <see cref="CohortIdentificationConfiguration"/> and pipes the resulting private identifier list to create a new <see cref="ExtractableCohort"/>.
/// </summary>
public class ExecuteCommandCreateNewCohortByExecutingACohortIdentificationConfiguration : CohortCreationCommandExecution
public sealed class ExecuteCommandCreateNewCohortByExecutingACohortIdentificationConfiguration : CohortCreationCommandExecution
{
private CohortIdentificationConfiguration _cic;

Expand Down Expand Up @@ -70,27 +69,28 @@ public override void Execute()
if (cic == null)
return;

if (BasicActivator.IsInteractive) {
var PromptForVersionOnCohortCommit = false;
var PromptForVersionOnCohortCommitSetting = BasicActivator.RepositoryLocator.CatalogueRepository.GetAllObjects<Setting.Setting>().Where(s => s.Key == "PromptForVersionOnCohortCommit").FirstOrDefault();
if (PromptForVersionOnCohortCommitSetting is not null) PromptForVersionOnCohortCommit = Convert.ToBoolean(PromptForVersionOnCohortCommitSetting.Value);
if (PromptForVersionOnCohortCommit && BasicActivator.YesNo("It is recommended to save your cohort as a new version before committing. Would you like to do this?", "Save cohort as new version before committing?"))
if (BasicActivator.IsInteractive)
{
var promptForVersionOnCohortCommit = false;
var promptForVersionOnCohortCommitSetting = BasicActivator.RepositoryLocator.CatalogueRepository.GetAllObjects<Setting.Setting>().Where(static s => s.Key == "PromptForVersionOnCohortCommit").FirstOrDefault();
if (promptForVersionOnCohortCommitSetting is not null) promptForVersionOnCohortCommit = Convert.ToBoolean(promptForVersionOnCohortCommitSetting.Value);
if (promptForVersionOnCohortCommit && BasicActivator.YesNo("It is recommended to save your cohort as a new version before committing. Would you like to do this?", "Save cohort as new version before committing?"))
{
var newVersion = new ExecuteCommandCreateVersionOfCohortConfiguration(BasicActivator, cic);
newVersion.Execute();
var versions = cic.GetVersions();
cic = versions.Last();
}

}

if (Project == null && BasicActivator.CoreChildProvider is DataExportChildProvider dx)
{
var projAssociations = dx.AllProjectAssociatedCics
.Where(c => c.CohortIdentificationConfiguration_ID == cic.ID).ToArray();
if (projAssociations.Length == 1) Project = projAssociations[0].Project;
}

var auditLogBuilder = new ExtractableCohortAuditLogBuilder();
_ = new ExtractableCohortAuditLogBuilder();
var request = GetCohortCreationRequest(ExtractableCohortAuditLogBuilder.GetDescription(cic));

//user choose to cancel the cohort creation request dialogue
Expand All @@ -101,7 +101,7 @@ public override void Execute()

var configureAndExecute = GetConfigureAndExecuteControl(request, $"Execute CIC {cic} and commit results", cic);

configureAndExecute.PipelineExecutionFinishedsuccessfully += (s, u) => OnImportCompletedSuccessfully(cic);
configureAndExecute.PipelineExecutionFinishedsuccessfully += (_, _) => OnImportCompletedSuccessfully(cic);

configureAndExecute.Run(BasicActivator.RepositoryLocator, null, null, null);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,8 @@ namespace Rdmp.Core.CommandExecution;
/// <see cref="CommandInvokerDelegate"/> that only ever returns a single object (in <see cref="CommandInvokerDelegate.Run"/>)
/// and claims only to handle that object's exact <see cref="Type"/>.
/// </summary>
internal class CommandInvokerFixedValueDelegate : CommandInvokerDelegate
internal sealed class CommandInvokerFixedValueDelegate(Type type, object o)
: CommandInvokerDelegate(type, false, _ => o)
{
public CommandInvokerFixedValueDelegate(Type type, object o) : base(type, false, p => o)
{
}

public override bool CanHandle(Type t) => HandledType == t;
}
3 changes: 1 addition & 2 deletions Rdmp.Core/Curation/Data/CatalogueItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
using Rdmp.Core.MapsDirectlyToDatabaseTable;
using Rdmp.Core.MapsDirectlyToDatabaseTable.Attributes;
using Rdmp.Core.MapsDirectlyToDatabaseTable.Injection;
using Rdmp.Core.MapsDirectlyToDatabaseTable.Revertable;
using Rdmp.Core.QueryBuilding;
using Rdmp.Core.Repositories;
using Rdmp.Core.ReusableLibraryCode;
Expand All @@ -36,7 +35,7 @@ namespace Rdmp.Core.Curation.Data;
///
/// <para>Both the above would extract from the same ColumnInfo DateOfBirth</para>
/// </summary>
public class CatalogueItem : DatabaseEntity, IComparable, IHasDependencies, INamed,
public sealed class CatalogueItem : DatabaseEntity, IComparable, IHasDependencies, INamed,
IInjectKnown<ExtractionInformation>, IInjectKnown<ColumnInfo>, IInjectKnown<Catalogue>
{
#region Database Properties
Expand Down
2 changes: 1 addition & 1 deletion Rdmp.Core/Curation/Data/DataLoad/Argument.cs
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ public string Description
#endregion

/// <inheritdoc/>
protected Argument() : base()
protected Argument()
{
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public string ReferencedObjectRepositoryType
}

/// <inheritdoc/>
protected ReferenceOtherObjectDatabaseEntity() : base()
protected ReferenceOtherObjectDatabaseEntity()
{
}

Expand Down
2 changes: 1 addition & 1 deletion Rdmp.Core/Curation/Data/Remoting/RemoteRDMP.cs
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ public RemoteRDMP()
}

/// <inheritdoc/>
public RemoteRDMP(ICatalogueRepository repository) : base()
public RemoteRDMP(ICatalogueRepository repository)
{
// need a new copy of the catalogue repository so a new DB connection can be made to use with the encrypted host.
_encryptedPasswordHost = new EncryptedPasswordHost(repository);
Expand Down
2 changes: 1 addition & 1 deletion Rdmp.Core/Curation/Data/TicketingSystemConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ public TicketingSystemConfiguration()
}

/// <inheritdoc/>
public TicketingSystemConfiguration(ICatalogueRepository repository, string name) : base()
public TicketingSystemConfiguration(ICatalogueRepository repository, string name)
{
repository.InsertAndHydrate(this, new Dictionary<string, object>
{
Expand Down
Loading

0 comments on commit 2b12494

Please sign in to comment.