From 8c51a287143d9a0039a2eb3f48387078de3577e0 Mon Sep 17 00:00:00 2001 From: James Friel Date: Wed, 3 Jul 2024 14:24:33 +0100 Subject: [PATCH 01/44] add cron test --- .github/workflows/build.yml | 6 ++-- .../RemoteDatabaseAttacherTests.cs | 8 ++--- .../Attachers/RemoteTableAttacherTests.cs | 36 +++++++++---------- 3 files changed, 26 insertions(+), 24 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 864260862d..78a2f96886 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -2,7 +2,9 @@ name: Build # Run this workflow every time a new commit pushed to your repository -on: push +on: + schedule: + - cron '30 * * * *' env: DOTNET_NOLOGO: 1 @@ -11,7 +13,7 @@ env: jobs: # Set the job key. The key is displayed as the job name # when a job name is not provided - tests_db: + tests_db: name: Run Database Tests runs-on: windows-latest steps: diff --git a/Rdmp.Core.Tests/DataLoad/Engine/Integration/RemoteDatabaseAttacherTests.cs b/Rdmp.Core.Tests/DataLoad/Engine/Integration/RemoteDatabaseAttacherTests.cs index 3b48e2085f..884fcbd9d6 100644 --- a/Rdmp.Core.Tests/DataLoad/Engine/Integration/RemoteDatabaseAttacherTests.cs +++ b/Rdmp.Core.Tests/DataLoad/Engine/Integration/RemoteDatabaseAttacherTests.cs @@ -213,13 +213,13 @@ public void TestRemoteDatabaseAttacherWithDateFilter(DatabaseType dbType, Scenar if (duration == AttacherHistoricalDurations.Custom) { - attacher.CustomFetchDurationStartDate = DateTime.Now.AddDays(-7); - attacher.CustomFetchDurationEndDate = DateTime.Now; + attacher.CustomFetchDurationStartDate = DateTime.UtcNow.AddDays(-7); + attacher.CustomFetchDurationEndDate = DateTime.UtcNow; } if (duration == AttacherHistoricalDurations.DeltaReading) { - attacher.DeltaReadingStartDate = DateTime.Now.AddDays(-7); + attacher.DeltaReadingStartDate = DateTime.UtcNow.AddDays(-7); attacher.DeltaReadingLookBackDays = 0; attacher.DeltaReadingLookForwardDays = 5; } @@ -236,7 +236,7 @@ public void TestRemoteDatabaseAttacherWithDateFilter(DatabaseType dbType, Scenar if (duration == AttacherHistoricalDurations.SinceLastUse) { - job.LoadMetadata.LastLoadTime = DateTime.Now.AddDays(-1);// last used yesterday + job.LoadMetadata.LastLoadTime = DateTime.UtcNow.AddDays(-1);// last used yesterday job.LoadMetadata.SaveToDatabase(); } if (scenario == Scenario.MissingPreLoadDiscardedColumn) diff --git a/Rdmp.Core.Tests/DataLoad/Modules/Attachers/RemoteTableAttacherTests.cs b/Rdmp.Core.Tests/DataLoad/Modules/Attachers/RemoteTableAttacherTests.cs index 464982691f..041e5773b0 100644 --- a/Rdmp.Core.Tests/DataLoad/Modules/Attachers/RemoteTableAttacherTests.cs +++ b/Rdmp.Core.Tests/DataLoad/Modules/Attachers/RemoteTableAttacherTests.cs @@ -269,19 +269,19 @@ private static string Within(AttacherHistoricalDurations duration) switch (duration) { case AttacherHistoricalDurations.Past24Hours: - return DateTime.Now.AddHours(-1).ToString(); + return DateTime.UtcNow.AddHours(-1).ToString(); case AttacherHistoricalDurations.Past7Days: - return DateTime.Now.AddHours(-1).ToString(); + return DateTime.UtcNow.AddHours(-1).ToString(); case AttacherHistoricalDurations.PastMonth: - return DateTime.Now.AddHours(-1).ToString(); + return DateTime.UtcNow.AddHours(-1).ToString(); case AttacherHistoricalDurations.PastYear: - return DateTime.Now.AddHours(-1).ToString(); + return DateTime.UtcNow.AddHours(-1).ToString(); case AttacherHistoricalDurations.SinceLastUse: - return DateTime.Now.AddHours(-1).ToString(); + return DateTime.UtcNow.AddHours(-1).ToString(); case AttacherHistoricalDurations.Custom: - return DateTime.Now.AddDays(-1).ToString(); + return DateTime.UtcNow.AddDays(-1).ToString(); case AttacherHistoricalDurations.DeltaReading: - return DateTime.Now.AddDays(-4).ToString(); + return DateTime.UtcNow.AddDays(-4).ToString(); default: return "fail"; } @@ -292,19 +292,19 @@ private static string Outwith(AttacherHistoricalDurations duration) switch (duration) { case AttacherHistoricalDurations.Past24Hours: - return DateTime.Now.AddDays(-2).ToString(); + return DateTime.UtcNow.AddDays(-2).ToString(); case AttacherHistoricalDurations.Past7Days: - return DateTime.Now.AddDays(-8).ToString(); + return DateTime.UtcNow.AddDays(-8).ToString(); case AttacherHistoricalDurations.PastMonth: - return DateTime.Now.AddMonths(-2).ToString(); + return DateTime.UtcNow.AddMonths(-2).ToString(); case AttacherHistoricalDurations.PastYear: - return DateTime.Now.AddYears(-2).ToString(); + return DateTime.UtcNow.AddYears(-2).ToString(); case AttacherHistoricalDurations.SinceLastUse: - return DateTime.Now.AddDays(-2).ToString(); + return DateTime.UtcNow.AddDays(-2).ToString(); case AttacherHistoricalDurations.Custom: - return DateTime.Now.AddDays(-14).ToString(); + return DateTime.UtcNow.AddDays(-14).ToString(); case AttacherHistoricalDurations.DeltaReading: - return DateTime.Now.AddDays(-10).ToString(); + return DateTime.UtcNow.AddDays(-10).ToString(); default: return "fail"; } @@ -351,17 +351,17 @@ private void RunAttachStageWithFilterJob(RemoteTableAttacher attacher, Discovere job.StartLogging(); if (duration == AttacherHistoricalDurations.SinceLastUse) { - job.LoadMetadata.LastLoadTime = DateTime.Now.AddDays(-1);// last used yesterday + job.LoadMetadata.LastLoadTime = DateTime.UtcNow.AddDays(-1);// last used yesterday job.LoadMetadata.SaveToDatabase(); } if (duration == AttacherHistoricalDurations.Custom) { - attacher.CustomFetchDurationStartDate = DateTime.Now.AddDays(-7); - attacher.CustomFetchDurationEndDate = DateTime.Now; + attacher.CustomFetchDurationStartDate = DateTime.UtcNow.AddDays(-7); + attacher.CustomFetchDurationEndDate = DateTime.UtcNow; } if (duration == AttacherHistoricalDurations.DeltaReading) { - attacher.DeltaReadingStartDate = DateTime.Now.AddDays(-7); + attacher.DeltaReadingStartDate = DateTime.UtcNow.AddDays(-7); attacher.DeltaReadingLookBackDays = 0; attacher.DeltaReadingLookForwardDays = 5; } From 03ea71f6bc11f2f8120ea362c019b0248c3cccdd Mon Sep 17 00:00:00 2001 From: James Friel Date: Wed, 3 Jul 2024 14:36:22 +0100 Subject: [PATCH 02/44] fix yaml --- .github/workflows/build.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 78a2f96886..4c22bf3bdc 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -4,7 +4,7 @@ name: Build on: schedule: - - cron '30 * * * *' + - cron '40 * * * *' env: DOTNET_NOLOGO: 1 @@ -74,8 +74,7 @@ jobs: files: ./db-ui.lcov ./db-core.lcov flag-name: unit tests - - tests_file_system: + tests_file_system: name: Run File System Tests runs-on: windows-latest steps: From 5a69530ce48c17d582c2e853660be213e8b5bba6 Mon Sep 17 00:00:00 2001 From: James Friel Date: Wed, 3 Jul 2024 14:36:54 +0100 Subject: [PATCH 03/44] fix yaml --- .github/workflows/build.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 4c22bf3bdc..142f19e078 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -135,7 +135,7 @@ jobs: files: ./fs-ui.lcov ./fs-core.lcov flag-name: unit tests - bundle: + bundle: name: Bundle Build runs-on: windows-latest steps: @@ -268,7 +268,7 @@ jobs: path: ${{ github.workspace }}/ key: ${{ github.sha }}-your-cache-key-bundled - production-upload: + production-upload: name: Production Upload runs-on: windows-latest needs: ['bundle','tests_db','tests_file_system'] From dfd84359df28e93a299aec24296854962569f7e5 Mon Sep 17 00:00:00 2001 From: James Friel Date: Wed, 3 Jul 2024 14:39:12 +0100 Subject: [PATCH 04/44] update spacing --- .github/workflows/build.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 142f19e078..d41300ab40 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -3,8 +3,8 @@ name: Build # Run this workflow every time a new commit pushed to your repository on: - schedule: - - cron '40 * * * *' + schedule: + - cron '40 * * * *' env: DOTNET_NOLOGO: 1 From 1eeb269c0c25c236a5123c893fe1b12ae21e9130 Mon Sep 17 00:00:00 2001 From: James Friel Date: Wed, 3 Jul 2024 14:39:54 +0100 Subject: [PATCH 05/44] use example --- .github/workflows/build.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index d41300ab40..b37f716355 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -2,9 +2,10 @@ name: Build # Run this workflow every time a new commit pushed to your repository -on: +on: schedule: - - cron '40 * * * *' + # * is a special character in YAML so you have to quote this string + - cron: '30 5,17 * * *' env: DOTNET_NOLOGO: 1 From dae3b767e10d673c9691acf293f7fe3ff1a3b2e7 Mon Sep 17 00:00:00 2001 From: James Friel Date: Wed, 3 Jul 2024 14:40:37 +0100 Subject: [PATCH 06/44] update cron --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index b37f716355..14c73adef4 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -5,7 +5,7 @@ name: Build on: schedule: # * is a special character in YAML so you have to quote this string - - cron: '30 5,17 * * *' + - cron: '42 * * * *' env: DOTNET_NOLOGO: 1 From 1b74e4bbf020a10969edb58d9ef58e1d85a40c15 Mon Sep 17 00:00:00 2001 From: James Friel Date: Wed, 3 Jul 2024 14:45:01 +0100 Subject: [PATCH 07/44] update to push --- .github/workflows/build.yml | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 14c73adef4..08dc500232 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -2,10 +2,7 @@ name: Build # Run this workflow every time a new commit pushed to your repository -on: - schedule: - # * is a special character in YAML so you have to quote this string - - cron: '42 * * * *' +on: push env: DOTNET_NOLOGO: 1 From 35582bdabafc78a336a334aa6709c92afd7486d7 Mon Sep 17 00:00:00 2001 From: James Friel Date: Thu, 4 Jul 2024 09:22:13 +0100 Subject: [PATCH 08/44] add 2am cron --- .github/workflows/build.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 08dc500232..af4935e23d 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -2,7 +2,10 @@ name: Build # Run this workflow every time a new commit pushed to your repository -on: push +on: + push: + schedule: + - cron: '0 2 * * *' env: DOTNET_NOLOGO: 1 From 813515855e8be33f2e7152f6f5fcffd0aaa393c9 Mon Sep 17 00:00:00 2001 From: James Friel Date: Thu, 4 Jul 2024 09:24:00 +0100 Subject: [PATCH 09/44] update yaml --- .github/workflows/build.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index af4935e23d..7fe327647c 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -14,7 +14,7 @@ env: jobs: # Set the job key. The key is displayed as the job name # when a job name is not provided - tests_db: + tests_db: name: Run Database Tests runs-on: windows-latest steps: @@ -75,7 +75,7 @@ jobs: files: ./db-ui.lcov ./db-core.lcov flag-name: unit tests - tests_file_system: + tests_file_system: name: Run File System Tests runs-on: windows-latest steps: @@ -136,7 +136,7 @@ jobs: files: ./fs-ui.lcov ./fs-core.lcov flag-name: unit tests - bundle: + bundle: name: Bundle Build runs-on: windows-latest steps: @@ -269,7 +269,7 @@ jobs: path: ${{ github.workspace }}/ key: ${{ github.sha }}-your-cache-key-bundled - production-upload: + production-upload: name: Production Upload runs-on: windows-latest needs: ['bundle','tests_db','tests_file_system'] From 3efba507e7d94827959cbd63ec27f045ba8c014b Mon Sep 17 00:00:00 2001 From: James Friel Date: Thu, 4 Jul 2024 09:25:25 +0100 Subject: [PATCH 10/44] use utc --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 7fe327647c..0e4ab09c2f 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -5,7 +5,7 @@ name: Build on: push: schedule: - - cron: '0 2 * * *' + - cron: '0 1 * * *' env: DOTNET_NOLOGO: 1 From 224511875fe34f8e57c48e2f478243c125c96c93 Mon Sep 17 00:00:00 2001 From: James Friel Date: Thu, 4 Jul 2024 15:55:46 +0100 Subject: [PATCH 11/44] add first update --- .../Caching/Integration/CachingHostTests.cs | 9 ++------- .../Integration/CustomDateCachingTests.cs | 9 ++------- .../AutomationLoopTests/EndToEndCacheTest.cs | 6 +----- .../Integration/LoadProgressUnitTests.cs | 9 ++------- .../CheckingTests/ProcessTaskCheckingTests.cs | 18 +++--------------- .../Integration/DataLoadEngineTestsBase.cs | 6 +----- ...enerationStrategyFactoryTestsIntegration.cs | 18 +++--------------- .../DataLoad/Engine/Integration/PayloadTest.cs | 6 +----- ...ExecuteCommandCreateNewDataLoadDirectory.cs | 8 ++------ Rdmp.Core/Curation/LoadDirectory.cs | 15 ++++++++++++--- Tests.Common/Scenarios/TestsRequiringADle.cs | 10 +++------- 11 files changed, 32 insertions(+), 82 deletions(-) diff --git a/Rdmp.Core.Tests/Caching/Integration/CachingHostTests.cs b/Rdmp.Core.Tests/Caching/Integration/CachingHostTests.cs index 91c80b48be..e8c53f0556 100644 --- a/Rdmp.Core.Tests/Caching/Integration/CachingHostTests.cs +++ b/Rdmp.Core.Tests/Caching/Integration/CachingHostTests.cs @@ -35,15 +35,10 @@ public void CacheHostOutwithPermissionWindow() if (testDir.Exists) Directory.Delete(testDir.FullName, true); - var loadDirectory = LoadDirectory.CreateDirectoryStructure(testDir, "Test"); - - var cp = WhenIHaveA(); var loadMetadata = cp.LoadProgress.LoadMetadata; - loadMetadata.LocationOfForLoadingDirectory = Path.Combine(loadDirectory.RootPath.FullName , ((LoadMetadata)loadMetadata).DefaultForLoadingPath); - loadMetadata.LocationOfForArchivingDirectory = Path.Combine(loadDirectory.RootPath.FullName , ((LoadMetadata)loadMetadata).DefaultForArchivingPath); - loadMetadata.LocationOfExecutablesDirectory = Path.Combine(loadDirectory.RootPath.FullName , ((LoadMetadata)loadMetadata).DefaultExecutablesPath); - loadMetadata.LocationOfCacheDirectory = Path.Combine(loadDirectory.RootPath.FullName , ((LoadMetadata)loadMetadata).DefaultCachePath); + + var loadDirectory = LoadDirectory.CreateDirectoryStructure(testDir, "Test", false, loadMetadata); // This feels a bit nasty, but quick and much better than having the test wait for an arbitrary time period. var listener = new ExpectedNotificationListener("Download not permitted at this time, sleeping for 60 seconds"); diff --git a/Rdmp.Core.Tests/Caching/Integration/CustomDateCachingTests.cs b/Rdmp.Core.Tests/Caching/Integration/CustomDateCachingTests.cs index 468cf44f07..8e4730b9b9 100644 --- a/Rdmp.Core.Tests/Caching/Integration/CustomDateCachingTests.cs +++ b/Rdmp.Core.Tests/Caching/Integration/CustomDateCachingTests.cs @@ -55,16 +55,11 @@ public void FetchMultipleDays_Success(bool singleDay) pipeline.Destination.Returns(destinationComponent); pipeline.Repository.Returns(CatalogueRepository); pipeline.PipelineComponents.Returns(Enumerable.Empty().OrderBy(o => o).ToList()); + var lmd = Substitute.For(); var projDir = LoadDirectory.CreateDirectoryStructure(new DirectoryInfo(TestContext.CurrentContext.TestDirectory), "delme", - true); - - var lmd = Substitute.For(); - lmd.LocationOfForLoadingDirectory = Path.Combine(projDir.RootPath.FullName , Path.Combine("Data", "ForLoading")); - lmd.LocationOfForArchivingDirectory = Path.Combine(projDir.RootPath.FullName , Path.Combine("Data", "ForArchiving")); - lmd.LocationOfExecutablesDirectory = Path.Combine(projDir.RootPath.FullName ,"Executables"); - lmd.LocationOfCacheDirectory = Path.Combine(projDir.RootPath.FullName , Path.Combine("Data", "Cache")); + true, lmd); var loadProgress = Substitute.For(); loadProgress.OriginDate.Returns(new DateTime(2001, 01, 01)); diff --git a/Rdmp.Core.Tests/CommandLine/AutomationLoopTests/EndToEndCacheTest.cs b/Rdmp.Core.Tests/CommandLine/AutomationLoopTests/EndToEndCacheTest.cs index 076f36a837..1acc1df77a 100644 --- a/Rdmp.Core.Tests/CommandLine/AutomationLoopTests/EndToEndCacheTest.cs +++ b/Rdmp.Core.Tests/CommandLine/AutomationLoopTests/EndToEndCacheTest.cs @@ -48,11 +48,7 @@ protected override void SetUp() _lmd = new LoadMetadata(CatalogueRepository, "Ive got a lovely bunch o' coconuts"); _LoadDirectory = LoadDirectory.CreateDirectoryStructure(new DirectoryInfo(TestContext.CurrentContext.TestDirectory), - @"EndToEndCacheTest", true); - _lmd.LocationOfForLoadingDirectory = Path.Combine(_LoadDirectory.RootPath.FullName , _lmd.DefaultForLoadingPath); - _lmd.LocationOfForArchivingDirectory = Path.Combine(_LoadDirectory.RootPath.FullName , _lmd.DefaultForArchivingPath); - _lmd.LocationOfExecutablesDirectory = Path.Combine(_LoadDirectory.RootPath.FullName , _lmd.DefaultExecutablesPath); - _lmd.LocationOfCacheDirectory = Path.Combine(_LoadDirectory.RootPath.FullName , _lmd.DefaultCachePath); + @"EndToEndCacheTest", true,_lmd); _lmd.SaveToDatabase(); Clear(_LoadDirectory); diff --git a/Rdmp.Core.Tests/Curation/Integration/LoadProgressUnitTests.cs b/Rdmp.Core.Tests/Curation/Integration/LoadProgressUnitTests.cs index 7f1e9bdbbf..7650f291a8 100644 --- a/Rdmp.Core.Tests/Curation/Integration/LoadProgressUnitTests.cs +++ b/Rdmp.Core.Tests/Curation/Integration/LoadProgressUnitTests.cs @@ -65,15 +65,10 @@ public void LoadProgress_JobFactory_NoDates() var stratFactory = new JobDateGenerationStrategyFactory(new AnyAvailableLoadProgressSelectionStrategy(lp.LoadMetadata)); var strat = stratFactory.Create(lp, ThrowImmediatelyDataLoadEventListener.Quiet); + var lmd = lp.LoadMetadata; var dir = LoadDirectory.CreateDirectoryStructure(new DirectoryInfo(TestContext.CurrentContext.WorkDirectory), - "LoadProgress_JobFactory_NoDates", true); - - var lmd = lp.LoadMetadata; - lmd.LocationOfForLoadingDirectory = Path.Combine(dir.RootPath.FullName , ((LoadMetadata)lmd).DefaultForLoadingPath); - lmd.LocationOfForArchivingDirectory = Path.Combine(dir.RootPath.FullName , ((LoadMetadata)lmd).DefaultForArchivingPath); - lmd.LocationOfExecutablesDirectory = Path.Combine(dir.RootPath.FullName , ((LoadMetadata)lmd).DefaultExecutablesPath); - lmd.LocationOfCacheDirectory = Path.Combine(dir.RootPath.FullName , ((LoadMetadata)lmd).DefaultCachePath); + "LoadProgress_JobFactory_NoDates", true, lmd); foreach (var cata in lmd.GetAllCatalogues()) { diff --git a/Rdmp.Core.Tests/DataLoad/Engine/Integration/CheckingTests/ProcessTaskCheckingTests.cs b/Rdmp.Core.Tests/DataLoad/Engine/Integration/CheckingTests/ProcessTaskCheckingTests.cs index 35bbe414d0..a6a707604e 100644 --- a/Rdmp.Core.Tests/DataLoad/Engine/Integration/CheckingTests/ProcessTaskCheckingTests.cs +++ b/Rdmp.Core.Tests/DataLoad/Engine/Integration/CheckingTests/ProcessTaskCheckingTests.cs @@ -35,11 +35,7 @@ public void CreateTask() _dir = new DirectoryInfo(Path.Combine(TestContext.CurrentContext.TestDirectory, "ProcessTaskCheckingTests")); _dir.Create(); - var hicdir = LoadDirectory.CreateDirectoryStructure(_dir, "ProjDir", true); - _lmd.LocationOfForLoadingDirectory = Path.Combine(hicdir.RootPath.FullName, _lmd.DefaultForLoadingPath); - _lmd.LocationOfForArchivingDirectory = Path.Combine(hicdir.RootPath.FullName, _lmd.DefaultForArchivingPath); - _lmd.LocationOfExecutablesDirectory = Path.Combine(hicdir.RootPath.FullName, _lmd.DefaultExecutablesPath); - _lmd.LocationOfCacheDirectory = Path.Combine(hicdir.RootPath.FullName, _lmd.DefaultCachePath); + var hicdir = LoadDirectory.CreateDirectoryStructure(_dir, "ProjDir", true, _lmd); _lmd.SaveToDatabase(); var c = new Catalogue(CatalogueRepository, "c"); @@ -128,13 +124,9 @@ public void MEFCompatibleType_NoArgs() { var projDir = LoadDirectory.CreateDirectoryStructure(new DirectoryInfo(TestContext.CurrentContext.TestDirectory), - "DelMeProjDir", true); + "DelMeProjDir", true, _lmd); try { - _lmd.LocationOfForLoadingDirectory = Path.Combine(projDir.RootPath.FullName, _lmd.DefaultForLoadingPath); - _lmd.LocationOfForArchivingDirectory = Path.Combine(projDir.RootPath.FullName, _lmd.DefaultForArchivingPath); - _lmd.LocationOfExecutablesDirectory = Path.Combine(projDir.RootPath.FullName, _lmd.DefaultExecutablesPath); - _lmd.LocationOfCacheDirectory = Path.Combine(projDir.RootPath.FullName, _lmd.DefaultCachePath); _task.ProcessTaskType = ProcessTaskType.Attacher; _task.LoadStage = LoadStage.Mounting; _task.Path = typeof(AnySeparatorFileAttacher).FullName; @@ -158,13 +150,9 @@ public void MEFCompatibleType_Passes() { var projDir = LoadDirectory.CreateDirectoryStructure(new DirectoryInfo(TestContext.CurrentContext.TestDirectory), - "DelMeProjDir", true); + "DelMeProjDir", true, _lmd); try { - _lmd.LocationOfForLoadingDirectory = Path.Combine(projDir.RootPath.FullName, _lmd.DefaultForLoadingPath); - _lmd.LocationOfForArchivingDirectory = Path.Combine(projDir.RootPath.FullName, _lmd.DefaultForArchivingPath); - _lmd.LocationOfExecutablesDirectory = Path.Combine(projDir.RootPath.FullName, _lmd.DefaultExecutablesPath); - _lmd.LocationOfCacheDirectory = Path.Combine(projDir.RootPath.FullName, _lmd.DefaultCachePath); _task.ProcessTaskType = ProcessTaskType.Attacher; _task.LoadStage = LoadStage.Mounting; _task.Path = typeof(AnySeparatorFileAttacher).FullName; diff --git a/Rdmp.Core.Tests/DataLoad/Engine/Integration/DataLoadEngineTestsBase.cs b/Rdmp.Core.Tests/DataLoad/Engine/Integration/DataLoadEngineTestsBase.cs index 454fae0e12..ef8210f040 100644 --- a/Rdmp.Core.Tests/DataLoad/Engine/Integration/DataLoadEngineTestsBase.cs +++ b/Rdmp.Core.Tests/DataLoad/Engine/Integration/DataLoadEngineTestsBase.cs @@ -71,11 +71,7 @@ protected static LoadDirectory SetupLoadDirectory(LoadMetadata lmd) { var projectDirectory = LoadDirectory.CreateDirectoryStructure(new DirectoryInfo(TestContext.CurrentContext.TestDirectory), - "MyLoadDir", true); - lmd.LocationOfForLoadingDirectory = Path.Combine(projectDirectory.RootPath.FullName, lmd.DefaultForLoadingPath); - lmd.LocationOfForArchivingDirectory = Path.Combine(projectDirectory.RootPath.FullName, lmd.DefaultForArchivingPath); - lmd.LocationOfExecutablesDirectory = Path.Combine(projectDirectory.RootPath.FullName, lmd.DefaultExecutablesPath); - lmd.LocationOfCacheDirectory = Path.Combine(projectDirectory.RootPath.FullName, lmd.DefaultCachePath); + "MyLoadDir", true,lmd); lmd.SaveToDatabase(); return projectDirectory; diff --git a/Rdmp.Core.Tests/DataLoad/Engine/Integration/JobDateGenerationStrategyFactoryTestsIntegration.cs b/Rdmp.Core.Tests/DataLoad/Engine/Integration/JobDateGenerationStrategyFactoryTestsIntegration.cs index 8ce1f15643..75d0ddbe15 100644 --- a/Rdmp.Core.Tests/DataLoad/Engine/Integration/JobDateGenerationStrategyFactoryTestsIntegration.cs +++ b/Rdmp.Core.Tests/DataLoad/Engine/Integration/JobDateGenerationStrategyFactoryTestsIntegration.cs @@ -126,11 +126,7 @@ public void CacheProvider_NoPipeline() var projDir = LoadDirectory.CreateDirectoryStructure(new DirectoryInfo(TestContext.CurrentContext.TestDirectory), "delme", - true); - _lmd.LocationOfForLoadingDirectory = Path.Combine(projDir.RootPath.FullName, _lmd.DefaultForLoadingPath); - _lmd.LocationOfForArchivingDirectory = Path.Combine(projDir.RootPath.FullName, _lmd.DefaultForArchivingPath); - _lmd.LocationOfExecutablesDirectory = Path.Combine(projDir.RootPath.FullName, _lmd.DefaultExecutablesPath); - _lmd.LocationOfCacheDirectory = Path.Combine(projDir.RootPath.FullName, _lmd.DefaultCachePath); + true, _lmd); _lmd.SaveToDatabase(); try { @@ -156,11 +152,7 @@ public void CacheProvider_NoCacheProgress() var projDir = LoadDirectory.CreateDirectoryStructure(new DirectoryInfo(TestContext.CurrentContext.TestDirectory), "delme", - true); - _lmd.LocationOfForLoadingDirectory = Path.Combine(projDir.RootPath.FullName, _lmd.DefaultForLoadingPath); - _lmd.LocationOfForArchivingDirectory = Path.Combine(projDir.RootPath.FullName, _lmd.DefaultForArchivingPath); - _lmd.LocationOfExecutablesDirectory = Path.Combine(projDir.RootPath.FullName, _lmd.DefaultExecutablesPath); - _lmd.LocationOfCacheDirectory = Path.Combine(projDir.RootPath.FullName, _lmd.DefaultCachePath); + true, _lmd); _lmd.SaveToDatabase(); var pipeAssembler = new TestDataPipelineAssembler("CacheProvider_Normal", CatalogueRepository); @@ -197,11 +189,7 @@ public void CacheProvider_Normal() var projDir = LoadDirectory.CreateDirectoryStructure(new DirectoryInfo(TestContext.CurrentContext.TestDirectory), "delme", - true); - _lmd.LocationOfForLoadingDirectory = Path.Combine(projDir.RootPath.FullName, _lmd.DefaultForLoadingPath); - _lmd.LocationOfForArchivingDirectory = Path.Combine(projDir.RootPath.FullName, _lmd.DefaultForArchivingPath); - _lmd.LocationOfExecutablesDirectory = Path.Combine(projDir.RootPath.FullName, _lmd.DefaultExecutablesPath); - _lmd.LocationOfCacheDirectory = Path.Combine(projDir.RootPath.FullName, _lmd.DefaultCachePath); + true, _lmd); _lmd.SaveToDatabase(); var pipeAssembler = new TestDataPipelineAssembler("CacheProvider_Normal", CatalogueRepository); diff --git a/Rdmp.Core.Tests/DataLoad/Engine/Integration/PayloadTest.cs b/Rdmp.Core.Tests/DataLoad/Engine/Integration/PayloadTest.cs index 3792edb53b..f442288206 100644 --- a/Rdmp.Core.Tests/DataLoad/Engine/Integration/PayloadTest.cs +++ b/Rdmp.Core.Tests/DataLoad/Engine/Integration/PayloadTest.cs @@ -39,12 +39,8 @@ public void TestPayloadInjection() var lmd = new LoadMetadata(CatalogueRepository, "Loading"); var filePath = LoadDirectory - .CreateDirectoryStructure(new DirectoryInfo(TestContext.CurrentContext.TestDirectory), "delme", true) + .CreateDirectoryStructure(new DirectoryInfo(TestContext.CurrentContext.TestDirectory), "delme", true,lmd) .RootPath.FullName; - lmd.LocationOfForLoadingDirectory = Path.Combine(filePath , lmd.DefaultForLoadingPath); - lmd.LocationOfForArchivingDirectory = Path.Combine(filePath , lmd.DefaultForArchivingPath); - lmd.LocationOfExecutablesDirectory = Path.Combine(filePath , lmd.DefaultExecutablesPath); - lmd.LocationOfCacheDirectory = Path.Combine(filePath , lmd.DefaultCachePath); lmd.SaveToDatabase(); MEF.AddTypeToCatalogForTesting(typeof(TestPayloadAttacher)); diff --git a/Rdmp.Core/CommandExecution/AtomicCommands/ExecuteCommandCreateNewDataLoadDirectory.cs b/Rdmp.Core/CommandExecution/AtomicCommands/ExecuteCommandCreateNewDataLoadDirectory.cs index 9642a2356b..deb5bf4d92 100644 --- a/Rdmp.Core/CommandExecution/AtomicCommands/ExecuteCommandCreateNewDataLoadDirectory.cs +++ b/Rdmp.Core/CommandExecution/AtomicCommands/ExecuteCommandCreateNewDataLoadDirectory.cs @@ -61,16 +61,12 @@ public override void Execute() var loadDir = string.IsNullOrWhiteSpace(newFolderName) - ? LoadDirectory.CreateDirectoryStructure(d.Parent, d.Name, true) - : LoadDirectory.CreateDirectoryStructure(d, newFolderName, true); + ? LoadDirectory.CreateDirectoryStructure(d.Parent, d.Name, true, LoadMetadata) + : LoadDirectory.CreateDirectoryStructure(d, newFolderName, true, LoadMetadata); // if we have a load then update the path to this location we just created if (LoadMetadata != null) { - LoadMetadata.LocationOfForLoadingDirectory = Path.Combine(loadDir.RootPath.FullName ,LoadMetadata.DefaultForLoadingPath); - LoadMetadata.LocationOfForArchivingDirectory = Path.Combine(loadDir.RootPath.FullName, LoadMetadata.DefaultForArchivingPath); - LoadMetadata.LocationOfExecutablesDirectory = Path.Combine(loadDir.RootPath.FullName , LoadMetadata.DefaultExecutablesPath); - LoadMetadata.LocationOfCacheDirectory = Path.Combine(loadDir.RootPath.FullName , LoadMetadata.DefaultCachePath); LoadMetadata.SaveToDatabase(); Publish(LoadMetadata); } diff --git a/Rdmp.Core/Curation/LoadDirectory.cs b/Rdmp.Core/Curation/LoadDirectory.cs index 8b678e2b71..aaf5a499a9 100644 --- a/Rdmp.Core/Curation/LoadDirectory.cs +++ b/Rdmp.Core/Curation/LoadDirectory.cs @@ -4,6 +4,7 @@ // RDMP is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. // You should have received a copy of the GNU General Public License along with RDMP. If not, see . +using Rdmp.Core.Curation.Data.DataLoad; using System; using System.IO; using System.Linq; @@ -52,7 +53,7 @@ public class LoadDirectory : ILoadDirectory /// /// /// - public LoadDirectory(string rootPath, bool validate=true) + public LoadDirectory(string rootPath, bool validate = true) { if (string.IsNullOrWhiteSpace(rootPath)) throw new Exception("Root path was blank, there is no LoadDirectory path specified?"); @@ -81,7 +82,7 @@ public LoadDirectory(string ForLoadingPath, string ForArchivingPath, string Exec throw new Exception($"One if the LoadDirectory Paths was blank. ForLoading: {ForLoading}. ForArchiving: {ForArchivingPath}. Cache: {CachePath}. Extractables:{ExecutablesPath}"); ForLoading = new DirectoryInfo(ForLoadingPath); ForArchiving = new DirectoryInfo(ForArchivingPath); - ExecutablesPath =new DirectoryInfo(ExecutablesPathString); + ExecutablesPath = new DirectoryInfo(ExecutablesPathString); Cache = new DirectoryInfo(CachePath); } @@ -102,9 +103,10 @@ private DirectoryInfo FindFolderInPathOrThrow(DirectoryInfo path, string folderN /// Parent folder to create the tree in e.g. c:\temp /// Root folder name for the DLE e.g. LoadingBiochem /// Determines behaviour if the folder already exists and contains files. True to carry on, False to throw an Exception + /// Optional loadMetadata object to populate with the created locations /// public static LoadDirectory CreateDirectoryStructure(DirectoryInfo parentDir, string dirName, - bool overrideExistsCheck = false) + bool overrideExistsCheck = false, ILoadMetadata loadMetadataToPopulate = null) { if (!parentDir.Exists) parentDir.Create(); @@ -128,6 +130,13 @@ public static LoadDirectory CreateDirectoryStructure(DirectoryInfo parentDir, st swExampleFixedWidth.Close(); projectDir.CreateSubdirectory("Executables"); + if (loadMetadataToPopulate != null) + { + loadMetadataToPopulate.LocationOfForLoadingDirectory = Path.Join(dataDir.FullName, "ForLoading"); + loadMetadataToPopulate.LocationOfForArchivingDirectory = Path.Join(dataDir.FullName, "ForArchiving"); + loadMetadataToPopulate.LocationOfExecutablesDirectory = Path.Join(dataDir.FullName, "Executables"); + loadMetadataToPopulate.LocationOfCacheDirectory = Path.Join(dataDir.FullName, "Cache"); + } return new LoadDirectory(projectDir.FullName); } diff --git a/Tests.Common/Scenarios/TestsRequiringADle.cs b/Tests.Common/Scenarios/TestsRequiringADle.cs index 42522915bd..5759553313 100644 --- a/Tests.Common/Scenarios/TestsRequiringADle.cs +++ b/Tests.Common/Scenarios/TestsRequiringADle.cs @@ -48,7 +48,9 @@ protected override void SetUp() var rootFolder = new DirectoryInfo(TestContext.CurrentContext.TestDirectory); var subdir = rootFolder.CreateSubdirectory("TestsRequiringADle"); - LoadDirectory = LoadDirectory.CreateDirectoryStructure(rootFolder, subdir.FullName, true); + TestLoadMetadata = new LoadMetadata(CatalogueRepository, "Loading Test Catalogue"); + + LoadDirectory = LoadDirectory.CreateDirectoryStructure(rootFolder, subdir.FullName, true, TestLoadMetadata); Clear(LoadDirectory); @@ -63,12 +65,6 @@ protected override void SetUp() TestCatalogue = Import(LiveTable); RowsBefore = 5000; - TestLoadMetadata = new LoadMetadata(CatalogueRepository, "Loading Test Catalogue"); - TestLoadMetadata.LocationOfForLoadingDirectory = Path.Combine(LoadDirectory.RootPath.FullName, TestLoadMetadata.DefaultForLoadingPath); - TestLoadMetadata.LocationOfForArchivingDirectory = Path.Combine(LoadDirectory.RootPath.FullName, TestLoadMetadata.DefaultForArchivingPath); - TestLoadMetadata.LocationOfExecutablesDirectory = Path.Combine(LoadDirectory.RootPath.FullName, TestLoadMetadata.DefaultExecutablesPath); - TestLoadMetadata.LocationOfCacheDirectory = Path.Combine(LoadDirectory.RootPath.FullName, TestLoadMetadata.DefaultCachePath); - TestLoadMetadata.SaveToDatabase(); From f40a8fea318ebe09861957c0075c9f438715f239 Mon Sep 17 00:00:00 2001 From: James Friel Date: Thu, 4 Jul 2024 16:12:02 +0100 Subject: [PATCH 12/44] add populate function --- .../CommandLine/AutomationLoopTests/EndToEndDLETest.cs | 5 +---- .../DataLoad/Engine/Integration/HICPipelineTests.cs | 1 + .../ExecuteCommandCreateNewSplitDataLoadDirectory.cs | 6 +----- Rdmp.Core/Curation/LoadDirectory.cs | 9 +++++++++ .../ExecuteCommandChooseHICProjectDirectory.cs | 10 ++-------- 5 files changed, 14 insertions(+), 17 deletions(-) diff --git a/Rdmp.Core.Tests/CommandLine/AutomationLoopTests/EndToEndDLETest.cs b/Rdmp.Core.Tests/CommandLine/AutomationLoopTests/EndToEndDLETest.cs index 2772b7f2af..4d4bea4243 100644 --- a/Rdmp.Core.Tests/CommandLine/AutomationLoopTests/EndToEndDLETest.cs +++ b/Rdmp.Core.Tests/CommandLine/AutomationLoopTests/EndToEndDLETest.cs @@ -46,10 +46,7 @@ public void TestDle_DodgyColumnNames(DatabaseType dbType) var cata = Import(tbl); var lmd = new LoadMetadata(CatalogueRepository, nameof(TestDle_DodgyColumnNames)); - lmd.LocationOfForLoadingDirectory = Path.Combine(LoadDirectory.RootPath.FullName , lmd.DefaultForLoadingPath); - lmd.LocationOfForArchivingDirectory = Path.Combine(LoadDirectory.RootPath.FullName , lmd.DefaultForArchivingPath); - lmd.LocationOfExecutablesDirectory = Path.Combine(LoadDirectory.RootPath.FullName , lmd.DefaultExecutablesPath); - lmd.LocationOfCacheDirectory = Path.Combine(LoadDirectory.RootPath.FullName , lmd.DefaultCachePath); + LoadDirectory.PopulateLoadMetadata(lmd); lmd.SaveToDatabase(); CreateFlatFileAttacher(lmd, "Troll.csv", cata.GetTableInfoList(false).Single()); diff --git a/Rdmp.Core.Tests/DataLoad/Engine/Integration/HICPipelineTests.cs b/Rdmp.Core.Tests/DataLoad/Engine/Integration/HICPipelineTests.cs index 8d3090f788..be41fad062 100644 --- a/Rdmp.Core.Tests/DataLoad/Engine/Integration/HICPipelineTests.cs +++ b/Rdmp.Core.Tests/DataLoad/Engine/Integration/HICPipelineTests.cs @@ -27,6 +27,7 @@ using Rdmp.Core.ReusableLibraryCode.Checks; using Rdmp.Core.ReusableLibraryCode.DataAccess; using Rdmp.Core.ReusableLibraryCode.Progress; +using Terminal.Gui; using Tests.Common; namespace Rdmp.Core.Tests.DataLoad.Engine.Integration; diff --git a/Rdmp.Core/CommandExecution/AtomicCommands/ExecuteCommandCreateNewSplitDataLoadDirectory.cs b/Rdmp.Core/CommandExecution/AtomicCommands/ExecuteCommandCreateNewSplitDataLoadDirectory.cs index b2f838c735..914fa3381e 100644 --- a/Rdmp.Core/CommandExecution/AtomicCommands/ExecuteCommandCreateNewSplitDataLoadDirectory.cs +++ b/Rdmp.Core/CommandExecution/AtomicCommands/ExecuteCommandCreateNewSplitDataLoadDirectory.cs @@ -114,11 +114,7 @@ public override void Execute() // if we have a load then update the path to this location we just created if (LoadMetadata != null) { - LoadMetadata.LocationOfForLoadingDirectory = loadDir.ForLoading.FullName; - LoadMetadata.LocationOfForArchivingDirectory = loadDir.ForArchiving.FullName; - LoadMetadata.LocationOfExecutablesDirectory = loadDir.ExecutablesPath.FullName; - LoadMetadata.LocationOfCacheDirectory = loadDir.Cache.FullName; - LoadMetadata.SaveToDatabase(); + loadDir.PopulateLoadMetadata(LoadMetadata); Publish(LoadMetadata); } } diff --git a/Rdmp.Core/Curation/LoadDirectory.cs b/Rdmp.Core/Curation/LoadDirectory.cs index aaf5a499a9..6b2c6ff09d 100644 --- a/Rdmp.Core/Curation/LoadDirectory.cs +++ b/Rdmp.Core/Curation/LoadDirectory.cs @@ -140,4 +140,13 @@ public static LoadDirectory CreateDirectoryStructure(DirectoryInfo parentDir, st return new LoadDirectory(projectDir.FullName); } + + public void PopulateLoadMetadata(ILoadMetadata loadMetadata) + { + loadMetadata.LocationOfForLoadingDirectory = ForLoading.FullName; + loadMetadata.LocationOfForArchivingDirectory = ForArchiving.FullName; + loadMetadata.LocationOfExecutablesDirectory = ExecutablesPath.FullName; + loadMetadata.LocationOfCacheDirectory = Cache.FullName; + + } } \ No newline at end of file diff --git a/Rdmp.UI/CommandExecution/AtomicCommands/ExecuteCommandChooseHICProjectDirectory.cs b/Rdmp.UI/CommandExecution/AtomicCommands/ExecuteCommandChooseHICProjectDirectory.cs index e4e991b37a..1ee3c67c58 100644 --- a/Rdmp.UI/CommandExecution/AtomicCommands/ExecuteCommandChooseHICProjectDirectory.cs +++ b/Rdmp.UI/CommandExecution/AtomicCommands/ExecuteCommandChooseHICProjectDirectory.cs @@ -39,20 +39,14 @@ public override void Execute() if (dialog.ResultDirectory.RootPath != null) { //todo check these are correct & make it work with linux - _loadMetadata.LocationOfForLoadingDirectory = Path.Combine(dialog.ResultDirectory.RootPath.FullName, _loadMetadata.DefaultForLoadingPath); - _loadMetadata.LocationOfForArchivingDirectory = Path.Combine(dialog.ResultDirectory.RootPath.FullName, _loadMetadata.DefaultForArchivingPath); - _loadMetadata.LocationOfExecutablesDirectory = Path.Combine(dialog.ResultDirectory.RootPath.FullName, _loadMetadata.DefaultExecutablesPath); - _loadMetadata.LocationOfCacheDirectory = Path.Combine(dialog.ResultDirectory.RootPath.FullName, _loadMetadata.DefaultCachePath); + dialog.ResultDirectory.PopulateLoadMetadata(_loadMetadata); } else if (dialog.ResultDirectory.ForLoading != null && dialog.ResultDirectory.ForArchiving != null && dialog.ResultDirectory.ExecutablesPath != null && dialog.ResultDirectory.Cache != null) { - _loadMetadata.LocationOfForLoadingDirectory = dialog.ResultDirectory.ForLoading.FullName; - _loadMetadata.LocationOfForArchivingDirectory = dialog.ResultDirectory.ForArchiving.FullName; - _loadMetadata.LocationOfExecutablesDirectory = dialog.ResultDirectory.ExecutablesPath.FullName; - _loadMetadata.LocationOfCacheDirectory = dialog.ResultDirectory.Cache.FullName; + dialog.ResultDirectory.PopulateLoadMetadata(_loadMetadata); } _loadMetadata.SaveToDatabase(); Publish(_loadMetadata); From e443f36278b20c58b321a7d04e6d31c6b4d91cf1 Mon Sep 17 00:00:00 2001 From: James Friel Date: Thu, 4 Jul 2024 16:16:36 +0100 Subject: [PATCH 13/44] add changelog --- CHANGELOG.md | 4 ++++ SharedAssemblyInfo.cs | 6 +++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index bf80a91c2e..06df5fb7f8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [8.2.1] - Unreleased + +## Changed +- Update to LoadDirectory API to allow for population of LoadMetadatas ## [8.2.0] - Unreleased ## Changed diff --git a/SharedAssemblyInfo.cs b/SharedAssemblyInfo.cs index aa2132ac5d..dd82fe9edf 100644 --- a/SharedAssemblyInfo.cs +++ b/SharedAssemblyInfo.cs @@ -10,6 +10,6 @@ [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] -[assembly: AssemblyVersion("8.2.0")] -[assembly: AssemblyFileVersion("8.2.0")] -[assembly: AssemblyInformationalVersion("8.2.0")] +[assembly: AssemblyVersion("8.2.1")] +[assembly: AssemblyFileVersion("8.2.1")] +[assembly: AssemblyInformationalVersion("8.2.1")] From 79abfd7229f83aea01c694c8bdf14b0551c6ef61 Mon Sep 17 00:00:00 2001 From: James Friel Date: Fri, 5 Jul 2024 08:34:47 +0100 Subject: [PATCH 14/44] update tests --- .../Caching/Integration/CachingHostTests.cs | 2 +- .../Caching/Integration/CustomDateCachingTests.cs | 2 +- .../Curation/Integration/LoadProgressUnitTests.cs | 2 +- .../CrossDatabaseDataLoadTests.cs | 1 - .../Engine/Integration/DataLoadEngineTestsBase.cs | 1 + Rdmp.Core/Curation/LoadDirectory.cs | 10 +++++----- 6 files changed, 9 insertions(+), 9 deletions(-) diff --git a/Rdmp.Core.Tests/Caching/Integration/CachingHostTests.cs b/Rdmp.Core.Tests/Caching/Integration/CachingHostTests.cs index e8c53f0556..ad1662ef62 100644 --- a/Rdmp.Core.Tests/Caching/Integration/CachingHostTests.cs +++ b/Rdmp.Core.Tests/Caching/Integration/CachingHostTests.cs @@ -38,7 +38,7 @@ public void CacheHostOutwithPermissionWindow() var cp = WhenIHaveA(); var loadMetadata = cp.LoadProgress.LoadMetadata; - var loadDirectory = LoadDirectory.CreateDirectoryStructure(testDir, "Test", false, loadMetadata); + var loadDirectory = LoadDirectory.CreateDirectoryStructure(testDir, "Test", false, (LoadMetadata)loadMetadata); // This feels a bit nasty, but quick and much better than having the test wait for an arbitrary time period. var listener = new ExpectedNotificationListener("Download not permitted at this time, sleeping for 60 seconds"); diff --git a/Rdmp.Core.Tests/Caching/Integration/CustomDateCachingTests.cs b/Rdmp.Core.Tests/Caching/Integration/CustomDateCachingTests.cs index 8e4730b9b9..8a7a552684 100644 --- a/Rdmp.Core.Tests/Caching/Integration/CustomDateCachingTests.cs +++ b/Rdmp.Core.Tests/Caching/Integration/CustomDateCachingTests.cs @@ -59,7 +59,7 @@ public void FetchMultipleDays_Success(bool singleDay) var projDir = LoadDirectory.CreateDirectoryStructure(new DirectoryInfo(TestContext.CurrentContext.TestDirectory), "delme", - true, lmd); + true, (LoadMetadata)lmd); var loadProgress = Substitute.For(); loadProgress.OriginDate.Returns(new DateTime(2001, 01, 01)); diff --git a/Rdmp.Core.Tests/Curation/Integration/LoadProgressUnitTests.cs b/Rdmp.Core.Tests/Curation/Integration/LoadProgressUnitTests.cs index 7650f291a8..ca14b85ba3 100644 --- a/Rdmp.Core.Tests/Curation/Integration/LoadProgressUnitTests.cs +++ b/Rdmp.Core.Tests/Curation/Integration/LoadProgressUnitTests.cs @@ -68,7 +68,7 @@ public void LoadProgress_JobFactory_NoDates() var lmd = lp.LoadMetadata; var dir = LoadDirectory.CreateDirectoryStructure(new DirectoryInfo(TestContext.CurrentContext.WorkDirectory), - "LoadProgress_JobFactory_NoDates", true, lmd); + "LoadProgress_JobFactory_NoDates", true, (LoadMetadata)lmd); foreach (var cata in lmd.GetAllCatalogues()) { diff --git a/Rdmp.Core.Tests/DataLoad/Engine/Integration/CrossDatabaseTypeTests/CrossDatabaseDataLoadTests.cs b/Rdmp.Core.Tests/DataLoad/Engine/Integration/CrossDatabaseTypeTests/CrossDatabaseDataLoadTests.cs index 2dab13fe1c..8189a5e5fc 100644 --- a/Rdmp.Core.Tests/DataLoad/Engine/Integration/CrossDatabaseTypeTests/CrossDatabaseDataLoadTests.cs +++ b/Rdmp.Core.Tests/DataLoad/Engine/Integration/CrossDatabaseTypeTests/CrossDatabaseDataLoadTests.cs @@ -155,7 +155,6 @@ public void Load(DatabaseType databaseType, TestCase testCase) //define a new load configuration var lmd = new LoadMetadata(CatalogueRepository, "MyLoad"); - if (testCase == TestCase.NoTrigger) { lmd.IgnoreTrigger = true; diff --git a/Rdmp.Core.Tests/DataLoad/Engine/Integration/DataLoadEngineTestsBase.cs b/Rdmp.Core.Tests/DataLoad/Engine/Integration/DataLoadEngineTestsBase.cs index ef8210f040..bdada6dbc1 100644 --- a/Rdmp.Core.Tests/DataLoad/Engine/Integration/DataLoadEngineTestsBase.cs +++ b/Rdmp.Core.Tests/DataLoad/Engine/Integration/DataLoadEngineTestsBase.cs @@ -72,6 +72,7 @@ protected static LoadDirectory SetupLoadDirectory(LoadMetadata lmd) var projectDirectory = LoadDirectory.CreateDirectoryStructure(new DirectoryInfo(TestContext.CurrentContext.TestDirectory), "MyLoadDir", true,lmd); + lmd.SaveToDatabase(); return projectDirectory; diff --git a/Rdmp.Core/Curation/LoadDirectory.cs b/Rdmp.Core/Curation/LoadDirectory.cs index 6b2c6ff09d..11b32e8f89 100644 --- a/Rdmp.Core/Curation/LoadDirectory.cs +++ b/Rdmp.Core/Curation/LoadDirectory.cs @@ -106,7 +106,7 @@ private DirectoryInfo FindFolderInPathOrThrow(DirectoryInfo path, string folderN /// Optional loadMetadata object to populate with the created locations /// public static LoadDirectory CreateDirectoryStructure(DirectoryInfo parentDir, string dirName, - bool overrideExistsCheck = false, ILoadMetadata loadMetadataToPopulate = null) + bool overrideExistsCheck = false, LoadMetadata loadMetadataToPopulate = null) { if (!parentDir.Exists) parentDir.Create(); @@ -132,10 +132,10 @@ public static LoadDirectory CreateDirectoryStructure(DirectoryInfo parentDir, st projectDir.CreateSubdirectory("Executables"); if (loadMetadataToPopulate != null) { - loadMetadataToPopulate.LocationOfForLoadingDirectory = Path.Join(dataDir.FullName, "ForLoading"); - loadMetadataToPopulate.LocationOfForArchivingDirectory = Path.Join(dataDir.FullName, "ForArchiving"); - loadMetadataToPopulate.LocationOfExecutablesDirectory = Path.Join(dataDir.FullName, "Executables"); - loadMetadataToPopulate.LocationOfCacheDirectory = Path.Join(dataDir.FullName, "Cache"); + loadMetadataToPopulate.LocationOfForLoadingDirectory = Path.Combine(projectDir.FullName, loadMetadataToPopulate.DefaultForLoadingPath); + loadMetadataToPopulate.LocationOfForArchivingDirectory = Path.Combine(projectDir.FullName, loadMetadataToPopulate.DefaultForArchivingPath); + loadMetadataToPopulate.LocationOfExecutablesDirectory = Path.Combine(projectDir.FullName, loadMetadataToPopulate.DefaultExecutablesPath); + loadMetadataToPopulate.LocationOfCacheDirectory = Path.Combine(projectDir.FullName, loadMetadataToPopulate.DefaultCachePath); } return new LoadDirectory(projectDir.FullName); From 54996201917cbc4bc6b14d9b8aa924e88bcf942f Mon Sep 17 00:00:00 2001 From: James Friel Date: Fri, 5 Jul 2024 09:07:57 +0100 Subject: [PATCH 15/44] fix test --- Rdmp.Core.Tests/Caching/Integration/CustomDateCachingTests.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Rdmp.Core.Tests/Caching/Integration/CustomDateCachingTests.cs b/Rdmp.Core.Tests/Caching/Integration/CustomDateCachingTests.cs index 8a7a552684..5ff575e4ad 100644 --- a/Rdmp.Core.Tests/Caching/Integration/CustomDateCachingTests.cs +++ b/Rdmp.Core.Tests/Caching/Integration/CustomDateCachingTests.cs @@ -55,7 +55,7 @@ public void FetchMultipleDays_Success(bool singleDay) pipeline.Destination.Returns(destinationComponent); pipeline.Repository.Returns(CatalogueRepository); pipeline.PipelineComponents.Returns(Enumerable.Empty().OrderBy(o => o).ToList()); - var lmd = Substitute.For(); + var lmd = Substitute.For(); var projDir = LoadDirectory.CreateDirectoryStructure(new DirectoryInfo(TestContext.CurrentContext.TestDirectory), "delme", From fdff4048af2a0deabad153fe7b620cd5681a3ebf Mon Sep 17 00:00:00 2001 From: James Friel Date: Fri, 5 Jul 2024 10:06:54 +0100 Subject: [PATCH 16/44] attempt to fix test --- .../Caching/Integration/CustomDateCachingTests.cs | 4 ++-- Rdmp.Core/Curation/LoadDirectory.cs | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Rdmp.Core.Tests/Caching/Integration/CustomDateCachingTests.cs b/Rdmp.Core.Tests/Caching/Integration/CustomDateCachingTests.cs index 5ff575e4ad..8e4730b9b9 100644 --- a/Rdmp.Core.Tests/Caching/Integration/CustomDateCachingTests.cs +++ b/Rdmp.Core.Tests/Caching/Integration/CustomDateCachingTests.cs @@ -55,11 +55,11 @@ public void FetchMultipleDays_Success(bool singleDay) pipeline.Destination.Returns(destinationComponent); pipeline.Repository.Returns(CatalogueRepository); pipeline.PipelineComponents.Returns(Enumerable.Empty().OrderBy(o => o).ToList()); - var lmd = Substitute.For(); + var lmd = Substitute.For(); var projDir = LoadDirectory.CreateDirectoryStructure(new DirectoryInfo(TestContext.CurrentContext.TestDirectory), "delme", - true, (LoadMetadata)lmd); + true, lmd); var loadProgress = Substitute.For(); loadProgress.OriginDate.Returns(new DateTime(2001, 01, 01)); diff --git a/Rdmp.Core/Curation/LoadDirectory.cs b/Rdmp.Core/Curation/LoadDirectory.cs index 11b32e8f89..b740ca1945 100644 --- a/Rdmp.Core/Curation/LoadDirectory.cs +++ b/Rdmp.Core/Curation/LoadDirectory.cs @@ -106,7 +106,7 @@ private DirectoryInfo FindFolderInPathOrThrow(DirectoryInfo path, string folderN /// Optional loadMetadata object to populate with the created locations /// public static LoadDirectory CreateDirectoryStructure(DirectoryInfo parentDir, string dirName, - bool overrideExistsCheck = false, LoadMetadata loadMetadataToPopulate = null) + bool overrideExistsCheck = false, ILoadMetadata loadMetadataToPopulate = null) { if (!parentDir.Exists) parentDir.Create(); @@ -132,10 +132,10 @@ public static LoadDirectory CreateDirectoryStructure(DirectoryInfo parentDir, st projectDir.CreateSubdirectory("Executables"); if (loadMetadataToPopulate != null) { - loadMetadataToPopulate.LocationOfForLoadingDirectory = Path.Combine(projectDir.FullName, loadMetadataToPopulate.DefaultForLoadingPath); - loadMetadataToPopulate.LocationOfForArchivingDirectory = Path.Combine(projectDir.FullName, loadMetadataToPopulate.DefaultForArchivingPath); - loadMetadataToPopulate.LocationOfExecutablesDirectory = Path.Combine(projectDir.FullName, loadMetadataToPopulate.DefaultExecutablesPath); - loadMetadataToPopulate.LocationOfCacheDirectory = Path.Combine(projectDir.FullName, loadMetadataToPopulate.DefaultCachePath); + loadMetadataToPopulate.LocationOfForLoadingDirectory = Path.Combine(projectDir.FullName, "Data", "ForLoading"); + loadMetadataToPopulate.LocationOfForArchivingDirectory = Path.Combine(projectDir.FullName, "Data", "ForArchiving"); + loadMetadataToPopulate.LocationOfExecutablesDirectory = Path.Combine(projectDir.FullName, "Executables"); + loadMetadataToPopulate.LocationOfCacheDirectory = Path.Combine(projectDir.FullName, "Data", "Cache"); } return new LoadDirectory(projectDir.FullName); From 50ae5fb253ccb629be90a58c391816372ba5cf5c Mon Sep 17 00:00:00 2001 From: James Friel Date: Mon, 8 Jul 2024 09:55:27 +0100 Subject: [PATCH 17/44] interim --- .../LookupConfigurationUI.Designer.cs | 509 +++--------------- .../JoinsAndLookups/LookupConfigurationUI.cs | 473 +++------------- .../LookupConfigurationUI.resx | 50 +- Rdmp.UI/SimpleDialogs/SelectDialog`1.resx | 63 --- 4 files changed, 172 insertions(+), 923 deletions(-) delete mode 100644 Rdmp.UI/SimpleDialogs/SelectDialog`1.resx diff --git a/Rdmp.UI/ExtractionUIs/JoinsAndLookups/LookupConfigurationUI.Designer.cs b/Rdmp.UI/ExtractionUIs/JoinsAndLookups/LookupConfigurationUI.Designer.cs index b415a5d3b0..a1bfe07d5a 100644 --- a/Rdmp.UI/ExtractionUIs/JoinsAndLookups/LookupConfigurationUI.Designer.cs +++ b/Rdmp.UI/ExtractionUIs/JoinsAndLookups/LookupConfigurationUI.Designer.cs @@ -1,6 +1,7 @@ using BrightIdeasSoftware; using Rdmp.UI.ChecksUI; using Rdmp.UI.SimpleControls; +using System; namespace Rdmp.UI.ExtractionUIs.JoinsAndLookups { @@ -32,445 +33,89 @@ protected override void Dispose(bool disposing) /// private void InitializeComponent() { - this.label1 = new System.Windows.Forms.Label(); - this.olvExtractionInformations = new BrightIdeasSoftware.ObjectListView(); - this.olvExtractionInformationsNameColumn = ((BrightIdeasSoftware.OLVColumn)(new BrightIdeasSoftware.OLVColumn())); - this.tbCollation = new System.Windows.Forms.TextBox(); - this.label13 = new System.Windows.Forms.Label(); - this.label12 = new System.Windows.Forms.Label(); - this.olvSelectedDescriptionColumns = new BrightIdeasSoftware.ObjectListView(); - this.olvDescriptionsColumn = ((BrightIdeasSoftware.OLVColumn)(new BrightIdeasSoftware.OLVColumn())); - this.olvLookupColumns = new BrightIdeasSoftware.ObjectListView(); - this.olvLookupNameColumn = ((BrightIdeasSoftware.OLVColumn)(new BrightIdeasSoftware.OLVColumn())); - this.btnImportNewTableInfo = new System.Windows.Forms.Button(); - this.groupBox1 = new System.Windows.Forms.GroupBox(); - this.cbxLookup = new SelectIMapsDirectlyToDatabaseTableComboBox(); - this.label3 = new System.Windows.Forms.Label(); - this.label6 = new System.Windows.Forms.Label(); - this.label2 = new System.Windows.Forms.Label(); - this.pictureBox1 = new System.Windows.Forms.PictureBox(); - this.tbCatalogue = new System.Windows.Forms.TextBox(); - this.label4 = new System.Windows.Forms.Label(); - this.label7 = new System.Windows.Forms.Label(); - this.label10 = new System.Windows.Forms.Label(); - this.btnPrimaryKeyCompositeHelp = new System.Windows.Forms.Button(); - this.btnCreateLookup = new System.Windows.Forms.Button(); - this.ragSmiley1 = new RAGSmiley(); - this.fk3 = new KeyDropLocationUI(); - this.fk2 = new KeyDropLocationUI(); - this.fk1 = new KeyDropLocationUI(); - this.pk2 = new KeyDropLocationUI(); - this.pk3 = new KeyDropLocationUI(); - this.pk1 = new KeyDropLocationUI(); - this.tbFilter = new System.Windows.Forms.TextBox(); - this.label5 = new System.Windows.Forms.Label(); - ((System.ComponentModel.ISupportInitialize)(this.olvExtractionInformations)).BeginInit(); - ((System.ComponentModel.ISupportInitialize)(this.olvSelectedDescriptionColumns)).BeginInit(); - ((System.ComponentModel.ISupportInitialize)(this.olvLookupColumns)).BeginInit(); - this.groupBox1.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit(); - this.SuspendLayout(); - // - // label1 - // - this.label1.AutoSize = true; - this.label1.Location = new System.Drawing.Point(7, 354); - this.label1.Name = "label1"; - this.label1.Size = new System.Drawing.Size(143, 13); - this.label1.TabIndex = 0; - this.label1.Text = "Extractable Dataset Columns"; - // - // olvExtractionInformations - // - this.olvExtractionInformations.AllColumns.Add(this.olvExtractionInformationsNameColumn); - this.olvExtractionInformations.AllowDrop = true; - this.olvExtractionInformations.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left))); - this.olvExtractionInformations.CellEditUseWholeCell = false; - this.olvExtractionInformations.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { - this.olvExtractionInformationsNameColumn}); - this.olvExtractionInformations.Cursor = System.Windows.Forms.Cursors.Default; - this.olvExtractionInformations.Location = new System.Drawing.Point(9, 370); - this.olvExtractionInformations.Name = "olvExtractionInformations"; - this.olvExtractionInformations.Size = new System.Drawing.Size(476, 369); - this.olvExtractionInformations.TabIndex = 1; - this.olvExtractionInformations.UseCompatibleStateImageBehavior = false; - this.olvExtractionInformations.View = System.Windows.Forms.View.Details; - this.olvExtractionInformations.ItemActivate += new System.EventHandler(this.olv_ItemActivate); - // - // olvExtractionInformationsNameColumn - // - this.olvExtractionInformationsNameColumn.AspectName = "ToString"; - this.olvExtractionInformationsNameColumn.FillsFreeSpace = true; - this.olvExtractionInformationsNameColumn.Groupable = false; - this.olvExtractionInformationsNameColumn.Text = "ExtractionInformations"; - this.olvExtractionInformationsNameColumn.MinimumWidth = 100; - // - // tbCollation - // - this.tbCollation.Location = new System.Drawing.Point(661, 595); - this.tbCollation.Name = "tbCollation"; - this.tbCollation.Size = new System.Drawing.Size(229, 20); - this.tbCollation.TabIndex = 18; - // - // label13 - // - this.label13.AutoSize = true; - this.label13.Location = new System.Drawing.Point(605, 599); - this.label13.Name = "label13"; - this.label13.Size = new System.Drawing.Size(50, 13); - this.label13.TabIndex = 17; - this.label13.Text = "Collation:"; - // - // label12 - // - this.label12.AutoSize = true; - this.label12.Location = new System.Drawing.Point(605, 437); - this.label12.Name = "label12"; - this.label12.Size = new System.Drawing.Size(146, 13); - this.label12.TabIndex = 15; - this.label12.Text = "Drag in Description Column(s)"; - // - // olvSelectedDescriptionColumns - // - this.olvSelectedDescriptionColumns.AllColumns.Add(this.olvDescriptionsColumn); - this.olvSelectedDescriptionColumns.CellEditUseWholeCell = false; - this.olvSelectedDescriptionColumns.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { - this.olvDescriptionsColumn}); - this.olvSelectedDescriptionColumns.Cursor = System.Windows.Forms.Cursors.Default; - this.olvSelectedDescriptionColumns.IsSimpleDropSink = true; - this.olvSelectedDescriptionColumns.Location = new System.Drawing.Point(603, 456); - this.olvSelectedDescriptionColumns.Name = "olvSelectedDescriptionColumns"; - this.olvSelectedDescriptionColumns.Size = new System.Drawing.Size(406, 134); - this.olvSelectedDescriptionColumns.TabIndex = 14; - this.olvSelectedDescriptionColumns.UseCompatibleStateImageBehavior = false; - this.olvSelectedDescriptionColumns.View = System.Windows.Forms.View.Details; - this.olvSelectedDescriptionColumns.ModelCanDrop += new System.EventHandler(this.olvSelectedDescriptionColumns_ModelCanDrop); - this.olvSelectedDescriptionColumns.ModelDropped += new System.EventHandler(this.olvSelectedDescriptionColumns_ModelDropped); - this.olvSelectedDescriptionColumns.KeyUp += new System.Windows.Forms.KeyEventHandler(this.olvSelectedDescriptionColumns_KeyUp); - // - // olvDescriptionsColumn - // - this.olvDescriptionsColumn.AspectName = "ToString"; - this.olvDescriptionsColumn.FillsFreeSpace = true; - this.olvDescriptionsColumn.Groupable = false; - this.olvDescriptionsColumn.Text = "Description Fields"; - this.olvDescriptionsColumn.MinimumWidth = 100; - // - // olvLookupColumns - // - this.olvLookupColumns.AllColumns.Add(this.olvLookupNameColumn); - this.olvLookupColumns.AllowDrop = true; - this.olvLookupColumns.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.olvLookupColumns.CellEditUseWholeCell = false; - this.olvLookupColumns.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { - this.olvLookupNameColumn}); - this.olvLookupColumns.Cursor = System.Windows.Forms.Cursors.Default; - this.olvLookupColumns.Location = new System.Drawing.Point(6, 67); - this.olvLookupColumns.Name = "olvLookupColumns"; - this.olvLookupColumns.Size = new System.Drawing.Size(461, 148); - this.olvLookupColumns.TabIndex = 12; - this.olvLookupColumns.UseCompatibleStateImageBehavior = false; - this.olvLookupColumns.View = System.Windows.Forms.View.Details; - this.olvLookupColumns.CellRightClick += new System.EventHandler(this.olvLookupColumns_CellRightClick); - this.olvLookupColumns.ItemActivate += new System.EventHandler(this.olv_ItemActivate); - // - // olvLookupNameColumn - // - this.olvLookupNameColumn.AspectName = "ToString"; - this.olvLookupNameColumn.FillsFreeSpace = true; - this.olvLookupNameColumn.Groupable = false; - this.olvLookupNameColumn.Text = "ColumnInfos"; - this.olvLookupNameColumn.MinimumWidth = 100; - // - // btnImportNewTableInfo - // - this.btnImportNewTableInfo.Location = new System.Drawing.Point(441, 24); - this.btnImportNewTableInfo.Name = "btnImportNewTableInfo"; - this.btnImportNewTableInfo.Size = new System.Drawing.Size(26, 26); - this.btnImportNewTableInfo.TabIndex = 148; - this.btnImportNewTableInfo.UseVisualStyleBackColor = true; - this.btnImportNewTableInfo.Click += new System.EventHandler(this.btnImportNewTableInfo_Click); - // - // groupBox1 - // - this.groupBox1.Controls.Add(this.cbxLookup); - this.groupBox1.Controls.Add(this.label3); - this.groupBox1.Controls.Add(this.label6); - this.groupBox1.Controls.Add(this.label2); - this.groupBox1.Controls.Add(this.olvLookupColumns); - this.groupBox1.Controls.Add(this.btnImportNewTableInfo); - this.groupBox1.Location = new System.Drawing.Point(3, 3); - this.groupBox1.Name = "groupBox1"; - this.groupBox1.Size = new System.Drawing.Size(473, 234); - this.groupBox1.TabIndex = 149; - this.groupBox1.TabStop = false; - this.groupBox1.Text = "1.Choose Lookup Table (contains the codes and descriptions e.g. T = Tayside, F = " + - "Fife"; - // - // cbxLookup - // - this.cbxLookup.Location = new System.Drawing.Point(9, 26); - this.cbxLookup.Name = "cbxLookup"; - this.cbxLookup.SelectedItem = null; - this.cbxLookup.Size = new System.Drawing.Size(426, 24); - this.cbxLookup.TabIndex = 152; - this.cbxLookup.SelectedItemChanged += new System.EventHandler(this.cbxLookup_SelectedItemChanged); - // - // label3 - // - this.label3.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.label3.AutoSize = true; - this.label3.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Italic, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.label3.Location = new System.Drawing.Point(224, 218); - this.label3.Name = "label3"; - this.label3.Size = new System.Drawing.Size(53, 13); - this.label3.TabIndex = 151; - this.label3.Text = "(Columns)"; - // - // label6 - // - this.label6.AutoSize = true; - this.label6.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Italic, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.label6.Location = new System.Drawing.Point(435, 51); - this.label6.Name = "label6"; - this.label6.Size = new System.Drawing.Size(36, 13); - this.label6.TabIndex = 151; - this.label6.Text = "Import"; + lblTitle = new System.Windows.Forms.Label(); + label2 = new System.Windows.Forms.Label(); + cbSelectLookupTable = new System.Windows.Forms.ComboBox(); + btnAddAnotherRelation = new System.Windows.Forms.Button(); + gbAddRelation = new System.Windows.Forms.GroupBox(); + gbAddRelation.SuspendLayout(); + SuspendLayout(); + // + // lblTitle + // + lblTitle.AutoSize = true; + lblTitle.Font = new System.Drawing.Font("Segoe UI", 16F); + lblTitle.Location = new System.Drawing.Point(3, 9); + lblTitle.Name = "lblTitle"; + lblTitle.Size = new System.Drawing.Size(385, 30); + lblTitle.TabIndex = 0; + lblTitle.Text = "Create Lookup For SOME_CATALOGUE"; + lblTitle.Visible = false; // // label2 // - this.label2.AutoSize = true; - this.label2.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Italic, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.label2.Location = new System.Drawing.Point(121, 51); - this.label2.Name = "label2"; - this.label2.Size = new System.Drawing.Size(79, 13); - this.label2.TabIndex = 151; - this.label2.Text = "(Lookup Table)"; - // - // pictureBox1 - // - this.pictureBox1.Location = new System.Drawing.Point(12, 325); - this.pictureBox1.Name = "pictureBox1"; - this.pictureBox1.Size = new System.Drawing.Size(25, 25); - this.pictureBox1.TabIndex = 150; - this.pictureBox1.TabStop = false; - // - // tbCatalogue - // - this.tbCatalogue.Location = new System.Drawing.Point(43, 331); - this.tbCatalogue.Name = "tbCatalogue"; - this.tbCatalogue.ReadOnly = true; - this.tbCatalogue.Size = new System.Drawing.Size(442, 20); - this.tbCatalogue.TabIndex = 151; - // - // label4 - // - this.label4.AutoSize = true; - this.label4.Location = new System.Drawing.Point(807, 295); - this.label4.Name = "label4"; - this.label4.Size = new System.Drawing.Size(13, 13); - this.label4.TabIndex = 152; - this.label4.Text = "="; - // - // label7 - // - this.label7.AutoSize = true; - this.label7.Location = new System.Drawing.Point(807, 334); - this.label7.Name = "label7"; - this.label7.Size = new System.Drawing.Size(13, 13); - this.label7.TabIndex = 152; - this.label7.Text = "="; - // - // label10 - // - this.label10.AutoSize = true; - this.label10.Location = new System.Drawing.Point(807, 373); - this.label10.Name = "label10"; - this.label10.Size = new System.Drawing.Size(13, 13); - this.label10.TabIndex = 152; - this.label10.Text = "="; - // - // btnPrimaryKeyCompositeHelp - // - this.btnPrimaryKeyCompositeHelp.Location = new System.Drawing.Point(1058, 328); - this.btnPrimaryKeyCompositeHelp.Name = "btnPrimaryKeyCompositeHelp"; - this.btnPrimaryKeyCompositeHelp.Size = new System.Drawing.Size(26, 26); - this.btnPrimaryKeyCompositeHelp.TabIndex = 153; - this.btnPrimaryKeyCompositeHelp.UseVisualStyleBackColor = true; - this.btnPrimaryKeyCompositeHelp.Click += new System.EventHandler(this.btnPrimaryKeyCompositeHelp_Click); - // - // btnCreateLookup - // - this.btnCreateLookup.Enabled = false; - this.btnCreateLookup.Location = new System.Drawing.Point(603, 621); - this.btnCreateLookup.Name = "btnCreateLookup"; - this.btnCreateLookup.Size = new System.Drawing.Size(109, 23); - this.btnCreateLookup.TabIndex = 162; - this.btnCreateLookup.Text = "Create Lookup"; - this.btnCreateLookup.UseVisualStyleBackColor = true; - this.btnCreateLookup.Click += new System.EventHandler(this.btnCreateLookup_Click); - // - // ragSmiley1 - // - this.ragSmiley1.AlwaysShowHandCursor = false; - this.ragSmiley1.BackColor = System.Drawing.Color.Transparent; - this.ragSmiley1.Cursor = System.Windows.Forms.Cursors.Arrow; - this.ragSmiley1.Location = new System.Drawing.Point(572, 619); - this.ragSmiley1.Name = "ragSmiley1"; - this.ragSmiley1.Size = new System.Drawing.Size(25, 25); - this.ragSmiley1.TabIndex = 163; - // - // fk3 - // - this.fk3.IsValidGetter = null; - this.fk3.KeyType = JoinKeyType.PrimaryKey; - this.fk3.Location = new System.Drawing.Point(826, 369); - this.fk3.Name = "fk3"; - this.fk3.Size = new System.Drawing.Size(226, 35); - this.fk3.TabIndex = 161; - // - // fk2 - // - this.fk2.IsValidGetter = null; - this.fk2.KeyType = JoinKeyType.PrimaryKey; - this.fk2.Location = new System.Drawing.Point(826, 328); - this.fk2.Name = "fk2"; - this.fk2.Size = new System.Drawing.Size(226, 35); - this.fk2.TabIndex = 160; - // - // fk1 - // - this.fk1.IsValidGetter = null; - this.fk1.KeyType = JoinKeyType.PrimaryKey; - this.fk1.Location = new System.Drawing.Point(826, 285); - this.fk1.Name = "fk1"; - this.fk1.Size = new System.Drawing.Size(226, 35); - this.fk1.TabIndex = 159; - // - // pk2 - // - this.pk2.IsValidGetter = null; - this.pk2.KeyType = JoinKeyType.PrimaryKey; - this.pk2.Location = new System.Drawing.Point(575, 328); - this.pk2.Name = "pk2"; - this.pk2.Size = new System.Drawing.Size(226, 35); - this.pk2.TabIndex = 158; - // - // pk3 - // - this.pk3.IsValidGetter = null; - this.pk3.KeyType = JoinKeyType.PrimaryKey; - this.pk3.Location = new System.Drawing.Point(575, 369); - this.pk3.Name = "pk3"; - this.pk3.Size = new System.Drawing.Size(226, 35); - this.pk3.TabIndex = 157; - // - // pk1 - // - this.pk1.IsValidGetter = null; - this.pk1.KeyType = JoinKeyType.PrimaryKey; - this.pk1.Location = new System.Drawing.Point(575, 285); - this.pk1.Name = "pk1"; - this.pk1.Size = new System.Drawing.Size(226, 35); - this.pk1.TabIndex = 156; - // - // tbFilter - // - this.tbFilter.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.tbFilter.Location = new System.Drawing.Point(43, 745); - this.tbFilter.Name = "tbFilter"; - this.tbFilter.Size = new System.Drawing.Size(442, 20); - this.tbFilter.TabIndex = 164; - this.tbFilter.TextChanged += new System.EventHandler(this.tbFilter_TextChanged); - // - // label5 - // - this.label5.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.label5.AutoSize = true; - this.label5.Location = new System.Drawing.Point(9, 748); - this.label5.Name = "label5"; - this.label5.Size = new System.Drawing.Size(32, 13); - this.label5.TabIndex = 165; - this.label5.Text = "Filter:"; - // - // LookupConfiguration - // - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.AutoScroll = true; - this.Controls.Add(this.label5); - this.Controls.Add(this.tbFilter); - this.Controls.Add(this.ragSmiley1); - this.Controls.Add(this.btnCreateLookup); - this.Controls.Add(this.fk3); - this.Controls.Add(this.fk2); - this.Controls.Add(this.fk1); - this.Controls.Add(this.pk2); - this.Controls.Add(this.pk3); - this.Controls.Add(this.pk1); - this.Controls.Add(this.btnPrimaryKeyCompositeHelp); - this.Controls.Add(this.label10); - this.Controls.Add(this.label7); - this.Controls.Add(this.label4); - this.Controls.Add(this.tbCatalogue); - this.Controls.Add(this.pictureBox1); - this.Controls.Add(this.groupBox1); - this.Controls.Add(this.tbCollation); - this.Controls.Add(this.label13); - this.Controls.Add(this.label12); - this.Controls.Add(this.olvSelectedDescriptionColumns); - this.Controls.Add(this.olvExtractionInformations); - this.Controls.Add(this.label1); - this.Name = "LookupConfiguration"; - this.Size = new System.Drawing.Size(1103, 772); - this.Paint += new System.Windows.Forms.PaintEventHandler(this.LookupConfiguration_Paint); - ((System.ComponentModel.ISupportInitialize)(this.olvExtractionInformations)).EndInit(); - ((System.ComponentModel.ISupportInitialize)(this.olvSelectedDescriptionColumns)).EndInit(); - ((System.ComponentModel.ISupportInitialize)(this.olvLookupColumns)).EndInit(); - this.groupBox1.ResumeLayout(false); - this.groupBox1.PerformLayout(); - ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit(); - this.ResumeLayout(false); - this.PerformLayout(); - + label2.AutoSize = true; + label2.Location = new System.Drawing.Point(18, 66); + label2.Name = "label2"; + label2.Size = new System.Drawing.Size(114, 15); + label2.TabIndex = 1; + label2.Text = "Select Lookup Table:"; + label2.Click += label2_Click; + // + // cbSelectLookupTable + // + cbSelectLookupTable.Enabled = false; + cbSelectLookupTable.FormattingEnabled = true; + cbSelectLookupTable.Location = new System.Drawing.Point(138, 63); + cbSelectLookupTable.Name = "cbSelectLookupTable"; + cbSelectLookupTable.Size = new System.Drawing.Size(281, 23); + cbSelectLookupTable.TabIndex = 2; + // + // btnAddAnotherRelation + // + btnAddAnotherRelation.Enabled = false; + btnAddAnotherRelation.Location = new System.Drawing.Point(0, 22); + btnAddAnotherRelation.Name = "btnAddAnotherRelation"; + btnAddAnotherRelation.Size = new System.Drawing.Size(153, 23); + btnAddAnotherRelation.TabIndex = 4; + btnAddAnotherRelation.Text = "Add Another"; + btnAddAnotherRelation.UseVisualStyleBackColor = true; + btnAddAnotherRelation.Click += btnAddAnotherRelation_Click; + // + // gbAddRelation + // + gbAddRelation.AutoSize = true; + gbAddRelation.Controls.Add(btnAddAnotherRelation); + gbAddRelation.Location = new System.Drawing.Point(18, 139); + gbAddRelation.Name = "gbAddRelation"; + gbAddRelation.Size = new System.Drawing.Size(300, 74); + gbAddRelation.TabIndex = 5; + gbAddRelation.TabStop = false; + gbAddRelation.Text = "Add Relation:"; + // + // LookupConfigurationUI + // + AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); + AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + AutoScroll = true; + Controls.Add(gbAddRelation); + Controls.Add(cbSelectLookupTable); + Controls.Add(label2); + Controls.Add(lblTitle); + Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); + Name = "LookupConfigurationUI"; + Size = new System.Drawing.Size(1287, 891); + gbAddRelation.ResumeLayout(false); + ResumeLayout(false); + PerformLayout(); } #endregion - private System.Windows.Forms.Label label1; - private ObjectListView olvExtractionInformations; - private ObjectListView olvLookupColumns; - private ObjectListView olvSelectedDescriptionColumns; - private System.Windows.Forms.Label label12; - private System.Windows.Forms.TextBox tbCollation; - private System.Windows.Forms.Label label13; - private System.Windows.Forms.Button btnImportNewTableInfo; - private System.Windows.Forms.GroupBox groupBox1; - private System.Windows.Forms.Label label3; + private System.Windows.Forms.Label lblTitle; private System.Windows.Forms.Label label2; - private OLVColumn olvLookupNameColumn; - private System.Windows.Forms.PictureBox pictureBox1; - private System.Windows.Forms.TextBox tbCatalogue; - private OLVColumn olvExtractionInformationsNameColumn; - private System.Windows.Forms.Label label4; - private System.Windows.Forms.Label label7; - private System.Windows.Forms.Label label10; - private System.Windows.Forms.Button btnPrimaryKeyCompositeHelp; - private KeyDropLocationUI pk1; - private KeyDropLocationUI pk3; - private KeyDropLocationUI pk2; - private KeyDropLocationUI fk1; - private KeyDropLocationUI fk2; - private KeyDropLocationUI fk3; - private OLVColumn olvDescriptionsColumn; - private System.Windows.Forms.Button btnCreateLookup; - private RAGSmiley ragSmiley1; - private System.Windows.Forms.TextBox tbFilter; - private System.Windows.Forms.Label label5; - private System.Windows.Forms.Label label6; - private SelectIMapsDirectlyToDatabaseTableComboBox cbxLookup; + private System.Windows.Forms.ComboBox cbSelectLookupTable; + private System.Windows.Forms.Button btnAddAnotherRelation; + private System.Windows.Forms.GroupBox gbAddRelation; } } \ No newline at end of file diff --git a/Rdmp.UI/ExtractionUIs/JoinsAndLookups/LookupConfigurationUI.cs b/Rdmp.UI/ExtractionUIs/JoinsAndLookups/LookupConfigurationUI.cs index 094a9627d5..1bdb715e2c 100644 --- a/Rdmp.UI/ExtractionUIs/JoinsAndLookups/LookupConfigurationUI.cs +++ b/Rdmp.UI/ExtractionUIs/JoinsAndLookups/LookupConfigurationUI.cs @@ -62,452 +62,119 @@ public partial class LookupConfigurationUI : LookupConfiguration_Design { private Catalogue _catalogue; private ToolTip toolTip = new(); + private string _errorMessage = null; + private List _allExtractionInformationFromCatalogue = new(); //constructor public LookupConfigurationUI() { InitializeComponent(); - olvLookupColumns.RowHeight = 19; - olvExtractionInformations.RowHeight = 19; - olvSelectedDescriptionColumns.RowHeight = 19; - - olvLookupColumns.IsSimpleDragSource = true; - olvExtractionInformations.IsSimpleDragSource = true; - - pk1.KeyType = JoinKeyType.PrimaryKey; - pk1.SelectedColumnChanged += pk1_SelectedColumnChanged; - - pk2.KeyType = JoinKeyType.PrimaryKey; - pk2.SelectedColumnChanged += UpdateValidityAssesment; - - pk3.KeyType = JoinKeyType.PrimaryKey; - pk3.SelectedColumnChanged += UpdateValidityAssesment; - - fk1.KeyType = JoinKeyType.ForeignKey; - fk1.SelectedColumnChanged += fk1_SelectedColumnChanged; - - fk2.KeyType = JoinKeyType.ForeignKey; - fk2.SelectedColumnChanged += UpdateValidityAssesment; - - fk3.KeyType = JoinKeyType.ForeignKey; - fk3.SelectedColumnChanged += UpdateValidityAssesment; - - AssociatedCollection = RDMPCollection.Tables; - } - - private void UpdateValidityAssesment() - { - UpdateValidityAssesment(false); - } - - private void fk1_SelectedColumnChanged() - { - SetStage( - pk1.SelectedColumn == null ? LookupCreationStage.DragAForeignKey : LookupCreationStage.DragADescription); - UpdateValidityAssesment(); - } - - private void pk1_SelectedColumnChanged() - { - SetStage(pk1.SelectedColumn == null - ? LookupCreationStage.DragAPrimaryKey - : LookupCreationStage.DragAForeignKey); - UpdateValidityAssesment(); } public override void SetDatabaseObject(IActivateItems activator, Catalogue databaseObject) { base.SetDatabaseObject(activator, databaseObject); _catalogue = databaseObject; - - cbxLookup.SetItemActivator(activator); - olvLookupNameColumn.ImageGetter = o => activator.CoreIconProvider.GetImage(o).ImageToBitmap(); - olvExtractionInformationsNameColumn.ImageGetter = o => activator.CoreIconProvider.GetImage(o).ImageToBitmap(); - olvDescriptionsColumn.ImageGetter = o => activator.CoreIconProvider.GetImage(o).ImageToBitmap(); - - //add the currently configured extraction informations in the order they appear in the dataset - var allExtractionInformationFromCatalogue = - new List(_catalogue.GetAllExtractionInformation(ExtractionCategory.Any)); - allExtractionInformationFromCatalogue.Sort(); - - olvExtractionInformations.ClearObjects(); - olvExtractionInformations.AddObjects(allExtractionInformationFromCatalogue.ToArray()); - - btnImportNewTableInfo.Image = activator.CoreIconProvider.GetImage(RDMPConcept.TableInfo, OverlayKind.Import) - .ImageToBitmap(); - toolTip.SetToolTip(btnImportNewTableInfo, "Import new..."); - - btnPrimaryKeyCompositeHelp.Image = FamFamFamIcons.help.ImageToBitmap(); - - pictureBox1.Image = activator.CoreIconProvider.GetImage(RDMPConcept.Catalogue).ImageToBitmap(); - tbCatalogue.Text = databaseObject.ToString(); - - cbxLookup.SetUp(activator.CoreChildProvider.AllTableInfos); - - UpdateValidityAssesment(); - } - - public void SetLookupTableInfo(TableInfo t, bool setComboBox = true) - { - if (t is { IsTableValuedFunction: true }) + lblTitle.Text = $"Create Lookup For {_catalogue.Name}"; + lblTitle.Visible = true; + var tableInfo = activator.CoreChildProvider.AllTableInfos; + if (tableInfo.Length == 0) { - WideMessageBox.Show("Lookup table not valid", - $"Table '{t}' is a TableValuedFunction, you cannot use it as a lookup table"); + HandleError("No Table Infos Available"); return; } - - if (setComboBox) - cbxLookup.SelectedItem = t; - - olvLookupColumns.ClearObjects(); - - if (t != null) + cbSelectLookupTable.Enabled = true; + foreach (var tb in tableInfo) { - olvLookupColumns.AddObjects(t.ColumnInfos); - - SetStage(LookupCreationStage.DragAPrimaryKey); - - pk1.IsValidGetter = c => c.TableInfo_ID == t.ID; - pk2.IsValidGetter = c => c.TableInfo_ID == t.ID; - pk3.IsValidGetter = c => c.TableInfo_ID == t.ID; - - fk1.IsValidGetter = c => c.TableInfo_ID != t.ID; - fk2.IsValidGetter = c => c.TableInfo_ID != t.ID; - fk3.IsValidGetter = c => c.TableInfo_ID != t.ID; - } - else - { - SetStage(LookupCreationStage.ChooseLookupTable); + cbSelectLookupTable.Items.Add(tb); } + _allExtractionInformationFromCatalogue = + new List(_catalogue.GetAllExtractionInformation(ExtractionCategory.Any)); + _allExtractionInformationFromCatalogue.Sort(); + AddRelationOption(); } - private void btnImportNewTableInfo_Click(object sender, EventArgs e) - { - var importDialog = new ImportSQLTableUI(Activator, false); - - if (importDialog.ShowDialog() == DialogResult.OK) - if (importDialog.TableInfoCreatedIfAny != null) - cbxLookup.SelectedItem = importDialog.TableInfoCreatedIfAny; - } + private List PKRelations = new(); + private List FKRelations = new(); + private List