public ExecuteCommandMakeProjectSpecificCatalogueNormalAgain(IActivateItems activator, Catalogue catalogue) : base(activator) { _catalogue = catalogue; var dataExportRepository = activator.RepositoryLocator.DataExportRepository; if (dataExportRepository == null) { SetImpossible("Data Export functionality is not available"); return; } _extractableDataSet = dataExportRepository.GetAllObjectsWithParent <ExtractableDataSet>(catalogue).SingleOrDefault(); if (_extractableDataSet == null) { SetImpossible("Catalogue is not extractable"); return; } if (_extractableDataSet.Project_ID == null) { SetImpossible("Catalogue is not a project specific Catalogue"); return; } }
private void SetupDataExport() { _extractableDataSet = new ExtractableDataSet(DataExportRepository, _catalogue); _project = new Project(DataExportRepository, _testDatabaseName); _project.ProjectNumber = 1; Directory.CreateDirectory(ProjectDirectory); _project.ExtractionDirectory = ProjectDirectory; _project.SaveToDatabase(); _configuration = new ExtractionConfiguration(DataExportRepository, _project); //select the dataset for extraction under this configuration _selectedDataSet = new SelectedDataSets(RepositoryLocator.DataExportRepository, _configuration, _extractableDataSet, null); //select all the columns for extraction foreach (var toSelect in _extractionInformations) { var col = new ExtractableColumn(DataExportRepository, _extractableDataSet, _configuration, toSelect, toSelect.Order, toSelect.SelectSQL); if (col.GetRuntimeName().Equals("PrivateID")) { col.IsExtractionIdentifier = true; } col.SaveToDatabase(); _extractableColumns.Add(col); } }
/// <summary> /// Returns true if the given <paramref name="modelObject"/> survives filtering based on the supplied inclusion /// criteria. Anything that isn't in some way related to a <see cref="Catalogue"/> automatically survives filtering /// </summary> /// <param name="modelObject"></param> /// <param name="descendancy"></param> /// <param name="includeInternal"></param> /// <param name="includeDeprecated"></param> /// <param name="includeColdStorage"></param> /// <param name="includeProjectSpecific"></param> /// <param name="includeNonExtractable"></param> /// <returns>True if the item should be shown to the user based on filters</returns> public static bool Filter(object modelObject, DescendancyList descendancy, bool includeInternal, bool includeDeprecated, bool includeColdStorage, bool includeProjectSpecific, bool includeNonExtractable) { var cata = modelObject as ICatalogue; //doesn't relate to us... if (cata == null) { // or are we one of these things that can be tied to a catalogue cata = modelObject switch { ExtractableDataSet eds => eds.Catalogue, SelectedDataSets sds => sds.GetCatalogue(), _ => descendancy?.Parents.OfType <Catalogue>().SingleOrDefault() }; if (cata == null) { return(true); } } bool isProjectSpecific = cata.IsProjectSpecific(null); bool isExtractable = cata.GetExtractabilityStatus(null) != null && cata.GetExtractabilityStatus(null).IsExtractable; return((isExtractable && !cata.IsColdStorageDataset && !cata.IsDeprecated && !cata.IsInternalDataset && !isProjectSpecific) || ((includeColdStorage && cata.IsColdStorageDataset) || (includeDeprecated && cata.IsDeprecated) || (includeInternal && cata.IsInternalDataset) || (includeProjectSpecific && isProjectSpecific) || (includeNonExtractable && !isExtractable))); }
public void PreventDeletingCatalogueBecauseOfLinkedDatasetTest() { var obscura = new BetweenCatalogueAndDataExportObscureDependencyFinder(RepositoryLocator); var cata = new Catalogue(CatalogueRepository, "MyCata"); //catalogue exists in isolation so is deletable Assert.DoesNotThrow(()=>obscura.ThrowIfDeleteDisallowed(cata)); //there is a new dataset which is linked to Catalogue var dataset = new ExtractableDataSet(DataExportRepository,cata); //and suddenly we cannot delete the catalogue var ex = Assert.Throws<Exception>(() => obscura.ThrowIfDeleteDisallowed(cata)); Assert.IsTrue(ex.Message.Contains("Cannot delete Catalogue MyCata because there are ExtractableDataSets which depend on them ")); //also if we try to force through a delete it should behave in identical manner var ex2 = Assert.Throws<Exception>(cata.DeleteInDatabase); Assert.IsTrue(ex2.Message.Contains("Cannot delete Catalogue MyCata because there are ExtractableDataSets which depend on them ")); //now we delete the linked dataset dataset.DeleteInDatabase(); //and because there is now no longer a dataset dependency on the catalogue we can delete it Assert.DoesNotThrow(() => obscura.ThrowIfDeleteDisallowed(cata)); //and the delete works too cata.DeleteInDatabase(); //both objects still exist in memory of course but we should be able to see they have disapeared Assert.IsTrue(dataset.HasLocalChanges().Evaluation == ChangeDescription.DatabaseCopyWasDeleted); Assert.IsTrue(cata.HasLocalChanges().Evaluation == ChangeDescription.DatabaseCopyWasDeleted); }
private void TestScoringFlag(Action <Catalogue, ExtractableDataSet> setter, bool expectedResult) { // Filter is hungry and eager to please. If you want to see ProjectSpecific Catalogues then // that it will show you them regardless of other settings. Likewise clicking Deprecated shows // all deprecated catalogues regardless of other settings. // // So set all to false to except the condition we are testing UserSettings.ShowDeprecatedCatalogues = false; UserSettings.ShowNonExtractableCatalogues = false; UserSettings.ShowProjectSpecificCatalogues = false; UserSettings.ShowInternalCatalogues = false; UserSettings.ShowColdStorageCatalogues = false; var c = WhenIHaveA <Catalogue>(); c.Name = "Bunny"; c.SaveToDatabase(); // this makes c extractable (the usual case for Catalogues) var eds = new ExtractableDataSet(Repository, c); eds.SaveToDatabase(); setter(c, eds); c.SaveToDatabase(); var scorer = new SearchablesMatchScorer() { RespectUserSettings = true }; var childProvider = new DataExportChildProvider(RepositoryLocator, null, new ThrowImmediatelyCheckNotifier(), null); // user is searching for the text 'troll' var scores = scorer.ScoreMatches(childProvider.GetAllSearchables(), "Bunny", CancellationToken.None, new List <Type>()); var score = scores.Single(d => Equals(d.Key.Key, c)); if (expectedResult) { Assert.Greater(score.Value, 0); } else { // score 0 and don't be included in results Assert.AreEqual(0, score.Value); } // Cleanup test foreach (var d in Repository.GetAllObjects <ExtractableDataSet>()) { d.DeleteInDatabase(); } foreach (var cat in Repository.GetAllObjects <Catalogue>()) { cat.DeleteInDatabase(); } }
public void ExtractionProgressConstructor_NoTimePeriodicity() { var cata = new Catalogue(CatalogueRepository, "MyCata"); var eds = new ExtractableDataSet(DataExportRepository, cata); var project = new Project(DataExportRepository, "My Proj"); var config = new ExtractionConfiguration(DataExportRepository, project); var sds = new SelectedDataSets(DataExportRepository, config, eds, null); var ex = Assert.Throws <ArgumentException>(() => new ExtractionProgress(DataExportRepository, sds)); Assert.AreEqual("Cannot create ExtractionProgress because Catalogue MyCata does not have a time coverage column", ex.Message); }
private void TestDataExportOfTvf() { var config = new ExtractionConfiguration(DataExportRepository, _project); config.Cohort_ID = DataExportRepository.GetAllObjects <ExtractableCohort>().Single().ID; config.SaveToDatabase(); var tvfExtractable = new ExtractableDataSet(DataExportRepository, _tvfCatalogue); var selected = new SelectedDataSets(DataExportRepository, config, tvfExtractable, null); //make all columns part of the extraction foreach (ExtractionInformation e in _tvfCatalogue.GetAllExtractionInformation(ExtractionCategory.Any)) { config.AddColumnToExtraction(tvfExtractable, e); } //the default value should be 10 Assert.AreEqual("10", _tvfTableInfo.GetAllParameters().Single().Value); //configure an extraction specific global of 1 so that only 1 chi number is fetched (which will be in the cohort) var globalP = new GlobalExtractionFilterParameter(DataExportRepository, config, "DECLARE @numberOfRecords AS int;"); globalP.Value = "1"; globalP.SaveToDatabase(); var extractionCommand = new ExtractDatasetCommand(config, new ExtractableDatasetBundle(tvfExtractable)); var source = new ExecuteDatasetExtractionSource(); source.PreInitialize(extractionCommand, new ThrowImmediatelyDataLoadEventListener()); var dt = source.GetChunk(new ThrowImmediatelyDataLoadEventListener(), new GracefulCancellationToken()); Assert.AreEqual(1, dt.Rows.Count); Assert.AreEqual("ReleaseId", dt.Columns[0].ColumnName); //should be a guid Assert.IsTrue(dt.Rows[0][0].ToString().Length > 10); Assert.IsTrue(dt.Rows[0][0].ToString().Contains("-")); selected.DeleteInDatabase(); globalP.DeleteInDatabase(); config.DeleteInDatabase(); tvfExtractable.DeleteInDatabase(); }
public ExtractableDatasetMenu(RDMPContextMenuStripArgs args, ExtractableDataSet dataset) : base(args, dataset) { _dataset = dataset; if (_dataset.DisableExtraction) { Items.Add("ReEnable Extraction", _activator.CoreIconProvider.GetImage(RDMPConcept.ExtractableDataSet), (s, e) => SetDisabled(false)); } else { Items.Add("Disable Extraction (temporarily)", CatalogueIcons.ExtractableDataSetDisabled, (s, e) => SetDisabled(true)); } }
private void SetupCohortDefinitionAndCustomTable() { DataTable dt = new DataTable(); dt.Columns.Add("SuperSecretThing"); dt.Columns.Add("PrivateID"); dt.Rows.Add(new[] { "monkeys can all secretly fly", "Priv_12345" }); dt.Rows.Add(new[] { "the wizard of OZ was a man behind a machine", "Priv_wtf11" }); CustomTable = _cohortDatabase.CreateTable("custTable99", dt); ColumnInfo[] cols; new TableInfoImporter(CatalogueRepository, CustomTable).DoImport(out CustomTableInfo, out cols); CatalogueItem[] cis; ExtractionInformation[] eis; new ForwardEngineerCatalogue(CustomTableInfo, cols, true).ExecuteForwardEngineering(out CustomCatalogue, out cis, out eis); CustomExtractableDataSet = new ExtractableDataSet(DataExportRepository, CustomCatalogue); foreach (ExtractionInformation e in eis) { e.ExtractionCategory = ExtractionCategory.ProjectSpecific; if (e.GetRuntimeName().Equals("PrivateID")) { e.IsExtractionIdentifier = true; } e.SaveToDatabase(); } using (var con = _cohortDatabase.Server.GetConnection()) { string insertSQL = "SET IDENTITY_INSERT " + definitionTableName + " ON ;" + Environment.NewLine; insertSQL += "INSERT INTO " + definitionTableName + " (id,projectNumber,description,version) VALUES (" + cohortIDInTestData + "," + projectNumberInTestData + ",'unitTestDataForCohort',1)"; con.Open(); using (var cmd = _cohortDatabase.Server.GetCommand(insertSQL, con)) cmd.ExecuteNonQuery(); } }
public void CreateAndAssociateColumns() { var cata = new Catalogue(CatalogueRepository, "MyCat"); var cataItem = new CatalogueItem(CatalogueRepository, cata, "MyCataItem"); var TableInfo = new TableInfo(CatalogueRepository, "Cata"); var ColumnInfo = new ColumnInfo(CatalogueRepository, "Col", "varchar(10)", TableInfo); var ExtractionInfo = new ExtractionInformation(CatalogueRepository, cataItem, ColumnInfo, "fish"); var ds = new ExtractableDataSet(DataExportRepository, cata); var proj = new Project(DataExportRepository, "MyProj"); var config = new ExtractionConfiguration(DataExportRepository, proj); SelectedDataSets selectedDataSets; var extractableColumn = new ExtractableColumn(DataExportRepository, ds, config, ExtractionInfo, 1, "fish"); try { selectedDataSets = new SelectedDataSets(DataExportRepository, config, ds, null); var cols = config.GetAllExtractableColumnsFor(ds); Assert.AreEqual(1, cols.Count()); Assert.AreEqual(extractableColumn, cols.Single()); cols = config.GetAllExtractableColumnsFor(ds); Assert.AreEqual(1, cols.Count()); Assert.AreEqual(extractableColumn, cols.Single()); } finally { extractableColumn.DeleteInDatabase(); config.DeleteInDatabase(); proj.DeleteInDatabase(); ds.DeleteInDatabase(); TableInfo.DeleteInDatabase(); cata.DeleteInDatabase(); } }
private ExtractionProgress CreateAnExtractionProgress() { var cata = new Catalogue(CatalogueRepository, "MyCata"); var cataItem = new CatalogueItem(CatalogueRepository, cata, "MyCol"); var table = new TableInfo(CatalogueRepository, "MyTable"); var col = new ColumnInfo(CatalogueRepository, "mycol", "datetime", table); var ei = new ExtractionInformation(CatalogueRepository, cataItem, col, "mycol"); cata.TimeCoverage_ExtractionInformation_ID = ei.ID; cata.SaveToDatabase(); var eds = new ExtractableDataSet(DataExportRepository, cata); var project = new Project(DataExportRepository, "My Proj"); var config = new ExtractionConfiguration(DataExportRepository, project); var sds = new SelectedDataSets(DataExportRepository, config, eds, null); return(new ExtractionProgress(DataExportRepository, sds)); }
/// <inheritdoc/> public virtual ICatalogue CreateAndConfigureCatalogue(ITableInfo tableInfo, ColumnInfo[] extractionIdentifierColumns, string initialDescription, IProject projectSpecific, CatalogueFolder catalogueFolder) { // Create a new Catalogue based on the table info var engineer = new ForwardEngineerCatalogue(tableInfo, tableInfo.ColumnInfos, true); engineer.ExecuteForwardEngineering(out ICatalogue cata, out _, out ExtractionInformation[] eis); // if we know the linkable private identifier column(s) if (extractionIdentifierColumns != null && extractionIdentifierColumns.Any()) { // Make the Catalogue extractable var eds = new ExtractableDataSet(RepositoryLocator.DataExportRepository, cata); // Mark the columns specified IsExtractionIdentifier foreach (var col in extractionIdentifierColumns) { var match = eis.FirstOrDefault(ei => ei.ColumnInfo?.ID == col.ID); if (match == null) { throw new ArgumentException($"Supplied ColumnInfo {col.GetRuntimeName()} was not found amongst the columns created"); } match.IsExtractionIdentifier = true; match.SaveToDatabase(); } // Catalogue must be extractable to be project specific if (projectSpecific != null) { eds.Project_ID = projectSpecific.ID; eds.SaveToDatabase(); } } if (catalogueFolder != null) { cata.Folder = catalogueFolder; cata.SaveToDatabase(); } return(cata); }
private void SetupDataExport(string testDbName, ICatalogue catalogue, out ExtractionConfiguration extractionConfiguration, out IExtractableDataSet extractableDataSet, out IProject project) { extractableDataSet = new ExtractableDataSet(DataExportRepository, catalogue); project = new Project(DataExportRepository, testDbName); project.ProjectNumber = 1; Directory.CreateDirectory(ProjectDirectory); project.ExtractionDirectory = ProjectDirectory; project.SaveToDatabase(); extractionConfiguration = new ExtractionConfiguration(DataExportRepository, project); extractionConfiguration.AddDatasetToConfiguration(extractableDataSet); foreach (var ei in _catalogue.GetAllExtractionInformation(ExtractionCategory.Supplemental)) { extractionConfiguration.AddColumnToExtraction(extractableDataSet, ei); } }
private void FinaliseExtractability() { var eds = new ExtractableDataSet(Activator.RepositoryLocator.DataExportRepository, _catalogue); IAtomicCommandWithTarget cmd; if (_projectSpecific != null) { cmd = new ExecuteCommandMakeCatalogueProjectSpecific(Activator).SetTarget(_projectSpecific).SetTarget(_catalogue); if (!cmd.IsImpossible) { cmd.Execute(); } else { MessageBox.Show("Could not make Catalogue ProjectSpecific:" + cmd.ReasonCommandImpossible); } } }
public void CreateExtractableDataSet() { ExtractableDataSet eds = null; var cata = new Catalogue(CatalogueRepository, "TestExtractableTables Cata"); try { //creates with a Null Catalogue until it is associated with a catalogue and saved eds = new ExtractableDataSet(DataExportRepository, cata); Assert.AreEqual(cata.ID, eds.Catalogue_ID); } finally { if (eds != null) { eds.DeleteInDatabase(); } cata.DeleteInDatabase(); } }
public void AllowDeletingWhenDataExportManagerIsNotSet() { var noDataExportManagerExists = new LinkedRepositoryProvider(CatalogueRepository.ConnectionString,null); var obscura1 = new BetweenCatalogueAndDataExportObscureDependencyFinder(RepositoryLocator); var obscura2 = new BetweenCatalogueAndDataExportObscureDependencyFinder(noDataExportManagerExists); var cata = new Catalogue(CatalogueRepository, "MyCata"); var dataset = new ExtractableDataSet(DataExportRepository,cata); //we cannot delete it because there is a dependency var ex = Assert.Throws<Exception>(() => obscura1.ThrowIfDeleteDisallowed(cata)); Assert.IsTrue(ex.Message.Contains("Cannot delete Catalogue MyCata because there are ExtractableDataSets which depend on them ")); //the second finder simulates when the repository locator doesn't have a record of the data export repository so it is unable to check it so it will let you delete it just fine Assert.DoesNotThrow(() => obscura2.ThrowIfDeleteDisallowed(cata)); //now delete them in the correct order dataset.DeleteInDatabase(); cata.DeleteInDatabase(); }
public void AddAndRemove() { var cata = new Catalogue(CatalogueRepository, "PackageContentsTests"); var ds = new ExtractableDataSet(DataExportRepository, cata); var package = new ExtractableDataSetPackage(DataExportRepository, "My Cool Package"); try { Assert.AreEqual("My Cool Package", package.Name); package.Name = "FishPackage"; package.SaveToDatabase(); var packageContents = new ExtractableDataSetPackageManager(DataExportRepository); var results = packageContents.GetAllDataSets(package, null); Assert.AreEqual(0, results.Length); packageContents.AddDataSetToPackage(package, ds); results = packageContents.GetAllDataSets(package, DataExportRepository.GetAllObjects <ExtractableDataSet>()); Assert.AreEqual(1, results.Length); Assert.AreEqual(ds, results[0]); packageContents.RemoveDataSetFromPackage(package, ds); //cannot delete the relationship twice Assert.Throws <ArgumentException>(() => packageContents.RemoveDataSetFromPackage(package, ds)); } finally { ds.DeleteInDatabase(); package.DeleteInDatabase(); cata.DeleteInDatabase(); } }
public ExtractableDatasetMenu(RDMPContextMenuStripArgs args, ExtractableDataSet dataset) : base(args, dataset) { _dataset = dataset; if (_dataset.DisableExtraction) { Items.Add("ReEnable Extraction", _activator.CoreIconProvider.GetImage(RDMPConcept.ExtractableDataSet), (s, e) => SetDisabled(false)); } else { Items.Add("Disable Extraction (temporarily)", CatalogueIcons.ExtractableDataSetDisabled, (s, e) => SetDisabled(true)); } AddGoTo <Catalogue>(_dataset.Catalogue_ID); if (_activator.CoreChildProvider is DataExportChildProvider dx) { AddGoTo(() => dx.SelectedDataSets.Where(s => s.ExtractableDataSet_ID == _dataset.ID).Select(s => s.ExtractionConfiguration), "Extraction Configurations"); } }
private Catalogue ImportCatalogue(TableInfo ti) { var forwardEngineer = new ForwardEngineerCatalogue(ti, ti.ColumnInfos, true); forwardEngineer.ExecuteForwardEngineering(out Catalogue cata, out _, out ExtractionInformation[] eis); //get descriptions of the columns from BadMedicine var desc = new Descriptions(); cata.Description = Trim(desc.Get(cata.Name)); if (cata.Description != null) { cata.SaveToDatabase(); foreach (var ci in cata.CatalogueItems) { var ciDescription = Trim(desc.Get(cata.Name, ci.Name)); if (ciDescription != null) { ci.Description = ciDescription; ci.SaveToDatabase(); } } } var chi = eis.SingleOrDefault(e => e.GetRuntimeName().Equals("chi", StringComparison.CurrentCultureIgnoreCase)); if (chi != null) { chi.IsExtractionIdentifier = true; chi.SaveToDatabase(); var eds = new ExtractableDataSet(_repos.DataExportRepository, cata); } return(cata); }
public void TestNoIsExtractionIdentifierFinding() { //nothing in database means no dodgy datasets Assert.IsEmpty(((DataExportRepository)DataExportRepository).GetSelectedDatasetsWithNoExtractionIdentifiers()); var cata = new Catalogue(CatalogueRepository, "ommn"); var ds = new ExtractableDataSet(DataExportRepository, cata); var proj = new Project(DataExportRepository, "proj"); var config = new ExtractionConfiguration(DataExportRepository, proj); var sds = new SelectedDataSets(DataExportRepository, config, ds, null); //only one selected dataset var dodgy = ((DataExportRepository)DataExportRepository).GetSelectedDatasetsWithNoExtractionIdentifiers().ToArray(); Assert.AreEqual(1, dodgy.Count()); Assert.AreEqual(sds, dodgy[0]); //make an extarctable column on that dataset var col = new ColumnInfo(CatalogueRepository, "ff", "varchar(1)", new TableInfo(CatalogueRepository, "fff")); var ci = new CatalogueItem(CatalogueRepository, cata, "A"); var ei = new ExtractionInformation(CatalogueRepository, ci, col, col.Name); var ec = new ExtractableColumn(DataExportRepository, ds, config, ei, 0, col.Name); //still shouldn't be dodgy dodgy = ((DataExportRepository)DataExportRepository).GetSelectedDatasetsWithNoExtractionIdentifiers().ToArray(); Assert.AreEqual(1, dodgy.Count()); Assert.AreEqual(sds, dodgy[0]); //now make it non dodgy by being IsExtractionIdentifier ec.IsExtractionIdentifier = true; ec.SaveToDatabase(); //no longer dodgy because there is an extraction identifier dodgy = ((DataExportRepository)DataExportRepository).GetSelectedDatasetsWithNoExtractionIdentifiers().ToArray(); Assert.AreEqual(0, dodgy.Count()); }
/// <summary> /// Creates a minimum viable object of Type T. This includes the object and any dependencies e.g. a /// <see cref="ColumnInfo"/> cannot exist without a <see cref="TableInfo"/>. /// </summary> /// <typeparam name="T">Type of object you want to create</typeparam> /// <returns></returns> /// <exception cref="NotSupportedException">If there is not yet an implementation for the given T. Feel free to write one.</exception> protected T WhenIHaveA <T>() where T : DatabaseEntity { if (typeof(T) == typeof(Catalogue)) { return((T)(object)Save(new Catalogue(Repository, "Mycata"))); } if (typeof(T) == typeof(ExtendedProperty)) { return((T)(object)new ExtendedProperty(Repository, Save(new Catalogue(Repository, "Mycata")), "TestProp", 0)); } if (typeof(T) == typeof(CatalogueItem)) { var cata = new Catalogue(Repository, "Mycata"); return((T)(object)new CatalogueItem(Repository, cata, "MyCataItem")); } if (typeof(T) == typeof(ExtractionInformation)) { var col = WhenIHaveA <ColumnInfo>(); var cata = new Catalogue(Repository, "Mycata"); var ci = new CatalogueItem(Repository, cata, "MyCataItem"); var ei = new ExtractionInformation(Repository, ci, col, "MyCataItem"); return((T)(object)Save(ei)); } if (typeof(T) == typeof(TableInfo)) { var table = new TableInfo(Repository, "My_Table") { DatabaseType = DatabaseType.MicrosoftSQLServer }; return((T)(object)table); } if (typeof(T) == typeof(ColumnInfo)) { var ti = WhenIHaveA <TableInfo>(); var col = new ColumnInfo(Repository, "My_Col", "varchar(10)", ti); return((T)(object)col); } if (typeof(T) == typeof(AggregateConfiguration)) { ExtractionInformation dateEi; ExtractionInformation otherEi; return((T)(object)WhenIHaveA <AggregateConfiguration>(out dateEi, out otherEi)); } if (typeof(T) == typeof(ExternalDatabaseServer)) { return((T)(object)Save(new ExternalDatabaseServer(Repository, "My Server", null))); } if (typeof(T) == typeof(ANOTable)) { ExternalDatabaseServer server; return((T)(object)WhenIHaveA <ANOTable>(out server)); } if (typeof(T) == typeof(LoadMetadata)) { //creates the table, column, catalogue, catalogue item and extraction information var ei = WhenIHaveA <ExtractionInformation>(); var cata = ei.CatalogueItem.Catalogue; var ti = ei.ColumnInfo.TableInfo; ti.Server = "localhost"; ti.Database = "mydb"; ti.SaveToDatabase(); var lmd = new LoadMetadata(Repository, "MyLoad"); cata.LoadMetadata_ID = lmd.ID; cata.SaveToDatabase(); return((T)(object)lmd); } if (typeof(T) == typeof(AggregateTopX)) { var agg = WhenIHaveA <AggregateConfiguration>(); return((T)(object)new AggregateTopX(Repository, agg, 10)); } if (typeof(T) == typeof(ConnectionStringKeyword)) { return((T)(object)new ConnectionStringKeyword(Repository, DatabaseType.MicrosoftSQLServer, "MultipleActiveResultSets", "true")); } if (typeof(T) == typeof(DashboardLayout)) { return((T)(object)new DashboardLayout(Repository, "My Layout")); } if (typeof(T) == typeof(DashboardControl)) { var layout = WhenIHaveA <DashboardLayout>(); return((T)(object)Save(new DashboardControl(Repository, layout, typeof(int), 0, 0, 100, 100, "") { ControlType = "GoodBadCataloguePieChart" })); } if (typeof(T) == typeof(DashboardObjectUse)) { var layout = WhenIHaveA <DashboardLayout>(); var control = Save(new DashboardControl(Repository, layout, typeof(int), 0, 0, 100, 100, "") { ControlType = "GoodBadCataloguePieChart" }); var use = new DashboardObjectUse(Repository, control, WhenIHaveA <Catalogue>()); return((T)(object)use); } if (typeof(T) == typeof(ExtractionFilter)) { var ei = WhenIHaveA <ExtractionInformation>(); return((T)(object)new ExtractionFilter(Repository, "My Filter", ei)); } if (typeof(T) == typeof(ExtractionFilterParameter)) { var filter = WhenIHaveA <ExtractionFilter>(); filter.WhereSQL = "@myParam = 'T'"; return((T)(object)new ExtractionFilterParameter(Repository, "DECLARE @myParam varchar(10)", filter)); } if (typeof(T) == typeof(ExtractionFilterParameterSetValue)) { var parameter = WhenIHaveA <ExtractionFilterParameter>(); var set = new ExtractionFilterParameterSet(Repository, parameter.ExtractionFilter, "Parameter Set"); return((T)(object)new ExtractionFilterParameterSetValue(Repository, set, parameter)); } if (typeof(T) == typeof(ExtractionFilterParameterSet)) { return((T)(object)WhenIHaveA <ExtractionFilterParameterSetValue>().ExtractionFilterParameterSet); } if (typeof(T) == typeof(Favourite)) { return((T)(object)new Favourite(Repository, WhenIHaveA <Catalogue>())); } if (typeof(T) == typeof(ObjectExport)) { ShareManager sm; return((T)(object)WhenIHaveA <ObjectExport>(out sm)); } if (typeof(T) == typeof(ObjectImport)) { ShareManager sm; ObjectExport export = WhenIHaveA <ObjectExport>(out sm); return((T)(object)sm.GetImportAs(export.SharingUID, WhenIHaveA <Catalogue>())); } if (typeof(T) == typeof(WindowLayout)) { return((T)(object)new WindowLayout(Repository, "My window arrangement", "<html><body>ignore this</body></html>")); } if (typeof(T) == typeof(RemoteRDMP)) { return((T)(object)new RemoteRDMP(Repository)); } if (typeof(T) == typeof(CohortIdentificationConfiguration)) { return((T)(object)new CohortIdentificationConfiguration(Repository, "My cic")); } if (typeof(T) == typeof(JoinableCohortAggregateConfiguration)) { var config = WhenIHaveCohortAggregateConfiguration("PatientIndexTable"); var cic = WhenIHaveA <CohortIdentificationConfiguration>(); cic.EnsureNamingConvention(config); return((T)(object)new JoinableCohortAggregateConfiguration(Repository, cic, config)); } if (typeof(T) == typeof(JoinableCohortAggregateConfigurationUse)) { var joinable = WhenIHaveA <JoinableCohortAggregateConfiguration>(); var config = WhenIHaveCohortAggregateConfiguration("Aggregate"); return((T)(object)joinable.AddUser(config)); } if (typeof(T) == typeof(Rdmp.Core.Curation.Data.Plugin)) { return((T)(object)new Rdmp.Core.Curation.Data.Plugin(Repository, new FileInfo("bob.nupkg"), new Version(1, 1, 1), new Version(1, 1, 1))); } if (typeof(T) == typeof(LoadModuleAssembly)) { var dll = Path.Combine(TestContext.CurrentContext.TestDirectory, "a.nupkg"); File.WriteAllBytes(dll, new byte[] { 0x11 }); return((T)(object)new LoadModuleAssembly(Repository, new FileInfo(dll), WhenIHaveA <Rdmp.Core.Curation.Data.Plugin>())); } if (typeof(T) == typeof(AggregateContinuousDateAxis)) { ExtractionInformation dateEi; ExtractionInformation otherEi; var config = WhenIHaveA <AggregateConfiguration>(out dateEi, out otherEi); //remove the other Ei config.AggregateDimensions[0].DeleteInDatabase(); //add the date one var dim = new AggregateDimension(Repository, dateEi, config); return((T)(object)new AggregateContinuousDateAxis(Repository, dim)); } if (typeof(T) == typeof(AggregateDimension)) { return((T)(object)WhenIHaveA <AggregateConfiguration>().AggregateDimensions[0]); } if (typeof(T) == typeof(AggregateFilterContainer)) { var config = WhenIHaveA <AggregateConfiguration>(); var container = new AggregateFilterContainer(Repository, FilterContainerOperation.AND); config.RootFilterContainer_ID = container.ID; config.SaveToDatabase(); return((T)(object)container); } if (typeof(T) == typeof(AggregateFilter)) { var container = WhenIHaveA <AggregateFilterContainer>(); return((T)(object)new AggregateFilter(Repository, "My Filter", container)); } if (typeof(T) == typeof(AggregateFilterParameter)) { var filter = WhenIHaveA <AggregateFilter>(); filter.WhereSQL = "@MyP = 'mnnn apples'"; filter.SaveToDatabase(); return((T)filter.GetFilterFactory().CreateNewParameter(filter, "DECLARE @MyP as varchar(10)")); } if (typeof(T) == typeof(LoadProgress)) { return((T)(object)new LoadProgress(Repository, WhenIHaveA <LoadMetadata>())); } if (typeof(T) == typeof(CacheProgress)) { return((T)(object)new CacheProgress(Repository, WhenIHaveA <LoadProgress>())); } if (typeof(T) == typeof(CacheFetchFailure)) { return((T)(object)new CacheFetchFailure(Repository, WhenIHaveA <CacheProgress>(), DateTime.Now.Subtract(new TimeSpan(1, 0, 0, 0)), DateTime.Now, new Exception("It didn't work"))); } if (typeof(T) == typeof(CohortAggregateContainer)) { var cic = WhenIHaveA <CohortIdentificationConfiguration>(); cic.CreateRootContainerIfNotExists(); return((T)(object)cic.RootCohortAggregateContainer); } if (typeof(T) == typeof(AnyTableSqlParameter)) { var cic = WhenIHaveA <CohortIdentificationConfiguration>(); return((T)(object)new AnyTableSqlParameter(Repository, cic, "DECLARE @myGlobal as varchar(10)")); } if (typeof(T) == typeof(DataAccessCredentials)) { return((T)(object)new DataAccessCredentials(Repository, "My credentials")); } if (typeof(T) == typeof(GovernancePeriod)) { return((T)(object)new GovernancePeriod(Repository)); } if (typeof(T) == typeof(GovernanceDocument)) { var fi = new FileInfo(Path.Combine(TestContext.CurrentContext.TestDirectory, "myfile.txt")); return((T)(object)new GovernanceDocument(Repository, WhenIHaveA <GovernancePeriod>(), fi)); } if (typeof(T) == typeof(PermissionWindow)) { return((T)(object)new PermissionWindow(Repository)); } if (typeof(T) == typeof(JoinInfo)) { ColumnInfo col1; ColumnInfo col2; ColumnInfo col3; WhenIHaveTwoTables(out col1, out col2, out col3); return((T)(object)new JoinInfo(Repository, col1, col2, ExtractionJoinType.Left, null)); } if (typeof(T) == typeof(Lookup)) { ColumnInfo col1; ColumnInfo col2; ColumnInfo col3; WhenIHaveTwoTables(out col1, out col2, out col3); return((T)(object)new Lookup(Repository, col3, col1, col2, ExtractionJoinType.Left, null)); } if (typeof(T) == typeof(LookupCompositeJoinInfo)) { var lookup = WhenIHaveA <Lookup>(); var otherJoinFk = new ColumnInfo(Repository, "otherJoinKeyForeign", "int", lookup.ForeignKey.TableInfo); var otherJoinPk = new ColumnInfo(Repository, "otherJoinKeyPrimary", "int", lookup.PrimaryKey.TableInfo); return((T)(object)new LookupCompositeJoinInfo(Repository, lookup, otherJoinFk, otherJoinPk)); } if (typeof(T) == typeof(Pipeline)) { return((T)(object)new Pipeline(Repository, "My Pipeline")); } if (typeof(T) == typeof(PipelineComponent)) { return((T)(object)new PipelineComponent(Repository, WhenIHaveA <Pipeline>(), typeof(ColumnForbidder), 0, "My Component")); } if (typeof(T) == typeof(PipelineComponentArgument)) { var comp = WhenIHaveA <PipelineComponent>(); return((T)comp.CreateArgumentsForClassIfNotExists <ColumnForbidder>().First()); } if (typeof(T) == typeof(PreLoadDiscardedColumn)) { return((T)(object)new PreLoadDiscardedColumn(Repository, WhenIHaveA <TableInfo>(), "MyDiscardedColum")); } if (typeof(T) == typeof(ProcessTask)) { return((T)(object)new ProcessTask(Repository, WhenIHaveA <LoadMetadata>(), LoadStage.AdjustRaw)); } if (typeof(T) == typeof(ProcessTaskArgument)) { return((T)(object)new ProcessTaskArgument(Repository, WhenIHaveA <ProcessTask>())); } if (typeof(T) == typeof(StandardRegex)) { return((T)(object)new StandardRegex(Repository)); } if (typeof(T) == typeof(SupportingSQLTable)) { return((T)(object)new SupportingSQLTable(Repository, WhenIHaveA <Catalogue>(), "Some Handy Query")); } if (typeof(T) == typeof(TicketingSystemConfiguration)) { return((T)(object)new TicketingSystemConfiguration(Repository, "My Ticketing System")); } if (typeof(T) == typeof(SupportingDocument)) { return((T)(object)new SupportingDocument(Repository, WhenIHaveA <Catalogue>(), "HelpFile.docx")); } if (typeof(T) == typeof(Project)) { return((T)(object)new Project(Repository, "My Project")); } if (typeof(T) == typeof(ExtractionConfiguration)) { return((T)(object)new ExtractionConfiguration(Repository, WhenIHaveA <Project>())); } if (typeof(T) == typeof(ExtractableDataSet)) { //To make an extractable dataset we need an extraction identifier (e.g. chi) that will be linked in the cohort var ei = WhenIHaveA <ExtractionInformation>(); ei.IsExtractionIdentifier = true; ei.SaveToDatabase(); //And we need another column too just for sanity sakes (in the same table) var ci2 = new CatalogueItem(Repository, ei.CatalogueItem.Catalogue, "ci2"); var col2 = new ColumnInfo(Repository, "My_Col2", "varchar(10)", ei.ColumnInfo.TableInfo); var ei2 = new ExtractionInformation(Repository, ci2, col2, col2.GetFullyQualifiedName()); return((T)(object)new ExtractableDataSet(Repository, ei.CatalogueItem.Catalogue)); } if (typeof(T) == typeof(CumulativeExtractionResults)) { return((T)(object)new CumulativeExtractionResults(Repository, WhenIHaveA <ExtractionConfiguration>(), WhenIHaveA <ExtractableDataSet>(), "SELECT * FROM Anywhere")); } if (typeof(T) == typeof(SelectedDataSets)) { var eds = WhenIHaveA <ExtractableDataSet>(); var config = WhenIHaveA <ExtractionConfiguration>(); foreach (var ei in eds.Catalogue.GetAllExtractionInformation(ExtractionCategory.Any)) { var ec = new ExtractableColumn(Repository, eds, config, ei, ei.Order, ei.SelectSQL); } return((T)(object)new SelectedDataSets(Repository, config, eds, null)); } if (typeof(T) == typeof(ReleaseLog)) { var file = Path.Combine(TestContext.CurrentContext.TestDirectory, "myDataset.csv"); File.WriteAllText(file, "omg rows"); var sds = WhenIHaveA <SelectedDataSets>(); new CumulativeExtractionResults(Repository, sds.ExtractionConfiguration, sds.ExtractableDataSet, "SELECT * FROM ANYWHERE"); var potential = new FlatFileReleasePotential(new RepositoryProvider(Repository), sds); return((T)(object)new ReleaseLog(Repository, potential, new ReleaseEnvironmentPotential(sds.ExtractionConfiguration), false, new DirectoryInfo(TestContext.CurrentContext.TestDirectory), new FileInfo(file))); } if (typeof(T) == typeof(ExtractableDataSetPackage)) { return((T)(object)new ExtractableDataSetPackage(Repository, "My Cool Package")); } if (typeof(T) == typeof(SupplementalExtractionResults)) { return((T)(object)new SupplementalExtractionResults(Repository, WhenIHaveA <CumulativeExtractionResults>(), "Select * from Lookup", WhenIHaveA <SupportingSQLTable>())); } if (typeof(T) == typeof(SelectedDataSetsForcedJoin)) { return((T)(object)new SelectedDataSetsForcedJoin(Repository, WhenIHaveA <SelectedDataSets>(), WhenIHaveA <TableInfo>())); } if (typeof(T) == typeof(ProjectCohortIdentificationConfigurationAssociation)) { return((T)(object)new ProjectCohortIdentificationConfigurationAssociation(Repository, WhenIHaveA <Project>(), WhenIHaveA <CohortIdentificationConfiguration>())); } if (typeof(T) == typeof(ExternalCohortTable)) { return(Save((T)(object)new ExternalCohortTable(Repository, "My cohorts", DatabaseType.MicrosoftSQLServer) { Database = "MyCohortsDb", DefinitionTableForeignKeyField = "c_id", PrivateIdentifierField = "priv", ReleaseIdentifierField = "rel", TableName = "Cohorts", DefinitionTableName = "InventoryTable", Server = "localhost\\sqlexpress" })); } if (typeof(T) == typeof(ExtractableCohort)) { throw new NotSupportedException("You should inherit from TestsRequiringACohort instead, cohorts have to exist to be constructed"); } if (typeof(T) == typeof(GlobalExtractionFilterParameter)) { return((T)(object)new GlobalExtractionFilterParameter(Repository, WhenIHaveA <ExtractionConfiguration>(), "DECLARE @ExtractionGlobal as varchar(100)")); } if (typeof(T) == typeof(ExtractableColumn)) { var ei = WhenIHaveA <ExtractionInformation>(); var eds = new ExtractableDataSet(Repository, ei.CatalogueItem.Catalogue); var config = WhenIHaveA <ExtractionConfiguration>(); config.AddDatasetToConfiguration(eds); return((T)(object)config.GetAllExtractableColumnsFor(eds).Single()); } if (typeof(T) == typeof(FilterContainer)) { var sds = WhenIHaveA <SelectedDataSets>(); var container = new FilterContainer(Repository, FilterContainerOperation.AND); sds.RootFilterContainer_ID = container.ID; sds.SaveToDatabase(); return((T)(object)container); } if (typeof(T) == typeof(DeployedExtractionFilter)) { var container = WhenIHaveA <FilterContainer>(); return((T)(object)new DeployedExtractionFilter(Repository, "Fish = 'haddock'", container)); } if (typeof(T) == typeof(DeployedExtractionFilterParameter)) { var filter = WhenIHaveA <DeployedExtractionFilter>(); filter.WhereSQL = "@had = 'enough'"; return((T)(object)filter.GetFilterFactory().CreateNewParameter(filter, "DECLARE @had as varchar(100)")); } if (typeof(T) == typeof(ExtractionProgress)) { var cata = new Catalogue(Repository, "MyCata"); var cataItem = new CatalogueItem(Repository, cata, "MyCol"); var table = new TableInfo(Repository, "MyTable"); var col = new ColumnInfo(Repository, "mycol", "datetime", table); var ei = new ExtractionInformation(Repository, cataItem, col, "mycol"); cata.TimeCoverage_ExtractionInformation_ID = ei.ID; cata.SaveToDatabase(); var eds = new ExtractableDataSet(Repository, cata); var project = new Project(Repository, "My Proj"); var config = new ExtractionConfiguration(Repository, project); var sds = new SelectedDataSets(Repository, config, eds, null); return((T)(object)new ExtractionProgress(Repository, sds)); } throw new TestCaseNotWrittenYetException(typeof(T)); }
public ExecuteCommandAddDatasetsToConfiguration(IBasicActivateItems itemActivator, ExtractableDataSet extractableDataSet, ExtractionConfiguration targetExtractionConfiguration) : this(itemActivator, targetExtractionConfiguration) { SetExtractableDataSets(false, extractableDataSet); }
public void ExtractableColumnTest() { ExtractableDataSet dataSet = null; ExtractionConfiguration configuration = null; Project project = null; Catalogue cata = null; CatalogueItem cataItem = null; ColumnInfo column = null; TableInfo table = null; ExtractionInformation extractionInformation = null; ExtractableColumn extractableColumn = null; try { //setup catalogue side of things cata = new Catalogue(CatalogueRepository, "unit_test_ExtractableColumnTest_Cata"); cataItem = new CatalogueItem(CatalogueRepository, cata, "unit_test_ExtractableColumnTest_CataItem"); table = new TableInfo(CatalogueRepository, "DaveTable"); column = new ColumnInfo(CatalogueRepository, "Name", "string", table); cataItem.SetColumnInfo(column); extractionInformation = new ExtractionInformation(CatalogueRepository, cataItem, column, "Hashme(Name)"); //setup extractor side of things dataSet = new ExtractableDataSet(DataExportRepository, cata); project = new Project(DataExportRepository, "unit_test_ExtractableColumnTest_Proj"); configuration = new ExtractionConfiguration(DataExportRepository, project); extractableColumn = new ExtractableColumn(DataExportRepository, dataSet, configuration, extractionInformation, 0, "Hashme2(Name)"); Assert.AreEqual(configuration.GetAllExtractableColumnsFor(dataSet).Length, 1); } finally { if (extractionInformation != null) { extractionInformation.DeleteInDatabase(); } if (column != null) { column.DeleteInDatabase(); } if (table != null) { table.DeleteInDatabase(); } if (cataItem != null) { cataItem.DeleteInDatabase(); } if (configuration != null) { configuration.DeleteInDatabase(); } if (project != null) { project.DeleteInDatabase(); } if (dataSet != null) { dataSet.DeleteInDatabase(); } if (cata != null) { cata.DeleteInDatabase(); } } }
public ExtractableDataSetCombineable(ExtractableDataSet extractableDataSet) { ExtractableDataSets = new ExtractableDataSet[] { extractableDataSet }; }
internal void Create(DiscoveredDatabase db, ICheckNotifier notifier, PlatformDatabaseCreationOptions options) { if (db.Exists()) { if (options.DropDatabases) { db.Drop(); } else { throw new Exception("Database " + db.GetRuntimeName() + " already exists and allowDrop option was not specified"); } } notifier.OnCheckPerformed(new CheckEventArgs("About to create " + db.GetRuntimeName(), CheckResult.Success)); //create a new database for the datasets db.Create(); notifier.OnCheckPerformed(new CheckEventArgs("Succesfully created " + db.GetRuntimeName(), CheckResult.Success)); //fixed seed so everyone gets the same datasets var r = new Random(options.Seed); notifier.OnCheckPerformed(new CheckEventArgs("Generating people", CheckResult.Success)); //people var people = new PersonCollection(); people.GeneratePeople(options.NumberOfPeople, r); //datasets var biochem = ImportCatalogue(Create <Biochemistry>(db, people, r, notifier, options.NumberOfRowsPerDataset, "chi", "Healthboard", "SampleDate", "TestCode")); var demography = ImportCatalogue(Create <Demography>(db, people, r, notifier, options.NumberOfRowsPerDataset, "chi", "dtCreated", "hb_extract")); var prescribing = ImportCatalogue(Create <Prescribing>(db, people, r, notifier, options.NumberOfRowsPerDataset, "chi", "PrescribedDate", "Name")); //<- this is slooo! var admissions = ImportCatalogue(Create <HospitalAdmissions>(db, people, r, notifier, options.NumberOfRowsPerDataset, "chi", "AdmissionDate")); //Create but do not import the CarotidArteryScan dataset so that users can test out referencing a brand new table Create <CarotidArteryScan>(db, people, r, notifier, options.NumberOfRowsPerDataset, "RECORD_NUMBER"); //the following should not be extractable ForExtractionInformations(demography, e => e.DeleteInDatabase(), "chi_num_of_curr_record", "surname", "forename", "current_address_L1", "current_address_L2", "current_address_L3", "current_address_L4", "birth_surname", "previous_surname", "midname", "alt_forename", "other_initials", "previous_address_L1", "previous_address_L2", "previous_address_L3", "previous_address_L4", "previous_postcode", "date_address_changed", "adr", "previous_gp_accept_date", "hic_dataLoadRunID"); //the following should be special approval only ForExtractionInformations(demography, e => { e.ExtractionCategory = ExtractionCategory.SpecialApprovalRequired; e.SaveToDatabase(); }, "current_postcode", "current_gp", "previous_gp", "date_of_birth"); CreateAdmissionsViews(db); var vConditions = ImportCatalogue(db.ExpectTable("vConditions", null, TableType.View)); var vOperations = ImportCatalogue(db.ExpectTable("vOperations", null, TableType.View)); CreateGraph(biochem, "Test Codes", "TestCode", false, null); CreateGraph(biochem, "Test Codes By Date", "SampleDate", true, "TestCode"); CreateFilter(biochem, "Creatinine", "TestCode", "TestCode like '%CRE%'", @"Serum creatinine is a blood measurement. It is an indicator of renal health."); CreateFilter(biochem, "Test Code", "TestCode", "TestCode like @code", "Filters any test code set"); CreateExtractionInformation(demography, "Age", "date_of_birth", "FLOOR(DATEDIFF(DAY, date_of_birth, GETDATE()) / 365.25) As Age"); var fAge = CreateFilter(demography, "Older at least x years", "Age", "FLOOR(DATEDIFF(DAY, date_of_birth, GETDATE()) / 365.25) >= @age", "Patients age is greater than or equal to the provided @age"); SetParameter(fAge, "@age", "int", "16"); CreateGraph(demography, "Patient Ages", "Age", false, null); CreateGraph(prescribing, "Approved Name", "ApprovedName", false, null); CreateGraph(prescribing, "Approved Name Over Time", "PrescribedDate", true, "ApprovedName"); CreateGraph(prescribing, "Bnf", "FormattedBnfCode", false, null); CreateGraph(prescribing, "Bnf Over Time", "PrescribedDate", true, "FormattedBnfCode"); CreateFilter( CreateGraph(vConditions, "Conditions frequency", "Field", false, "Condition"), "Common Conditions Only", @"(Condition in (select top 40 Condition from vConditions c WHERE Condition <> 'NULL' AND Condition <> 'Nul' group by Condition order by count(*) desc))"); CreateFilter( CreateGraph(vOperations, "Operation frequency", "Field", false, "Operation"), "Common Operation Only", @"(Operation in (select top 40 Operation from vOperations c WHERE Operation <> 'NULL' AND Operation <> 'Nul' group by Operation order by count(*) desc))"); //group these all into the same folder admissions.Folder = new CatalogueFolder(admissions, @"\admissions"); admissions.SaveToDatabase(); vConditions.Folder = new CatalogueFolder(vConditions, @"\admissions"); vConditions.SaveToDatabase(); vOperations.Folder = new CatalogueFolder(vOperations, @"\admissions"); vOperations.SaveToDatabase(); var cmdCreateCohortTable = new ExecuteCommandCreateNewCohortStore(_activator, db, false, "chi", "varchar(10)"); cmdCreateCohortTable.Execute(); var externalCohortTable = cmdCreateCohortTable.Created; //Find the pipeline for committing cohorts var cohortCreationPipeline = _repos.CatalogueRepository.GetAllObjects <Pipeline>().FirstOrDefault(p => p?.Source?.Class == typeof(CohortIdentificationConfigurationSource).FullName); if (cohortCreationPipeline == null) { throw new Exception("Could not find a cohort committing pipeline"); } //A cohort creation query var f = CreateFilter(vConditions, "Lung Cancer Condition", "Condition", "Condition like 'C349'", "ICD-10-CM Diagnosis Code C34.9 Malignant neoplasm of unspecified part of bronchus or lung"); var cic = CreateCohortIdentificationConfiguration((ExtractionFilter)f); var cohort = CommitCohortToNewProject(cic, externalCohortTable, cohortCreationPipeline, "Lung Cancer Project", "P1 Lung Cancer Patients", 123, out Project project); var cohortTable = cohort.ExternalCohortTable.DiscoverCohortTable(); using (var con = cohortTable.Database.Server.GetConnection()) { con.Open(); //delete half the records (so we can simulate cohort refresh) using (var cmd = cohortTable.Database.Server.GetCommand(string.Format("DELETE TOP (10) PERCENT from {0}", cohortTable.GetFullyQualifiedName()), con)) cmd.ExecuteNonQuery(); } var ec1 = CreateExtractionConfiguration(project, cohort, "First Extraction (2016 - project 123)", true, notifier, biochem, prescribing, demography); var ec2 = CreateExtractionConfiguration(project, cohort, "Project 123 - 2017 Refresh", true, notifier, biochem, prescribing, demography, admissions); var ec3 = CreateExtractionConfiguration(project, cohort, "Project 123 - 2018 Refresh", true, notifier, biochem, prescribing, demography, admissions); ReleaseAllConfigurations(notifier, ec1, ec2, ec3); if (options.Nightmare) { //Lots of datasets for (int i = 0; i < 1000; i++) { var cata = new Catalogue(_repos.CatalogueRepository, $"Catalogue {i}"); var eds = new ExtractableDataSet(_repos.DataExportRepository, cata); var ti = new TableInfo(_repos.CatalogueRepository, $"[MyDb].[Table{i}]"); for (int j = 0; j < 40; j++) { var col = new ColumnInfo(_repos.CatalogueRepository, $"MyCol{j}", "varchar(10)", ti); var ci = new CatalogueItem(_repos.CatalogueRepository, cata, col.Name); new ExtractionInformation(_repos.CatalogueRepository, ci, col, col.Name); } Project p = new Project(_repos.DataExportRepository, $"Project {i}"); for (int j = 0; j < 20; j++) { var config = new ExtractionConfiguration(_repos.DataExportRepository, p); new SelectedDataSets(_repos.DataExportRepository, config, eds, null); } } } }
public ExtractableDataSetCommand(ExtractableDataSet extractableDataSet) { ExtractableDataSets = new ExtractableDataSet[] { extractableDataSet }; }