コード例 #1
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);
        }
コード例 #2
0
ファイル: LinkerTests.cs プロジェクト: HicServices/RDMP
        public void AddLinkBetween_createNewLink_pass()
        {
            ///////////////Create the things that we are going to create relationships between /////////////////
            var predator        = new Catalogue(CatalogueRepository, "Predator");
            var lazor           = new CatalogueItem(CatalogueRepository, predator, "QuadlzorVelocity");
            var highEnergyTable = new TableInfo(CatalogueRepository, "HighEnergyShizzle");
            var velocityColumn  = new ColumnInfo(CatalogueRepository, "Velocity Of Matter", "int", highEnergyTable);

            ////////////Check the creation worked ok
            Assert.IsNotNull(predator); //catalogue
            Assert.IsNotNull(lazor);

            Assert.IsNotNull(highEnergyTable); //underlying table stuff
            Assert.IsNotNull(velocityColumn);

            ////////////// Create links between stuff and check they were created successfully //////////////

            //create a link between catalogue item lazor and velocity column
            lazor.SetColumnInfo(velocityColumn);
            Assert.IsTrue(lazor.ColumnInfo.ID == velocityColumn.ID);

            ////////////////cleanup ---- Delete everything that we created -------- //////////////
            velocityColumn.DeleteInDatabase(); //delete causes CASCADE: CatalogueItem no longer associated with ColumnInfo because ColumnInfo died

            lazor.RevertToDatabaseState();

            Assert.IsNull(lazor.ColumnInfo);//involves a database query so won't actually invalidate the below

            predator.DeleteInDatabase();

            highEnergyTable.DeleteInDatabase();
        }
コード例 #3
0
        public ActionResult Create([Bind(Include = "Title,Deadline,Description,DateCreated,DateModified,Complete")] CatalogueItem catalogueItem)
        {
            if (string.IsNullOrEmpty(Session["Login"] as string))
            {
                return(RedirectToAction("Index", "Login"));
            }

            if (ModelState.IsValid)
            {
                catalogueItem.DateCreated  = DateTime.Now;
                catalogueItem.DateModified = DateTime.Now;
                catalogueItem.ItemID       = db.CatalogueItems.Count <Models.CatalogueItem>() + 1;

                if (Session["CataID"] != null)
                {
                    catalogueItem.CataID = int.Parse(Session["CataID"].ToString());
                    db.CatalogueItems.Add(catalogueItem);
                    db.SaveChanges();
                    return(RedirectToAction("Index", "Home"));
                }
                if (Session["SubCataID"] != null)
                {
                    catalogueItem.SubCataID = int.Parse(Session["SubCataID"].ToString());
                    db.CatalogueItems.Add(catalogueItem);
                    db.SaveChanges();
                    return(RedirectToAction("Index", "Home"));
                }
            }

            ViewBag.CataID = new SelectList(db.Catalogues, "CataID", "Title", catalogueItem.CataID);
            return(View(catalogueItem));
        }
