public DeployedExtractionFilterUIOptions(DeployedExtractionFilter deployedExtractionFilter) : base(deployedExtractionFilter) { var selectedDataSet = deployedExtractionFilter.GetDataset(); var ds = selectedDataSet.ExtractableDataSet; var c = selectedDataSet.ExtractionConfiguration; _tables = ds.Catalogue.GetTableInfoList(false); _globals = c.GlobalExtractionFilterParameters; List <IColumn> columns = new List <IColumn>(); columns.AddRange(c.GetAllExtractableColumnsFor(ds)); columns.AddRange(c.Project.GetAllProjectCatalogueColumns(ExtractionCategory.ProjectSpecific)); _columns = columns.ToArray(); }
public void TestImportTree_FromSelectedDatasets_ToCohortIdentificationConfiguration() { // Import From Selected Dataset var sds = WhenIHaveA <SelectedDataSets>(); sds.CreateRootContainerIfNotExists(); var filterToImport = new DeployedExtractionFilter(Repository, "MyFilter", (FilterContainer)sds.RootFilterContainer) { WhereSQL = "true" }; filterToImport.SaveToDatabase(); var cata = sds.ExtractableDataSet.Catalogue; // Into an Aggregate Configuration var cic = new CohortIdentificationConfiguration(Repository, "my cic"); cic.CreateRootContainerIfNotExists(); var ac = new AggregateConfiguration(Repository, cata, "myagg"); cic.RootCohortAggregateContainer.AddChild(ac, 1); //there should be no root container Assert.IsNull(ac.RootFilterContainer); //run the command var mgr = new ConsoleInputManager(RepositoryLocator, new ThrowImmediatelyCheckNotifier()); mgr.DisallowInput = true; var cmd = new ExecuteCommandImportFilterContainerTree(mgr, ac, sds); Assert.IsFalse(cmd.IsImpossible, cmd.ReasonCommandImpossible); cmd.Execute(); ac.ClearAllInjections(); Assert.IsNotNull(ac.RootFilterContainer); Assert.AreEqual(1, ac.RootFilterContainer.GetFilters().Length); Assert.AreEqual("MyFilter", ac.RootFilterContainer.GetFilters()[0].Name); Assert.AreEqual("true", ac.RootFilterContainer.GetFilters()[0].WhereSQL); Assert.AreNotEqual(filterToImport.GetType(), ac.RootFilterContainer.GetFilters()[0].GetType()); }
private void AddChildren(DeployedExtractionFilter filter, DescendancyList descendancyList) { AddToDictionaries(new HashSet <object>(_allParameters.Where(p => p.ExtractionFilter_ID == filter.ID)), descendancyList); }
public void Extract_ProjectSpecificCatalogue_FilterReference() { //make the catalogue a custom catalogue for this project CustomExtractableDataSet.Project_ID = _project.ID; CustomExtractableDataSet.SaveToDatabase(); var pipe = SetupPipeline(); pipe.Name = "Extract_ProjectSpecificCatalogue_FilterReference Pipe"; pipe.SaveToDatabase(); var rootContainer = new FilterContainer(DataExportRepository); _selectedDataSet.RootFilterContainer_ID = rootContainer.ID; _selectedDataSet.SaveToDatabase(); var filter = new DeployedExtractionFilter(DataExportRepository, "monkeys only", rootContainer); filter.WhereSQL = "SuperSecretThing = 'monkeys can all secretly fly'"; filter.SaveToDatabase(); rootContainer.AddChild(filter); //get rid of any lingering joins foreach (JoinInfo j in CatalogueRepository.GetAllObjects <JoinInfo>()) { j.DeleteInDatabase(); } //add the ability to join the two tables in the query var idCol = _extractableDataSet.Catalogue.GetAllExtractionInformation(ExtractionCategory.Core).Single(c => c.IsExtractionIdentifier).ColumnInfo; var otherIdCol = CustomCatalogue.GetAllExtractionInformation(ExtractionCategory.ProjectSpecific).Single(e => e.GetRuntimeName().Equals("PrivateID")).ColumnInfo; new JoinInfo(CatalogueRepository, idCol, otherIdCol, ExtractionJoinType.Left, null); new SelectedDataSetsForcedJoin(DataExportRepository, _selectedDataSet, CustomTableInfo); //generate a new request (this will include the newly created column) _request = new ExtractDatasetCommand(_configuration, new ExtractableDatasetBundle(_extractableDataSet)); var tbl = Database.ExpectTable("TestTable"); tbl.Truncate(); using (var blk = tbl.BeginBulkInsert()) { var dt = new DataTable(); dt.Columns.Add("PrivateID"); dt.Columns.Add("Name"); dt.Columns.Add("DateOfBirth"); dt.Rows.Add(new object[] { "Priv_12345", "Bob", "2001-01-01" }); dt.Rows.Add(new object[] { "Priv_wtf11", "Frank", "2001-10-29" }); blk.Upload(dt); } ExtractionPipelineUseCase useCase; IExecuteDatasetExtractionDestination results; Execute(out useCase, out results); var mainDataTableCsv = results.DirectoryPopulated.GetFiles().Single(f => f.Name.Equals("TestTable.csv")); Assert.IsNotNull(mainDataTableCsv); var lines = File.ReadAllLines(mainDataTableCsv.FullName); Assert.AreEqual("ReleaseID,Name,DateOfBirth", lines[0]); Assert.AreEqual("Pub_54321,Bob,2001-01-01", lines[1]); Assert.AreEqual(2, lines.Length); }