コード例 #1
0
ファイル: MetadataReport.cs プロジェクト: HicServices/RDMP
        private bool Include(ExtractionInformation arg)
        {
            switch (arg.ExtractionCategory)
            {
            case ExtractionCategory.Core:
                return(true);

            case ExtractionCategory.Supplemental:
                return(true);

            case ExtractionCategory.SpecialApprovalRequired:
                return(true);

            case ExtractionCategory.Internal:
                return(_args.IncludeInternalItems);

            case ExtractionCategory.Deprecated:
                return(_args.IncludeDeprecatedItems);

            case ExtractionCategory.ProjectSpecific:
                return(true);

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
コード例 #2
0
        private IExtractionRequestFulfiller CreateRequestFulfiller(CohortExtractorOptions opts)
        {
            var c    = WhenIHaveA <ExtractionInformation>().CatalogueItem.Catalogue;
            var t    = c.GetTableInfoList(false).Single();
            var repo = Repository.CatalogueRepository;

            foreach (string requiredColumn in new string[]
            {
                QueryToExecuteColumnSet.DefaultImagePathColumnName,
                QueryToExecuteColumnSet.DefaultStudyIdColumnName,
                QueryToExecuteColumnSet.DefaultSeriesIdColumnName,
                QueryToExecuteColumnSet.DefaultInstanceIdColumnName,
            })
            {
                var ei = new ExtractionInformation(repo, new CatalogueItem(repo, c, "a"), new ColumnInfo(repo, requiredColumn, "varchar(10)", (TableInfo)t), requiredColumn);
                ei.ExtractionCategory = ExtractionCategory.Core;
                ei.SaveToDatabase();
            }

            c.ClearAllInjections();

            Assert.AreEqual(5, c.GetAllExtractionInformation(ExtractionCategory.Any).Length);

            var f         = new MicroserviceObjectFactory();
            var fulfiller = f.CreateInstance <IExtractionRequestFulfiller>(opts.RequestFulfillerType,
                                                                           typeof(IExtractionRequestFulfiller).Assembly,
                                                                           new object[] { new[] { c } });

            if (fulfiller != null)
            {
                fulfiller.Rejectors.Add(f.CreateInstance <IRejector>(opts.RejectorType, typeof(TestRejector).Assembly) ?? new RejectNone());
            }

            return(fulfiller);
        }
        private void SetupJoin()
        {
            DataTable dt = new DataTable();

            dt.Columns.Add("Name");
            dt.Columns.Add("Description");

            dt.Rows.Add(new object[] { "Dave", "Is a maniac" });

            var tbl = Database.CreateTable("SimpleJoin", dt, new[] { new DatabaseColumnRequest("Name", new DatabaseTypeRequest(typeof(string), 50))
                                                                     {
                                                                         IsPrimaryKey = true
                                                                     } });

            var lookupCata = Import(tbl);

            ExtractionInformation fkEi = _catalogue.GetAllExtractionInformation(ExtractionCategory.Any).Single(n => n.GetRuntimeName() == "Name");
            ColumnInfo            pk   = lookupCata.GetTableInfoList(false).Single().ColumnInfos.Single(n => n.GetRuntimeName() == "Name");

            new JoinInfo(CatalogueRepository, fkEi.ColumnInfo, pk, ExtractionJoinType.Left, null);

            var ci = new CatalogueItem(CatalogueRepository, _catalogue, "Name_2");
            var ei = new ExtractionInformation(CatalogueRepository, ci, pk, pk.Name)
            {
                Alias = "Name_2"
            };

            ei.SaveToDatabase();
        }
コード例 #4
0
        protected override void SetUp()
        {
            base.SetUp();

            c    = new Catalogue(CatalogueRepository, "MyCata");
            ci   = new CatalogueItem(CatalogueRepository, c, "MyCataItem");
            ci2  = new CatalogueItem(CatalogueRepository, c, "YearColumn");
            t    = new TableInfo(CatalogueRepository, "MyTable");
            col  = new ColumnInfo(CatalogueRepository, "mycol", "varchar(10)", t);
            col2 = new ColumnInfo(CatalogueRepository, "myOtherCol", "varchar(10)", t);


            acCohort  = new AggregateConfiguration(CatalogueRepository, c, CohortIdentificationConfiguration.CICPrefix + "Agg1_Cohort");
            acDataset = new AggregateConfiguration(CatalogueRepository, c, "Agg2_Dataset");

            ei_Year = new ExtractionInformation(CatalogueRepository, ci2, col2, "Year");
            ei_Year.IsExtractionIdentifier = true;
            ei_Year.SaveToDatabase();
            acDataset.AddDimension(ei_Year);
            acDataset.CountSQL = "count(*)";
            acDataset.SaveToDatabase();


            ei_Chi = new ExtractionInformation(CatalogueRepository, ci, col, "CHI");
            ei_Chi.IsExtractionIdentifier = true;
            ei_Chi.SaveToDatabase();

            acCohort.AddDimension(ei_Chi);

            cic = new CohortIdentificationConfiguration(CatalogueRepository, "mycic");
            cic.CreateRootContainerIfNotExists();
            cic.RootCohortAggregateContainer.AddChild(acCohort, 0);
        }
コード例 #5
0
        private string DescribeProblem(ExtractionInformation extractionInformation)
        {
            //Get the Catalogue that this ExtractionInformation is descended from
            var descendancy = _childProvider.GetDescendancyListIfAnyFor(extractionInformation);

            if (descendancy != null)
            {
                var catalogue = descendancy.Parents.OfType <Catalogue>().SingleOrDefault();
                if (catalogue != null)
                {
                    //if we know the Catalogue extractability

                    //ExtractionCategory.ProjectSpecific should match the Catalogue extractability.IsProjectSpecific
                    //otherwise it's a Problem

                    if (catalogue.IsProjectSpecific(null))
                    {
                        if (extractionInformation.ExtractionCategory != ExtractionCategory.ProjectSpecific)
                        {
                            return("Catalogue " + catalogue + " is Project Specific Catalogue so all ExtractionCategory should be " + ExtractionCategory.ProjectSpecific);
                        }
                    }
                    else if (extractionInformation.ExtractionCategory == ExtractionCategory.ProjectSpecific)
                    {
                        return("ExtractionCategory is only valid when the Catalogue ('" + catalogue + "') is also ProjectSpecific");
                    }
                }
            }

            return(null);
        }
コード例 #6
0
        public void TestSetExtractionIdentifier_Catalogue_PickOther()
        {
            var ei1 = WhenIHaveA <ExtractionInformation>();

            var otherCol     = new ColumnInfo(Repository, "Other", "varchar", ei1.ColumnInfo.TableInfo);
            var otherCatItem = new CatalogueItem(Repository, ei1.CatalogueItem.Catalogue, "Other");
            var otherEi      = new ExtractionInformation(Repository, otherCatItem, otherCol, "FFF");

            ei1.Alias = "happyfun";
            ei1.IsExtractionIdentifier = true;
            ei1.SaveToDatabase();

            // before we run the command the primary ei1 is the identifier
            Assert.IsTrue(ei1.IsExtractionIdentifier);
            Assert.IsFalse(otherEi.IsExtractionIdentifier);

            // by picking the second (FFF) we should switch
            var cmd = new ExecuteCommandSetExtractionIdentifier(GetMockActivator().Object, ei1.CatalogueItem.Catalogue, null, "FFF");

            cmd.Execute();

            // original should no longer be the extraction identifer
            Assert.IsFalse(ei1.IsExtractionIdentifier);

            // and the one picked should now be the only one
            Assert.IsTrue(otherEi.IsExtractionIdentifier);
        }
コード例 #7
0
        protected override void SetUp()
        {
            base.SetUp();

            _c         = new Catalogue(CatalogueRepository, "AggregateBuilderTests");
            _cataItem1 = new CatalogueItem(CatalogueRepository, _c, "Col1");
            _cataItem2 = new CatalogueItem(CatalogueRepository, _c, "Col2");

            _ti          = new TableInfo(CatalogueRepository, "T1");
            _columnInfo1 = new ColumnInfo(CatalogueRepository, "Col1", "varchar(100)", _ti);
            _columnInfo2 = new ColumnInfo(CatalogueRepository, "Col2", "date", _ti);

            _ei1 = new ExtractionInformation(CatalogueRepository, _cataItem1, _columnInfo1, _columnInfo1.Name);
            _ei2 = new ExtractionInformation(CatalogueRepository, _cataItem2, _columnInfo2, _columnInfo2.Name);

            _configuration = new AggregateConfiguration(CatalogueRepository, _c, "MyConfig");

            _dimension1 = new AggregateDimension(CatalogueRepository, _ei1, _configuration);
            _dimension2 = new AggregateDimension(CatalogueRepository, _ei2, _configuration);

            _dimension1.Order = 1;
            _dimension1.SaveToDatabase();
            _dimension2.Order = 2;
            _dimension2.SaveToDatabase();
        }
コード例 #8
0
        public void test_creating_ExtractionInformation()
        {
            ExtractionInformation extractInfo = null;

            try
            {
                //define extraction information
                //change some values and then save it
                extractInfo = new ExtractionInformation(CatalogueRepository, cataItem, columnInfo, "dave")
                {
                    Order = 123,
                    ExtractionCategory = ExtractionCategory.Supplemental
                };
                extractInfo.SaveToDatabase();

                //confirm the insert worked
                Assert.AreEqual(extractInfo.SelectSQL, "dave");

                //fetch the extraction information via the linked CatalogueItem - ColumnInfo pair (i.e. we are testing the alternate route to fetch ExtractionInformation - by ID or by colum/item pair)
                ExtractionInformation extractInfo2_CameFromLinker = cataItem.ExtractionInformation;
                Assert.AreEqual(extractInfo.ID, extractInfo2_CameFromLinker.ID);
                Assert.AreEqual(extractInfo.SelectSQL, extractInfo2_CameFromLinker.SelectSQL);

                //make sure it saves properly
                Assert.AreEqual(extractInfo2_CameFromLinker.Order, 123);
                Assert.AreEqual(extractInfo2_CameFromLinker.ExtractionCategory, ExtractionCategory.Supplemental);
            }
            finally
            {
                if (extractInfo != null)
                {
                    extractInfo.DeleteInDatabase();
                }
            }
        }
コード例 #9
0
        private void CreateANormalCatalogue()
        {
            var svr = _database.Server;

            using (var con = svr.GetConnection())
            {
                con.Open();
                svr.GetCommand("CREATE TABLE NonTVFTable ( chi varchar(10))", con).ExecuteNonQuery();
                svr.GetCommand("INSERT INTO NonTVFTable VALUES ('0101010101')", con).ExecuteNonQuery();
                svr.GetCommand("INSERT INTO NonTVFTable VALUES ('0202020202')", con).ExecuteNonQuery();
                svr.GetCommand("INSERT INTO NonTVFTable VALUES ('0303030303')", con).ExecuteNonQuery();
            }

            var importer = new TableInfoImporter(CatalogueRepository, svr.Name,
                                                 _database.GetRuntimeName(), "NonTVFTable",
                                                 DatabaseType.MicrosoftSQLServer, _database.Server.ExplicitUsernameIfAny, _database.Server.ExplicitPasswordIfAny);

            importer.DoImport(out var tbl, out var cols);

            var engineer = new ForwardEngineerCatalogue(tbl, cols, true);

            engineer.ExecuteForwardEngineering(out var cata, out var cis, out var eis);

            _nonTvfExtractionIdentifier = eis.Single();
            _nonTvfExtractionIdentifier.IsExtractionIdentifier = true;
            _nonTvfExtractionIdentifier.SaveToDatabase();

            _nonTvfCatalogue = cata;
            _nonTvfTableInfo = tbl;
        }
コード例 #10
0
        public void TestQueryBuilder_MySql_Normal()
        {
            var t = new TableInfo(CatalogueRepository, "`db`.`tbl`");

            t.DatabaseType = DatabaseType.MySql;
            t.SaveToDatabase();

            var col = new ColumnInfo(CatalogueRepository, "`db`.`tbl`.`col`", "varchar(10)", t);

            Assert.AreEqual("col", col.GetRuntimeName());

            var cata           = new Catalogue(CatalogueRepository, "cata");
            var catalogueItem  = new CatalogueItem(CatalogueRepository, cata, "col");
            var extractionInfo = new ExtractionInformation(CatalogueRepository, catalogueItem, col, col.Name);

            var qb = new QueryBuilder(null, null);

            qb.AddColumn(extractionInfo);
            Assert.AreEqual(CollapseWhitespace(
                                @"SELECT 
`db`.`tbl`.`col`
FROM 
`db`.`tbl`"
                                ), CollapseWhitespace(qb.SQL));
        }
コード例 #11
0
        private void SetExtractionIdentifierColumn(ExtractionInformation extractionInformation)
        {
            //if they are trying to set the identifier column to something that isn't marked IsExtractionIdentifier
            if (_extractionIdentifierColumn != null && !extractionInformation.IsExtractionIdentifier)
                SetImpossible("Column is not marked IsExtractionIdentifier");

            _extractionIdentifierColumn = extractionInformation;
        }
コード例 #12
0
        public void test_creating_ExtractionFilter()
        {
            ExtractionInformation     extractInfo      = null;
            ExtractionFilter          filterFastThings = null;
            ExtractionFilterParameter parameter        = null;

            try
            {
                //define extraction information
                extractInfo = new ExtractionInformation(CatalogueRepository, cataItem, columnInfo, "ROUND(VelocityOfMatter,2) VelocityOfMatterRounded");

                //define filter and parameter
                filterFastThings = new ExtractionFilter(CatalogueRepository, "FastThings", extractInfo)
                {
                    WhereSQL    = "VelocityOfMatter > @X",
                    Description = "Query to identify things that travel faster than X miles per hour!"
                };
                filterFastThings.SaveToDatabase();
                Assert.AreEqual(filterFastThings.Name, "FastThings");

                parameter = new ExtractionFilterParameter(CatalogueRepository, "DECLARE @X INT", filterFastThings);

                Assert.IsNotNull(parameter);
                Assert.AreEqual(parameter.ParameterName, "@X");

                parameter.Value = "500";
                parameter.SaveToDatabase();

                ExtractionFilterParameter afterSave = CatalogueRepository.GetObjectByID <ExtractionFilterParameter>(parameter.ID);
                Assert.AreEqual(afterSave.Value, "500");


                ExtractionFilter filterFastThings_NewCopyFromDB = CatalogueRepository.GetObjectByID <ExtractionFilter>(filterFastThings.ID);

                Assert.AreEqual(filterFastThings.ID, filterFastThings_NewCopyFromDB.ID);
                Assert.AreEqual(filterFastThings.Description, filterFastThings_NewCopyFromDB.Description);
                Assert.AreEqual(filterFastThings.Name, filterFastThings_NewCopyFromDB.Name);
                Assert.AreEqual(filterFastThings.WhereSQL, filterFastThings_NewCopyFromDB.WhereSQL);
            }
            finally
            {
                if (parameter != null)
                {
                    parameter.DeleteInDatabase();
                }

                //filters are children of extraction info with CASCADE DELETE so have to delete this one first if we want to test it programatically (although we could just skip deleting it since SQL will handle it anyway)
                if (filterFastThings != null)
                {
                    filterFastThings.DeleteInDatabase();
                }

                if (extractInfo != null)
                {
                    extractInfo.DeleteInDatabase();
                }
            }
        }
コード例 #13
0
 public ViewColumnExtractCollection(ExtractionInformation ei, ViewType viewType, IContainer container) : this()
 {
     DatabaseObjects.Add(ei);
     if (container != null)
     {
         DatabaseObjects.Add(container);
     }
     ViewType = viewType;
 }
コード例 #14
0
 public ViewColumnExtractCollection(ExtractionInformation ei, ViewType viewType, IFilter filter = null) : this()
 {
     DatabaseObjects.Add(ei);
     if (filter != null)
     {
         DatabaseObjects.Add(filter);
     }
     ViewType = viewType;
 }
        private ExtractDatasetCommand SetupExtractDatasetCommand(string testTableName, string[] pkExtractionColumns, string[] pkColumnInfos = null, bool withLookup = false, bool withJoin = false)
        {
            DataTable dt = new DataTable();

            dt.Columns.Add("PrivateID");
            dt.Columns.Add("Name");
            dt.Columns.Add("DateOfBirth");

            if (pkColumnInfos != null)
            {
                dt.PrimaryKey =
                    dt.Columns.Cast <DataColumn>().Where(col => pkColumnInfos.Contains(col.ColumnName)).ToArray();
            }

            dt.Rows.Add(new object[] { _cohortKeysGenerated.Keys.First(), "Dave", "2001-01-01" });

            var tbl = Database.CreateTable(testTableName,
                                           dt,
                                           new[] { new DatabaseColumnRequest("Name", new DatabaseTypeRequest(typeof(string), 50)) });

            _catalogue = Import(tbl, out var tableInfo, out var columnInfos, out var cataItems, out var extractionInformations);

            ExtractionInformation privateID = extractionInformations.First(e => e.GetRuntimeName().Equals("PrivateID"));

            privateID.IsExtractionIdentifier = true;
            privateID.SaveToDatabase();

            if (withLookup)
            {
                SetupLookupTable();
            }

            if (withJoin)
            {
                SetupJoin();
            }

            _catalogue.ClearAllInjections();
            extractionInformations = _catalogue.GetAllExtractionInformation(ExtractionCategory.Any);

            foreach (var pkExtractionColumn in pkExtractionColumns)
            {
                ExtractionInformation column = extractionInformations.First(e => e.GetRuntimeName().Equals(pkExtractionColumn));
                column.IsPrimaryKey = true;
                column.SaveToDatabase();
            }

            SetupDataExport(testTableName, _catalogue,
                            out var configuration, out var extractableDataSet, out var project);

            configuration.Cohort_ID = _extractableCohort.ID;
            configuration.SaveToDatabase();

            return(new ExtractDatasetCommand(configuration, new ExtractableDatasetBundle(extractableDataSet)));
        }
コード例 #16
0
        private IViewSQLAndResultsCollection CreateCollection(ExtractionInformation ei)
        {
            var toReturn = new ViewColumnExtractCollection(ei, _viewType);

            if ((!ei.ColumnInfo?.IsNumerical() ?? false) && _viewType == ViewType.Distribution)
            {
                SetImpossible("Column is not numerical");
            }

            return(toReturn);
        }
コード例 #17
0
        public void CreateAFilter()
        {
            aggregate1.RootFilterContainer_ID = new AggregateFilterContainer(CatalogueRepository, FilterContainerOperation.AND).ID;
            aggregate1.SaveToDatabase();

            _chiExtractionInformation = aggregate1.AggregateDimensions.Single().ExtractionInformation;

            _container = aggregate1.RootFilterContainer;

            _filter = new AggregateFilter(CatalogueRepository, "folk", _container);
        }
コード例 #18
0
        public ExecuteCommandCreateNewCohortFromCatalogue(IActivateItems activator, ExtractionInformation extractionInformation) : this(activator)
        {
            if (!extractionInformation.IsExtractionIdentifier)
            {
                SetImpossible("Column is not marked IsExtractionIdentifier");
            }

            OverrideCommandName = "Create New Cohort From Column...";

            SetExtractionIdentifierColumn(extractionInformation);
        }
コード例 #19
0
ファイル: ExtractableColumn.cs プロジェクト: rkm/RDMP
        private CatalogueItem FetchCatalogueItem()
        {
            ExtractionInformation ei = _knownExtractionInformation.Value;

            if (ei == null)
            {
                return(null);
            }

            return(ei.CatalogueItem);
        }
コード例 #20
0
        private void MakeExtractable(object o, bool shouldBeExtractable, ExtractionCategory?category = null)
        {
            var n = (ColPair)o;

            //if it has extraction information
            if (n.ExtractionInformation != null)
            {
                if (shouldBeExtractable)
                {
                    //if they want to change the extraction category
                    if (category.HasValue && n.ExtractionInformation.ExtractionCategory != category.Value)
                    {
                        n.ExtractionInformation.ExtractionCategory = category.Value;
                        n.ExtractionInformation.Order = olvColumnExtractability.IndexOf(n);
                        n.ExtractionInformation.SaveToDatabase();
                        olvColumnExtractability.RefreshObject(n);
                    }
                    return;
                }
                else
                {
                    //make it not extractable by deleting the extraction information
                    n.ExtractionInformation.DeleteInDatabase();
                    n.ExtractionInformation = null;
                }
            }
            else
            {
                //it doesn't have ExtractionInformation

                if (!shouldBeExtractable) //it's already not extractable job done
                {
                    return;
                }
                else
                {
                    //make it extractable
                    var newExtractionInformation = new ExtractionInformation((ICatalogueRepository)n.ColumnInfo.Repository, n.CatalogueItem, n.ColumnInfo, n.ColumnInfo.Name);

                    if (category.HasValue)
                    {
                        newExtractionInformation.ExtractionCategory = category.Value;
                        newExtractionInformation.Order = olvColumnExtractability.IndexOf(n);
                        newExtractionInformation.SaveToDatabase();
                    }

                    n.ExtractionInformation = newExtractionInformation;
                }
            }

            olvColumnExtractability.RefreshObject(n);
        }
コード例 #21
0
        protected override void SetUp()
        {
            base.SetUp();

            aggregate1.RootFilterContainer_ID = new AggregateFilterContainer(CatalogueRepository, FilterContainerOperation.AND).ID;
            aggregate1.SaveToDatabase();

            _chiExtractionInformation = aggregate1.AggregateDimensions.Single().ExtractionInformation;

            _container = (AggregateFilterContainer)aggregate1.RootFilterContainer;

            _filter = new AggregateFilter(CatalogueRepository, "folk", _container);
        }
コード例 #22
0
        private AggregateConfiguration GetAggregateConfigurationWithNoDimensions(out ExtractionInformation dateEi, out ExtractionInformation otherEi)
        {
            var config = WhenIHaveA <AggregateConfiguration>(out dateEi, out otherEi);

            //remove any existing dimensions
            foreach (var d in config.AggregateDimensions)
            {
                d.DeleteInDatabase();
            }

            config.ClearAllInjections();
            return(config);
        }
コード例 #23
0
ファイル: MetadataReport.cs プロジェクト: HicServices/RDMP
        private int IsExtractionIdentifiersFirstOrder(ExtractionInformation x, ExtractionInformation y)
        {
            if (x.IsExtractionIdentifier && !y.IsExtractionIdentifier)
            {
                return(-1);
            }

            if (y.IsExtractionIdentifier && y.IsExtractionIdentifier)
            {
                return(1);
            }

            return(x.Order - y.Order);
        }
コード例 #24
0
        protected override void SetBindings(BinderWithErrorProviderFactory rules, ExtractionInformation databaseObject)
        {
            base.SetBindings(rules, databaseObject);

            Bind(tbId, "Text", "ID", ei => ei.ID);
            Bind(tbDefaultOrder, "Text", "Order", ei => ei.Order);
            Bind(tbAlias, "Text", "Alias", ei => ei.Alias);

            Bind(cbHashOnDataRelease, "Checked", "HashOnDataRelease", ei => ei.HashOnDataRelease);
            Bind(cbIsExtractionIdentifier, "Checked", "IsExtractionIdentifier", ei => ei.IsExtractionIdentifier);
            Bind(cbIsPrimaryKey, "Checked", "IsPrimaryKey", ei => ei.IsPrimaryKey);

            Bind(ddExtractionCategory, "SelectedItem", "ExtractionCategory", ei => ei.ExtractionCategory);
        }
コード例 #25
0
        private object AvailableColumnCategoryAspectGetter(object rowObject)
        {
            ExtractionInformation ei = (ExtractionInformation)rowObject;

            var cata = ei.CatalogueItem.Catalogue;

            string toReturn = null;

            toReturn = ei.ExtractionCategory == ExtractionCategory.ProjectSpecific ? ei.ExtractionCategory + "::" + cata.Name : ei.ExtractionCategory.ToString();

            toReturn = cata.IsDeprecated ? toReturn + " (DEPRECATED)" : toReturn;

            return(toReturn);
        }
コード例 #26
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();
        }
コード例 #27
0
ファイル: ReOrderCatalogueItemsUI.cs プロジェクト: HDRUK/RDMP
        private void WorkOutNewOrderAndAddToNewOrderListbox()
        {
            lbNewOrder.Items.Clear();

            var extractionInformations = olvExtractionInformations.Objects.Cast <ExtractionInformation>().ToArray();

            //for all the things that appear above the thing the user wants first in his dream order
            for (int i = 0; i < currentOrderStartReorderAtIndex; i++)
            {
                ExtractionInformation considerMoving = extractionInformations[i];

                //if it doesnt feature in the users dream list order then move it across
                if (!itemsToReOrderAndOffsetRelativeToFirst.Contains(considerMoving))
                {
                    lbNewOrder.Items.Add(considerMoving);
                }
            }

            //could not find the users desired reordering startcolumn
            if (currentOrderStartReorderAtIndex == -1)
            {
                return;
            }

            //move the first one in the users dream order across
            lbNewOrder.Items.Add(extractionInformations[currentOrderStartReorderAtIndex]);
            //record the location of the 'start reordering at' item in the new listbox so we can highlight it in the draw method
            indexOfStartOfReordingInNewOrderListbox = lbNewOrder.Items.Count - 1;

            //move everything in the users dream list
            foreach (ExtractionInformation extractionInformation in itemsToReOrderAndOffsetRelativeToFirst)
            {
                lbNewOrder.Items.Add(extractionInformation);
            }

            //move everything that doesnt feature in the users dream list (but that occurred after the first thing they wanted)

            //for all the things that appear above the thing the user wants first in his dream order
            for (int i = currentOrderStartReorderAtIndex + 1; i < extractionInformations.Length; i++)
            {
                ExtractionInformation considerMoving = extractionInformations[i];

                //if it doesnt feature in the users dream list order then move it across
                if (!itemsToReOrderAndOffsetRelativeToFirst.Contains(considerMoving))
                {
                    lbNewOrder.Items.Add(considerMoving);
                }
            }
        }
コード例 #28
0
        private void UnlockIdentifier(ExtractionInformation currentSelectionIfAny)
        {
            cbxColumns.Enabled      = true;
            cbxColumns.SelectedItem = null;

            //if there are multiple extraction identifiers e.g. SMR02 where there could be Mother CHI, Baby CHI and Father CHI do not unmark extraction identifier just because they changed it
            if (!_knownIdentifiersMode && currentSelectionIfAny != null)
            {
                currentSelectionIfAny.IsExtractionIdentifier = false;
                currentSelectionIfAny.SaveToDatabase();
            }

            btnLockExtractionIdentifier.Image = _linkImage;
            lockIn = true;
        }
コード例 #29
0
ファイル: ExtractableColumn.cs プロジェクト: rkm/RDMP
        /// <inheritdoc/>
        public void InjectKnown(ExtractionInformation extractionInformation)
        {
            if (extractionInformation == null)
            {
                InjectKnown((CatalogueItem)null);
                InjectKnown((ColumnInfo)(null));
            }
            else
            {
                InjectKnown(extractionInformation.CatalogueItem);
                InjectKnown(extractionInformation.ColumnInfo);
            }

            _knownExtractionInformation = new Lazy <ExtractionInformation>(() => extractionInformation);
        }
コード例 #30
0
        private void LockIdentifier(ExtractionInformation extractionInformation)
        {
            cbxColumns.Enabled                = false;
            cbxColumns.SelectedItem           = extractionInformation;
            btnLockExtractionIdentifier.Image = _unlinkImage;

            //if it isn't yet marked as an extraction identifier save it as one for next time
            if (!extractionInformation.IsExtractionIdentifier)
            {
                extractionInformation.IsExtractionIdentifier = true;
                extractionInformation.SaveToDatabase();
            }

            lockIn = false;
        }