コード例 #4
0
        public async Task <IActionResult> PutCatalogueItem(int id, CatalogueItem catalogueItem)
        {
            if (id != catalogueItem.Id)
            {
                return(BadRequest());
            }

            context.Entry(catalogueItem).State = EntityState.Modified;

            try
            {
                await context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!CatalogueItemExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
コード例 #5
0
        public async Task <ActionResult <CatalogueItem> > PostCatalogueItem(CatalogueItem catalogueItem)
        {
            context.CatalogueItems.Add(catalogueItem);
            await context.SaveChangesAsync();

            return(CreatedAtAction("GetCatalogueItem", new { id = catalogueItem.Id }, catalogueItem));
        }
コード例 #6
0
        public override void SetDatabaseObject(IActivateItems activator, CatalogueItem databaseObject)
        {
            _catalogueItem = databaseObject;

            if (_scintillaDescription == null)
            {
                var f = new ScintillaTextEditorFactory();
                _scintillaDescription      = f.Create(null, null, null, true, false, activator.CurrentDirectory);
                _scintillaDescription.Font = System.Drawing.SystemFonts.DefaultFont;
                panel1.Controls.Add(_scintillaDescription);
            }

            base.SetDatabaseObject(activator, databaseObject);


            if (_catalogueItem.ExtractionInformation != null)
            {
                CommonFunctionality.AddToMenu(new ExecuteCommandActivate(activator, _catalogueItem.ExtractionInformation), "Go To Extraction Information");
            }
            else
            {
                CommonFunctionality.AddToMenu(new ExecuteCommandMakeCatalogueItemExtractable(activator, _catalogueItem), "Make Extractable");
            }

            if (_catalogueItem.ColumnInfo_ID != null)
            {
                CommonFunctionality.AddToMenu(new ExecuteCommandShow(activator, _catalogueItem.ColumnInfo, 0, true));
            }
        }
コード例 #7
0
ファイル: CatalogueItemMenu.cs プロジェクト: lulzzz/RDMP
 public CatalogueItemMenu(RDMPContextMenuStripArgs args, CatalogueItem catalogueItem) : base(args, catalogueItem)
 {
     Add(new ExecuteCommandLinkCatalogueItemToColumnInfo(_activator, catalogueItem));
     Add(new ExecuteCommandMakeCatalogueItemExtractable(_activator, catalogueItem));
     Add(new ExecuteCommandChangeExtractionCategory(_activator, catalogueItem.ExtractionInformation));
     Add(new ExecuteCommandImportCatalogueItemDescription(_activator, catalogueItem), Keys.Control | Keys.I);
 }
コード例 #8
0
        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);
        }
コード例 #9
0
        private void CreateCatalogueItemFile(Catalogue c, CatalogueItem ci)
        {
            string saveLocation = Path.Combine(_folderToCreateIn.FullName, GetFileNameForCatalogueItem(c, ci));

            if (File.Exists(saveLocation))
            {
                throw new Exception("Attempted to create CatalogueItem named " + saveLocation + " but it already existed (possibly you have two CatalogueItems with the same name");
            }

            string xml = "";

            xml += @"<?xml version=""1.0"" encoding=""UTF-8""?>
<!DOCTYPE concept PUBLIC ""-//OASIS//DTD DITA Concept//EN""
""concept.dtd"">";

            xml += "<concept id=\"" + FixName(c.Name) + "_" + FixName(ci.Name) + "\">" + Environment.NewLine;

            xml += "<title>" + FixName(ci.Name) + "</title>" + Environment.NewLine;

            xml += "<conbody>" + Environment.NewLine;

            xml += @"<simpletable keycol=""1"">" + Environment.NewLine;

            xml += GenerateObjectPropertiesAsRowUsingReflection(ci);


            xml += @"</simpletable>" + Environment.NewLine;

            xml += "</conbody>" + Environment.NewLine;

            xml += "</concept>" + Environment.NewLine;


            File.WriteAllText(saveLocation, xml);
        }
コード例 #10
0
        private string GetFileNameForCatalogueItem(Catalogue c, CatalogueItem ci)
        {
            string parentName = FixName(c.Acronym);
            string childName  = FixName(ci.Name);

            return(parentName + "_" + childName + ".dita");
        }
コード例 #11
0
 public override int GetHashCode()
 {
     unchecked
     {
         return(((CatalogueItem != null ? CatalogueItem.GetHashCode() : 0) * 397) ^ (ColumnInfo != null ? ColumnInfo.GetHashCode() : 0));
     }
 }
コード例 #12
0
        public async Task DeleteAsync(int catalogueItemId)
        {
            CatalogueItem catalogueItem = await _unitOfWork.CatalogueItemRepository.GetCatalogueItemByIdAsync(catalogueItemId);

            _unitOfWork.CatalogueItemRepository.Remove(catalogueItem);
            await _unitOfWork.CommitAsync();
        }
コード例 #13
0
        // GET: CatalogueItems/Edit/5
        public ActionResult Edit(int?id)
        {
            if (string.IsNullOrEmpty(Session["Login"] as string))
            {
                return(RedirectToAction("Index", "Login"));
            }

            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            CatalogueItem catalogueItem = db.CatalogueItems.Find(id);

            if (catalogueItem == null)
            {
                return(HttpNotFound());
            }

            Session["ItemID"] = catalogueItem.ItemID;

            if (catalogueItem.CataID > 0)
            {
                Session["CataID"] = catalogueItem.CataID;
            }
            else if (catalogueItem.SubCataID > 0)
            {
                Session["SubCataID"] = catalogueItem.SubCataID;
            }

            Session["DateCreated"] = catalogueItem.DateCreated;
            ViewBag.CataID         = catalogueItem.CataID;

            return(View(catalogueItem));
        }
