Exemplo n.º 1
0
        public void CreateAndAssociateColumns()
        {
            var cata           = new Catalogue(CatalogueRepository, "MyCat");
            var cataItem       = new CatalogueItem(CatalogueRepository, cata, "MyCataItem");
            var TableInfo      = new TableInfo(CatalogueRepository, "Cata");
            var ColumnInfo     = new ColumnInfo(CatalogueRepository, "Col", "varchar(10)", TableInfo);
            var ExtractionInfo = new ExtractionInformation(CatalogueRepository, cataItem, ColumnInfo, "fish");

            var ds = new ExtractableDataSet(DataExportRepository, cata);

            var proj   = new Project(DataExportRepository, "MyProj");
            var config = new ExtractionConfiguration(DataExportRepository, proj);

            SelectedDataSets selectedDataSets;

            var extractableColumn = new ExtractableColumn(DataExportRepository, ds, config, ExtractionInfo, 1, "fish");

            try
            {
                selectedDataSets = new SelectedDataSets(DataExportRepository, config, ds, null);

                var cols = config.GetAllExtractableColumnsFor(ds);

                Assert.AreEqual(1, cols.Count());
                Assert.AreEqual(extractableColumn, cols.Single());

                cols = config.GetAllExtractableColumnsFor(ds);

                Assert.AreEqual(1, cols.Count());
                Assert.AreEqual(extractableColumn, cols.Single());
            }
            finally
            {
                extractableColumn.DeleteInDatabase();
                config.DeleteInDatabase();
                proj.DeleteInDatabase();

                ds.DeleteInDatabase();

                TableInfo.DeleteInDatabase();
                cata.DeleteInDatabase();
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// The left list contains ExtractionInformation from the Data Catalogue, this is columns in the database which could be extracted
        /// The right list contains ExtractableColumn which is a more advanced class that contains runtime configurations such as order to be outputed in etc.
        /// </summary>
        private void SetupUserInterface()
        {
            //clear the UI
            olvAvailable.ClearObjects();
            olvSelected.ClearObjects();

            //get the catalogue and then all the items
            ICatalogue cata;

            try
            {
                cata = _dataSet.Catalogue;
            }
            catch (Exception e)
            {
                //catalogue has probably been deleted!
                ExceptionViewer.Show("Unable to find Catalogue for ExtractableDataSet", e);
                return;
            }

            //on the left

            HashSet <IColumn> toAdd = new HashSet <IColumn>();

            //add all the extractable columns from the current Catalogue
            foreach (ExtractionInformation e in cata.GetAllExtractionInformation(ExtractionCategory.Any))
            {
                toAdd.Add(e);
            }

            //plus all the Project Specific columns
            foreach (ExtractionInformation e in _config.Project.GetAllProjectCatalogueColumns(ExtractionCategory.ProjectSpecific))
            {
                toAdd.Add(e);
            }

            //add the stuff that is in Project Catalogues so they can pick these too
            olvAvailable.AddObjects(toAdd.ToArray());

            //on the right

            //add the already included ones on the right
            ConcreteColumn[] allExtractableColumns = _config.GetAllExtractableColumnsFor(_dataSet);

            //now get all the ExtractableColumns that are already configured for this configuration (previously)
            olvSelected.AddObjects(allExtractableColumns);

            RefreshDisabledObjectStatus();
        }
Exemplo n.º 3
0
        public void ExtractableColumnTest()
        {
            ExtractableDataSet      dataSet       = null;
            ExtractionConfiguration configuration = null;
            Project project = null;

            Catalogue     cata     = null;
            CatalogueItem cataItem = null;
            ColumnInfo    column   = null;
            TableInfo     table    = null;

            ExtractionInformation extractionInformation = null;
            ExtractableColumn     extractableColumn     = null;

            try
            {
                //setup catalogue side of things
                cata     = new Catalogue(CatalogueRepository, "unit_test_ExtractableColumnTest_Cata");
                cataItem = new CatalogueItem(CatalogueRepository, cata, "unit_test_ExtractableColumnTest_CataItem");
                table    = new TableInfo(CatalogueRepository, "DaveTable");
                column   = new ColumnInfo(CatalogueRepository, "Name", "string", table);
                cataItem.SetColumnInfo(column);

                extractionInformation = new ExtractionInformation(CatalogueRepository, cataItem, column, "Hashme(Name)");

                //setup extractor side of things
                dataSet = new ExtractableDataSet(DataExportRepository, cata);
                project = new Project(DataExportRepository, "unit_test_ExtractableColumnTest_Proj");

                configuration = new ExtractionConfiguration(DataExportRepository, project);

                extractableColumn = new ExtractableColumn(DataExportRepository, dataSet, configuration, extractionInformation, 0, "Hashme2(Name)");
                Assert.AreEqual(configuration.GetAllExtractableColumnsFor(dataSet).Length, 1);
            }
            finally
            {
                if (extractionInformation != null)
                {
                    extractionInformation.DeleteInDatabase();
                }

                if (column != null)
                {
                    column.DeleteInDatabase();
                }

                if (table != null)
                {
                    table.DeleteInDatabase();
                }

                if (cataItem != null)
                {
                    cataItem.DeleteInDatabase();
                }

                if (configuration != null)
                {
                    configuration.DeleteInDatabase();
                }

                if (project != null)
                {
                    project.DeleteInDatabase();
                }

                if (dataSet != null)
                {
                    dataSet.DeleteInDatabase();
                }

                if (cata != null)
                {
                    cata.DeleteInDatabase();
                }
            }
        }