Exemplo n.º 1
0
        public void TestSuiteCreation(DatabaseType dbType)
        {
            var db = GetCleanedServer(dbType);

            var template = Path.Combine(TestContext.CurrentContext.WorkDirectory, "CT.it");

            File.WriteAllText(template, TemplateYaml);

            var cmd = new ExecuteCommandCreateNewImagingDatasetSuite(RepositoryLocator, db,
                                                                     new DirectoryInfo(TestContext.CurrentContext.WorkDirectory),
                                                                     typeof(DicomFileCollectionSource),
                                                                     "CT_",
                                                                     new FileInfo(template),
                                                                     persistentRaw: false,
                                                                     createLoad: true);

            Assert.IsFalse(cmd.IsImpossible);

            cmd.Execute();

            Assert.IsNotNull(cmd.NewLoadMetadata);

            var pipelineCreated = RepositoryLocator.CatalogueRepository.GetAllObjects <Pipeline>().OrderByDescending(p => p.ID).First();

            Assert.AreEqual(typeof(DicomFileCollectionSource), pipelineCreated.Source.GetClassAsSystemType());

            var argFieldMap = pipelineCreated.Source.GetAllArguments().Single(a => a.Name.Equals(nameof(DicomSource.UseAllTableInfoInLoadAsFieldMap)));

            Assert.IsNotNull(argFieldMap);
            Assert.AreEqual(argFieldMap.GetValueAsSystemType(), cmd.NewLoadMetadata);
        }
Exemplo n.º 2
0
        private void CreateSuite(ImageTableTemplateCollection template)
        {
            var db = serverDatabaseTableSelector1.GetDiscoveredDatabase();

            if (!CreateDatabaseIfNotExists(db))
            {
                return;
            }


            DirectoryInfo dir = null;

            using (FolderBrowserDialog dialog = new FolderBrowserDialog
            {
                Description = "Select Project Directory (For Sql scripts/Executables etc)"
            })
            {
                //if we are creating a load we need to know where to store load scripts etc
                if (cbCreateLoad.Checked)
                {
                    if (dialog.ShowDialog() == DialogResult.OK)
                    {
                        dir = new DirectoryInfo(dialog.SelectedPath);
                    }
                    else
                    {
                        return;
                    }
                }
            }

            var cmd = new ExecuteCommandCreateNewImagingDatasetSuite(_activator.RepositoryLocator, db, dir)
            {
                DicomSourceType = rbJsonSources.Checked
                    ? typeof(DicomDatasetCollectionSource)
                    : typeof(DicomFileCollectionSource),
                CreateCoalescer = cbMergeNullability.Checked,
                CreateLoad      = cbCreateLoad.Checked,
                TablePrefix     = tbPrefix.Text,
                Template        = template
            };

            cmd.Execute();

            var firstCata = cmd.NewCataloguesCreated.First();

            if (firstCata != null)
            {
                _activator.Publish(firstCata);
            }

            MessageBox.Show("Create Suite Completed");
        }
Exemplo n.º 3
0
        public void SetupSuite(DiscoveredDatabase databaseToCreateInto, IRDMPPlatformRepositoryServiceLocator repositoryLocator, GlobalOptions globalOptions, Type pipelineDicomSourceType, string root = null, ImageTableTemplateCollection template = null, bool persistentRaw = false, string modalityPrefix = null)
        {
            ImageTable  = databaseToCreateInto.ExpectTable(modalityPrefix + "ImageTable");
            SeriesTable = databaseToCreateInto.ExpectTable(modalityPrefix + "SeriesTable");
            StudyTable  = databaseToCreateInto.ExpectTable(modalityPrefix + "StudyTable");

            try
            {
                File.Copy(typeof(InvalidDataHandling).Assembly.Location, Path.Combine(TestContext.CurrentContext.TestDirectory, "Rdmp.Dicom.dll"), true);
            }
            catch (System.IO.IOException)
            {
                //nevermind, it's probably locked
            }


            //The Rdmp.Dicom assembly should be loaded as a plugin, this simulates it.
            foreach (var type in typeof(InvalidDataHandling).Assembly.GetTypes())
            {
                repositoryLocator.CatalogueRepository.MEF.AddTypeToCatalogForTesting(type);
            }


            ICatalogueRepository  catalogueRepository  = repositoryLocator.CatalogueRepository;
            IDataExportRepository dataExportRepository = repositoryLocator.DataExportRepository;

            foreach (var t in new[] { ImageTable, SeriesTable, StudyTable })
            {
                if (t.Exists())
                {
                    t.Drop();
                }
            }

            var suite = new ExecuteCommandCreateNewImagingDatasetSuite(repositoryLocator, databaseToCreateInto, new DirectoryInfo(TestContext.CurrentContext.TestDirectory));

            suite.Template = template ?? GetDefaultTemplate(databaseToCreateInto.Server.DatabaseType);

            suite.PersistentRaw = persistentRaw;
            suite.TablePrefix   = modalityPrefix;

            suite.DicomSourceType = pipelineDicomSourceType;
            suite.CreateCoalescer = true;

            suite.Execute();
            DicomSourcePipelineComponent = suite.DicomSourcePipelineComponent; //store the component created so we can inject/adjust the arguments e.g. adding ElevationRequests to it

            LoadMetadata = suite.NewLoadMetadata;


            var tableInfos = LoadMetadata.GetAllCatalogues().SelectMany(c => c.GetTableInfoList(false)).Distinct().ToArray();

            ImageTableInfo  = (TableInfo)tableInfos.Single(t => t.GetRuntimeName().Equals(ImageTable.GetRuntimeName()));
            SeriesTableInfo = (TableInfo)tableInfos.Single(t => t.GetRuntimeName().Equals(SeriesTable.GetRuntimeName()));
            StudyTableInfo  = (TableInfo)tableInfos.Single(t => t.GetRuntimeName().Equals(StudyTable.GetRuntimeName()));

            // Override the options with stuff coming from Core RDMP DatabaseTests (TestDatabases.txt)
            globalOptions.FileSystemOptions.FileSystemRoot = root ?? TestContext.CurrentContext.TestDirectory;

            globalOptions.RDMPOptions.CatalogueConnectionString  = ((TableRepository)catalogueRepository).DiscoveredServer.Builder.ConnectionString;
            globalOptions.RDMPOptions.DataExportConnectionString = ((TableRepository)dataExportRepository).DiscoveredServer.Builder.ConnectionString;

            globalOptions.DicomRelationalMapperOptions.LoadMetadataId               = LoadMetadata.ID;
            globalOptions.DicomRelationalMapperOptions.MinimumBatchSize             = 1;
            globalOptions.DicomRelationalMapperOptions.UseInsertIntoForRAWMigration = true;

            //Image table now needs all the UIDs in order to be extractable
            var adder = new TagColumnAdder("StudyInstanceUID", "varchar(100)", ImageTableInfo, new AcceptAllCheckNotifier());

            adder.Execute();
        }