コード例 #14
0
        public void RelatedCatalogueTest_OneCatalogue(bool createExtractionInformation)
        {
            TableInfo  t = new TableInfo(Repository, "MyTable");
            ColumnInfo c = new ColumnInfo(Repository, "MyCol", "varchar(10)", t);

            Catalogue     cata = new Catalogue(Repository, "MyCata");
            CatalogueItem ci   = new CatalogueItem(Repository, cata, "MyCataItem");

            try
            {
                if (createExtractionInformation)
                {
                    new ExtractionInformation(Repository, ci, c, "dbo.SomeFunc('Bob') as MySelectLine");
                }
                else
                {
                    ci.SetColumnInfo(c);
                }

                var catas = t.GetAllRelatedCatalogues();
                Assert.AreEqual(1, catas.Length);
                Assert.AreEqual(cata, catas[0]);
            }
            finally
            {
                ci.DeleteInDatabase();
                cata.DeleteInDatabase();
                t.DeleteInDatabase();
            }
        }
コード例 #15
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);
        }
コード例 #16
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();
        }
コード例 #17
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));
        }
コード例 #18
0
        public void TestPruning()
        {
            Catalogue c  = new Catalogue(CatalogueRepository, "Catapault");
            var       ci = new CatalogueItem(CatalogueRepository, c, "string");

            Catalogue c2  = new Catalogue(CatalogueRepository, "Catapault (Import)");
            var       ci2 = new CatalogueItem(CatalogueRepository, c2, "string (Import)");

            Assert.AreEqual(CatalogueRepository.GetAllObjects <ObjectExport>().Count(), 0);
            var ec  = _share.GetNewOrExistingExportFor(c);
            var eci = _share.GetNewOrExistingExportFor(ci);

            _share.GetImportAs(ec.SharingUID, c2);
            _share.GetImportAs(eci.SharingUID, ci2);

            Assert.AreEqual(2, CatalogueRepository.GetAllObjects <ObjectExport>().Count());
            Assert.AreEqual(2, CatalogueRepository.GetAllObjects <ObjectImport>().Count());
            Assert.AreEqual(2, CatalogueRepository.GetAllObjects <ObjectImport>().Count());//successive calls shouldhn't generate extra entries since they are same obj
            Assert.AreEqual(2, CatalogueRepository.GetAllObjects <ObjectImport>().Count());

            //cannot delete the shared object
            Assert.Throws <Exception>(c.DeleteInDatabase);

            //can delete the import because that's ok
            Assert.DoesNotThrow(c2.DeleteInDatabase);

            //now that we deleted the import it should have deleted everything else including the CatalogueItem import which magically disapeared when we deleted the Catalogue via database level cascade events
            Assert.AreEqual(0, CatalogueRepository.GetAllObjects <ObjectImport>().Count());

            _share.GetImportAs(eci.SharingUID, ci2);
        }
        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();
        }
コード例 #20
0
        public ActionResult Edit([Bind(Exclude = "ItemID,CataID,DateCreated,DateModified,Catalogue", Include = "Title,Deadline,Description,DateModified,Complete")] CatalogueItem catalogueItem)
        {
            if (string.IsNullOrEmpty(Session["Login"] as string))
            {
                return(RedirectToAction("Index", "Login"));
            }

            if (ModelState.IsValid)
            {
                catalogueItem.ItemID = int.Parse(Session["ItemID"].ToString());

                if (Session["CataID"] != null)
                {
                    catalogueItem.CataID = int.Parse(Session["CataID"].ToString());
                }
                else if (Session["SubCataID"] != null)
                {
                    catalogueItem.SubCataID = int.Parse(Session["SubCataID"].ToString());
                }
                else
                {
                    return(View(catalogueItem));
                }

                catalogueItem.DateCreated     = DateTime.Parse(Session["DateCreated"].ToString());
                catalogueItem.DateModified    = DateTime.Now;
                db.Entry(catalogueItem).State = EntityState.Modified;

                db.SaveChanges();
                return(RedirectToAction("Index", "Home"));
            }
            ViewBag.CataID = new SelectList(db.Catalogues, "CataID", "Title", catalogueItem.CataID);
            return(View(catalogueItem));
        }
