Exemplo n.º 1
0
        /// <summary>
        /// Tests that the logging database for the load is reachable and that it has an appropriate logging task for the load (if not a new task will be created 'Loading X')
        /// </summary>
        /// <param name="catalogue"></param>
        public void EnsureLoggingWorksFor(ICatalogue catalogue)
        {
            //if there's no logging task / logging server set them up with the same name as the lmd
            IExternalDatabaseServer loggingServer;

            if (catalogue.LiveLoggingServer_ID == null)
            {
                loggingServer = CatalogueRepository.GetServerDefaults().GetDefaultFor(PermissableDefaults.LiveLoggingServer_ID);

                if (loggingServer != null)
                {
                    catalogue.LiveLoggingServer_ID = loggingServer.ID;
                }
                else
                {
                    throw new NotSupportedException("You do not yet have any logging servers configured so cannot create data loads");
                }
            }
            else
            {
                loggingServer = Repository.GetObjectByID <ExternalDatabaseServer>(catalogue.LiveLoggingServer_ID.Value);
            }

            //if there's no logging task yet and there's a logging server
            if (string.IsNullOrWhiteSpace(catalogue.LoggingDataTask))
            {
                var lm = new LogManager(loggingServer);
                var loggingTaskName = Name;

                lm.CreateNewLoggingTaskIfNotExists(loggingTaskName);
                catalogue.LoggingDataTask = loggingTaskName;
                catalogue.SaveToDatabase();
            }
        }
Exemplo n.º 2
0
        private void ThreeTableSetupWhereTimePeriodIsGrandparent()
        {
            CreateTables("Headers", "ID int NOT NULL, HeaderDate DATETIME, Discipline varchar(32)", "ID");
            CreateTables("Samples", "ID int NOT NULL, HeaderID int NOT NULL, SampleType varchar(32)", "ID", "CONSTRAINT [FK_Headers_Samples] FOREIGN KEY (HeaderID) REFERENCES Headers (ID)");
            CreateTables("Results", "ID int NOT NULL, SampleID int NOT NULL, Result int", "ID", "CONSTRAINT [FK_Samples_Results] FOREIGN KEY (SampleID) REFERENCES Samples (ID)");

            // Set SetUp catalogue entities
            ColumnInfo[] ciHeaders;
            ColumnInfo[] ciSamples;
            ColumnInfo[] ciResults;

            var tiHeaders = AddTableToCatalogue(DatabaseName, "Headers", "ID", out ciHeaders, true);

            AddTableToCatalogue(DatabaseName, "Samples", "ID", out ciSamples);
            AddTableToCatalogue(DatabaseName, "Results", "ID", out ciResults);

            _catalogue.Time_coverage = "[Headers].[HeaderDate]";
            _catalogue.SaveToDatabase();

            tiHeaders.IsPrimaryExtractionTable = true;
            tiHeaders.SaveToDatabase();

            Assert.AreEqual(15, _catalogue.CatalogueItems.Count(), "Unexpected number of items in catalogue");

            // Headers (1:M) Samples join
            new JoinInfo(CatalogueRepository, ciSamples.Single(ci => ci.GetRuntimeName().Equals("HeaderID")),
                         ciHeaders.Single(ci => ci.GetRuntimeName().Equals("ID")),
                         ExtractionJoinType.Left, "");

            // Samples (1:M) Results join
            new JoinInfo(CatalogueRepository, ciResults.Single(info => info.GetRuntimeName().Equals("SampleID")),
                         ciSamples.Single(info => info.GetRuntimeName().Equals("ID")),
                         ExtractionJoinType.Left, "");
        }
Exemplo n.º 3
0
        public void SetupValidationOnCatalogue()
        {
            Validator v  = new Validator();
            var       iv = new ItemValidator("chi");

            iv.PrimaryConstraint             = new Chi();
            iv.PrimaryConstraint.Consequence = Consequence.Wrong;

            v.AddItemValidator(iv, "chi", typeof(string));
            catalogue.ValidatorXML = v.SaveToXml();

            catalogue.TimeCoverage_ExtractionInformation_ID =
                catalogue.GetAllExtractionInformation(ExtractionCategory.Any)
                .Single(e => e.GetRuntimeName().Equals("dtCreated")).ID;

            catalogue.SaveToDatabase();
        }
Exemplo n.º 4
0
        protected override void SetUp()
        {
            base.SetUp();

            Database = GetCleanedServer(FAnsi.DatabaseType.MicrosoftSQLServer);

            var rootFolder = new DirectoryInfo(TestContext.CurrentContext.TestDirectory);
            var subdir     = rootFolder.CreateSubdirectory("TestsRequiringADle");

            LoadDirectory = LoadDirectory.CreateDirectoryStructure(rootFolder, subdir.FullName, true);

            Clear(LoadDirectory);

            LiveTable = CreateDataset <Demography>(Database, 500, 5000, new Random(190));
            LiveTable.CreatePrimaryKey(new DiscoveredColumn[] {
                LiveTable.DiscoverColumn("chi"),
                LiveTable.DiscoverColumn("dtCreated"),
                LiveTable.DiscoverColumn("hb_extract")
            });

            TestCatalogue = Import(LiveTable);
            RowsBefore    = 5000;

            TestLoadMetadata = new LoadMetadata(CatalogueRepository, "Loading Test Catalogue");
            TestLoadMetadata.LocationOfFlatFiles = LoadDirectory.RootPath.FullName;
            TestLoadMetadata.SaveToDatabase();


            //make the load load the table
            TestCatalogue.LoadMetadata_ID = TestLoadMetadata.ID;
            TestCatalogue.SaveToDatabase();

            CreateFlatFileAttacher(TestLoadMetadata, "*.csv", TestCatalogue.GetTableInfoList(false).Single(), ",");

            //Get DleRunner to run pre load checks (includes trigger creation etc)
            var runner = new DleRunner(new DleOptions()
            {
                LoadMetadata = TestLoadMetadata.ID, Command = CommandLineActivity.check
            });

            runner.Run(RepositoryLocator, new ThrowImmediatelyDataLoadEventListener(), new AcceptAllCheckNotifier(), new GracefulCancellationToken());
        }
