private void TestScoringFlag(Action <Catalogue, ExtractableDataSet> setter, bool expectedResult) { // Filter is hungry and eager to please. If you want to see ProjectSpecific Catalogues then // that it will show you them regardless of other settings. Likewise clicking Deprecated shows // all deprecated catalogues regardless of other settings. // // So set all to false to except the condition we are testing UserSettings.ShowDeprecatedCatalogues = false; UserSettings.ShowNonExtractableCatalogues = false; UserSettings.ShowProjectSpecificCatalogues = false; UserSettings.ShowInternalCatalogues = false; UserSettings.ShowColdStorageCatalogues = false; var c = WhenIHaveA <Catalogue>(); c.Name = "Bunny"; c.SaveToDatabase(); // this makes c extractable (the usual case for Catalogues) var eds = new ExtractableDataSet(Repository, c); eds.SaveToDatabase(); setter(c, eds); c.SaveToDatabase(); var scorer = new SearchablesMatchScorer() { RespectUserSettings = true }; var childProvider = new DataExportChildProvider(RepositoryLocator, null, new ThrowImmediatelyCheckNotifier(), null); // user is searching for the text 'troll' var scores = scorer.ScoreMatches(childProvider.GetAllSearchables(), "Bunny", CancellationToken.None, new List <Type>()); var score = scores.Single(d => Equals(d.Key.Key, c)); if (expectedResult) { Assert.Greater(score.Value, 0); } else { // score 0 and don't be included in results Assert.AreEqual(0, score.Value); } // Cleanup test foreach (var d in Repository.GetAllObjects <ExtractableDataSet>()) { d.DeleteInDatabase(); } foreach (var cat in Repository.GetAllObjects <Catalogue>()) { cat.DeleteInDatabase(); } }
public override void Execute() { base.Execute(); _extractableDataSet.Project_ID = null; _extractableDataSet.SaveToDatabase(); foreach (var ei in _catalogue.GetAllExtractionInformation(ExtractionCategory.ProjectSpecific)) { ei.ExtractionCategory = ExtractionCategory.Core; ei.SaveToDatabase(); } Publish(_catalogue); }
/// <inheritdoc/> public virtual ICatalogue CreateAndConfigureCatalogue(ITableInfo tableInfo, ColumnInfo[] extractionIdentifierColumns, string initialDescription, IProject projectSpecific, CatalogueFolder catalogueFolder) { // Create a new Catalogue based on the table info var engineer = new ForwardEngineerCatalogue(tableInfo, tableInfo.ColumnInfos, true); engineer.ExecuteForwardEngineering(out ICatalogue cata, out _, out ExtractionInformation[] eis); // if we know the linkable private identifier column(s) if (extractionIdentifierColumns != null && extractionIdentifierColumns.Any()) { // Make the Catalogue extractable var eds = new ExtractableDataSet(RepositoryLocator.DataExportRepository, cata); // Mark the columns specified IsExtractionIdentifier foreach (var col in extractionIdentifierColumns) { var match = eis.FirstOrDefault(ei => ei.ColumnInfo?.ID == col.ID); if (match == null) { throw new ArgumentException($"Supplied ColumnInfo {col.GetRuntimeName()} was not found amongst the columns created"); } match.IsExtractionIdentifier = true; match.SaveToDatabase(); } // Catalogue must be extractable to be project specific if (projectSpecific != null) { eds.Project_ID = projectSpecific.ID; eds.SaveToDatabase(); } } if (catalogueFolder != null) { cata.Folder = catalogueFolder; cata.SaveToDatabase(); } return(cata); }
private void SetDisabled(bool disable) { _dataset.DisableExtraction = disable; _dataset.SaveToDatabase(); Publish(_dataset); }