コード例 #21
0
ファイル: LookupTest.cs プロジェクト: HicServices/RDMP
        public void Test_MultipleLookupReferences()
        {
            var tiHeader      = new TableInfo(CatalogueRepository, "Head");
            var tiHeader_Code = new ColumnInfo(CatalogueRepository, "code", "", tiHeader);

            var tiLookup      = new TableInfo(CatalogueRepository, "z_HeadLookup");
            var tiLookup_Code = new ColumnInfo(CatalogueRepository, "code", "", tiLookup);
            var tiLookup_Desc = new ColumnInfo(CatalogueRepository, "desc", "", tiLookup);

            var lookup = new Lookup(CatalogueRepository, tiLookup_Desc, tiHeader_Code, tiLookup_Code, ExtractionJoinType.Left, null);

            var cata1 = new Catalogue(CatalogueRepository, "Catalogue1");
            var cata2 = new Catalogue(CatalogueRepository, "Catalogue2");

            var cata1_code = new CatalogueItem(CatalogueRepository, cata1, "code");
            var cata1_desc = new CatalogueItem(CatalogueRepository, cata1, "desc");

            new ExtractionInformation(CatalogueRepository, cata1_code, tiHeader_Code, "[tbl]..[code]");
            new ExtractionInformation(CatalogueRepository, cata1_desc, tiLookup_Desc, "[lookup]..[desc]");

            var cata2_code = new CatalogueItem(CatalogueRepository, cata2, "code");
            var cata2_desc = new CatalogueItem(CatalogueRepository, cata2, "desc");

            new ExtractionInformation(CatalogueRepository, cata2_code, tiHeader_Code, "[tbl]..[code]");
            new ExtractionInformation(CatalogueRepository, cata2_desc, tiLookup_Desc, "[lookup]..[desc]");

            new CatalogueChildProvider(CatalogueRepository, null, new ThrowImmediatelyCheckNotifier()
            {
                ThrowOnWarning = true
            }, null);
        }
コード例 #22
0
ファイル: LinkerTests.cs プロジェクト: HicServices/RDMP
        public void AddSameLinkTwice()
        {
            Catalogue     predator        = null;
            CatalogueItem lazor           = null;
            TableInfo     highEnergyTable = null;
            ColumnInfo    velocityColumn  = null;

            try
            {
                ///////////////Create the things that we are going to create relationships between /////////////////
                predator        = new Catalogue(CatalogueRepository, "Predator");
                lazor           = new CatalogueItem(CatalogueRepository, predator, "QuadlzorVelocity");
                highEnergyTable = new TableInfo(CatalogueRepository, "HighEnergyShizzle");
                velocityColumn  = new ColumnInfo(CatalogueRepository, "Velocity Of Matter", "int", highEnergyTable);

                //now you can add as many links as you want, it just skips them
                lazor.SetColumnInfo(velocityColumn);
                Assert.AreEqual(lazor.ColumnInfo, velocityColumn);
            }
            finally
            {
                lazor.DeleteInDatabase();           //delete child
                predator.DeleteInDatabase();        //delete parent

                velocityColumn.DeleteInDatabase();  //delete child
                highEnergyTable.DeleteInDatabase(); //delete parent
            }
        }
コード例 #23
0
ファイル: DependencyTests.cs プロジェクト: HicServices/RDMP
        public void ExtractionInformationTriangle()
        {
            var t   = new TableInfo(CatalogueRepository, "t");
            var col = new ColumnInfo(CatalogueRepository, "mycol", "varchar(10)", t);

            var cat = new Catalogue(CatalogueRepository, "MyCat");
            var ci  = new CatalogueItem(CatalogueRepository, cat, "myci");


            try
            {
                //col depends on tr
                Assert.Contains(t, col.GetObjectsThisDependsOn());
                Assert.Contains(col, t.GetObjectsDependingOnThis());

                //catalogue depends on catalogue items existing (slightly counter intuitive but think of it as data flow out of technical low level data through transforms into datasets - and then into researchers and research projects)
                Assert.Contains(cat, ci.GetObjectsDependingOnThis());
                Assert.Contains(ci, cat.GetObjectsThisDependsOn());

                //catalogue item should not be relying on anything currently (no link to underlying technical data)
                Assert.IsNull(ci.GetObjectsThisDependsOn());

                //now they are associated so the ci should be dependent on the col
                ci.SetColumnInfo(col);
                Assert.Contains(col, ci.GetObjectsDependingOnThis());
            }
            finally
            {
                t.DeleteInDatabase();
                cat.DeleteInDatabase();
            }
        }
