public static List <HtmlReportDataQualityCategory> GroupByCategories( [NotNull] IIssueStatistics issueStatistics, [NotNull] HtmlReportDataQualityCategoryComparer categoryComparer, [NotNull] HtmlReportQualityConditionComparer qualityConditionComparer, [NotNull] HtmlReportIssueGroupComparer issueGroupComparer, [CanBeNull] Func <IssueGroup, string> getTestIdentifier, [CanBeNull] IHtmlDataQualityCategoryOptionsProvider optionsProvider, [NotNull] out List <HtmlReportIssueGroup> htmlReportIssueGroups) { List <IssueGroup> issueGroupList = issueStatistics.GetIssueGroups().ToList(); IDictionary <string, HtmlReportDataQualityCategory> reportCategories = MapReportCategories(issueGroupList, issueStatistics.ExceptionCategories, categoryComparer, qualityConditionComparer, issueGroupComparer, optionsProvider); int maximumIssueCount = GetMaximumIssueCount(issueGroupList); htmlReportIssueGroups = new List <HtmlReportIssueGroup>(); foreach (IssueGroup issueGroup in issueGroupList) { string testIdentifier = getTestIdentifier != null ? getTestIdentifier(issueGroup) : issueGroup.QualityCondition.TestDescriptor.Name; var reportIssueGroup = new HtmlReportIssueGroup(issueGroup, maximumIssueCount, testIdentifier, GetHtmlExceptionCategories( issueStatistics, issueGroup)); HtmlReportDataQualityCategory reportCategory = reportCategories[GetCategoryKey(issueGroup.QualityCondition.Category)]; reportCategory.AddIssueGroup(reportIssueGroup, issueGroup.IssueCount); htmlReportIssueGroups.Add(reportIssueGroup); } htmlReportIssueGroups.Sort(issueGroupComparer); // exclude undefined root category if it does not contain any quality conditions return(reportCategories.Values .Where(cat => !cat.IsRoot || !cat.IsUndefinedCategory || cat.QualityConditions.Count > 0) .Distinct() .OrderBy(c => c, categoryComparer) .ToList()); }
public HtmlReportDataQualityCategory( [CanBeNull] DataQualityCategory category, [NotNull] IList <ExceptionCategory> exceptionCategories, [CanBeNull] HtmlDataQualityCategoryOptions options, [NotNull] HtmlReportDataQualityCategoryComparer categoryComparer, [NotNull] HtmlReportQualityConditionComparer qualityConditionComparer, [NotNull] HtmlReportIssueGroupComparer issueGroupComparer) { Assert.ArgumentNotNull(categoryComparer, nameof(categoryComparer)); Assert.ArgumentNotNull(exceptionCategories, nameof(exceptionCategories)); Assert.ArgumentNotNull(qualityConditionComparer, nameof(qualityConditionComparer)); Assert.ArgumentNotNull(issueGroupComparer, nameof(issueGroupComparer)); _category = category; _exceptionCategories = exceptionCategories; _categoryComparer = categoryComparer; _qualityConditionComparer = qualityConditionComparer; _issueGroupComparer = issueGroupComparer; if (category == null) { IsUndefinedCategory = true; _uniqueName = "<nocategory>"; Name = string.Empty; Abbreviation = string.Empty; Description = string.Empty; } else { IsUndefinedCategory = false; _uniqueName = category.GetQualifiedName("||"); Name = GetDisplayName(category, options); Abbreviation = category.Abbreviation ?? string.Empty; Description = category.Description ?? string.Empty; } }
private static Dictionary <string, HtmlReportDataQualityCategory> MapReportCategories ([NotNull] IEnumerable <IssueGroup> issueGroups, [NotNull] IList <ExceptionCategory> exceptionCategories, [NotNull] HtmlReportDataQualityCategoryComparer categoryComparer, [NotNull] HtmlReportQualityConditionComparer qualityConditionComparer, [NotNull] HtmlReportIssueGroupComparer issueGroupComparer, [CanBeNull] IHtmlDataQualityCategoryOptionsProvider optionsProvider = null) { var result = new Dictionary <string, HtmlReportDataQualityCategory>(); foreach (IssueGroup issueGroup in issueGroups) { // add the next non-ignored category AddReportCategory(issueGroup.QualityCondition.Category, exceptionCategories, categoryComparer, qualityConditionComparer, issueGroupComparer, result, optionsProvider); } return(result); }
private static HtmlReportDataQualityCategory AddReportCategory( [CanBeNull] DataQualityCategory category, [NotNull] IList <ExceptionCategory> exceptionCategories, [NotNull] HtmlReportDataQualityCategoryComparer categoryComparer, [NotNull] HtmlReportQualityConditionComparer qualityConditionComparer, [NotNull] HtmlReportIssueGroupComparer issueGroupComparer, [NotNull] IDictionary <string, HtmlReportDataQualityCategory> reportCategories, [CanBeNull] IHtmlDataQualityCategoryOptionsProvider optionsProvider = null) { string key = GetCategoryKey(category); HtmlReportDataQualityCategory result; if (reportCategories.TryGetValue(key, out result)) { // already added (including parents) return(result); } HtmlDataQualityCategoryOptions options = GetReportCategoryOptions(optionsProvider, category); if (category != null && options != null && options.IgnoreCategoryLevel) { // skip this category level result = AddReportCategory(category.ParentCategory, exceptionCategories, categoryComparer, qualityConditionComparer, issueGroupComparer, reportCategories, optionsProvider); reportCategories.Add(key, result); return(result); } result = new HtmlReportDataQualityCategory(category, exceptionCategories, options, categoryComparer, qualityConditionComparer, issueGroupComparer); reportCategories.Add(key, result); if (category?.ParentCategory != null) { HtmlReportDataQualityCategory parent = AddReportCategory(category.ParentCategory, exceptionCategories, categoryComparer, qualityConditionComparer, issueGroupComparer, reportCategories, optionsProvider); if (!parent.IsUndefinedCategory) { result.ParentCategory = parent; result.ParentCategory.IncludeSubCategory(result); } } return(result); }