Esempio n. 1
0
        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());
        }
Esempio n. 2
0
        public static string GetQualifiedText(
            [NotNull] HtmlReportDataQualityCategory category,
            [NotNull] Func <HtmlReportDataQualityCategory, string> getText,
            [CanBeNull] string separator = "/",
            bool skipNullOrEmpty         = false)
        {
            Assert.ArgumentNotNull(category, nameof(category));

            var strings = new List <string>();

            CollectStrings(strings, category, getText, skipNullOrEmpty);

            return(string.Join(separator, strings.ToArray()));
        }
Esempio n. 3
0
        private static void CollectStrings(
            [NotNull] ICollection <string> strings,
            [NotNull] HtmlReportDataQualityCategory category,
            [NotNull] Func <HtmlReportDataQualityCategory, string> getString,
            bool skipNullOrEmpty)
        {
            if (category.ParentCategory != null)
            {
                CollectStrings(strings, category.ParentCategory, getString, skipNullOrEmpty);
            }

            string value = getString(category);

            if (!skipNullOrEmpty || !string.IsNullOrEmpty(value))
            {
                strings.Add(getString(category));
            }
        }
Esempio n. 4
0
        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);
        }