コード例 #24
0
        private void Setup2Catalogues(out Catalogue c1, out Catalogue c2)
        {
            c1             = WhenIHaveA <Catalogue>();
            c1.Name        = "ffff";
            c1.Description = "A cool dataset with interesting stuff";
            c1.SaveToDatabase();

            var c1ci1 = new CatalogueItem(RepositoryLocator.CatalogueRepository, c1, "Col1");

            c1ci1.Description = "some info about column 1";
            c1ci1.SaveToDatabase();

            var c1ci2 = new CatalogueItem(RepositoryLocator.CatalogueRepository, c1, "Col2");

            c1ci2.Description = "some info about column 2";
            c1ci2.SaveToDatabase();

            c2             = WhenIHaveA <Catalogue>();
            c2.Name        = "Demog";
            c2.Description = "This is expensive dataset: $30 to use";
            c2.SaveToDatabase();

            var c2ci1 = new CatalogueItem(RepositoryLocator.CatalogueRepository, c2, "Name");

            c2ci1.Description = "Name of the patient";
            c2ci1.SaveToDatabase();
            var c2ci2 = new CatalogueItem(RepositoryLocator.CatalogueRepository, c2, "Address");

            c2ci2.Description = "Where they live";
            c2ci2.SaveToDatabase();
            var c2ci3 = new CatalogueItem(RepositoryLocator.CatalogueRepository, c2, "Postcode");

            c2ci3.Description = "Patients postcode";
            c2ci3.SaveToDatabase();
        }
コード例 #25
0
ファイル: CatalogueItemTests.cs プロジェクト: lulzzz/RDMP
        public void update_changeAllPropertiesOfCatalogueItem_passes()
        {
            Catalogue     parent = new Catalogue(CatalogueRepository, "KONGOR");
            CatalogueItem child  = new CatalogueItem(CatalogueRepository, parent, "KONGOR_SUPERKING")
            {
                Agg_method  = "Adding SetUp",
                Comments    = "do not change amagad super secret!",
                Limitations = "Extreme limitaitons",
                Description =
                    "Exciting things are going down in the streets of new your this time of year it would be a great idea if you were to go there",
                Name               = "KONGOR_MINIMAN",
                Periodicity        = Catalogue.CataloguePeriodicity.Monthly,
                Research_relevance = "Highly relevant to all fields of subatomic particle study",
                Statistical_cons   = "Dangerous cons frequent the areas that this stats is happening, be afraid",
                Topic              = "nothing much, lots of stuff"
            };

            child.SaveToDatabase();

            CatalogueItem childAfter = CatalogueRepository.GetObjectByID <CatalogueItem>(child.ID);

            Assert.IsTrue(child.Name == childAfter.Name);
            Assert.IsTrue(child.Agg_method == childAfter.Agg_method);
            Assert.IsTrue(child.Comments == childAfter.Comments);
            Assert.IsTrue(child.Limitations == childAfter.Limitations);
            Assert.IsTrue(child.Description == childAfter.Description);
            Assert.IsTrue(child.Periodicity == childAfter.Periodicity);
            Assert.IsTrue(child.Research_relevance == childAfter.Research_relevance);
            Assert.IsTrue(child.Statistical_cons == childAfter.Statistical_cons);
            Assert.IsTrue(child.Topic == childAfter.Topic);

            child.DeleteInDatabase();
            parent.DeleteInDatabase();
        }
