public void CreateNew_UseConstraint() { // Clean up any existing regexes CatalogueRepository.GetAllObjects <StandardRegex>("WHERE ConceptName = 'Fish'").ToList().ForEach(r => r.DeleteInDatabase()); var regex = new StandardRegex(CatalogueRepository); try { Assert.IsNotNull(regex.ConceptName); Assert.IsTrue(string.IsNullOrEmpty(regex.Description)); regex.ConceptName = "Fish"; regex.Regex = "^(Fish)$"; regex.SaveToDatabase(); StandardRegexConstraint constraint = new StandardRegexConstraint(CatalogueRepository); constraint.CatalogueStandardRegex = regex; Assert.IsNull(constraint.Validate("Fish", null, null)); ValidationFailure failure = constraint.Validate("FishFingers", null, null); Assert.IsNotNull(failure); } finally { regex.DeleteInDatabase(); } }
public override void Execute() { base.Execute(); var existing = HICDatabaseConfiguration.GetGlobalIgnorePatternIfAny(BasicActivator.RepositoryLocator.CatalogueRepository); if (existing == null) { existing = new StandardRegex(BasicActivator.RepositoryLocator.CatalogueRepository) { ConceptName = StandardRegex.DataLoadEngineGlobalIgnorePattern, Description = "Regex that will be applied as an ignore when running the data load engine", Regex = "^ignore_.*" }; existing.SaveToDatabase(); } if (_explicitPatternProvided) { existing.Regex = _pattern; existing.SaveToDatabase(); } else { Publish(existing); Activate(existing); } }
public override void Execute() { var regex = new StandardRegex(Activator.RepositoryLocator.CatalogueRepository); Publish(regex); Emphasise(regex); Activate(regex); }
protected override void SetBindings(BinderWithErrorProviderFactory rules, StandardRegex databaseObject) { base.SetBindings(rules, databaseObject); Bind(tbID, "Text", "ID", r => r.ID); Bind(tbConceptName, "Text", "ConceptName", r => r.ConceptName); Bind(tbRegex, "Text", "Regex", r => r.Regex); Bind(tbDescription, "Text", "Description", r => r.Description); }
public override void SetDatabaseObject(IActivateItems activator, StandardRegex databaseObject) { base.SetDatabaseObject(activator, databaseObject); _standardRegex = databaseObject; CommonFunctionality.AddChecks(_standardRegex); CommonFunctionality.StartChecking(); }
public void TestTemporalTable(bool ignoreWithGlobalPattern) { var dbtype = FAnsi.DatabaseType.MicrosoftSQLServer; var db = GetCleanedServer(dbtype); using (var con = db.Server.GetConnection()) { con.Open(); db.Server.GetCommand(sql, con).ExecuteNonQuery(); } var tbl = db.ExpectTable("Employee"); var defaults = new ServerDefaults(CatalogueRepository); var logServer = defaults.GetDefaultFor(PermissableDefaults.LiveLoggingServer_ID); var logManager = new LogManager(logServer); var raw = db.Server.ExpectDatabase(db.GetRuntimeName() + "_RAW"); if (raw.Exists()) { raw.Drop(); } //define a new load configuration var lmd = new LoadMetadata(CatalogueRepository, "MyLoad"); lmd.IgnoreTrigger = true; lmd.SaveToDatabase(); ITableInfo ti = Import(tbl, lmd, logManager); var projectDirectory = SetupLoadDirectory(lmd); CreateCSVProcessTask(lmd, ti, "*.csv"); //create a text file to load where we update Frank's favourite colour (it's a pk field) and we insert a new record (MrMurder) File.WriteAllText( Path.Combine(projectDirectory.ForLoading.FullName, "LoadMe.csv"), @"EmployeeID,Name,Position,Department,Address,AnnualSalary 1,Frank,Boss,Department of F'Tang, 22 Innsmouth Way, 55000.5 2,Herbert,Super Boss,Department of F'Tang, 22 Innsmouth Way, 155000.5"); //the checks will probably need to be run as ddl admin because it involves creating _Archive table and trigger the first time //clean SetUp RAW / STAGING etc and generally accept proposed cleanup operations var checker = new CheckEntireDataLoadProcess(lmd, new HICDatabaseConfiguration(lmd), new HICLoadConfigurationFlags(), CatalogueRepository.MEF); checker.Check(new AcceptAllCheckNotifier()); if (ignoreWithGlobalPattern) { var regex = new StandardRegex(RepositoryLocator.CatalogueRepository) { ConceptName = StandardRegex.DataLoadEngineGlobalIgnorePattern, Regex = "^Valid((From)|(To))$" }; regex.SaveToDatabase(); } else { var col = ti.ColumnInfos.Single(c => c.GetRuntimeName().Equals("ValidFrom")); col.IgnoreInLoads = true; col.SaveToDatabase(); col = ti.ColumnInfos.Single(c => c.GetRuntimeName().Equals("ValidTo")); col.IgnoreInLoads = true; col.SaveToDatabase(); } var dbConfig = new HICDatabaseConfiguration(lmd, null); var loadFactory = new HICDataLoadFactory( lmd, dbConfig, new HICLoadConfigurationFlags(), CatalogueRepository, logManager ); var exe = loadFactory.Create(new ThrowImmediatelyDataLoadEventListener()); var exitCode = exe.Run( new DataLoadJob(RepositoryLocator, "Go go go!", logManager, lmd, projectDirectory, new ThrowImmediatelyDataLoadEventListener(), dbConfig), new GracefulCancellationToken()); Assert.AreEqual(ExitCodeType.Success, exitCode); //frank should be updated to his new departement and role Assert.AreEqual(2, tbl.GetRowCount()); var result = tbl.GetDataTable(); var frank = result.Rows.Cast <DataRow>().Single(r => (string)r["Name"] == "Frank"); Assert.AreEqual("Department of F'Tang", frank["Department"]); Assert.AreEqual("Boss", frank["Position"]); //post test cleanup foreach (var regex in RepositoryLocator.CatalogueRepository.GetAllObjects <StandardRegex>()) { regex.DeleteInDatabase(); } }