public override void Execute() { base.Execute(); _extractionConfiguration.IsReleased = true; _extractionConfiguration.SaveToDatabase(); Publish(_extractionConfiguration); }
public override void Execute() { base.Execute(); _targetExtractionConfiguration.Cohort_ID = _sourceExtractableCohortComand.Cohort.ID; _targetExtractionConfiguration.SaveToDatabase(); Publish(_targetExtractionConfiguration); }
void tcRequest_TicketTextChanged(object sender, EventArgs e) { if (_extractionConfiguration == null) { return; } //don't change if it is already that if (_extractionConfiguration.RequestTicket != null && _extractionConfiguration.RequestTicket.Equals(tcRequest.TicketText)) { return; } _extractionConfiguration.RequestTicket = tcRequest.TicketText; _extractionConfiguration.SaveToDatabase(); }
private ExtractionConfiguration CreateExtractionConfiguration(Project project, ExtractableCohort cohort, string name, bool isReleased, ICheckNotifier notifier, params Catalogue[] catalogues) { var extractionConfiguration = new ExtractionConfiguration(_repos.DataExportRepository, project); extractionConfiguration.Name = name; extractionConfiguration.Cohort_ID = cohort.ID; extractionConfiguration.SaveToDatabase(); foreach (var c in catalogues) { //Get it's extractableness var eds = _repos.DataExportRepository.GetAllObjectsWithParent <ExtractableDataSet>(c).SingleOrDefault() ?? new ExtractableDataSet(_repos.DataExportRepository, c); //or make it extractable extractionConfiguration.AddDatasetToConfiguration(eds); } var extractionPipeline = _repos.CatalogueRepository.GetAllObjects <Pipeline>().FirstOrDefault(p => p?.Destination?.Class == typeof(ExecuteDatasetExtractionFlatFileDestination).FullName); if (isReleased && extractionConfiguration != null) { var optsExtract = new ExtractionOptions() { Pipeline = extractionPipeline.ID, ExtractionConfiguration = extractionConfiguration.ID }; var runnerExtract = new ExtractionRunner(optsExtract); try { runnerExtract.Run(_repos, new ThrowImmediatelyDataLoadEventListener(), notifier, new GracefulCancellationToken()); } catch (Exception ex) { notifier.OnCheckPerformed(new CheckEventArgs("Could not run ExtractionConfiguration (nevermind)", CheckResult.Warning, ex)); } extractionConfiguration.IsReleased = true; extractionConfiguration.SaveToDatabase(); } return(extractionConfiguration); }
public override void Execute() { base.Execute(); if (SelectOne(_compatibleCohorts.Where(c => c.ID != _extractionConfiguration.Cohort_ID).ToList(), out ExtractableCohort selected)) { //clear current one _extractionConfiguration.Cohort_ID = selected.ID; _extractionConfiguration.SaveToDatabase(); Publish(_extractionConfiguration); } }
public override void Execute() { base.Execute(); var dialog = new SelectIMapsDirectlyToDatabaseTableDialog(_compatibleCohorts.Where(c => c.ID != _extractionConfiguration.Cohort_ID), false, false); if (dialog.ShowDialog() == DialogResult.OK) { //clear current one _extractionConfiguration.Cohort_ID = ((ExtractableCohort)dialog.Selected).ID; _extractionConfiguration.SaveToDatabase(); Publish(_extractionConfiguration); } }
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(); }
protected override void SetUp() { base.SetUp(); SetupCatalogueConfigurationEtc(); SetupDataExport(); _configuration.Cohort_ID = _extractableCohort.ID; _configuration.SaveToDatabase(); _request = new ExtractDatasetCommand(_configuration, _extractableCohort, new ExtractableDatasetBundle(_extractableDataSet), _extractableColumns, new HICProjectSalt(_project), new ExtractionDirectory(@"C:\temp\", _configuration)); }
protected override void OneTimeSetUp() { base.OneTimeSetUp(); ProjectDirectory = Path.Combine(TestContext.CurrentContext.WorkDirectory, "TestProject"); SetupCatalogueConfigurationEtc(); SetupDataExport(); _configuration.Cohort_ID = _extractableCohort.ID; _configuration.SaveToDatabase(); _request = new ExtractDatasetCommand(_configuration, _extractableCohort, new ExtractableDatasetBundle(_extractableDataSet), _extractableColumns, new HICProjectSalt(_project), new ExtractionDirectory(ProjectDirectory, _configuration)); }
void mi_ChooseFileSeparator_Click(object sender, EventArgs e) { ExtractionConfiguration toSetDescriptionOn = Activator.RepositoryLocator.DataExportRepository.GetObjectByID <ExtractionConfiguration>(_rightClickedRowExtractionConfigurationID); if (toSetDescriptionOn.IsReleased) { return; } TypeTextOrCancelDialog dialog = new TypeTextOrCancelDialog("Separator", "Choose a character(s) separator", 3, toSetDescriptionOn.Separator); dialog.ShowDialog(this); if (dialog.DialogResult == DialogResult.OK) { toSetDescriptionOn.Separator = dialog.ResultText; toSetDescriptionOn.SaveToDatabase(); RefreshLists(); } }
void mi_SetDescription_Click(object sender, EventArgs e) { ExtractionConfiguration toSetDescriptionOn = Activator.RepositoryLocator.DataExportRepository.GetObjectByID <ExtractionConfiguration>(_rightClickedRowExtractionConfigurationID); if (toSetDescriptionOn.IsReleased) { return; } TypeTextOrCancelDialog dialog = new TypeTextOrCancelDialog("Description", "Enter a Description for the Extraction:", 1000, toSetDescriptionOn.Description); dialog.ShowDialog(this); if (dialog.DialogResult == DialogResult.OK) { toSetDescriptionOn.Description = dialog.ResultText; toSetDescriptionOn.SaveToDatabase(); RefreshLists(); } }
public void Execute() { var engine = Request.GetEngine(_configuration.CohortRefreshPipeline, _listener); //if the refresh pipeline is a cic source var cicSource = engine.SourceObject as CohortIdentificationConfigurationSource; if (cicSource != null) { //a cohort identification configuration is a complex query possibly with many cached subqueries, if we are refreshing the cic we will want to clear (and recache) identifiers //from the live tables cicSource.ClearCohortIdentificationConfigurationCacheBeforeRunning = true; } engine.ExecutePipeline(new GracefulCancellationToken()); var newCohort = Request.CohortCreatedIfAny; if (newCohort != null) { _configuration.Cohort_ID = newCohort.ID; _configuration.SaveToDatabase(); } }
private void btnExecute_Click(object sender, EventArgs e) { Cursor = Cursors.WaitCursor; string problem = AllRequiredDataPresent(); try { if (problem != null) { MessageBox.Show(problem); return; } ragExecute.Reset(); //create the project if (_project == null) { _project = new Project(Activator.RepositoryLocator.DataExportRepository, tbProjectName.Text); } _project.ProjectNumber = int.Parse(tbProjectNumber.Text); _project.ExtractionDirectory = tbExtractionDirectory.Text; if (!Directory.Exists(_project.ExtractionDirectory)) { Directory.CreateDirectory(_project.ExtractionDirectory); } _project.SaveToDatabase(); if (_configuration == null) { _configuration = new ExtractionConfiguration(Activator.RepositoryLocator.DataExportRepository, _project); _configuration.Name = "Cases"; _configuration.SaveToDatabase(); } foreach (ExtractableDataSet ds in _selectedDatasets) { _configuration.AddDatasetToConfiguration(ds); } ICommandExecution cmdAssociateCicWithProject = null; if (_cohortCreated == null && cbDefineCohort.Checked) { var cohortDefinition = new CohortDefinition(null, tbCohortName.Text, 1, _project.ProjectNumber.Value, (ExternalCohortTable)ddCohortSources.SelectedItem); //execute the cohort creation bit var cohortRequest = new CohortCreationRequest(_project, cohortDefinition, (DataExportRepository)Activator.RepositoryLocator.DataExportRepository, tbCohortName.Text); ComboBox dd; if (_cohortFile != null) { //execute cohort creation from file. cohortRequest.FileToLoad = new FlatFileToLoad(_cohortFile); dd = ddFilePipeline; } else { //execute cohort creation from cic cohortRequest.CohortIdentificationConfiguration = (CohortIdentificationConfiguration)cbxCohort.SelectedItem; dd = ddCicPipeline; //since we are about to execute a cic and store the results we should associate it with the Project (if successful) cmdAssociateCicWithProject = new ExecuteCommandAssociateCohortIdentificationConfigurationWithProject(Activator).SetTarget( _project).SetTarget(cohortRequest.CohortIdentificationConfiguration); } var engine = cohortRequest.GetEngine((Pipeline)dd.SelectedItem, new ThrowImmediatelyDataLoadEventListener()); engine.ExecutePipeline(new GracefulCancellationToken()); _cohortCreated = cohortRequest.CohortCreatedIfAny; } if (cbDefineCohort.Checked) { //associate the configuration with the cohort _configuration.Cohort_ID = _cohortCreated.ID; //set the pipeline to use var pipeline = (Pipeline)ddExtractionPipeline.SelectedItem; if (pipeline != null) { _configuration.DefaultPipeline_ID = pipeline.ID; } _configuration.SaveToDatabase(); //User defined cohort if it came from cic then associate the cic with the project if (cmdAssociateCicWithProject != null && !cmdAssociateCicWithProject.IsImpossible) { cmdAssociateCicWithProject.Execute(); } } Cursor = Cursors.Default; ExtractionConfigurationCreatedIfAny = _configuration; DialogResult = DialogResult.OK; MessageBox.Show("Project Created Successfully"); Close(); } catch (Exception exception) { ragExecute.Fatal(exception); } finally { Cursor = Cursors.Default; } }
public void MigrateUsages(bool migrate) { var proj = new Project(DataExportRepository, projName); proj.ProjectNumber = 999; proj.SaveToDatabase(); // we are replacing this imaginary cohort var definition998 = new CohortDefinition(null, "CommittingNewCohorts", 1, 999, _externalCohortTable); // with this one (v2) var definition999 = new CohortDefinition(null, "CommittingNewCohorts", 2, 999, _externalCohortTable); // Create a basic cohort first CohortCreationRequest request1 = new CohortCreationRequest(proj, definition998, (DataExportRepository)DataExportRepository, "fish"); request1.Check(new ThrowImmediatelyCheckNotifier()); using var con = _cohortDatabase.Server.GetManagedConnection(); request1.PushToServer(con); request1.ImportAsExtractableCohort(true, migrate); // the definition was imported and should now be a saved ExtractableCohort var cohort998 = request1.CohortCreatedIfAny; Assert.IsNotNull(cohort998); Assert.IsFalse(cohort998.IsDeprecated); // legit user 1 var ec1 = new ExtractionConfiguration(DataExportRepository, proj) { IsReleased = false, Cohort_ID = cohort998.ID }; ec1.SaveToDatabase(); // legit user 2 var ec2 = new ExtractionConfiguration(DataExportRepository, proj) { IsReleased = false, Cohort_ID = cohort998.ID }; ec2.SaveToDatabase(); // has no cohort yet defined so should not be migrated var ec3 = new ExtractionConfiguration(DataExportRepository, proj); // is frozen so should not be migrated var ec4 = new ExtractionConfiguration(DataExportRepository, proj) { IsReleased = true, Cohort_ID = cohort998.ID }; ec4.SaveToDatabase(); // define that the new definition attempts to replace the old one definition999.CohortReplacedIfAny = cohort998; CohortCreationRequest request2 = new CohortCreationRequest(proj, definition999, (DataExportRepository)DataExportRepository, "fish"); request2.Check(new ThrowImmediatelyCheckNotifier()); request2.PushToServer(con); request2.ImportAsExtractableCohort(true, migrate); // the definition was imported and should now be a saved ExtractableCohort var cohort999 = request2.CohortCreatedIfAny; Assert.IsNotNull(cohort999); // after committing the new cohort who should be migrated? ec1.RevertToDatabaseState(); ec2.RevertToDatabaseState(); ec3.RevertToDatabaseState(); ec4.RevertToDatabaseState(); // should have been updated to use the new cohort Assert.AreEqual(ec1.Cohort_ID, migrate ? cohort999.ID : cohort998.ID); Assert.AreEqual(ec2.Cohort_ID, migrate ? cohort999.ID: cohort998.ID); // should not have magically gotten a cohort Assert.IsNull(ec3.Cohort_ID); // is frozen so should not have been changed to the new cohort (and therefore still use cohort998) Assert.AreEqual(ec4.Cohort_ID, cohort998.ID); }
private void Freeze() { _extractionConfiguration.IsReleased = true; _extractionConfiguration.SaveToDatabase(); Publish(_extractionConfiguration); }