コード例 #26
0
        private Catalogue SetupATestCatalogue(SqlConnectionStringBuilder builder, string database, string table)
        {
            //create a new catalogue for test data (in the test data catalogue)
            var cat = new Catalogue(CatalogueRepository, "DeleteMe");
            TableInfoImporter importer = new TableInfoImporter(CatalogueRepository, builder.DataSource, database, table, DatabaseType.MicrosoftSQLServer, builder.UserID, builder.Password);
            importer.DoImport(out var tableInfo, out var columnInfos);

            toCleanUp.Push(cat);

            //push the credentials if there are any
            var creds = (DataAccessCredentials)tableInfo.GetCredentialsIfExists(DataAccessContext.InternalDataProcessing);
            if (creds != null)
                toCleanUp.Push(creds);

            //and the TableInfo
            toCleanUp.Push(tableInfo);

            //for each column we will add a new one to the
            foreach (ColumnInfo col in columnInfos)
            {
                //create it with the same name
                var cataItem = new CatalogueItem(CatalogueRepository, cat, col.Name.Substring(col.Name.LastIndexOf(".") + 1).Trim('[', ']', '`'));
                toCleanUp.Push(cataItem);

                cataItem.SetColumnInfo(col);

                toCleanUp.Push(col);
            }

            return cat;
        }
コード例 #27
0
 private CatalogueItem[] GetAllCatalogueItemsSharingNameWith(CatalogueItem catalogueItemBeingSaved)
 {
     return(Activator.CoreChildProvider.AllCatalogueItems
            .Where(ci =>
                   ci.Name.Equals(catalogueItemBeingSaved.Name, StringComparison.CurrentCultureIgnoreCase) &&
                   ci.ID != catalogueItemBeingSaved.ID)
            .ToArray());
 }
コード例 #28
0
    void AddItem()
    {
        CatalogueItem newItem = new CatalogueItem();

        newItem.itemName = "New Item";
        inventoryItemList.itemList.Add(newItem);
        viewIndex = inventoryItemList.itemList.Count;
    }
