public ParameterCollectionUIOptions Create(ExtractionFilterParameterSet parameterSet)
        {
            var pm = new ParameterManager();

            pm.ParametersFoundSoFarInQueryGeneration[ParameterLevel.TableInfo].AddRange(parameterSet.Values);

            return(new ParameterCollectionUIOptions(UseCaseParameterValueSet, parameterSet, ParameterLevel.TableInfo, pm));
        }
示例#2
0
        private void AddParameterValueSet(ExtractionFilter filter)
        {
            var parameterSet = new ExtractionFilterParameterSet(RepositoryLocator.CatalogueRepository, filter);

            parameterSet.CreateNewValueEntries();
            Publish(filter);
            Activate(parameterSet);
        }
示例#3
0
        public override void Execute()
        {
            base.Execute();

            var parameterSet = new ExtractionFilterParameterSet(BasicActivator.RepositoryLocator.CatalogueRepository, _filter);

            parameterSet.CreateNewValueEntries();
            Publish(_filter);
            Activate(parameterSet);
        }
示例#4
0
        public void GatherAndShare_ExtractionFilter_Test()
        {
            //Setup some objects under Catalogue
            var cata = new Catalogue(CatalogueRepository, "Cata");

            cata.Periodicity = Catalogue.CataloguePeriodicity.BiMonthly;
            cata.SaveToDatabase();

            var catalogueItem1 = new CatalogueItem(CatalogueRepository, cata, "Ci1");

            var tableInfo = new TableInfo(CatalogueRepository, "Myt");
            var colInfo   = new ColumnInfo(CatalogueRepository, "[Mt].[C1]", "varchar(10)", tableInfo);

            catalogueItem1.ColumnInfo_ID = colInfo.ID;
            catalogueItem1.SaveToDatabase();

            //Setup a Filter under this extractable column (the filter is what we will share)
            var ei = new ExtractionInformation(CatalogueRepository, catalogueItem1, colInfo, "UPPER(C1) as Fish");

            var filter = new ExtractionFilter(CatalogueRepository, "My Filter", ei);

            filter.Description = "amagad";
            filter.WhereSQL    = "UPPER(C1) = @a";

            //Give the filter a parameter @a just to make things interesting
            var declaration = filter.GetQuerySyntaxHelper().GetParameterDeclaration("@a", new DatabaseTypeRequest(typeof(string), 1));
            var param       = filter.GetFilterFactory().CreateNewParameter(filter, declaration);

            //Also create a 'known good value' set i.e. recommended value for the parameter to achive some goal (you can have multiple of these - this will not be shared)
            var set = new ExtractionFilterParameterSet(CatalogueRepository, filter, "Fife");
            var val = new ExtractionFilterParameterSetValue(CatalogueRepository, set, (ExtractionFilterParameter)param);

            val.Value = "'FISH'";

            //Gather the dependencies (this is what we are testing)
            var gatherer = new Gatherer(RepositoryLocator);

            Assert.IsTrue(gatherer.CanGatherDependencies(filter));
            var gathered = gatherer.GatherDependencies(filter);

            //gatherer should have gathered the filter and the parameter (but not the ExtractionFilterParameterSet sets)
            Assert.AreEqual(1, gathered.Children.Count);
            Assert.AreEqual(param, gathered.Children[0].Object);

            //Cleanup
            val.DeleteInDatabase();
            set.DeleteInDatabase();
            cata.DeleteInDatabase();
        }
示例#5
0
        public void SetValueTo(ExtractionFilterParameterSet set)
        {
            if (set == null)
            {
                return;
            }

            var correctValue = set.GetAllParameters().FirstOrDefault(p => p.ParameterName.Equals(_parameter.ParameterName));

            if (correctValue == null)
            {
                tbValue.Text = "";
                return;
            }

            tbValue.Text = correctValue.Value;
        }
