diff --git a/CHANGELOG.md b/CHANGELOG.md index bc64dd64fa..eeab67821a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,8 @@ 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). -## [9.2.1] - Unreleased +## [9.3.0] - Unreleased +- Update Load Metadata logging linkage to Catalogue - Update Sql Merge component to force destination column types ## [9.2.0] - 2026-03-10 diff --git a/Rdmp.Core.Tests/CommandExecution/ExecuteCommandCloneLoadMetadataTests.cs b/Rdmp.Core.Tests/CommandExecution/ExecuteCommandCloneLoadMetadataTests.cs index 1097a59ffe..599e1c5e8f 100644 --- a/Rdmp.Core.Tests/CommandExecution/ExecuteCommandCloneLoadMetadataTests.cs +++ b/Rdmp.Core.Tests/CommandExecution/ExecuteCommandCloneLoadMetadataTests.cs @@ -15,10 +15,7 @@ public void TestCloneLoadMetadata() { var lmd1 = new LoadMetadata(CatalogueRepository, "MyLmd"); lmd1.Description = "Desc!"; - var cata = new Catalogue(CatalogueRepository, "myCata") - { - LoggingDataTask = "B" - }; + var cata = new Catalogue(CatalogueRepository, "myCata"); cata.SaveToDatabase(); lmd1.LinkToCatalogue(cata); var pt1 = new ProcessTask(CatalogueRepository, lmd1, LoadStage.Mounting) diff --git a/Rdmp.Core.Tests/CommandExecution/ExecuteCommandConfirmLogsTests.cs b/Rdmp.Core.Tests/CommandExecution/ExecuteCommandConfirmLogsTests.cs index fb44d35722..fb405cd3ea 100644 --- a/Rdmp.Core.Tests/CommandExecution/ExecuteCommandConfirmLogsTests.cs +++ b/Rdmp.Core.Tests/CommandExecution/ExecuteCommandConfirmLogsTests.cs @@ -22,10 +22,7 @@ internal class ExecuteCommandConfirmLogsTests : DatabaseTests public void ConfirmLogs_NoEntries_Throws() { var lmd = new LoadMetadata(CatalogueRepository, "MyLmd"); - var cata = new Catalogue(CatalogueRepository, "myCata") - { - LoggingDataTask = "GGG" - }; + var cata = new Catalogue(CatalogueRepository, "myCata"); cata.SaveToDatabase(); lmd.LinkToCatalogue(cata); var lm = new LogManager(lmd.GetDistinctLoggingDatabase()); @@ -42,12 +39,9 @@ public void ConfirmLogs_NoEntries_Throws() public void ConfirmLogs_HappyEntries_Passes(bool withinTime) { var lmd = new LoadMetadata(CatalogueRepository, "MyLmd"); - var cata = new Catalogue(CatalogueRepository, "myCata") - { - LoggingDataTask = "FFF" - }; + var cata = new Catalogue(CatalogueRepository, "myCata"); cata.SaveToDatabase(); - lmd.LinkToCatalogue(cata); + lmd.LinkToCatalogue(cata,"FFF"); var lm = new LogManager(lmd.GetDistinctLoggingDatabase()); lm.CreateNewLoggingTaskIfNotExists("FFF"); var logEntry = lm.CreateDataLoadInfo("FFF", "pack o' cards", "going down gambling", null, true); @@ -66,12 +60,9 @@ public void ConfirmLogs_HappyEntries_Passes(bool withinTime) public void ConfirmLogs_SadEntry_BecauseNeverEnded_Throws() { var lmd = new LoadMetadata(CatalogueRepository, "MyLmd"); - var cata = new Catalogue(CatalogueRepository, "myCata") - { - LoggingDataTask = "FFF" - }; + var cata = new Catalogue(CatalogueRepository, "myCata"); cata.SaveToDatabase(); - lmd.LinkToCatalogue(cata); + lmd.LinkToCatalogue(cata,"FFF"); var lm = new LogManager(lmd.GetDistinctLoggingDatabase()); lm.CreateNewLoggingTaskIfNotExists("FFF"); @@ -88,12 +79,9 @@ public void ConfirmLogs_SadEntry_BecauseNeverEnded_Throws() public void ConfirmLogs_SadEntryWithEx_Throws() { var lmd = new LoadMetadata(CatalogueRepository, "MyLmd"); - var cata = new Catalogue(CatalogueRepository, "myCata") - { - LoggingDataTask = "FFF" - }; + var cata = new Catalogue(CatalogueRepository, "myCata"); cata.SaveToDatabase(); - lmd.LinkToCatalogue(cata); + lmd.LinkToCatalogue(cata,"FFF"); var lm = new LogManager(lmd.GetDistinctLoggingDatabase()); lm.CreateNewLoggingTaskIfNotExists("FFF"); var logEntry = lm.CreateDataLoadInfo("FFF", "pack o' cards", "going down gambling", null, true); @@ -110,12 +98,9 @@ public void ConfirmLogs_SadEntryWithEx_Throws() public void ConfirmLogs_NotWithinTime_Throws() { var lmd = new LoadMetadata(CatalogueRepository, "MyLmd"); - var cata = new Catalogue(CatalogueRepository, "myCata") - { - LoggingDataTask = "FFF" - }; + var cata = new Catalogue(CatalogueRepository, "myCata"); cata.SaveToDatabase(); - lmd.LinkToCatalogue(cata); + lmd.LinkToCatalogue(cata,"FFF"); var lm = new LogManager(lmd.GetDistinctLoggingDatabase()); lm.CreateNewLoggingTaskIfNotExists("FFF"); var logEntry = lm.CreateDataLoadInfo("FFF", "pack o' cards", "going down gambling", null, true); @@ -137,17 +122,11 @@ public void ConfirmLogs_NotWithinTime_Throws() public void ConfirmLogs_With2CacheProgress_Throws() { var lmd1 = new LoadMetadata(CatalogueRepository, "MyLmd"); - var cata = new Catalogue(CatalogueRepository, "myCata") - { - LoggingDataTask = "B" - }; + var cata = new Catalogue(CatalogueRepository, "myCata"); cata.SaveToDatabase(); lmd1.LinkToCatalogue(cata); var lmd2 = new LoadMetadata(CatalogueRepository, "MyLmd"); - var cata2 = new Catalogue(CatalogueRepository, "myCata") - { - LoggingDataTask = "A" - }; + var cata2 = new Catalogue(CatalogueRepository, "myCata"); cata2.SaveToDatabase(); var linkage2 = new LoadMetadataCatalogueLinkage(CatalogueRepository, lmd2, cata2); linkage2.SaveToDatabase(); diff --git a/Rdmp.Core.Tests/CommandExecution/ExecuteCommandCreateLoadMetadataVersionTests.cs b/Rdmp.Core.Tests/CommandExecution/ExecuteCommandCreateLoadMetadataVersionTests.cs index 7ce1e56ef9..e848b3e923 100644 --- a/Rdmp.Core.Tests/CommandExecution/ExecuteCommandCreateLoadMetadataVersionTests.cs +++ b/Rdmp.Core.Tests/CommandExecution/ExecuteCommandCreateLoadMetadataVersionTests.cs @@ -15,10 +15,7 @@ public void TestCreateLoadMetadataVersion() { var lmd1 = new LoadMetadata(CatalogueRepository, "MyLmd"); lmd1.Description = "Desc!"; - var cata = new Catalogue(CatalogueRepository, "myCata") - { - LoggingDataTask = "B" - }; + var cata = new Catalogue(CatalogueRepository, "myCata"); cata.SaveToDatabase(); lmd1.LinkToCatalogue(cata); var pt1 = new ProcessTask(CatalogueRepository, lmd1, LoadStage.Mounting) diff --git a/Rdmp.Core.Tests/CommandExecution/ExecuteCommandRestoreLoadMetadataTests.cs b/Rdmp.Core.Tests/CommandExecution/ExecuteCommandRestoreLoadMetadataTests.cs index fa5eb6ab6a..7ebccc28bf 100644 --- a/Rdmp.Core.Tests/CommandExecution/ExecuteCommandRestoreLoadMetadataTests.cs +++ b/Rdmp.Core.Tests/CommandExecution/ExecuteCommandRestoreLoadMetadataTests.cs @@ -19,7 +19,6 @@ public void TestRestoreLoadMetadataVersion() lmd1.Description = "Desc!"; var cata = new Catalogue(CatalogueRepository, "myCata") { - LoggingDataTask = "B" }; cata.SaveToDatabase(); lmd1.LinkToCatalogue(cata); diff --git a/Rdmp.Core.Tests/Curation/Integration/LoadProgressUnitTests.cs b/Rdmp.Core.Tests/Curation/Integration/LoadProgressUnitTests.cs index ca14b85ba3..9a16f8198a 100644 --- a/Rdmp.Core.Tests/Curation/Integration/LoadProgressUnitTests.cs +++ b/Rdmp.Core.Tests/Curation/Integration/LoadProgressUnitTests.cs @@ -70,12 +70,6 @@ public void LoadProgress_JobFactory_NoDates() var dir = LoadDirectory.CreateDirectoryStructure(new DirectoryInfo(TestContext.CurrentContext.WorkDirectory), "LoadProgress_JobFactory_NoDates", true, (LoadMetadata)lmd); - foreach (var cata in lmd.GetAllCatalogues()) - { - cata.LoggingDataTask = "ff"; - cata.SaveToDatabase(); - } - lmd.SaveToDatabase(); var jobFactory = new SingleScheduledJobFactory(lp, strat, 999, lp.LoadMetadata, null); diff --git a/Rdmp.Core.Tests/Curation/Integration/MetadataLoggingConfigurationChecksTests.cs b/Rdmp.Core.Tests/Curation/Integration/MetadataLoggingConfigurationChecksTests.cs index e598813681..6f12b9576e 100644 --- a/Rdmp.Core.Tests/Curation/Integration/MetadataLoggingConfigurationChecksTests.cs +++ b/Rdmp.Core.Tests/Curation/Integration/MetadataLoggingConfigurationChecksTests.cs @@ -17,39 +17,6 @@ namespace Rdmp.Core.Tests.Curation.Integration; public class MetadataLoggingConfigurationChecksTests : UnitTests { - [Test] - public void Test_NoLoggingTask() - { - var lmd = WhenIHaveA(); - var cata = WhenIHaveA(); - lmd.LinkToCatalogue(cata); - Assert.That(lmd.GetAllCatalogues().Count(), Is.EqualTo(2)); - - var checks = new MetadataLoggingConfigurationChecks(lmd); - var toMem = new ToMemoryCheckNotifier(); - checks.Check(toMem); - - AssertFailWithFix("Catalogues Mycata,Mycata do not have a logging task specified", - "Create a new Logging Task called 'MyLoad'?", toMem); - } - - [Test] - public void Test_MismatchedLoggingTask() - { - var lmd = WhenIHaveA(); - var cata1 = lmd.GetAllCatalogues().Single(); - var cata2 = WhenIHaveA(); - lmd.LinkToCatalogue(cata2); - cata1.LoggingDataTask = "OMG YEAGH"; - - Assert.That(lmd.GetAllCatalogues().Count(), Is.EqualTo(2)); - - var checks = new MetadataLoggingConfigurationChecks(lmd); - var toMem = new ToMemoryCheckNotifier(); - checks.Check(toMem); - - AssertFailWithFix("Some catalogues have NULL LoggingDataTasks", "Set task to OMG YEAGH", toMem); - } [Test] public void Test_MissingLoggingServer() @@ -58,9 +25,7 @@ public void Test_MissingLoggingServer() var cata1 = lmd.GetAllCatalogues().Single(); var cata2 = WhenIHaveA(); lmd.LinkToCatalogue(cata2); - cata1.LoggingDataTask = "OMG YEAGH"; cata1.LiveLoggingServer_ID = 2; - cata2.LoggingDataTask = "OMG YEAGH"; cata2.LiveLoggingServer_ID = null; Assert.That(lmd.GetAllCatalogues().Count(), Is.EqualTo(2)); @@ -84,9 +49,7 @@ public void Test_MissingLoggingServer_UseDefault() eds.SaveToDatabase(); lmd.LinkToCatalogue(cata2); - cata1.LoggingDataTask = "OMG YEAGH"; cata1.LiveLoggingServer_ID = null; - cata2.LoggingDataTask = "OMG YEAGH"; cata2.LiveLoggingServer_ID = null; var defaults = RepositoryLocator.CatalogueRepository; diff --git a/Rdmp.Core.Tests/Curation/UnitTestsAllObjectsSupported.cs b/Rdmp.Core.Tests/Curation/UnitTestsAllObjectsSupported.cs index 95d816bebc..c04a16a9ed 100644 --- a/Rdmp.Core.Tests/Curation/UnitTestsAllObjectsSupported.cs +++ b/Rdmp.Core.Tests/Curation/UnitTestsAllObjectsSupported.cs @@ -38,7 +38,7 @@ public void TestAllSupported() foreach (var t in types) { //ignore these types too - if (SkipTheseTypes.Contains(t.Name) || t.Name.StartsWith("Spontaneous", StringComparison.Ordinal) || + if (SkipTheseTypes.Contains(t.Name) || t.Name.EndsWith("Proxy") || t.Name.StartsWith("Spontaneous", StringComparison.Ordinal) || typeof(SpontaneousObject).IsAssignableFrom(t)) continue; diff --git a/Rdmp.Core.Tests/DataLoad/Engine/Integration/CachedFileRetrieverTests.cs b/Rdmp.Core.Tests/DataLoad/Engine/Integration/CachedFileRetrieverTests.cs index e2a9f9b7f7..3ac7bca87e 100644 --- a/Rdmp.Core.Tests/DataLoad/Engine/Integration/CachedFileRetrieverTests.cs +++ b/Rdmp.Core.Tests/DataLoad/Engine/Integration/CachedFileRetrieverTests.cs @@ -175,11 +175,15 @@ private ScheduledDataLoadJob CreateTestJob(ILoadDirectory directory) var catalogue = Substitute.For(); catalogue.GetTableInfoList(false).Returns(Array.Empty()); catalogue.GetLookupTableInfoList().Returns(Array.Empty()); - catalogue.LoggingDataTask.Returns("TestLogging"); var logManager = Substitute.For(); var loadMetadata = Substitute.For(); loadMetadata.GetAllCatalogues().Returns(new[] { catalogue }); + var link = Substitute.For(); + link.CatalogueID.Returns(catalogue.ID); + link.LoadMetadataID.Returns(loadMetadata.ID); + link.Name.Returns("Test linkage"); + catalogue.LoggingDataTasks.Returns(new List() { link }); var j = new ScheduledDataLoadJob(RepositoryLocator, "Test job", logManager, loadMetadata, directory, ThrowImmediatelyDataLoadEventListener.Quiet, null) diff --git a/Rdmp.Core.Tests/DataLoad/Engine/Integration/DataLoadChainerTests.cs b/Rdmp.Core.Tests/DataLoad/Engine/Integration/DataLoadChainerTests.cs index 31c174e057..994d2a4bda 100644 --- a/Rdmp.Core.Tests/DataLoad/Engine/Integration/DataLoadChainerTests.cs +++ b/Rdmp.Core.Tests/DataLoad/Engine/Integration/DataLoadChainerTests.cs @@ -98,9 +98,9 @@ INSERT [DLCTest] ([AdmissionDate], [DischargeDate], [Condition1], [Condition2], var loggingServer = CatalogueRepository.GetDefaultFor(PermissableDefaults.LiveLoggingServer_ID); var logManager = new LogManager(loggingServer); logManager.CreateNewLoggingTaskIfNotExists(lmd.Name); - cata.LoggingDataTask = lmd.Name; cata.SaveToDatabase(); - lmd.LinkToCatalogue(cata2); + lmd.LinkToCatalogue(cata, "MyLoad"); + lmd.LinkToCatalogue(cata2, "MyLoad"); var pc = new ProcessTask(CatalogueRepository, lmd, LoadStage.PostLoad); pc.ProcessTaskType = ProcessTaskType.DataProvider; pc.Path = "Rdmp.Core.DataLoad.Modules.DataProvider.DataLoadChainer"; @@ -126,7 +126,7 @@ INSERT [DLCTest] ([AdmissionDate], [DischargeDate], [Condition1], [Condition2], lmd2.LocationOfExecutablesDirectory = Path.GetTempPath(); lmd2.LocationOfCacheDirectory = Path.GetTempPath(); lmd2.SaveToDatabase(); - lmd2.LinkToCatalogue(cata2); + lmd2.LinkToCatalogue(cata2, "MyLoad"); pc = new ProcessTask(CatalogueRepository, lmd2, LoadStage.GetFiles); pc.ProcessTaskType = ProcessTaskType.DataProvider; pc.Path = "Rdmp.Core.DataLoad.Modules.DataProvider.DoNothingDataProvider"; diff --git a/Rdmp.Core.Tests/DataLoad/Engine/Integration/DataLoadEngineTestsBase.cs b/Rdmp.Core.Tests/DataLoad/Engine/Integration/DataLoadEngineTestsBase.cs index bdada6dbc1..c35c8a0733 100644 --- a/Rdmp.Core.Tests/DataLoad/Engine/Integration/DataLoadEngineTestsBase.cs +++ b/Rdmp.Core.Tests/DataLoad/Engine/Integration/DataLoadEngineTestsBase.cs @@ -80,7 +80,7 @@ protected static LoadDirectory SetupLoadDirectory(LoadMetadata lmd) protected ITableInfo Import(DiscoveredTable tbl, LoadMetadata lmd, LogManager logManager) { - logManager.CreateNewLoggingTaskIfNotExists(lmd.Name); + logManager.CreateNewLoggingTaskIfNotExists($"Loading {lmd.Name}({lmd.ID})"); //import TableInfos var importer = new TableInfoImporter(CatalogueRepository, tbl); @@ -90,8 +90,6 @@ protected ITableInfo Import(DiscoveredTable tbl, LoadMetadata lmd, LogManager lo var forwardEngineer = new ForwardEngineerCatalogue(ti, cis); forwardEngineer.ExecuteForwardEngineering(out var cata, out var cataItems, out var eis); - //make the catalogue use the load configuration - cata.LoggingDataTask = lmd.Name; Assert.That(cata.LiveLoggingServer_ID, Is.Not.Null); //catalogue should have one of these because of system defaults cata.SaveToDatabase(); lmd.LinkToCatalogue(cata); diff --git a/Rdmp.Core.Tests/DataLoad/Engine/Integration/DataLoadProgressUpdateInfoTests.cs b/Rdmp.Core.Tests/DataLoad/Engine/Integration/DataLoadProgressUpdateInfoTests.cs index 8bfade42a4..4643e37ce2 100644 --- a/Rdmp.Core.Tests/DataLoad/Engine/Integration/DataLoadProgressUpdateInfoTests.cs +++ b/Rdmp.Core.Tests/DataLoad/Engine/Integration/DataLoadProgressUpdateInfoTests.cs @@ -28,13 +28,17 @@ public class DataLoadProgressUpdateInfoTests : DatabaseTests public DataLoadProgressUpdateInfoTests() { var cata = Substitute.For(); - cata.LoggingDataTask.Returns("NothingTask"); + cata.GetTableInfoList(false).Returns(Array.Empty()); cata.GetLookupTableInfoList().Returns(Array.Empty()); var lmd = Substitute.For(); lmd.GetAllCatalogues().Returns(new[] { cata }); - + var link = Substitute.For(); + link.CatalogueID.Returns(cata.ID); + link.LoadMetadataID.Returns(lmd.ID); + link.Name.Returns("fish"); + cata.LoggingDataTasks.Returns(new List() { link }); _job = new ScheduledDataLoadJob(null, "fish", Substitute.For(), lmd, null, new ThrowImmediatelyDataLoadJob(), null); } diff --git a/Rdmp.Core.Tests/DataLoad/Engine/Integration/HICPipelineTests.cs b/Rdmp.Core.Tests/DataLoad/Engine/Integration/HICPipelineTests.cs index 8d3090f788..7a9aeca0a3 100644 --- a/Rdmp.Core.Tests/DataLoad/Engine/Integration/HICPipelineTests.cs +++ b/Rdmp.Core.Tests/DataLoad/Engine/Integration/HICPipelineTests.cs @@ -79,10 +79,7 @@ public void Create(CatalogueRepository repository, DiscoveredDatabase database, LoadMetadata.LocationOfCacheDirectory = Path.Combine(directory.RootPath.FullName, LoadMetadata.DefaultCachePath); LoadMetadata.SaveToDatabase(); - Catalogue = new Catalogue(repository, "HICLoadPipelineTests") - { - LoggingDataTask = "Test", - }; + Catalogue = new Catalogue(repository, "HICLoadPipelineTests"); Catalogue.SaveToDatabase(); LoadMetadata.LinkToCatalogue(Catalogue); var catalogueItem = new CatalogueItem(repository, Catalogue, "Test"); diff --git a/Rdmp.Core.Tests/DataLoad/Engine/Integration/PayloadTest.cs b/Rdmp.Core.Tests/DataLoad/Engine/Integration/PayloadTest.cs index f442288206..a42e5c6f76 100644 --- a/Rdmp.Core.Tests/DataLoad/Engine/Integration/PayloadTest.cs +++ b/Rdmp.Core.Tests/DataLoad/Engine/Integration/PayloadTest.cs @@ -45,9 +45,8 @@ public void TestPayloadInjection() MEF.AddTypeToCatalogForTesting(typeof(TestPayloadAttacher)); - b.catalogue.LoggingDataTask = "TestPayloadInjection"; b.catalogue.SaveToDatabase(); - lmd.LinkToCatalogue(b.catalogue); + lmd.LinkToCatalogue(b.catalogue, "TestPayloadInjection"); var lm = new LogManager(CatalogueRepository.GetDefaultFor(PermissableDefaults.LiveLoggingServer_ID)); lm.CreateNewLoggingTaskIfNotExists("TestPayloadInjection"); diff --git a/Rdmp.Core.Tests/DataLoad/Modules/Mutilators/RegexRedactionMutilatorTests.cs b/Rdmp.Core.Tests/DataLoad/Modules/Mutilators/RegexRedactionMutilatorTests.cs index 4ffed00465..08e8e7c3d7 100644 --- a/Rdmp.Core.Tests/DataLoad/Modules/Mutilators/RegexRedactionMutilatorTests.cs +++ b/Rdmp.Core.Tests/DataLoad/Modules/Mutilators/RegexRedactionMutilatorTests.cs @@ -65,6 +65,7 @@ public void RedactionMutilator_BasicTest() lmd.IgnoreTrigger = true; lmd.SaveToDatabase(); + var ti = Import(tbl, lmd, logManager); var projectDirectory = SetupLoadDirectory(lmd); diff --git a/Rdmp.Core.Tests/Reports/CustomMetadataReportTests.cs b/Rdmp.Core.Tests/Reports/CustomMetadataReportTests.cs index 8223b48985..fa198a357d 100644 --- a/Rdmp.Core.Tests/Reports/CustomMetadataReportTests.cs +++ b/Rdmp.Core.Tests/Reports/CustomMetadataReportTests.cs @@ -1387,7 +1387,7 @@ public void TestAllSubs_Catalogue() $IsDeprecated $IsInternalDataset $Last_revision_date -$LoggingDataTask +$LoggingDataTasks $Name $Periodicity $PivotCategory_ExtractionInformation_ID diff --git a/Rdmp.Core/CommandExecution/AtomicCommands/ExecuteCommandAssociateCatalogueWithLoadMetadata.cs b/Rdmp.Core/CommandExecution/AtomicCommands/ExecuteCommandAssociateCatalogueWithLoadMetadata.cs index 8b35a984c2..49dc441a9c 100644 --- a/Rdmp.Core/CommandExecution/AtomicCommands/ExecuteCommandAssociateCatalogueWithLoadMetadata.cs +++ b/Rdmp.Core/CommandExecution/AtomicCommands/ExecuteCommandAssociateCatalogueWithLoadMetadata.cs @@ -4,7 +4,6 @@ // 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 System.Linq; using Rdmp.Core.Curation.Data; using Rdmp.Core.Curation.Data.DataLoad; using Rdmp.Core.Icons.IconProvision; @@ -12,6 +11,8 @@ using Rdmp.Core.ReusableLibraryCode.Icons.IconProvision; using SixLabors.ImageSharp; using SixLabors.ImageSharp.PixelFormats; +using System.Linq; +using System.Threading.Tasks; namespace Rdmp.Core.CommandExecution.AtomicCommands; @@ -66,14 +67,14 @@ public override void Execute() //if there are other catalogues if (_otherCatalogues.Any()) { - var tasks = _otherCatalogues.Select(c => c.LoggingDataTask).Distinct().ToArray(); + var tasks = _otherCatalogues.SelectMany(c => c.LoggingDataTasks).Distinct().ToArray(); //if the other catalogues have an agreed logging task if (tasks.Length == 1) { var task = tasks.Single(); //and that logging task is not blank!, and differs from this Catalogue - if (!string.IsNullOrWhiteSpace(task) && !task.Equals(cata.LoggingDataTask)) + if ( !cata.LoggingDataTasks.Select(ldt => ldt.Name).Contains(task.Name)) { var liveServers = _otherCatalogues.Where(c => c.LiveLoggingServer_ID != null) .Select(c => c.LiveLoggingServer_ID).Distinct().ToArray(); @@ -81,21 +82,23 @@ public override void Execute() //AND if there is agreement on what logging server to use! if (liveServers.Length <= 1) //if there is no current logging task for the Catalogue - if (string.IsNullOrWhiteSpace(cata.LoggingDataTask) + if (!cata.LoggingDataTasks.Any() //or if the user wants to switch to the new one || YesNo( - $"Do you want to set Catalogue '{cata.Name}' to use shared logging task '{task}' instead of its current Logging Task '{cata.LoggingDataTask}' (All Catalogues in a load must share the same task and logging servers)?", + $"Do you want to set Catalogue '{cata.Name}' to use shared logging task '{task}' instead of its current Logging Task '{cata.LoggingDataTasks.FirstOrDefault()}' (All Catalogues in a load must share the same task and logging servers)?", "Synchronise Logging Tasks")) { //switch Catalogue to use that logging task (including servers) - cata.LoggingDataTask = task; + var lmdcl = new LoadMetadataCatalogueLinkage(cata.CatalogueRepository, _loadMetadata, cata,task.Name); + lmdcl.SaveToDatabase(); cata.LiveLoggingServer_ID = liveServers.SingleOrDefault(); } } } else if (tasks.Length == 0) { - cata.LoggingDataTask = $"Loading {_loadMetadata.Name}"; + var lmdcl = new LoadMetadataCatalogueLinkage(cata.CatalogueRepository, _loadMetadata, cata); + lmdcl.SaveToDatabase(); } } cata.SaveToDatabase(); diff --git a/Rdmp.Core/CommandExecution/AtomicCommands/ExecuteCommandCreateNewLoadMetadata.cs b/Rdmp.Core/CommandExecution/AtomicCommands/ExecuteCommandCreateNewLoadMetadata.cs index 17af1ccdd1..0f559e636c 100644 --- a/Rdmp.Core/CommandExecution/AtomicCommands/ExecuteCommandCreateNewLoadMetadata.cs +++ b/Rdmp.Core/CommandExecution/AtomicCommands/ExecuteCommandCreateNewLoadMetadata.cs @@ -60,8 +60,6 @@ public override void Execute() lmd.EnsureLoggingWorksFor(_catalogue); - _catalogue.SaveToDatabase(); - lmd.Folder = Folder; lmd.SaveToDatabase(); diff --git a/Rdmp.Core/Curation/Data/Catalogue.cs b/Rdmp.Core/Curation/Data/Catalogue.cs index e144c636b6..f9d538d4d0 100644 --- a/Rdmp.Core/Curation/Data/Catalogue.cs +++ b/Rdmp.Core/Curation/Data/Catalogue.cs @@ -6,6 +6,7 @@ using System; using System.Collections.Generic; +using System.ComponentModel.DataAnnotations.Schema; using System.Data.Common; using System.IO; using System.Linq; @@ -80,7 +81,6 @@ public sealed class Catalogue : DatabaseEntity, IComparable, ICatalogue, IInject private string _sourceOfDataCollection; private string _ticket; private DateTime? _datasetStartDate; - private string _loggingDataTask; private string _validatorXml; private int? _timeCoverageExtractionInformationID; private int? _pivotCategoryExtractionInformationID; @@ -444,13 +444,6 @@ public string Ticket set => SetField(ref _ticket, value); } - /// - [DoNotExtractProperty] - public string LoggingDataTask - { - get => _loggingDataTask; - set => SetField(ref _loggingDataTask, value); - } /// [DoNotExtractProperty] @@ -556,6 +549,15 @@ public DateTime? DatasetStartDate [NoMappingToDatabase] public CatalogueItem[] CatalogueItems => _knownCatalogueItems.Value; + + /// + [DoNotExtractProperty] + [NoMappingToDatabase] + public List LoggingDataTasks + { + get => Repository.GetAllObjectsWhere("CatalogueID", this.ID).Select(lmcl => (ILoadMetadataCatalogueLinkage)lmcl).ToList(); + } + /// public LoadMetadata[] LoadMetadatas() { @@ -977,8 +979,6 @@ internal Catalogue(ICatalogueRepository repository, DbDataReader r) //detailed info url with support for invalid urls Detail_Page_URL = ParseUrl(r, "Detail_Page_URL"); - LoggingDataTask = r["LoggingDataTask"] as string; - if (r["LiveLoggingServer_ID"] == DBNull.Value) LiveLoggingServer_ID = null; else diff --git a/Rdmp.Core/Curation/Data/DataLoad/ILoadMetadataCatalogueLinkage.cs b/Rdmp.Core/Curation/Data/DataLoad/ILoadMetadataCatalogueLinkage.cs index 9706648d0c..b46550619e 100644 --- a/Rdmp.Core/Curation/Data/DataLoad/ILoadMetadataCatalogueLinkage.cs +++ b/Rdmp.Core/Curation/Data/DataLoad/ILoadMetadataCatalogueLinkage.cs @@ -20,5 +20,5 @@ public interface ILoadMetadataCatalogueLinkage: IMapsDirectlyToDatabaseTable int LoadMetadataID{ get; } int CatalogueID { get; } - + string Name { get; } } diff --git a/Rdmp.Core/Curation/Data/DataLoad/LoadMetadata.cs b/Rdmp.Core/Curation/Data/DataLoad/LoadMetadata.cs index 479746a5ae..39910815de 100644 --- a/Rdmp.Core/Curation/Data/DataLoad/LoadMetadata.cs +++ b/Rdmp.Core/Curation/Data/DataLoad/LoadMetadata.cs @@ -308,9 +308,9 @@ internal LoadMetadata(ShareManager shareManager, ShareDefinition shareDefinition shareManager.UpsertAndHydrate(this, shareDefinition); } - public void LinkToCatalogue(ICatalogue catalogue) + public void LinkToCatalogue(ICatalogue catalogue,string linkageName=null) { - var linkage = new LoadMetadataCatalogueLinkage(CatalogueRepository, this, catalogue); + var linkage = new LoadMetadataCatalogueLinkage(CatalogueRepository, this, catalogue, linkageName); linkage.SaveToDatabase(); } @@ -386,32 +386,26 @@ private IDataAccessPoint[] GetLoggingServers() return !catalogue.Any() ? throw new NotSupportedException( $"LoadMetaData '{ToString()} (ID={ID}) does not have any Catalogues associated with it so it is not possible to fetch its LoggingDatabaseSettings") - : (IDataAccessPoint[])catalogue.Select(c => c.LiveLoggingServer).ToArray(); + : (IDataAccessPoint[])catalogue.Select(c => c.LiveLoggingServer).Where(lls => lls != null).ToArray(); } /// - /// Returns the unique value of amongst all catalogues loaded by the + /// Returns the unique value of amongst all catalogues loaded by the /// /// public string GetDistinctLoggingTask() { - var catalogueMetadatas = GetAllCatalogues().ToArray(); - - if (!catalogueMetadatas.Any()) - throw new Exception($"There are no Catalogues associated with load metadata (ID={ID})"); - - var cataloguesWithoutLoggingTasks = - catalogueMetadatas.Where(c => string.IsNullOrWhiteSpace(c.LoggingDataTask)).ToArray(); - - if (cataloguesWithoutLoggingTasks.Any()) - throw new Exception( - $"The following Catalogues do not have a LoggingDataTask specified:{cataloguesWithoutLoggingTasks.Aggregate("", (s, n) => $"{s}{n}(ID={n.ID}),")}"); - - var distinctLoggingTasks = catalogueMetadatas.Select(c => c.LoggingDataTask).Distinct().ToArray(); - return distinctLoggingTasks.Length >= 2 - ? throw new Exception( - $"There are {distinctLoggingTasks.Length} logging tasks in Catalogues belonging to this metadata (ID={ID})") - : distinctLoggingTasks[0]; + var tasks = Repository.GetAllObjectsWhere("LoadMetadataID", ID); + var names = tasks.Select(t => t.Name).Distinct().ToArray(); + if (!tasks.Any()) + throw new Exception($"This LoadMetadata () is not associated with any logging tasks"); + if (names.Length == 1) + { + return names[0]; + } else + { + throw new Exception($"There are {names.Length} distinct logging tasks associated with this LoadMetadata (ID={ID}) - not allowed"); + } } /// @@ -487,14 +481,14 @@ public void EnsureLoggingWorksFor(ICatalogue catalogue) } //if there's no logging task yet and there's a logging server - if (string.IsNullOrWhiteSpace(catalogue.LoggingDataTask)) + if (!catalogue.LoggingDataTasks.Any()) { var lm = new LogManager(loggingServer); var loggingTaskName = Name; lm.CreateNewLoggingTaskIfNotExists(loggingTaskName); - catalogue.LoggingDataTask = loggingTaskName; - catalogue.SaveToDatabase(); + var loadMetadataCatalogueLinkage = new LoadMetadataCatalogueLinkage(CatalogueRepository, this, catalogue); + loadMetadataCatalogueLinkage.SaveToDatabase(); } } diff --git a/Rdmp.Core/Curation/Data/DataLoad/LoadMetadataCatalogueLinkage.cs b/Rdmp.Core/Curation/Data/DataLoad/LoadMetadataCatalogueLinkage.cs index b550ac78e9..5f81ecab30 100644 --- a/Rdmp.Core/Curation/Data/DataLoad/LoadMetadataCatalogueLinkage.cs +++ b/Rdmp.Core/Curation/Data/DataLoad/LoadMetadataCatalogueLinkage.cs @@ -7,9 +7,9 @@ using Rdmp.Core.Curation.Data.ImportExport; using Rdmp.Core.Curation.Data.Serialization; using Rdmp.Core.Repositories; +using Rdmp.Core.ReusableLibraryCode.Annotations; using System.Collections.Generic; using System.Data.Common; -using System.Diagnostics.CodeAnalysis; namespace Rdmp.Core.Curation.Data.DataLoad; @@ -19,7 +19,7 @@ public class LoadMetadataCatalogueLinkage : DatabaseEntity, ILoadMetadataCatalog private int _LoadMetadataID; private int _CatalogueID; - + private string _name; [NotNull] public int LoadMetadataID @@ -35,6 +35,13 @@ public int CatalogueID set => SetField(ref _CatalogueID, value); } + [NotNull] + public string Name + { + get => _name; + set => SetField(ref _name, value); + } + public LoadMetadataCatalogueLinkage() { } /// @@ -43,12 +50,14 @@ public LoadMetadataCatalogueLinkage() { } /// /// /// - public LoadMetadataCatalogueLinkage(ICatalogueRepository repository, ILoadMetadata loadMetadata, ICatalogue catalogue) + /// + public LoadMetadataCatalogueLinkage(ICatalogueRepository repository, ILoadMetadata loadMetadata, ICatalogue catalogue,string name=null) { repository.InsertAndHydrate(this, new Dictionary { {"LoadMetadataID", loadMetadata.ID}, - {"CatalogueID", catalogue.ID } + {"CatalogueID", catalogue.ID }, + {"Name",name??$"Loading {loadMetadata.Name}({loadMetadata.ID})" } }); } @@ -57,6 +66,7 @@ internal LoadMetadataCatalogueLinkage(ICatalogueRepository repository, DbDataRea { LoadMetadataID = int.Parse(r["LoadMetadataID"].ToString()); CatalogueID = int.Parse(r["CatalogueID"].ToString()); + Name = r["Name"].ToString(); } internal LoadMetadataCatalogueLinkage(ShareManager shareManager, ShareDefinition shareDefinition) diff --git a/Rdmp.Core/Curation/Data/ICatalogue.cs b/Rdmp.Core/Curation/Data/ICatalogue.cs index 4e6632b3fe..e161574fb3 100644 --- a/Rdmp.Core/Curation/Data/ICatalogue.cs +++ b/Rdmp.Core/Curation/Data/ICatalogue.cs @@ -4,13 +4,12 @@ // 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 System; -using System.Collections.Generic; using FAnsi; using FAnsi.Discovery; using FAnsi.Discovery.QuerySyntax; using Rdmp.Core.CohortCreation.Execution; using Rdmp.Core.Curation.Data.Aggregation; +using Rdmp.Core.Curation.Data.DataLoad; using Rdmp.Core.Logging; using Rdmp.Core.MapsDirectlyToDatabaseTable; using Rdmp.Core.MapsDirectlyToDatabaseTable.Injection; @@ -19,6 +18,8 @@ using Rdmp.Core.ReusableLibraryCode; using Rdmp.Core.ReusableLibraryCode.Checks; using Rdmp.Core.ReusableLibraryCode.DataAccess; +using System; +using System.Collections.Generic; namespace Rdmp.Core.Curation.Data; @@ -44,7 +45,7 @@ public interface ICatalogue : IHasDependencies, IHasQuerySyntaxHelper, INamed, I /// Name of a task in the logging database which should be used for documenting the loading of this Catalogue. /// /// - string LoggingDataTask { get; set; } + List LoggingDataTasks { get;} /// /// The ID of the logging server that is to be used to log data loads of the dataset diff --git a/Rdmp.Core/DataLoad/Engine/Checks/Checkers/MetadataLoggingConfigurationChecks.cs b/Rdmp.Core/DataLoad/Engine/Checks/Checkers/MetadataLoggingConfigurationChecks.cs index 60df6325d0..5a3e9ed736 100644 --- a/Rdmp.Core/DataLoad/Engine/Checks/Checkers/MetadataLoggingConfigurationChecks.cs +++ b/Rdmp.Core/DataLoad/Engine/Checks/Checkers/MetadataLoggingConfigurationChecks.cs @@ -30,7 +30,7 @@ public void Check(ICheckNotifier notifier) var catalogues = _loadMetadata.GetAllCatalogues().ToArray(); //if there are no logging tasks defined on any Catalogues - if (catalogues.Any() && catalogues.All(c => string.IsNullOrWhiteSpace(c.LoggingDataTask))) + if (catalogues.Any() && catalogues.All(c => c.LoggingDataTasks.Count() ==0 )) { string proposedName; @@ -63,24 +63,8 @@ public void Check(ICheckNotifier notifier) #region Fix missing LoggingDataTask - var missingTasks = catalogues.Where(c => string.IsNullOrWhiteSpace(c.LoggingDataTask)).ToArray(); - var potentialTasks = catalogues.Except(missingTasks).Select(c => c.LoggingDataTask).Distinct().ToArray(); - - //If any Catalogues are missing tasks - if (missingTasks.Any()) - //but there is consensus for those that are not missing tasks - if (potentialTasks.Length == 1) - { - var fix = notifier.OnCheckPerformed(new CheckEventArgs("Some catalogues have NULL LoggingDataTasks", - CheckResult.Fail, null, $"Set task to {potentialTasks.Single()}")); - - if (fix) - foreach (var cata in missingTasks) - { - cata.LoggingDataTask = potentialTasks.Single(); - cata.SaveToDatabase(); - } - } + var missingTasks = catalogues.Where(c => c.LoggingDataTasks.Count() ==0).ToArray(); + var potentialTasks = catalogues.Except(missingTasks).SelectMany(c => c.LoggingDataTasks).Distinct().ToArray(); #endregion @@ -171,7 +155,7 @@ public void Check(ICheckNotifier notifier) } catch (Exception e) { - notifier.OnCheckPerformed(new CheckEventArgs("Could reach default logging server", CheckResult.Fail, e)); + notifier.OnCheckPerformed(new CheckEventArgs("Could not reach default logging server", CheckResult.Fail, e)); } } @@ -207,8 +191,8 @@ private void CreateNewLoggingTaskFor(ICheckNotifier notifier, ICatalogue[] catal foreach (var catalogue in catalogues.Cast()) { catalogue.LiveLoggingServer_ID = loggingServer.ID; - catalogue.LoggingDataTask = proposedName; - catalogue.SaveToDatabase(); + var lmdcl = new LoadMetadataCatalogueLinkage(catarepo,_loadMetadata, catalogue, proposedName); + lmdcl.SaveToDatabase(); } } } \ No newline at end of file diff --git a/Rdmp.Core/DataLoad/Engine/Job/DataLoadJob.cs b/Rdmp.Core/DataLoad/Engine/Job/DataLoadJob.cs index 844ce8a17e..751077e809 100644 --- a/Rdmp.Core/DataLoad/Engine/Job/DataLoadJob.cs +++ b/Rdmp.Core/DataLoad/Engine/Job/DataLoadJob.cs @@ -76,12 +76,12 @@ public DataLoadJob(IRDMPPlatformRepositoryServiceLocator repositoryLocator, stri private string GetLoggingTask(IEnumerable cataloguesToLoad) { - var distinctLoggingTasks = cataloguesToLoad.Select(catalogue => catalogue.LoggingDataTask).Distinct().ToList(); + var distinctLoggingTasks = cataloguesToLoad.SelectMany(catalogue => catalogue.LoggingDataTasks).DistinctBy(l => l.Name ).ToList(); if (distinctLoggingTasks.Count > 1) throw new Exception( - $"The catalogues to be loaded do not share the same logging task: {string.Join(", ", distinctLoggingTasks)}"); + $"The catalogues to be loaded do not share the same logging task: {string.Join(", ", distinctLoggingTasks.Select(l => l.Name))}"); - _loggingTask = distinctLoggingTasks.First(); + _loggingTask = distinctLoggingTasks.First().Name; return string.IsNullOrWhiteSpace(_loggingTask) ? throw new Exception("There is no logging task specified for this load (the name is blank)") : _loggingTask; diff --git a/Rdmp.Core/Databases/CatalogueDatabase/runAfterCreateDatabase/CreateCatalogue.sql b/Rdmp.Core/Databases/CatalogueDatabase/runAfterCreateDatabase/CreateCatalogue.sql index 72065b0dbb..3accbe2d26 100644 --- a/Rdmp.Core/Databases/CatalogueDatabase/runAfterCreateDatabase/CreateCatalogue.sql +++ b/Rdmp.Core/Databases/CatalogueDatabase/runAfterCreateDatabase/CreateCatalogue.sql @@ -946,6 +946,7 @@ CREATE TABLE [dbo].LoadMetadataCatalogueLinkage( [ID] [int] IDENTITY(1,1) NOT NULL, [LoadMetadataID] [int] NOT NULL, [CatalogueID] [int] NOT NULL, + [Name] [nvarchar](max) NOT NULL, FOREIGN KEY ([LoadMetadataID]) REFERENCES [dbo].[LoadMetadata](ID) ON DELETE CASCADE, FOREIGN KEY ([CatalogueID]) REFERENCES [dbo].[Catalogue](ID) ON DELETE CASCADE, CONSTRAINT [PK_LoadMetadataCatalogueLinkage] PRIMARY KEY CLUSTERED diff --git a/Rdmp.Core/Databases/CatalogueDatabase/up/093_AddLoadMetadataCatalogueLinkageName.sql b/Rdmp.Core/Databases/CatalogueDatabase/up/093_AddLoadMetadataCatalogueLinkageName.sql new file mode 100644 index 0000000000..f4c4cf138a --- /dev/null +++ b/Rdmp.Core/Databases/CatalogueDatabase/up/093_AddLoadMetadataCatalogueLinkageName.sql @@ -0,0 +1,20 @@ +--Version: 9.3.0 +--Description: Add name to load metadata catalogue linkage +if not exists (select 1 from sys.columns where name = 'Name' and OBJECT_NAME(object_id) = 'LoadMetadataCatalogueLinkage') +BEGIN +ALTER TABLE [dbo].[LoadMetadataCatalogueLinkage] +ADD +[Name] [nvarchar](max) NOT NULL DEFAULT 'Unknown Logging Task'; +END +GO + +if exists(select 1 from [dbo].[LoadMetadataCatalogueLinkage] where [Name]='Unknown Logging Task') +BEGIN + UPDATE [dbo].[LoadMetadataCatalogueLinkage] + SET [dbo].[LoadMetadataCatalogueLinkage].[Name] = [C].[LoggingDataTask] + FROM [dbo].[LoadMetadataCatalogueLinkage] [LMDCL] + INNER JOIN [dbo].[Catalogue] [C] + ON [C].[ID] = [LMDCL].[CatalogueID] + WHERE [C].[LoggingDataTask] IS NOT NULL AND [LMDCL].[Name] = 'Unknown Logging Task' +END +GO \ No newline at end of file diff --git a/Rdmp.Core/Rdmp.Core.csproj b/Rdmp.Core/Rdmp.Core.csproj index 55182ca4ad..71fa79cf63 100644 --- a/Rdmp.Core/Rdmp.Core.csproj +++ b/Rdmp.Core/Rdmp.Core.csproj @@ -256,6 +256,7 @@ + diff --git a/Rdmp.UI/CatalogueSummary/LoadEvents/LoadEventsTreeView.cs b/Rdmp.UI/CatalogueSummary/LoadEvents/LoadEventsTreeView.cs index a69c6496a2..a0f13b6a5d 100644 --- a/Rdmp.UI/CatalogueSummary/LoadEvents/LoadEventsTreeView.cs +++ b/Rdmp.UI/CatalogueSummary/LoadEvents/LoadEventsTreeView.cs @@ -82,7 +82,7 @@ public LoadEventsTreeView() _btnApplyFilter.Click += (s, e) => ApplyFilter(_tbFilterBox.Text); _tbToFetch.TextChanged += TbToFetchTextChanged; _btnFetch.Click += (s, e) => PopulateLoadHistory(); - _btnFlat.Click += (s,e) => ToggleView(); + _btnFlat.Click += (s, e) => ToggleView(); RDMPCollectionCommonFunctionality.SetupColumnTracking(treeView1, olvDescription, new Guid("6b09f39c-2b88-41ed-a396-42a2d2288952")); RDMPCollectionCommonFunctionality.SetupColumnTracking(treeView1, olvDate, @@ -218,7 +218,8 @@ private void _populateLoadHistory_RunWorkerCompleted(object sender, RunWorkerCom public void AddObjects(ArchivalDataLoadInfo[] archivalDataLoadInfos) { - if (_flatView) { + if (_flatView) + { treeView1.AddObjects(archivalDataLoadInfos.SelectMany(adli => adli.TableLoadInfos).ToList()); treeView1.AddObjects(archivalDataLoadInfos.SelectMany(adli => adli.Errors).ToList()); treeView1.AddObjects(archivalDataLoadInfos.SelectMany(adli => adli.Progress).ToList()); @@ -264,7 +265,7 @@ private void _populateLoadHistory_DoWork(object sender, DoWorkEventArgs e) private void ToggleView() { _flatView = !_flatView; - _btnFlat.Text = _flatView ?"Nested View": "Flat View"; + _btnFlat.Text = _flatView ? "Nested View" : "Flat View"; PopulateLoadHistory(); } diff --git a/Rdmp.UI/DataLoadUIs/CreateNewLoadMetadataUI.Designer.cs b/Rdmp.UI/DataLoadUIs/CreateNewLoadMetadataUI.Designer.cs deleted file mode 100644 index 6575e8ef13..0000000000 --- a/Rdmp.UI/DataLoadUIs/CreateNewLoadMetadataUI.Designer.cs +++ /dev/null @@ -1,102 +0,0 @@ -using Rdmp.UI.SimpleDialogs; - -namespace Rdmp.UI.DataLoadUIs -{ - partial class CreateNewLoadMetadataUI - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Windows Form Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - this.btnCreate = new System.Windows.Forms.Button(); - this.tbLoadMetadataNameToCreate = new System.Windows.Forms.TextBox(); - this.label3 = new System.Windows.Forms.Label(); - this.chooseLoggingTaskUI1 = new ChooseLoggingTaskUI(); - this.SuspendLayout(); - // - // btnCreate - // - this.btnCreate.Enabled = false; - this.btnCreate.Location = new System.Drawing.Point(39, 175); - this.btnCreate.Name = "btnCreate"; - this.btnCreate.Size = new System.Drawing.Size(75, 23); - this.btnCreate.TabIndex = 3; - this.btnCreate.Text = "Create"; - this.btnCreate.UseVisualStyleBackColor = true; - this.btnCreate.Click += new System.EventHandler(this.btnCreate_Click); - // - // tbLoadMetadataNameToCreate - // - this.tbLoadMetadataNameToCreate.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.tbLoadMetadataNameToCreate.Location = new System.Drawing.Point(63, 8); - this.tbLoadMetadataNameToCreate.Name = "tbLoadMetadataNameToCreate"; - this.tbLoadMetadataNameToCreate.Size = new System.Drawing.Size(1003, 20); - this.tbLoadMetadataNameToCreate.TabIndex = 2; - this.tbLoadMetadataNameToCreate.TextChanged += new System.EventHandler(this.tbLoadMetadataNameToCreate_TextChanged); - // - // label3 - // - this.label3.AutoSize = true; - this.label3.Location = new System.Drawing.Point(19, 11); - this.label3.Name = "label3"; - this.label3.Size = new System.Drawing.Size(38, 13); - this.label3.TabIndex = 1; - this.label3.Text = "Name:"; - // - // chooseLoggingTaskUI1 - // - this.chooseLoggingTaskUI1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.chooseLoggingTaskUI1.Catalogue = null; - this.chooseLoggingTaskUI1.Location = new System.Drawing.Point(22, 34); - this.chooseLoggingTaskUI1.Name = "chooseLoggingTaskUI1"; - this.chooseLoggingTaskUI1.Size = new System.Drawing.Size(1044, 144); - this.chooseLoggingTaskUI1.TabIndex = 0; - // - // CreateNewLoadMetadataUI - // - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(1078, 202); - this.Controls.Add(this.btnCreate); - this.Controls.Add(this.tbLoadMetadataNameToCreate); - this.Controls.Add(this.label3); - this.Controls.Add(this.chooseLoggingTaskUI1); - this.Name = "CreateNewLoadMetadataUI"; - this.Text = "Create New Load"; - this.ResumeLayout(false); - this.PerformLayout(); - - } - - #endregion - - private SimpleDialogs.ChooseLoggingTaskUI chooseLoggingTaskUI1; - private System.Windows.Forms.Button btnCreate; - private System.Windows.Forms.TextBox tbLoadMetadataNameToCreate; - private System.Windows.Forms.Label label3; - } -} \ No newline at end of file diff --git a/Rdmp.UI/DataLoadUIs/CreateNewLoadMetadataUI.cs b/Rdmp.UI/DataLoadUIs/CreateNewLoadMetadataUI.cs deleted file mode 100644 index 73d732c8b3..0000000000 --- a/Rdmp.UI/DataLoadUIs/CreateNewLoadMetadataUI.cs +++ /dev/null @@ -1,60 +0,0 @@ -// Copyright (c) The University of Dundee 2018-2019 -// This file is part of the Research Data Management Platform (RDMP). -// RDMP is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. -// 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 System; -using System.ComponentModel; -using System.Windows.Forms; -using Rdmp.Core.Curation.Data; -using Rdmp.Core.Curation.Data.DataLoad; -using Rdmp.UI.ItemActivation; -using Rdmp.UI.TestsAndSetup.ServicePropogation; - -namespace Rdmp.UI.DataLoadUIs; - -/// -/// There is a M-1 relationship between Catalogues (datasets) and LoadMetadata (data load recipes). This window is accessed by right clicking a Catalogue and choosing -/// to configure its LoadMetadata (how data is loaded). You can either select an existing LoadMetadata (which will probably need modifying such that it correctly loads -/// the new table in addition to what other datasets it already loaded. Or you can create a new LoadMetadata and create a load from scratch. -/// -/// Once selected you will be taken to the dataset load configuration screen (See LoadMetadataUI) -/// -/// -public partial class CreateNewLoadMetadataUI : RDMPForm -{ - private readonly Catalogue _catalogue; - - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public LoadMetadata LoadMetadataCreatedIfAny { get; set; } - - public CreateNewLoadMetadataUI(Catalogue catalogue, IActivateItems activator) : base(activator) - { - _catalogue = catalogue; - InitializeComponent(); - - chooseLoggingTaskUI1.SetItemActivator(activator); - chooseLoggingTaskUI1.Catalogue = catalogue; - } - - private void tbLoadMetadataNameToCreate_TextChanged(object sender, EventArgs e) - { - btnCreate.Enabled = !string.IsNullOrWhiteSpace(tbLoadMetadataNameToCreate.Text); - } - - private void btnCreate_Click(object sender, EventArgs e) - { - if (string.IsNullOrWhiteSpace(_catalogue.LoggingDataTask)) - { - MessageBox.Show("You must configure a logging task first"); - return; - } - - LoadMetadataCreatedIfAny = new LoadMetadata(Activator.RepositoryLocator.CatalogueRepository, - tbLoadMetadataNameToCreate.Text); - - DialogResult = DialogResult.OK; - Close(); - } -} \ No newline at end of file diff --git a/Rdmp.UI/DataLoadUIs/CreateNewLoadMetadataUI.resx b/Rdmp.UI/DataLoadUIs/CreateNewLoadMetadataUI.resx deleted file mode 100644 index 1af7de150c..0000000000 --- a/Rdmp.UI/DataLoadUIs/CreateNewLoadMetadataUI.resx +++ /dev/null @@ -1,120 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - \ No newline at end of file diff --git a/Rdmp.UI/SimpleDialogs/ChooseLoggingTaskUI.Designer.cs b/Rdmp.UI/SimpleDialogs/ChooseLoggingTaskUI.Designer.cs deleted file mode 100644 index f9f5af5e35..0000000000 --- a/Rdmp.UI/SimpleDialogs/ChooseLoggingTaskUI.Designer.cs +++ /dev/null @@ -1,195 +0,0 @@ -using Rdmp.UI.ChecksUI; - -namespace Rdmp.UI.SimpleDialogs -{ - partial class ChooseLoggingTaskUI - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Windows Form Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - this.groupBox2 = new System.Windows.Forms.GroupBox(); - this.btnClearLive = new System.Windows.Forms.Button(); - this.btnCreateNewLoggingServer = new System.Windows.Forms.Button(); - this.ragSmiley1 = new RAGSmiley(); - this.ddLoggingServer = new System.Windows.Forms.ComboBox(); - this.btnCreateNewLoggingTask = new System.Windows.Forms.Button(); - this.btnRefresh = new System.Windows.Forms.Button(); - this.label2 = new System.Windows.Forms.Label(); - this.label1 = new System.Windows.Forms.Label(); - this.cbxDataLoadTasks = new System.Windows.Forms.ComboBox(); - this.groupBox2.SuspendLayout(); - this.SuspendLayout(); - // - // groupBox2 - // - this.groupBox2.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.groupBox2.Controls.Add(this.btnClearLive); - this.groupBox2.Controls.Add(this.btnCreateNewLoggingServer); - this.groupBox2.Controls.Add(this.ragSmiley1); - this.groupBox2.Controls.Add(this.ddLoggingServer); - this.groupBox2.Controls.Add(this.btnCreateNewLoggingTask); - this.groupBox2.Controls.Add(this.btnRefresh); - this.groupBox2.Controls.Add(this.label2); - this.groupBox2.Controls.Add(this.label1); - this.groupBox2.Controls.Add(this.cbxDataLoadTasks); - this.groupBox2.Location = new System.Drawing.Point(12, 12); - this.groupBox2.Name = "groupBox2"; - this.groupBox2.Size = new System.Drawing.Size(1015, 80); - this.groupBox2.TabIndex = 1; - this.groupBox2.TabStop = false; - this.groupBox2.Text = "Logging Architecture"; - // - // btnClearLive - // - this.btnClearLive.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); - this.btnClearLive.Location = new System.Drawing.Point(786, 49); - this.btnClearLive.Name = "btnClearLive"; - this.btnClearLive.Size = new System.Drawing.Size(52, 23); - this.btnClearLive.TabIndex = 8; - this.btnClearLive.Text = "Clear"; - this.btnClearLive.UseVisualStyleBackColor = true; - this.btnClearLive.Click += new System.EventHandler(this.btnClear_Click); - // - // btnCreateNewLoggingServer - // - this.btnCreateNewLoggingServer.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); - this.btnCreateNewLoggingServer.Location = new System.Drawing.Point(841, 48); - this.btnCreateNewLoggingServer.Name = "btnCreateNewLoggingServer"; - this.btnCreateNewLoggingServer.Size = new System.Drawing.Size(168, 23); - this.btnCreateNewLoggingServer.TabIndex = 7; - this.btnCreateNewLoggingServer.Text = "Create New Logging Server..."; - this.btnCreateNewLoggingServer.UseVisualStyleBackColor = true; - this.btnCreateNewLoggingServer.Click += new System.EventHandler(this.btnCreateNewLoggingServer_Click); - // - // ragSmiley1 - // - this.ragSmiley1.AlwaysShowHandCursor = false; - this.ragSmiley1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); - this.ragSmiley1.BackColor = System.Drawing.Color.Transparent; - this.ragSmiley1.Cursor = System.Windows.Forms.Cursors.Arrow; - this.ragSmiley1.Location = new System.Drawing.Point(962, 11); - this.ragSmiley1.Name = "ragSmiley1"; - this.ragSmiley1.Size = new System.Drawing.Size(37, 38); - this.ragSmiley1.TabIndex = 6; - // - // ddLoggingServer - // - this.ddLoggingServer.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.ddLoggingServer.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; - this.ddLoggingServer.FormattingEnabled = true; - this.ddLoggingServer.Location = new System.Drawing.Point(118, 50); - this.ddLoggingServer.Name = "ddLoggingServer"; - this.ddLoggingServer.Size = new System.Drawing.Size(664, 21); - this.ddLoggingServer.TabIndex = 5; - this.ddLoggingServer.SelectedIndexChanged += new System.EventHandler(this.ddLoggingServer_SelectedIndexChanged); - // - // btnCreateNewLoggingTask - // - this.btnCreateNewLoggingTask.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); - this.btnCreateNewLoggingTask.Location = new System.Drawing.Point(869, 21); - this.btnCreateNewLoggingTask.Name = "btnCreateNewLoggingTask"; - this.btnCreateNewLoggingTask.Size = new System.Drawing.Size(75, 23); - this.btnCreateNewLoggingTask.TabIndex = 4; - this.btnCreateNewLoggingTask.Text = "Create"; - this.btnCreateNewLoggingTask.UseVisualStyleBackColor = true; - this.btnCreateNewLoggingTask.Click += new System.EventHandler(this.btnCreateNewLoggingTask_Click); - // - // btnRefresh - // - this.btnRefresh.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); - this.btnRefresh.Location = new System.Drawing.Point(788, 21); - this.btnRefresh.Name = "btnRefresh"; - this.btnRefresh.Size = new System.Drawing.Size(75, 23); - this.btnRefresh.TabIndex = 4; - this.btnRefresh.Text = "Refresh"; - this.btnRefresh.UseVisualStyleBackColor = true; - this.btnRefresh.Click += new System.EventHandler(this.btnRefresh_Click); - // - // label2 - // - this.label2.AutoSize = true; - this.label2.Location = new System.Drawing.Point(6, 53); - this.label2.Name = "label2"; - this.label2.Size = new System.Drawing.Size(82, 13); - this.label2.TabIndex = 1; - this.label2.Text = "Logging Server:"; - this.label2.Click += new System.EventHandler(this.label1_Click); - // - // label1 - // - this.label1.AutoSize = true; - this.label1.Location = new System.Drawing.Point(7, 26); - this.label1.Name = "label1"; - this.label1.Size = new System.Drawing.Size(81, 13); - this.label1.TabIndex = 1; - this.label1.Text = "DataLoadTask:"; - this.label1.Click += new System.EventHandler(this.label1_Click); - // - // cbxDataLoadTasks - // - this.cbxDataLoadTasks.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.cbxDataLoadTasks.AutoCompleteMode = System.Windows.Forms.AutoCompleteMode.Suggest; - this.cbxDataLoadTasks.AutoCompleteSource = System.Windows.Forms.AutoCompleteSource.ListItems; - this.cbxDataLoadTasks.FormattingEnabled = true; - this.cbxDataLoadTasks.Location = new System.Drawing.Point(94, 23); - this.cbxDataLoadTasks.Name = "cbxDataLoadTasks"; - this.cbxDataLoadTasks.Size = new System.Drawing.Size(688, 21); - this.cbxDataLoadTasks.TabIndex = 0; - this.cbxDataLoadTasks.SelectedIndexChanged += new System.EventHandler(this.cbxDataLoadTasks_SelectedIndexChanged); - this.cbxDataLoadTasks.TextChanged += new System.EventHandler(this.cbxDataLoadTasks_TextChanged); - this.cbxDataLoadTasks.KeyUp += new System.Windows.Forms.KeyEventHandler(this.cbxDataLoadTasks_KeyUp); - this.cbxDataLoadTasks.Leave += new System.EventHandler(this.cbxDataLoadTasks_Leave); - // - // ChooseLoggingTaskUI - // - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.Controls.Add(this.groupBox2); - this.Name = "ChooseLoggingTaskUI"; - this.Size = new System.Drawing.Size(1039, 99); - this.groupBox2.ResumeLayout(false); - this.groupBox2.PerformLayout(); - this.ResumeLayout(false); - - } - - #endregion - - private System.Windows.Forms.GroupBox groupBox2; - private System.Windows.Forms.Label label1; - private System.Windows.Forms.ComboBox cbxDataLoadTasks; - private System.Windows.Forms.Button btnRefresh; - private System.Windows.Forms.ComboBox ddLoggingServer; - private System.Windows.Forms.Label label2; - private System.Windows.Forms.Button btnCreateNewLoggingTask; - private RAGSmiley ragSmiley1; - private System.Windows.Forms.Button btnCreateNewLoggingServer; - private System.Windows.Forms.Button btnClearLive; - } -} \ No newline at end of file diff --git a/Rdmp.UI/SimpleDialogs/ChooseLoggingTaskUI.cs b/Rdmp.UI/SimpleDialogs/ChooseLoggingTaskUI.cs deleted file mode 100644 index cad0b16577..0000000000 --- a/Rdmp.UI/SimpleDialogs/ChooseLoggingTaskUI.cs +++ /dev/null @@ -1,265 +0,0 @@ -// Copyright (c) The University of Dundee 2018-2019 -// This file is part of the Research Data Management Platform (RDMP). -// RDMP is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. -// 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 System; -using System.ComponentModel; -using System.Linq; -using System.Windows.Forms; -using Rdmp.Core.Curation.Data; -using Rdmp.Core.Curation.Data.Defaults; -using Rdmp.Core.Databases; -using Rdmp.Core.Logging; -using Rdmp.Core.ReusableLibraryCode.Checks; -using Rdmp.Core.ReusableLibraryCode.DataAccess; -using Rdmp.UI.ChecksUI; -using Rdmp.UI.TestsAndSetup.ServicePropogation; -using Rdmp.UI.Versioning; - -namespace Rdmp.UI.SimpleDialogs; - -/// -/// Every dataset (Catalogue) can have its own Logging task and Logging server. If you have multiple logging servers (e.g. a test logging server and a live logging server). You -/// can configure each of these independently. If you only have one logging server then just set the live logging server. -/// -/// Once you have set the logging server you should create or select an existing task (e.g. 'Loading Biochemistry' might be a good logging task for Biochemistry dataset). All datasets -/// in a given load (see LoadMetadataUI) must share the same logging task so it is worth considering the naming for example you might call the task 'Loading Hospital Data' and another -/// 'Loading Primary Care Data'. -/// -/// Data Extraction always gets logged under a task called 'Data Extraction' but the server you select here will be the one that it is logged against when the dataset is extracted. -/// -/// You can configure defaults for the logging servers of new datasets through ManageExternalServers dialog (See ManageExternalServers) -/// -public partial class ChooseLoggingTaskUI : RDMPUserControl, ICheckNotifier -{ - private Catalogue _catalogue; - private string expectedDatabaseTypeString = "HIC.Logging.Database"; - - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public Catalogue Catalogue - { - get => _catalogue; - set - { - _catalogue = value; - RefreshUIFromDatabase(); - } - } - - private void RefreshUIFromDatabase() - { - if (_catalogue == null) - return; - - var servers = Activator.RepositoryLocator.CatalogueRepository.GetAllObjects() - .Where(s => string.Equals(expectedDatabaseTypeString, s.CreatedByAssembly)).ToArray(); - - ddLoggingServer.Items.Clear(); - ddLoggingServer.Items.AddRange(servers); - - ExternalDatabaseServer liveserver = null; - - if (_catalogue.LiveLoggingServer_ID != null) - { - liveserver = ddLoggingServer.Items.Cast() - .SingleOrDefault(i => i.ID == (int)_catalogue.LiveLoggingServer_ID); - ddLoggingServer.SelectedItem = liveserver ?? throw new Exception( - $"Catalogue '{_catalogue}' lists its Live Logging Server as '{_catalogue.LiveLoggingServer}' did not appear in combo box, possibly it is not marked as a '{expectedDatabaseTypeString}' server? Try editing it in Locations=>Manage External Servers"); - } - - try - { - //load data tasks (new architecture) - //if the catalogue knows its logging server - populate values - if (liveserver != null) - { - var lm = new LogManager(liveserver); - - foreach (var t in lm.ListDataTasks()) - if (!cbxDataLoadTasks.Items.Contains(t)) - cbxDataLoadTasks.Items.Add(t); - } - } - catch (Exception ex) - { - MessageBox.Show($"Problem getting the list of DataTasks from the new logging architecture:{ex.Message}"); - } - - if (!string.IsNullOrWhiteSpace(_catalogue.LoggingDataTask)) - cbxDataLoadTasks.Text = _catalogue.LoggingDataTask; - - CheckNameExists(); - } - - public ChooseLoggingTaskUI() - { - InitializeComponent(); - } - - protected override void OnLoad(EventArgs e) - { - base.OnLoad(e); - - if (Activator == null) - return; - - RefreshUIFromDatabase(); - } - - private void btnRefresh_Click(object sender, EventArgs e) - { - RefreshTasks(); - } - - private void RefreshTasks() - { - var liveserver = ddLoggingServer.SelectedItem as ExternalDatabaseServer; - var server = DataAccessPortal.ExpectServer(liveserver, DataAccessContext.Logging); - - if (liveserver != null) - { - cbxDataLoadTasks.Items.Clear(); - - try - { - var lm = new LogManager(server); - cbxDataLoadTasks.Items.AddRange(lm.ListDataTasks()); - } - catch (Exception e) - { - ExceptionViewer.Show(e); - } - } - } - - - private void cbxDataLoadTasks_SelectedIndexChanged(object sender, EventArgs e) - { - _catalogue.LoggingDataTask = (string)cbxDataLoadTasks.SelectedItem; - _catalogue.SaveToDatabase(); - } - - private void label1_Click(object sender, EventArgs e) - { - } - - private void ddLoggingServer_SelectedIndexChanged(object sender, EventArgs e) - { - if (ddLoggingServer.SelectedItem == null) - { - _catalogue.LiveLoggingServer_ID = null; - _catalogue.SaveToDatabase(); - return; - } - - _catalogue.LiveLoggingServer_ID = ((ExternalDatabaseServer)ddLoggingServer.SelectedItem).ID; - _catalogue.SaveToDatabase(); - RefreshTasks(); - } - - private void cbxDataLoadTasks_TextChanged(object sender, EventArgs e) - { - if (_catalogue == null) - return; - - _catalogue.LoggingDataTask = cbxDataLoadTasks.Text; - _catalogue.SaveToDatabase(); - } - - private void btnCreateNewLoggingTask_Click(object sender, EventArgs e) - { - try - { - var liveServer = ddLoggingServer.SelectedItem as ExternalDatabaseServer; - - var target = ""; - - var toCreate = cbxDataLoadTasks.Text; - - if (liveServer != null) - target = $"{liveServer.Server}.{liveServer.Database}"; - - if (string.IsNullOrEmpty(target)) - { - MessageBox.Show("You must select a logging server"); - return; - } - - if (Activator.YesNo($"Create a new dataset and new data task called \"{toCreate}\" in {target}", - "Create new logging task")) - { - if (liveServer != null) - { - var checker = new LoggingDatabaseChecker(liveServer); - checker.Check(this); - - new LogManager(liveServer) - .CreateNewLoggingTaskIfNotExists(toCreate); - } - - MessageBox.Show("Done"); - - RefreshTasks(); - } - - RefreshUIFromDatabase(); - } - catch (Exception exception) - { - ExceptionViewer.Show(exception); - } - } - - public bool OnCheckPerformed(CheckEventArgs args) - { - if (args.ProposedFix != null) - return MakeChangePopup.ShowYesNoMessageBoxToApplyFix(null, args.Message, args.ProposedFix); - //if it is successful user doesn't need to be spammed with messages - if (args.Result == CheckResult.Success) - return true; - - //its a warning or an error possibly with an exception attached - if (args.Ex != null) - ExceptionViewer.Show(args.Message, args.Ex); - else - MessageBox.Show(args.Message); - - return false; - } - - private void cbxDataLoadTasks_Leave(object sender, EventArgs e) - { - CheckNameExists(); - } - - private void cbxDataLoadTasks_KeyUp(object sender, KeyEventArgs e) - { - CheckNameExists(); - } - - private void CheckNameExists() - { - ragSmiley1.Reset(); - - if (string.IsNullOrWhiteSpace(cbxDataLoadTasks.Text)) - ragSmiley1.Warning(new Exception("You must provide a Data Task name e.g. 'Loading my cool dataset'")); - else if (!cbxDataLoadTasks.Items.Contains(cbxDataLoadTasks.Text)) - ragSmiley1.Fatal(new Exception( - $"Task '{cbxDataLoadTasks.Text}' does not exist yet, select 'Create' to create it")); - } - - private void btnCreateNewLoggingServer_Click(object sender, EventArgs e) - { - CreatePlatformDatabase.CreateNewExternalServer(Activator.RepositoryLocator.CatalogueRepository, - PermissableDefaults.LiveLoggingServer_ID, new LoggingDatabasePatcher()); - RefreshUIFromDatabase(); - } - - private void btnClear_Click(object sender, EventArgs e) - { - if (sender == btnClearLive) - ddLoggingServer.SelectedItem = null; - } -} \ No newline at end of file diff --git a/Rdmp.UI/SimpleDialogs/ChooseLoggingTaskUI.resx b/Rdmp.UI/SimpleDialogs/ChooseLoggingTaskUI.resx deleted file mode 100644 index 1af7de150c..0000000000 --- a/Rdmp.UI/SimpleDialogs/ChooseLoggingTaskUI.resx +++ /dev/null @@ -1,120 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - \ No newline at end of file diff --git a/SharedAssemblyInfo.cs b/SharedAssemblyInfo.cs index c997379eca..134927da2f 100644 --- a/SharedAssemblyInfo.cs +++ b/SharedAssemblyInfo.cs @@ -10,6 +10,7 @@ [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] -[assembly: AssemblyVersion("9.2.1")] -[assembly: AssemblyFileVersion("9.2.1")] -[assembly: AssemblyInformationalVersion("9.2.1")] +[assembly: AssemblyVersion("9.3.0")] +[assembly: AssemblyFileVersion("9.3.0")] +[assembly: AssemblyInformationalVersion("9.3.0")] + diff --git a/Tests.Common/RdmpMockFactory.cs b/Tests.Common/RdmpMockFactory.cs index f0a862c951..5c698d4053 100644 --- a/Tests.Common/RdmpMockFactory.cs +++ b/Tests.Common/RdmpMockFactory.cs @@ -10,6 +10,7 @@ using Rdmp.Core.Curation.Data.DataLoad; using Rdmp.Core.Curation.Data.EntityNaming; using Rdmp.Core.ReusableLibraryCode.DataAccess; +using System.Collections.Generic; namespace Tests.Common; @@ -61,9 +62,12 @@ public static ILoadMetadata Mock_LoadMetadataLoadingTable(ITableInfo tableInfo) lmd.GetDistinctLiveDatabaseServer().Returns(server); lmd.GetAllCatalogues().Returns(new[] { cata }); lmd.GetDistinctLoggingTask().Returns(TestLoggingTask); - + var link = Substitute.For(); + link.CatalogueID.Returns(cata.ID); + link.LoadMetadataID.Returns(lmd.ID); + link.Name = TestLoggingTask; + cata.LoggingDataTasks.Returns(new List() { link}); cata.GetTableInfoList(Arg.Any()).Returns(new[] { tableInfo }); - cata.LoggingDataTask.Returns(TestLoggingTask); return lmd; } diff --git a/Tests.Common/UnitTests.cs b/Tests.Common/UnitTests.cs index 9569870268..d75b6919cb 100644 --- a/Tests.Common/UnitTests.cs +++ b/Tests.Common/UnitTests.cs @@ -609,7 +609,6 @@ public static T WhenIHaveA(MemoryDataExportRepository repository) where T : D return (T)(object)new ExtractableDataSetProject(repository, WhenIHaveA(repository), WhenIHaveA(repository)); } - throw new TestCaseNotWrittenYetException(typeof(T)); }