/// <summary> /// The user has selected an extractable thing in the catalogue and opted to include it in the extraction /// So we have to convert it to an <see cref="ExtractableColumn"/> (which has configuration specific stuff - and lets /// data analyst override stuff for this extraction only) /// /// <para>Then add it to the right hand list</para> /// </summary> /// <param name="columns"></param> private void Include(params IColumn[] columns) { olvSelected.BeginUpdate(); try { //for each column we are adding foreach (IColumn c in columns) { //make sure it is up to date with database IRevertable r = c as IRevertable; //if the column is out of date if (r != null && r.HasLocalChanges().Evaluation == ChangeDescription.DatabaseCopyDifferent) { r.RevertToDatabaseState();//get a fresh copy } //add to the config ExtractableColumn addMe = _config.AddColumnToExtraction(_dataSet, c); //update on the UI olvSelected.AddObject(addMe); } } finally { olvSelected.EndUpdate(); } RefreshDisabledObjectStatus(); SortSelectedByOrder(); Publish(_config); }
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(); }
/// <summary> /// The user has selected an extractable thing in the catalogue and opted to include it in the extraction /// So we have to convert it to an ExtractableColumn (which has configuration specific stuff - and lets /// data analyst override stuff for this extraction only) /// /// <para>Then add it to the right hand list</para> /// </summary> /// <param name="item"></param> private ExtractableColumn AddColumnToExtraction(IColumn item) { IRevertable r = item as IRevertable; //if the column is out of date if (r != null && r.HasLocalChanges().Evaluation == ChangeDescription.DatabaseCopyDifferent) { r.RevertToDatabaseState();//get a fresh copy } ExtractableColumn addMe = _config.AddColumnToExtraction(_dataSet, item); olvSelected.AddObject(addMe); RefreshDisabledObjectStatus(); SortSelectedByOrder(); return(addMe); }
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); } }