public void AuditLogReFetch_WhenAuditLogIsNull() { var builder = new ExtractableCohortAuditLogBuilder(); var moqCohort = Mock.Of <IExtractableCohort>(e => e.AuditLog == null); Assert.IsNull(builder.GetObjectIfAny(moqCohort, RepositoryLocator)); }
public void AuditLogReFetch_WhenAuditLogIsRubbish() { var builder = new ExtractableCohortAuditLogBuilder(); var moqCohort = Mock.Of <IExtractableCohort>(e => e.AuditLog == "troll doll dur I invented this cohort myself"); Assert.IsNull(builder.GetObjectIfAny(moqCohort, RepositoryLocator)); }
public override void Execute() { if (_extractionIdentifierColumn == null) { var cata = (ICatalogue)BasicActivator.SelectOne("Select Catalogue to create cohort from", BasicActivator.RepositoryLocator.CatalogueRepository.GetAllObjects<Catalogue>()); if (cata == null) return; SetExtractionIdentifierColumn(GetExtractionInformationFromCatalogue(cata)); } base.Execute(); var auditLogBuilder = new ExtractableCohortAuditLogBuilder(); var request = GetCohortCreationRequest(auditLogBuilder.GetDescription(_extractionIdentifierColumn)); //user choose to cancel the cohort creation request dialogue if (request == null) return; request.ExtractionIdentifierColumn = _extractionIdentifierColumn; var configureAndExecute = GetConfigureAndExecuteControl(request, "Import column " + _extractionIdentifierColumn + " as cohort and commmit results"); configureAndExecute.Run(BasicActivator.RepositoryLocator, null, null, null); }
public void AuditLogReFetch_ExtractionInformation() { var builder = new ExtractableCohortAuditLogBuilder(); var ei = WhenIHaveA <ExtractionInformation>(); var desc = builder.GetDescription(ei); var moqCohort = Mock.Of <IExtractableCohort>(e => e.AuditLog == desc); var ei2 = builder.GetObjectIfAny(moqCohort, RepositoryLocator); Assert.IsNotNull(ei2); Assert.IsInstanceOf <ExtractionInformation>(ei2); Assert.AreEqual(ei, ei2); }
public void AuditLogReFetch_CohortIdentificationConfiguration() { var builder = new ExtractableCohortAuditLogBuilder(); var cic = WhenIHaveA <CohortIdentificationConfiguration>(); var desc = builder.GetDescription(cic); var moqCohort = Mock.Of <IExtractableCohort>(e => e.AuditLog == desc); var cic2 = builder.GetObjectIfAny(moqCohort, RepositoryLocator); Assert.IsNotNull(cic2); Assert.IsInstanceOf <CohortIdentificationConfiguration>(cic2); Assert.AreEqual(cic, cic2); }
public void AuditLogReFetch_FileInfo() { var builder = new ExtractableCohortAuditLogBuilder(); var fi = new FileInfo("durdur.txt"); var desc = builder.GetDescription(fi); var moqCohort = Mock.Of <IExtractableCohort>(e => e.AuditLog == desc); var fi2 = builder.GetObjectIfAny(moqCohort, RepositoryLocator); Assert.IsNotNull(fi2); Assert.IsInstanceOf <FileInfo>(fi2); Assert.AreEqual(fi.FullName, ((FileInfo)fi2).FullName); }
public void AuditLogReFetch_WhenSourceIsDeleted() { var builder = new ExtractableCohortAuditLogBuilder(); var ei = WhenIHaveA <ExtractionInformation>(); var desc = builder.GetDescription(ei); var moqCohort = Mock.Of <IExtractableCohort>(e => e.AuditLog == desc); // delete the source ei.DeleteInDatabase(); // should now return null Assert.IsNull(builder.GetObjectIfAny(moqCohort, RepositoryLocator)); }
public override void Execute() { base.Execute(); var cic = _cic; if (cic == null) { cic = (CohortIdentificationConfiguration)BasicActivator.SelectOne("Select Cohort Builder Query", BasicActivator.GetAll <CohortIdentificationConfiguration>().ToArray()); } if (cic == null) { return; } if (Project == null && BasicActivator.CoreChildProvider is DataExportChildProvider dx) { var projAssociations = dx.AllProjectAssociatedCics.Where(c => c.CohortIdentificationConfiguration_ID == cic.ID).ToArray(); if (projAssociations.Length == 1) { Project = projAssociations[0].Project; } } var auditLogBuilder = new ExtractableCohortAuditLogBuilder(); var request = GetCohortCreationRequest(auditLogBuilder.GetDescription(cic)); //user choose to cancel the cohort creation request dialogue if (request == null) { return; } request.CohortIdentificationConfiguration = cic; var configureAndExecute = GetConfigureAndExecuteControl(request, "Execute CIC " + cic + " and commmit results"); configureAndExecute.PipelineExecutionFinishedsuccessfully += (s, u) => OnImportCompletedSuccessfully(s, u, cic); configureAndExecute.Run(BasicActivator.RepositoryLocator, null, null, null); }
private ExtractableCohort CommitCohortToNewProject(CohortIdentificationConfiguration cic, ExternalCohortTable externalCohortTable, IPipeline cohortCreationPipeline, string projectName, string cohortName, int projectNumber, out Project project) { //create a new data extraction Project project = new Project(_repos.DataExportRepository, projectName); project.ProjectNumber = projectNumber; project.ExtractionDirectory = Path.GetTempPath(); project.SaveToDatabase(); //create a cohort var auditLogBuilder = new ExtractableCohortAuditLogBuilder(); var request = new CohortCreationRequest(project, new CohortDefinition(null, cohortName, 1, projectNumber, externalCohortTable), _repos.DataExportRepository, auditLogBuilder.GetDescription(cic)); request.CohortIdentificationConfiguration = cic; var engine = request.GetEngine(cohortCreationPipeline, new ThrowImmediatelyDataLoadEventListener()); engine.ExecutePipeline(new GracefulCancellationToken()); return(request.CohortCreatedIfAny); }
public override void Execute() { base.Execute(); FlatFileToLoad flatFile; //if no explicit file has been chosen if (_file == null) { var file = BasicActivator.SelectFile("Cohort file"); //get user to pick one if (file == null) { return; } flatFile = new FlatFileToLoad(file); } else { flatFile = new FlatFileToLoad(_file); } var auditLogBuilder = new ExtractableCohortAuditLogBuilder(); var request = GetCohortCreationRequest(auditLogBuilder.GetDescription(flatFile.File)); //user choose to cancel the cohort creation request dialogue if (request == null) { return; } request.FileToLoad = flatFile; var configureAndExecuteDialog = GetConfigureAndExecuteControl(request, "Uploading File " + flatFile.File.Name); //add the flat file to the dialog with an appropriate description of what they are trying to achieve configureAndExecuteDialog.Run(BasicActivator.RepositoryLocator, null, null, null); }