示例#6
0
        private ExtractionFilter GetFilterWithParameterSet()
        {
            var cata     = new Catalogue(CatalogueRepository, "myCata");
            var cataItem = new CatalogueItem(CatalogueRepository, cata, "MyCol");

            var table = new TableInfo(CatalogueRepository, "myTbl");
            var col   = new ColumnInfo(CatalogueRepository, "myCol", "varchar(10)", table);

            var ei     = new ExtractionInformation(CatalogueRepository, cataItem, col, "[myTbl].[mycol]");
            var filter = new ExtractionFilter(CatalogueRepository, "Age", ei);

            filter.WhereSQL = "Age >= @age";
            new ExtractionFilterParameter(CatalogueRepository, "DECLARE @age int", filter);

            var paramSet = new ExtractionFilterParameterSet(CatalogueRepository, filter, "Old");

            paramSet.CreateNewValueEntries();

            return(filter);
        }
        public void TestExtractionFilterDeleting_WhenItHas_ExtractionFilterParameterSet_Interactive()
        {
            var filter = WhenIHaveA <ExtractionFilter>();

            var set = new ExtractionFilterParameterSet(Repository, filter, "fff");

            Assert.IsTrue(filter.Exists());
            Assert.IsTrue(set.Exists());

            var activator = new TestActivateItems(this, Repository);

            activator.InteractiveDeletes = true;
            activator.YesNoResponse      = true;

            var del = new ExecuteCommandDelete(activator, filter);

            del.Execute();

            Assert.IsFalse(filter.Exists());
            Assert.IsFalse(set.Exists());
        }
示例#8
0
        public void ExtractionFilterParameterSet_Deleting()
        {
            var cata     = new Catalogue(CatalogueRepository, "myCata");
            var cataItem = new CatalogueItem(CatalogueRepository, cata, "MyCol");

            var table = new TableInfo(CatalogueRepository, "myTbl");
            var col   = new ColumnInfo(CatalogueRepository, "myCol", "varchar(10)", table);

            var ei     = new ExtractionInformation(CatalogueRepository, cataItem, col, "[myTbl].[mycol]");
            var filter = new ExtractionFilter(CatalogueRepository, "Age", ei);

            filter.WhereSQL = "Age >= @age";
            new ExtractionFilterParameter(CatalogueRepository, "DECLARE @age int", filter);

            var paramSet = new ExtractionFilterParameterSet(CatalogueRepository, filter, "Old");
            var vals     = paramSet.CreateNewValueEntries();

            Assert.AreEqual(1, vals.Length);
            Assert.IsTrue(vals[0].Exists());

            paramSet.DeleteInDatabase();
            Assert.IsFalse(paramSet.Exists());
            Assert.IsFalse(vals[0].Exists());
        }
