public void CreateTask() { _lmd = new LoadMetadata(CatalogueRepository); _dir = new DirectoryInfo(Path.Combine(TestContext.CurrentContext.TestDirectory, "ProcessTaskCheckingTests")); _dir.Create(); var hicdir = LoadDirectory.CreateDirectoryStructure(_dir, "ProjDir", true); _lmd.LocationOfFlatFiles = hicdir.RootPath.FullName; _lmd.SaveToDatabase(); Catalogue c = new Catalogue(CatalogueRepository, "c"); CatalogueItem ci = new CatalogueItem(CatalogueRepository, c, "ci"); TableInfo t = new TableInfo(CatalogueRepository, "t"); t.Server = DiscoveredServerICanCreateRandomDatabasesAndTablesOn.Name; t.Database = "mydb"; t.SaveToDatabase(); ColumnInfo col = new ColumnInfo(CatalogueRepository, "col", "bit", t); ci.SetColumnInfo(col); c.LoadMetadata_ID = _lmd.ID; c.SaveToDatabase(); _task = new ProcessTask(CatalogueRepository, _lmd, LoadStage.GetFiles); _checker = new ProcessTaskChecks(_lmd); }
public void Check(ICheckNotifier notifier) { var catalogueLoadChecks = new CatalogueLoadChecks(LoadMetadata, _loadConfigurationFlags, _databaseConfiguration); var metadataLoggingConfigurationChecks = new MetadataLoggingConfigurationChecks(LoadMetadata); var processTaskChecks = new ProcessTaskChecks(LoadMetadata); var preExecutionChecks = new PreExecutionChecker(LoadMetadata, _databaseConfiguration); _mef.CheckForVersionMismatches(notifier); //If the load is a progressable (loaded over time) then make sure any associated caches are compatible with the load ProcessTasks foreach (ILoadProgress loadProgress in LoadMetadata.LoadProgresses) { loadProgress.Check(notifier); var cp = loadProgress.CacheProgress; if (cp != null) { try { var f = new CacheLayoutFactory(); f.CreateCacheLayout(loadProgress, LoadMetadata); } catch (Exception e) { notifier.OnCheckPerformed(new CheckEventArgs("Load contains a CacheProgress '" + cp + "' but we were unable to generate an ICacheLayout, see Inner Exception for details", CheckResult.Fail, e)); } } } //Make sure there are some load tasks and they are valid processTaskChecks.Check(notifier); try { metadataLoggingConfigurationChecks.Check(notifier); preExecutionChecks.Check(notifier); if (!preExecutionChecks.HardFail) { catalogueLoadChecks.Check(notifier); } } catch (Exception e) { notifier.OnCheckPerformed(new CheckEventArgs("Entire check process crashed in an unexpected way", CheckResult.Fail, e)); } }
public void IntegrationTest_HappyPath_WithIsolation(DatabaseType databaseType, Type namerType) { var server = GetCleanedServer(databaseType, ScratchDatabaseName); SetupSuite(server, false, "MR_"); //this ensures that the ExtractionConfiguration.ID and Project.ID properties are out of sync (they are automnums). Its just a precaution since we are using both IDs in places if we //had any bugs where we used the wrong one but they were the same then it would be obscured until production var p = new Project(DataExportRepository, "delme"); p.DeleteInDatabase(); _globals.DicomRelationalMapperOptions.Guid = new Guid("fc229fc3-f700-4515-86e8-e3d38b3d1823"); _globals.DicomRelationalMapperOptions.QoSPrefetchCount = 5000; _globals.DicomRelationalMapperOptions.MinimumBatchSize = 3; _globals.DicomRelationalMapperOptions.DatabaseNamerType = namerType.FullName; _helper.TruncateTablesIfExists(); //Create test directory with a single image var dir = new DirectoryInfo(Path.Combine(TestContext.CurrentContext.TestDirectory, nameof(IntegrationTest_HappyPath_WithIsolation))); dir.Create(); var ptIsolation = new ProcessTask(CatalogueRepository, _helper.LoadMetadata, LoadStage.AdjustRaw); ptIsolation.CreateArgumentsForClassIfNotExists <PrimaryKeyCollisionIsolationMutilation>(); ptIsolation.Path = typeof(PrimaryKeyCollisionIsolationMutilation).FullName; ptIsolation.ProcessTaskType = ProcessTaskType.MutilateDataTable; ptIsolation.SaveToDatabase(); var arg1 = _helper.LoadMetadata.ProcessTasks.SelectMany(a => a.ProcessTaskArguments).Single(a => a.Name.Equals("TablesToIsolate")); arg1.SetValue(new[] { _helper.StudyTableInfo, _helper.SeriesTableInfo, _helper.ImageTableInfo }); arg1.SaveToDatabase(); var db = new ExternalDatabaseServer(CatalogueRepository, "IsolationDatabase(live)", null); db.SetProperties(server); var arg2 = _helper.LoadMetadata.ProcessTasks.SelectMany(a => a.ProcessTaskArguments).Single(a => a.Name.Equals("IsolationDatabase")); arg2.SetValue(db); arg2.SaveToDatabase(); var arg3 = _helper.LoadMetadata.ProcessTasks.SelectMany(a => a.ProcessTaskArguments).Single(a => a.Name.Equals("ModalityMatchingRegex")); arg3.SetValue(new Regex("([A-z]*)_.*$")); arg3.SaveToDatabase(); //build the joins new JoinInfo(CatalogueRepository, _helper.ImageTableInfo.ColumnInfos.Single(c => c.GetRuntimeName().Equals("SeriesInstanceUID")), _helper.SeriesTableInfo.ColumnInfos.Single(c => c.GetRuntimeName().Equals("SeriesInstanceUID")), ExtractionJoinType.Right, null); new JoinInfo(CatalogueRepository, _helper.SeriesTableInfo.ColumnInfos.Single(c => c.GetRuntimeName().Equals("StudyInstanceUID")), _helper.StudyTableInfo.ColumnInfos.Single(c => c.GetRuntimeName().Equals("StudyInstanceUID")), ExtractionJoinType.Right, null); //start with Study table _helper.StudyTableInfo.IsPrimaryExtractionTable = true; _helper.StudyTableInfo.SaveToDatabase(); //clean up the directory foreach (FileInfo f in dir.GetFiles()) { f.Delete(); } TestData.Create(new FileInfo(Path.Combine(dir.FullName, "MyTestFile.dcm"))); var ds1 = new DicomDataset(); ds1.Add(DicomTag.StudyInstanceUID, "1.2.3"); ds1.Add(DicomTag.SeriesInstanceUID, "1.2.2"); ds1.Add(DicomTag.SOPInstanceUID, "1.2.3"); ds1.Add(DicomTag.PatientAge, "030Y"); ds1.Add(DicomTag.PatientID, "123"); ds1.Add(DicomTag.SOPClassUID, "1"); ds1.Add(DicomTag.Modality, "MR"); new DicomFile(ds1).Save(Path.Combine(dir.FullName, "abc.dcm")); var ds2 = new DicomDataset(); ds2.Add(DicomTag.StudyInstanceUID, "1.2.3"); ds2.Add(DicomTag.SeriesInstanceUID, "1.2.4"); ds2.Add(DicomTag.SOPInstanceUID, "1.2.7"); ds2.Add(DicomTag.PatientAge, "040Y"); //age is replicated but should be unique at study level so gets isolated ds2.Add(DicomTag.PatientID, "123"); ds2.Add(DicomTag.SOPClassUID, "1"); ds2.Add(DicomTag.Modality, "MR"); new DicomFile(ds2).Save(Path.Combine(dir.FullName, "def.dcm")); var checks = new ProcessTaskChecks(_helper.LoadMetadata); checks.Check(new AcceptAllCheckNotifier()); RunTest(dir, 1); Assert.AreEqual(1, _helper.ImageTable.GetRowCount()); var isoTable = server.ExpectTable(_helper.ImageTable.GetRuntimeName() + "_Isolation"); Assert.AreEqual(2, isoTable.GetRowCount()); }