コード例 #29
0
 public bool ItemMatches(CatalogueItem item)
 {
     return(MatchType switch
     {
         CompoundMatchType.And => ChildRules.All(rule => rule.ItemMatches(item)),
         CompoundMatchType.Or => ChildRules.Any(rule => rule.ItemMatches(item)),
         CompoundMatchType.Not => !ChildRules.Any(rule => rule.ItemMatches(item)),
         _ => throw new InvalidOperationException($"Unkown MatchType {MatchType}")
     });
コード例 #30
0
        public ExecuteCommandLinkCatalogueItemToColumnInfo(IActivateItems activator, CatalogueItem catalogueItem) : base(activator)
        {
            _catalogueItem = catalogueItem;

            if (_catalogueItem.ColumnInfo_ID != null)
            {
                SetImpossible("ColumnInfo is already set");
            }
        }
コード例 #31
0
 public void AddToCatalogueItems(CatalogueItem catalogueItem)
 {
     base.AddObject("CatalogueItems", catalogueItem);
 }
コード例 #32
0
ファイル: Utils.cs プロジェクト: clarencemorse/myzilla
        /// <summary>
        /// Populate the specified list box.
        /// </summary>
        /// <param name="lbControl">The control to be populated.</param>
        /// <param name="lst">
        /// The list of items. 
        /// An item in the list has the following format: 'value, text'
        /// </param>
        public static void PopulateListBox(ListBox lbControl, List<string> lst)
        {
            lbControl.DataSource = null;

            ArrayList al = new ArrayList();

            foreach (string item in lst)
            {
                string[] itemValueText = item.Split(',');

                CatalogueItem cItem = null;
                if (itemValueText.Length == 2)
                {

                    cItem = new CatalogueItem(itemValueText[0], itemValueText[1]);
                }
                else
                {
                    cItem = new CatalogueItem(itemValueText[0], itemValueText[0]);
                }

                al.Add(cItem);
            }

            lbControl.DisplayMember = "CatText";
            lbControl.ValueMember = "CatValue";
            lbControl.DataSource = al;
        }
コード例 #33
0
ファイル: Utils.cs プロジェクト: clarencemorse/myzilla
        public static void PopulateListBox(ListBox lbControl, NameValueCollection lst)
        {
            lbControl.DataSource = null;

            ArrayList al = new ArrayList();

            for (int i = 0; i < lst.Count; i++)
            {
                string[] element = lst.GetKey(i).Split(',');

                if (element.Length == 2)
                {
                    // items in collection are stored as <element, parent>,and the element is (value, text)

                    CatalogueItem cItem = new CatalogueItem(element[0], element[1]);

                    al.Add(cItem);

                }
                else
                {
                    // items in collection are stored as <element, parent>
                    // I assume that the dependent collections are value = key  // mmi
                    CatalogueItem cItem = new CatalogueItem(lst.GetKey(i), lst.GetKey(i));

                    al.Add(cItem);

                }

            }

            lbControl.DisplayMember = "CatText";
            lbControl.ValueMember = "CatValue";
            lbControl.DataSource = al;
        }
コード例 #34
0
ファイル: Utils.cs プロジェクト: clarencemorse/myzilla
        public static void FillAssignToCombo(string component, ComboBox cmbAssignedTo, NameValueCollection catAssignedTo)
        {
            // populate the AssignTo and CC accordingly.

            List<string> alAssignedTo = new List<string>();

            for (int i = 0; i < catAssignedTo.Count; i++)
            {
                if (catAssignedTo.GetKey(i) == component)
                {
                    if (catAssignedTo.GetValues(i) != null)
                    {
                        foreach (string item in catAssignedTo.GetValues(i))
                        {
                            alAssignedTo.Add(item);
                        }
                    }
                }
            }

            if (alAssignedTo.Count > 0)
            {

                ArrayList al = new ArrayList();

                if (alAssignedTo.Count == 1)
                {
                    al.Add(new CatalogueItem(alAssignedTo[0], alAssignedTo[0]));
                }
                else
                {
                    // alAssignedTo[0] is the default assignee
                    for (int i = 1; i < alAssignedTo.Count; i++)
                    {
                        CatalogueItem item = new CatalogueItem(alAssignedTo[i], alAssignedTo[i]);

                        al.Add(item);
                    }

                }

                cmbAssignedTo.DisplayMember = "CatText";
                cmbAssignedTo.ValueMember = "CatValue";
                cmbAssignedTo.DataSource = al;

                cmbAssignedTo.SelectedValue = alAssignedTo[0];

            }
            else
            {
                // no code here.
            }
        }
コード例 #35
0
ファイル: Utils.cs プロジェクト: clarencemorse/myzilla
        /// <summary>
        /// Populate the specified combo box.
        /// </summary>
        /// <param name="cbControl">The control to be populated.</param>
        /// <param name="lst">
        /// The list of items. 
        /// An item in the list has the following format: 'value, text'
        /// </param>
        public static void PopulateComboBox(ComboBox cbControl, NameValueCollection lst)
        {
            cbControl.DataSource = null;

            if (lst != null && lst.Count > 0)
            {

                ArrayList al = new ArrayList();

                for (int i = 0; i < lst.Count; i++)
                {
                    string[] element = lst.GetKey(i).Split(',');

                    if (element.Length == 2)
                    {
                        // items in collection are stored as <element, parent>,and the element is (value, text)

                        CatalogueItem cItem = new CatalogueItem(element[0], element[1]);

                        al.Add(cItem);

                    }
                    else
                    {
                        string[] values = lst.GetValues(i);
                        foreach (string strValue in values)
                        {
                            CatalogueItem cItem = new CatalogueItem(strValue, strValue);
                            al.Add(cItem);

                        }
                    }

                }

                cbControl.DisplayMember = "CatText";
                cbControl.ValueMember = "CatValue";
                cbControl.DataSource = al;
            }
        }
コード例 #36
0
 public static CatalogueItem CreateCatalogueItem(long catalogueId, long productId, global::System.DateTimeOffset validFrom, global::System.DateTimeOffset validUntil, global::System.DateTimeOffset endOfLife, long ID, global::System.Guid tid, string name, long createdById, long modifiedById, global::System.DateTimeOffset created, global::System.DateTimeOffset modified)
 {
     CatalogueItem catalogueItem = new CatalogueItem();
     catalogueItem.CatalogueId = catalogueId;
     catalogueItem.ProductId = productId;
     catalogueItem.ValidFrom = validFrom;
     catalogueItem.ValidUntil = validUntil;
     catalogueItem.EndOfLife = endOfLife;
     catalogueItem.Id = ID;
     catalogueItem.Tid = tid;
     catalogueItem.Name = name;
     catalogueItem.CreatedById = createdById;
     catalogueItem.ModifiedById = modifiedById;
     catalogueItem.Created = created;
     catalogueItem.Modified = modified;
     return catalogueItem;
 }