示例#9
0
        /// <summary>
        /// Creates a minimum viable object of Type T.  This includes the object and any dependencies e.g. a
        /// <see cref="ColumnInfo"/> cannot exist without a <see cref="TableInfo"/>.
        /// </summary>
        /// <typeparam name="T">Type of object you want to create</typeparam>
        /// <returns></returns>
        /// <exception cref="NotSupportedException">If there is not yet an implementation for the given T.  Feel free to write one.</exception>
        protected T WhenIHaveA <T>() where T : DatabaseEntity
        {
            if (typeof(T) == typeof(Catalogue))
            {
                return((T)(object)Save(new Catalogue(Repository, "Mycata")));
            }


            if (typeof(T) == typeof(ExtendedProperty))
            {
                return((T)(object)new ExtendedProperty(Repository, Save(new Catalogue(Repository, "Mycata")), "TestProp", 0));
            }


            if (typeof(T) == typeof(CatalogueItem))
            {
                var cata = new Catalogue(Repository, "Mycata");
                return((T)(object)new CatalogueItem(Repository, cata, "MyCataItem"));
            }

            if (typeof(T) == typeof(ExtractionInformation))
            {
                var col = WhenIHaveA <ColumnInfo>();

                var cata = new Catalogue(Repository, "Mycata");
                var ci   = new CatalogueItem(Repository, cata, "MyCataItem");
                var ei   = new ExtractionInformation(Repository, ci, col, "MyCataItem");
                return((T)(object)Save(ei));
            }

            if (typeof(T) == typeof(TableInfo))
            {
                var table = new TableInfo(Repository, "My_Table")
                {
                    DatabaseType = DatabaseType.MicrosoftSQLServer
                };
                return((T)(object)table);
            }

            if (typeof(T) == typeof(ColumnInfo))
            {
                var ti  = WhenIHaveA <TableInfo>();
                var col = new ColumnInfo(Repository, "My_Col", "varchar(10)", ti);
                return((T)(object)col);
            }

            if (typeof(T) == typeof(AggregateConfiguration))
            {
                ExtractionInformation dateEi;
                ExtractionInformation otherEi;
                return((T)(object)WhenIHaveA <AggregateConfiguration>(out dateEi, out otherEi));
            }

            if (typeof(T) == typeof(ExternalDatabaseServer))
            {
                return((T)(object)Save(new ExternalDatabaseServer(Repository, "My Server", null)));
            }

            if (typeof(T) == typeof(ANOTable))
            {
                ExternalDatabaseServer server;
                return((T)(object)WhenIHaveA <ANOTable>(out server));
            }

            if (typeof(T) == typeof(LoadMetadata))
            {
                //creates the table, column, catalogue, catalogue item and extraction information
                var ei   = WhenIHaveA <ExtractionInformation>();
                var cata = ei.CatalogueItem.Catalogue;

                var ti = ei.ColumnInfo.TableInfo;
                ti.Server   = "localhost";
                ti.Database = "mydb";
                ti.SaveToDatabase();

                var lmd = new LoadMetadata(Repository, "MyLoad");
                cata.LoadMetadata_ID = lmd.ID;
                cata.SaveToDatabase();
                return((T)(object)lmd);
            }

            if (typeof(T) == typeof(AggregateTopX))
            {
                var agg = WhenIHaveA <AggregateConfiguration>();
                return((T)(object)new AggregateTopX(Repository, agg, 10));
            }

            if (typeof(T) == typeof(ConnectionStringKeyword))
            {
                return((T)(object)new ConnectionStringKeyword(Repository, DatabaseType.MicrosoftSQLServer, "MultipleActiveResultSets", "true"));
            }

            if (typeof(T) == typeof(DashboardLayout))
            {
                return((T)(object)new DashboardLayout(Repository, "My Layout"));
            }

            if (typeof(T) == typeof(DashboardControl))
            {
                var layout = WhenIHaveA <DashboardLayout>();
                return((T)(object)Save(new DashboardControl(Repository, layout, typeof(int), 0, 0, 100, 100, "")
                {
                    ControlType = "GoodBadCataloguePieChart"
                }));
            }

            if (typeof(T) == typeof(DashboardObjectUse))
            {
                var layout  = WhenIHaveA <DashboardLayout>();
                var control = Save(new DashboardControl(Repository, layout, typeof(int), 0, 0, 100, 100, "")
                {
                    ControlType = "GoodBadCataloguePieChart"
                });
                var use = new DashboardObjectUse(Repository, control, WhenIHaveA <Catalogue>());
                return((T)(object)use);
            }

            if (typeof(T) == typeof(ExtractionFilter))
            {
                var ei = WhenIHaveA <ExtractionInformation>();
                return((T)(object)new ExtractionFilter(Repository, "My Filter", ei));
            }

            if (typeof(T) == typeof(ExtractionFilterParameter))
            {
                var filter = WhenIHaveA <ExtractionFilter>();
                filter.WhereSQL = "@myParam = 'T'";

                return((T)(object)new ExtractionFilterParameter(Repository, "DECLARE @myParam varchar(10)", filter));
            }

            if (typeof(T) == typeof(ExtractionFilterParameterSetValue))
            {
                var parameter = WhenIHaveA <ExtractionFilterParameter>();
                var set       = new ExtractionFilterParameterSet(Repository, parameter.ExtractionFilter, "Parameter Set");
                return((T)(object)new ExtractionFilterParameterSetValue(Repository, set, parameter));
            }

            if (typeof(T) == typeof(ExtractionFilterParameterSet))
            {
                return((T)(object)WhenIHaveA <ExtractionFilterParameterSetValue>().ExtractionFilterParameterSet);
            }

            if (typeof(T) == typeof(Favourite))
            {
                return((T)(object)new Favourite(Repository, WhenIHaveA <Catalogue>()));
            }

            if (typeof(T) == typeof(ObjectExport))
            {
                ShareManager sm;
                return((T)(object)WhenIHaveA <ObjectExport>(out sm));
            }

            if (typeof(T) == typeof(ObjectImport))
            {
                ShareManager sm;
                ObjectExport export = WhenIHaveA <ObjectExport>(out sm);
                return((T)(object)sm.GetImportAs(export.SharingUID, WhenIHaveA <Catalogue>()));
            }

            if (typeof(T) == typeof(WindowLayout))
            {
                return((T)(object)new WindowLayout(Repository, "My window arrangement", "<html><body>ignore this</body></html>"));
            }

            if (typeof(T) == typeof(RemoteRDMP))
            {
                return((T)(object)new RemoteRDMP(Repository));
            }

            if (typeof(T) == typeof(CohortIdentificationConfiguration))
            {
                return((T)(object)new CohortIdentificationConfiguration(Repository, "My cic"));
            }

            if (typeof(T) == typeof(JoinableCohortAggregateConfiguration))
            {
                var config = WhenIHaveCohortAggregateConfiguration("PatientIndexTable");
                var cic    = WhenIHaveA <CohortIdentificationConfiguration>();
                cic.EnsureNamingConvention(config);
                return((T)(object)new JoinableCohortAggregateConfiguration(Repository, cic, config));
            }

            if (typeof(T) == typeof(JoinableCohortAggregateConfigurationUse))
            {
                var joinable = WhenIHaveA <JoinableCohortAggregateConfiguration>();
                var config   = WhenIHaveCohortAggregateConfiguration("Aggregate");
                return((T)(object)joinable.AddUser(config));
            }

            if (typeof(T) == typeof(Rdmp.Core.Curation.Data.Plugin))
            {
                return((T)(object)new Rdmp.Core.Curation.Data.Plugin(Repository, new FileInfo("bob.nupkg"), new Version(1, 1, 1), new Version(1, 1, 1)));
            }

            if (typeof(T) == typeof(LoadModuleAssembly))
            {
                var dll = Path.Combine(TestContext.CurrentContext.TestDirectory, "a.nupkg");
                File.WriteAllBytes(dll, new byte[] { 0x11 });

                return((T)(object)new LoadModuleAssembly(Repository, new FileInfo(dll), WhenIHaveA <Rdmp.Core.Curation.Data.Plugin>()));
            }

            if (typeof(T) == typeof(AggregateContinuousDateAxis))
            {
                ExtractionInformation dateEi;
                ExtractionInformation otherEi;
                var config = WhenIHaveA <AggregateConfiguration>(out dateEi, out otherEi);

                //remove the other Ei
                config.AggregateDimensions[0].DeleteInDatabase();
                //add the date one
                var dim = new AggregateDimension(Repository, dateEi, config);

                return((T)(object)new AggregateContinuousDateAxis(Repository, dim));
            }

            if (typeof(T) == typeof(AggregateDimension))
            {
                return((T)(object)WhenIHaveA <AggregateConfiguration>().AggregateDimensions[0]);
            }

            if (typeof(T) == typeof(AggregateFilterContainer))
            {
                var config    = WhenIHaveA <AggregateConfiguration>();
                var container = new AggregateFilterContainer(Repository, FilterContainerOperation.AND);
                config.RootFilterContainer_ID = container.ID;
                config.SaveToDatabase();
                return((T)(object)container);
            }
            if (typeof(T) == typeof(AggregateFilter))
            {
                var container = WhenIHaveA <AggregateFilterContainer>();
                return((T)(object)new AggregateFilter(Repository, "My Filter", container));
            }

            if (typeof(T) == typeof(AggregateFilterParameter))
            {
                var filter = WhenIHaveA <AggregateFilter>();
                filter.WhereSQL = "@MyP = 'mnnn apples'";
                filter.SaveToDatabase();

                return((T)filter.GetFilterFactory().CreateNewParameter(filter, "DECLARE @MyP as varchar(10)"));
            }

            if (typeof(T) == typeof(LoadProgress))
            {
                return((T)(object)new LoadProgress(Repository, WhenIHaveA <LoadMetadata>()));
            }

            if (typeof(T) == typeof(CacheProgress))
            {
                return((T)(object)new CacheProgress(Repository, WhenIHaveA <LoadProgress>()));
            }

            if (typeof(T) == typeof(CacheFetchFailure))
            {
                return((T)(object)new CacheFetchFailure(Repository, WhenIHaveA <CacheProgress>(), DateTime.Now.Subtract(new TimeSpan(1, 0, 0, 0)), DateTime.Now, new Exception("It didn't work")));
            }

            if (typeof(T) == typeof(CohortAggregateContainer))
            {
                var cic = WhenIHaveA <CohortIdentificationConfiguration>();
                cic.CreateRootContainerIfNotExists();
                return((T)(object)cic.RootCohortAggregateContainer);
            }

            if (typeof(T) == typeof(AnyTableSqlParameter))
            {
                var cic = WhenIHaveA <CohortIdentificationConfiguration>();
                return((T)(object)new AnyTableSqlParameter(Repository, cic, "DECLARE @myGlobal as varchar(10)"));
            }

            if (typeof(T) == typeof(DataAccessCredentials))
            {
                return((T)(object)new DataAccessCredentials(Repository, "My credentials"));
            }

            if (typeof(T) == typeof(GovernancePeriod))
            {
                return((T)(object)new GovernancePeriod(Repository));
            }

            if (typeof(T) == typeof(GovernanceDocument))
            {
                var fi = new FileInfo(Path.Combine(TestContext.CurrentContext.TestDirectory, "myfile.txt"));
                return((T)(object)new GovernanceDocument(Repository, WhenIHaveA <GovernancePeriod>(), fi));
            }

            if (typeof(T) == typeof(PermissionWindow))
            {
                return((T)(object)new PermissionWindow(Repository));
            }


            if (typeof(T) == typeof(JoinInfo))
            {
                ColumnInfo col1;
                ColumnInfo col2;
                ColumnInfo col3;
                WhenIHaveTwoTables(out col1, out col2, out col3);

                return((T)(object)new JoinInfo(Repository, col1, col2, ExtractionJoinType.Left, null));
            }
            if (typeof(T) == typeof(Lookup))
            {
                ColumnInfo col1;
                ColumnInfo col2;
                ColumnInfo col3;
                WhenIHaveTwoTables(out col1, out col2, out col3);

                return((T)(object)new Lookup(Repository, col3, col1, col2, ExtractionJoinType.Left, null));
            }
            if (typeof(T) == typeof(LookupCompositeJoinInfo))
            {
                var lookup = WhenIHaveA <Lookup>();

                var otherJoinFk = new ColumnInfo(Repository, "otherJoinKeyForeign", "int", lookup.ForeignKey.TableInfo);
                var otherJoinPk = new ColumnInfo(Repository, "otherJoinKeyPrimary", "int", lookup.PrimaryKey.TableInfo);

                return((T)(object)new LookupCompositeJoinInfo(Repository, lookup, otherJoinFk, otherJoinPk));
            }
            if (typeof(T) == typeof(Pipeline))
            {
                return((T)(object)new Pipeline(Repository, "My Pipeline"));
            }

            if (typeof(T) == typeof(PipelineComponent))
            {
                return((T)(object)new PipelineComponent(Repository, WhenIHaveA <Pipeline>(), typeof(ColumnForbidder), 0, "My Component"));
            }

            if (typeof(T) == typeof(PipelineComponentArgument))
            {
                var comp = WhenIHaveA <PipelineComponent>();
                return((T)comp.CreateArgumentsForClassIfNotExists <ColumnForbidder>().First());
            }

            if (typeof(T) == typeof(PreLoadDiscardedColumn))
            {
                return((T)(object)new PreLoadDiscardedColumn(Repository, WhenIHaveA <TableInfo>(), "MyDiscardedColum"));
            }


            if (typeof(T) == typeof(ProcessTask))
            {
                return((T)(object)new ProcessTask(Repository, WhenIHaveA <LoadMetadata>(), LoadStage.AdjustRaw));
            }

            if (typeof(T) == typeof(ProcessTaskArgument))
            {
                return((T)(object)new ProcessTaskArgument(Repository, WhenIHaveA <ProcessTask>()));
            }


            if (typeof(T) == typeof(StandardRegex))
            {
                return((T)(object)new StandardRegex(Repository));
            }

            if (typeof(T) == typeof(SupportingSQLTable))
            {
                return((T)(object)new SupportingSQLTable(Repository, WhenIHaveA <Catalogue>(), "Some Handy Query"));
            }

            if (typeof(T) == typeof(TicketingSystemConfiguration))
            {
                return((T)(object)new TicketingSystemConfiguration(Repository, "My Ticketing System"));
            }

            if (typeof(T) == typeof(SupportingDocument))
            {
                return((T)(object)new SupportingDocument(Repository, WhenIHaveA <Catalogue>(), "HelpFile.docx"));
            }

            if (typeof(T) == typeof(Project))
            {
                return((T)(object)new Project(Repository, "My Project"));
            }

            if (typeof(T) == typeof(ExtractionConfiguration))
            {
                return((T)(object)new ExtractionConfiguration(Repository, WhenIHaveA <Project>()));
            }

            if (typeof(T) == typeof(ExtractableDataSet))
            {
                //To make an extractable dataset we need an extraction identifier (e.g. chi) that will be linked in the cohort
                var ei = WhenIHaveA <ExtractionInformation>();
                ei.IsExtractionIdentifier = true;
                ei.SaveToDatabase();

                //And we need another column too just for sanity sakes (in the same table)
                var ci2  = new CatalogueItem(Repository, ei.CatalogueItem.Catalogue, "ci2");
                var col2 = new ColumnInfo(Repository, "My_Col2", "varchar(10)", ei.ColumnInfo.TableInfo);
                var ei2  = new ExtractionInformation(Repository, ci2, col2, col2.GetFullyQualifiedName());

                return((T)(object)new ExtractableDataSet(Repository, ei.CatalogueItem.Catalogue));
            }

            if (typeof(T) == typeof(CumulativeExtractionResults))
            {
                return((T)(object)new CumulativeExtractionResults(Repository, WhenIHaveA <ExtractionConfiguration>(), WhenIHaveA <ExtractableDataSet>(), "SELECT * FROM Anywhere"));
            }

            if (typeof(T) == typeof(SelectedDataSets))
            {
                var eds    = WhenIHaveA <ExtractableDataSet>();
                var config = WhenIHaveA <ExtractionConfiguration>();

                foreach (var ei in eds.Catalogue.GetAllExtractionInformation(ExtractionCategory.Any))
                {
                    var ec = new ExtractableColumn(Repository, eds, config, ei, ei.Order, ei.SelectSQL);
                }

                return((T)(object)new SelectedDataSets(Repository, config, eds, null));
            }


            if (typeof(T) == typeof(ReleaseLog))
            {
                var file = Path.Combine(TestContext.CurrentContext.TestDirectory, "myDataset.csv");
                File.WriteAllText(file, "omg rows");

                var sds = WhenIHaveA <SelectedDataSets>();
                new CumulativeExtractionResults(Repository, sds.ExtractionConfiguration, sds.ExtractableDataSet, "SELECT * FROM ANYWHERE");
                var potential = new FlatFileReleasePotential(new RepositoryProvider(Repository), sds);

                return((T)(object)new ReleaseLog(Repository,
                                                 potential,
                                                 new ReleaseEnvironmentPotential(sds.ExtractionConfiguration),
                                                 false,
                                                 new DirectoryInfo(TestContext.CurrentContext.TestDirectory),
                                                 new FileInfo(file)));
            }

            if (typeof(T) == typeof(ExtractableDataSetPackage))
            {
                return((T)(object)new ExtractableDataSetPackage(Repository, "My Cool Package"));
            }


            if (typeof(T) == typeof(SupplementalExtractionResults))
            {
                return((T)(object)new SupplementalExtractionResults(Repository, WhenIHaveA <CumulativeExtractionResults>(), "Select * from Lookup", WhenIHaveA <SupportingSQLTable>()));
            }

            if (typeof(T) == typeof(SelectedDataSetsForcedJoin))
            {
                return((T)(object)new SelectedDataSetsForcedJoin(Repository, WhenIHaveA <SelectedDataSets>(), WhenIHaveA <TableInfo>()));
            }

            if (typeof(T) == typeof(ProjectCohortIdentificationConfigurationAssociation))
            {
                return((T)(object)new ProjectCohortIdentificationConfigurationAssociation(Repository, WhenIHaveA <Project>(), WhenIHaveA <CohortIdentificationConfiguration>()));
            }

            if (typeof(T) == typeof(ExternalCohortTable))
            {
                return(Save((T)(object)new ExternalCohortTable(Repository, "My cohorts", DatabaseType.MicrosoftSQLServer)
                {
                    Database = "MyCohortsDb",
                    DefinitionTableForeignKeyField = "c_id",
                    PrivateIdentifierField = "priv",
                    ReleaseIdentifierField = "rel",
                    TableName = "Cohorts",
                    DefinitionTableName = "InventoryTable",
                    Server = "localhost\\sqlexpress"
                }));
            }

            if (typeof(T) == typeof(ExtractableCohort))
            {
                throw new NotSupportedException("You should inherit from TestsRequiringACohort instead, cohorts have to exist to be constructed");
            }

            if (typeof(T) == typeof(GlobalExtractionFilterParameter))
            {
                return((T)(object)new GlobalExtractionFilterParameter(Repository, WhenIHaveA <ExtractionConfiguration>(), "DECLARE @ExtractionGlobal as varchar(100)"));
            }


            if (typeof(T) == typeof(ExtractableColumn))
            {
                var ei = WhenIHaveA <ExtractionInformation>();

                var eds    = new ExtractableDataSet(Repository, ei.CatalogueItem.Catalogue);
                var config = WhenIHaveA <ExtractionConfiguration>();
                config.AddDatasetToConfiguration(eds);

                return((T)(object)config.GetAllExtractableColumnsFor(eds).Single());
            }

            if (typeof(T) == typeof(FilterContainer))
            {
                var sds       = WhenIHaveA <SelectedDataSets>();
                var container = new FilterContainer(Repository, FilterContainerOperation.AND);
                sds.RootFilterContainer_ID = container.ID;
                sds.SaveToDatabase();

                return((T)(object)container);
            }


            if (typeof(T) == typeof(DeployedExtractionFilter))
            {
                var container = WhenIHaveA <FilterContainer>();
                return((T)(object)new DeployedExtractionFilter(Repository, "Fish = 'haddock'", container));
            }
            if (typeof(T) == typeof(DeployedExtractionFilterParameter))
            {
                var filter = WhenIHaveA <DeployedExtractionFilter>();
                filter.WhereSQL = "@had = 'enough'";
                return((T)(object)filter.GetFilterFactory().CreateNewParameter(filter, "DECLARE @had as varchar(100)"));
            }

            if (typeof(T) == typeof(ExtractionProgress))
            {
                var cata     = new Catalogue(Repository, "MyCata");
                var cataItem = new CatalogueItem(Repository, cata, "MyCol");
                var table    = new TableInfo(Repository, "MyTable");
                var col      = new ColumnInfo(Repository, "mycol", "datetime", table);

                var ei = new ExtractionInformation(Repository, cataItem, col, "mycol");
                cata.TimeCoverage_ExtractionInformation_ID = ei.ID;
                cata.SaveToDatabase();

                var eds     = new ExtractableDataSet(Repository, cata);
                var project = new Project(Repository, "My Proj");
                var config  = new ExtractionConfiguration(Repository, project);
                var sds     = new SelectedDataSets(Repository, config, eds, null);

                return((T)(object)new ExtractionProgress(Repository, sds));
            }

            throw new TestCaseNotWrittenYetException(typeof(T));
        }
 public ExecuteCommandAddMissingParameters(IBasicActivateItems activator, ExtractionFilterParameterSet set) : this(activator, new[] { set })
 {
 }
示例#11
0
 public override void SetDatabaseObject(IActivateItems activator, ExtractionFilterParameterSet databaseObject)
 {
     base.SetDatabaseObject(activator, databaseObject);
     ExtractionFilterParameterSet = databaseObject;
 }