From 5b13f58f1f970f8ac09f4688c910c1c5793a3472 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 13 Mar 2024 01:00:28 +0000 Subject: [PATCH 1/2] Bump HIC.BadMedicine from 1.1.2 to 1.2.0 Bumps [HIC.BadMedicine](https://github.com/HicServices/BadMedicine) from 1.1.2 to 1.2.0. - [Release notes](https://github.com/HicServices/BadMedicine/releases) - [Changelog](https://github.com/HicServices/BadMedicine/blob/develop/CHANGELOG.md) - [Commits](https://github.com/HicServices/BadMedicine/compare/v1.1.2...v1.2.0) --- updated-dependencies: - dependency-name: HIC.BadMedicine dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- Directory.Packages.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Directory.Packages.props b/Directory.Packages.props index ae3d3d8dbc..9f565a4c47 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -4,7 +4,7 @@ - + From c51be2f5cbbb5579aa194086af80395886dabcd3 Mon Sep 17 00:00:00 2001 From: James A Sutherland Date: Tue, 12 Mar 2024 20:41:22 -0500 Subject: [PATCH 2/2] BadMedicine API update --- .../ExecuteCommandGenerateTestData.cs | 11 +++++------ .../DatabaseCreation/ExampleDatasetsCreation.cs | 9 +++------ .../SimpleDialogs/Reports/GenerateTestDataUI.cs | 17 ++++++----------- Tests.Common/Scenarios/TestsRequiringA.cs | 3 +-- 4 files changed, 15 insertions(+), 25 deletions(-) diff --git a/Rdmp.Core/CommandExecution/AtomicCommands/ExecuteCommandGenerateTestData.cs b/Rdmp.Core/CommandExecution/AtomicCommands/ExecuteCommandGenerateTestData.cs index 7cbddc52ff..6c06f5f793 100644 --- a/Rdmp.Core/CommandExecution/AtomicCommands/ExecuteCommandGenerateTestData.cs +++ b/Rdmp.Core/CommandExecution/AtomicCommands/ExecuteCommandGenerateTestData.cs @@ -32,19 +32,18 @@ public ExecuteCommandGenerateTestData(IBasicActivateItems activator, string data _numberOfRecords = numberOfRecords; _toFile = toFile; - var dataGeneratorFactory = new DataGeneratorFactory(); - var match = dataGeneratorFactory.GetAvailableGenerators().FirstOrDefault(g => - g.Name.Contains(datasetName, StringComparison.InvariantCultureIgnoreCase)); + var match = DataGeneratorFactory.GetAvailableGenerators().Cast().FirstOrDefault(g => + g?.Type.FullName?.Contains(datasetName, StringComparison.InvariantCultureIgnoreCase) == true); - if (match == null) + if (match is null) { SetImpossible( - $"Unknown dataset '{datasetName}'. Known datasets are:{Environment.NewLine}{string.Join(Environment.NewLine, dataGeneratorFactory.GetAvailableGenerators().Select(g => g.Name).ToArray())}"); + $"Unknown dataset '{datasetName}'. Known datasets are:{Environment.NewLine}{string.Join(Environment.NewLine, DataGeneratorFactory.GetAvailableGenerators().Select(static g => g.Type.FullName).ToArray())}"); return; } _r = new Random(seed); - _generator = dataGeneratorFactory.Create(match, _r); + _generator = DataGeneratorFactory.Create(match.Value.Type, _r); } public override void Execute() diff --git a/Rdmp.Core/CommandLine/DatabaseCreation/ExampleDatasetsCreation.cs b/Rdmp.Core/CommandLine/DatabaseCreation/ExampleDatasetsCreation.cs index 2ebd4393cf..720c1b5d31 100644 --- a/Rdmp.Core/CommandLine/DatabaseCreation/ExampleDatasetsCreation.cs +++ b/Rdmp.Core/CommandLine/DatabaseCreation/ExampleDatasetsCreation.cs @@ -588,10 +588,8 @@ private static DiscoveredTable Create(DiscoveredDatabase db, PersonCollection notifier.OnCheckPerformed(new CheckEventArgs($"Generating {numberOfRecords} records for {dataset}", CheckResult.Success)); - var factory = new DataGeneratorFactory(); - //half a million biochemistry results - var biochem = factory.Create(typeof(T), r); + var biochem = DataGeneratorFactory.Create(typeof(T), r); var dt = biochem.GetDataTable(people, numberOfRecords); //prune "nulls" @@ -647,15 +645,14 @@ private ICatalogue ImportCatalogue(ITableInfo ti) forwardEngineer.ExecuteForwardEngineering(out var cata, out _, out var eis); //get descriptions of the columns from BadMedicine - var desc = new Descriptions(); - cata.Description = Trim(desc.Get(cata.Name)); + cata.Description = Trim(Descriptions.Get(cata.Name)); if (cata.Description != null) { cata.SaveToDatabase(); foreach (var ci in cata.CatalogueItems) { - var ciDescription = Trim(desc.Get(cata.Name, ci.Name)); + var ciDescription = Trim(Descriptions.Get(cata.Name, ci.Name)); if (ciDescription != null) { ci.Description = ciDescription; diff --git a/Rdmp.UI/SimpleDialogs/Reports/GenerateTestDataUI.cs b/Rdmp.UI/SimpleDialogs/Reports/GenerateTestDataUI.cs index 236bed5fb6..2f03de650f 100644 --- a/Rdmp.UI/SimpleDialogs/Reports/GenerateTestDataUI.cs +++ b/Rdmp.UI/SimpleDialogs/Reports/GenerateTestDataUI.cs @@ -42,15 +42,13 @@ public GenerateTestDataUI(IActivateItems activator, ICommandExecution command) : { InitializeComponent(); - var dataGeneratorFactory = new DataGeneratorFactory(); - var yLoc = 0; - foreach (var t in dataGeneratorFactory.GetAvailableGenerators()) + foreach (var t in DataGeneratorFactory.GetAvailableGenerators()) { var ui = new DataGeneratorUI { - Generator = dataGeneratorFactory.Create(t, new Random()), + Generator = DataGeneratorFactory.Create(t.Type, new Random()), Location = new Point(0, yLoc) }; yLoc += ui.Height; @@ -143,9 +141,9 @@ private void EnableOrDisableGoButton() private void btnGenerate_Click(object sender, EventArgs e) { - var uis = pDatasets.Controls.OfType().Where(ui => ui.Generate).ToArray(); + var uis = pDatasets.Controls.OfType().Where(static ui => ui.Generate).ToArray(); - if (!uis.Any()) + if (uis.Length == 0) { MessageBox.Show("At least one dataset must be selected"); return; @@ -206,11 +204,8 @@ private void Execute(PersonCollection identifiers, Queue queue, //tell form it is running Executing.Add(current); - var dataGeneratorFactory = new DataGeneratorFactory(); - //reset the current generator to use the seed provided - current.Generator = dataGeneratorFactory.Create(current.Generator.GetType(), r); - + current.Generator = DataGeneratorFactory.Create(current.Generator.GetType(), r); current.BeginGeneration(identifiers, _extractDirectory); @@ -227,7 +222,7 @@ private void Execute(PersonCollection identifiers, Queue queue, private void AnnounceIfComplete() { - if (!Executing.Any()) + if (Executing.Count == 0) { MessageBox.Show("Finished generating test data"); Close(); diff --git a/Tests.Common/Scenarios/TestsRequiringA.cs b/Tests.Common/Scenarios/TestsRequiringA.cs index 2d83f9d00b..a337056a7e 100644 --- a/Tests.Common/Scenarios/TestsRequiringA.cs +++ b/Tests.Common/Scenarios/TestsRequiringA.cs @@ -43,8 +43,7 @@ protected DiscoveredTable CreateDataset(DiscoveredDatabase db, int people, in protected DiscoveredTable CreateDataset(DiscoveredDatabase db, PersonCollection people, int rows, Random r) where T : IDataGenerator { - var f = new DataGeneratorFactory(); - var instance = f.Create(r); + var instance = DataGeneratorFactory.Create(r); var dt = instance.GetDataTable(people, rows);