Exemplo n.º 5
0
        private void Initialize(IActivateItems activator, string initialDescription, IProject projectSpecificIfAny)
        {
            CommonFunctionality.SetItemActivator(activator);
            var cols = _tableInfo.ColumnInfos;

            var forwardEngineer = new ForwardEngineerCatalogue(_tableInfo, cols, false);

            ExtractionInformation[] eis;
            forwardEngineer.ExecuteForwardEngineering(out _catalogue, out _catalogueItems, out eis);

            tbDescription.Text = initialDescription + " (" + Environment.UserName + " - " + DateTime.Now + ")";
            tbTableName.Text   = _tableInfo.Name;
            _catalogue.SaveToDatabase();
            objectSaverButton1.SetupFor(this, (DatabaseEntity)_catalogue, activator);

            if (_binder == null)
            {
                _binder = new BinderWithErrorProviderFactory(activator);
                _binder.Bind(tbCatalogueName, "Text", _catalogue, "Name", false, DataSourceUpdateMode.OnPropertyChanged, c => c.Name);
                _binder.Bind(tbAcronym, "Text", _catalogue, "Acronym", false, DataSourceUpdateMode.OnPropertyChanged, c => c.Acronym);
                _binder.Bind(tbDescription, "Text", _catalogue, "Description", false, DataSourceUpdateMode.OnPropertyChanged, c => c.Description);
            }

            //Every CatalogueItem is either mapped to a ColumnInfo (not extractable) or a ExtractionInformation (extractable).  To start out with they are not extractable
            foreach (CatalogueItem ci in _catalogueItems)
            {
                olvColumnExtractability.AddObject(new ColPair(ci, cols.Single(col => ci.ColumnInfo_ID == col.ID)));
            }

            _extractionCategories = new object[]
            {
                NotExtractable,
                ExtractionCategory.Core,
                ExtractionCategory.Supplemental,
                ExtractionCategory.SpecialApprovalRequired,
                ExtractionCategory.Internal,
                ExtractionCategory.Deprecated
            };

            ddCategoriseMany.Items.AddRange(_extractionCategories);

            olvExtractionCategory.AspectGetter         += ExtractionCategoryAspectGetter;
            olvColumnExtractability.AlwaysGroupByColumn = olvExtractionCategory;

            olvColumnExtractability.CellEditStarting  += TlvColumnExtractabilityOnCellEditStarting;
            olvColumnExtractability.CellEditFinishing += TlvColumnExtractabilityOnCellEditFinishing;
            olvColumnExtractability.CellEditActivation = ObjectListView.CellEditActivateMode.SingleClick;

            olvIsExtractionIdentifier.AspectPutter += IsExtractionIdentifier_AspectPutter;
            olvIsExtractionIdentifier.AspectGetter += IsExtractionIdentifier_AspectGetter;


            olvIsHashOnRelease.AspectPutter += IsHashOnRelease_AspectPutter;
            olvIsHashOnRelease.AspectGetter += IsHashOnRelease_AspectGetter;

            olvColumnInfoName.ImageGetter = ImageGetter;
            olvColumnExtractability.RebuildColumns();

            if (Activator.RepositoryLocator.DataExportRepository == null)
            {
                gbProjectSpecific.Enabled = false;
            }
            else
            {
                SelectProject(projectSpecificIfAny);
                pbProject.Image = activator.CoreIconProvider.GetImage(RDMPConcept.Project);
            }

            ddIsExtractionIdentifier.Items.Add(None);
            ddIsExtractionIdentifier.Items.AddRange(olvColumnExtractability.Objects.OfType <ColPair>().ToArray());

            RDMPControlCommonFunctionality.DisableMouseWheel(ddIsExtractionIdentifier);

            CommonFunctionality.AddHelp(btnPickProject, "IExtractableDataSet.Project_ID", "Project Specific Datasets");
            CommonFunctionality.AddHelpString(btnAddToExisting, "Add to existing catalogue", "Use this option if you want to create a Catalogue which extracts from multiple tables (via a JOIN).  Once used you will still need to configure a JoinInfo between column(s) in all the tables the Catalogue draws data from.");

            RDMPCollectionCommonFunctionality.SetupColumnTracking(olvColumnExtractability, olvColumnInfoName, new Guid("86e7bf77-8829-4f72-aa47-29a30710621f"));
            RDMPCollectionCommonFunctionality.SetupColumnTracking(olvColumnExtractability, olvExtractionCategory, new Guid("ad106fe4-bea0-4670-9ded-61967699269f"));
            RDMPCollectionCommonFunctionality.SetupColumnTracking(olvColumnExtractability, olvIsExtractionIdentifier, new Guid("f9a87191-9676-4c86-a292-608dc95e8eef"));
            RDMPCollectionCommonFunctionality.SetupColumnTracking(olvColumnExtractability, olvIsHashOnRelease, new Guid("d3590a68-ee78-40c6-b073-eea32cac49ec"));
        }