public static HtmlQualitySpecification CreateHtmlQualitySpecification(
            [NotNull] QualitySpecification qualitySpecification,
            [CanBeNull] IHtmlDataQualityCategoryOptionsProvider optionsProvider,
            bool showQualityConditionUuids = true)
        {
            Assert.ArgumentNotNull(qualitySpecification, nameof(qualitySpecification));

            IDictionary <TestDescriptor, HtmlTestDescriptor> htmlTestDescriptors =
                GetHtmlTestDescriptors(qualitySpecification);

            List <HtmlQualitySpecificationElement> htmlElements;
            IEnumerable <HtmlDataQualityCategory>  htmlCategories =
                GroupByCategories(qualitySpecification.Elements,
                                  htmlTestDescriptors,
                                  new HtmlDataQualityCategoryComparer(),
                                  new HtmlQualitySpecificationElementComparer(),
                                  optionsProvider, out htmlElements);

            IEnumerable <HtmlDataModel> dataModels = GetInvolvedDataModels(htmlElements);

            return(new HtmlQualitySpecification(qualitySpecification,
                                                htmlCategories,
                                                htmlElements,
                                                htmlTestDescriptors.Values
                                                .OrderBy(t => t.Name),
                                                dataModels,
                                                DateTime.Now)
            {
                ShowQualityConditionUuids = showQualityConditionUuids
            });
        }
Example #2
0
 private static HtmlDataQualityCategoryOptions GetReportCategoryOptions(
     [CanBeNull] IHtmlDataQualityCategoryOptionsProvider categoryOptionsProvider,
     [CanBeNull] DataQualityCategory category)
 {
     return(category == null
                                ? null
                                : categoryOptionsProvider?.GetCategoryOptions(category.Uuid));
 }
        private static HtmlDataQualityCategory AddDataQualityCategory(
            [CanBeNull] DataQualityCategory category,
            [NotNull] HtmlDataQualityCategoryComparer categoryComparer,
            [NotNull] HtmlQualitySpecificationElementComparer elementComparer,
            [NotNull] IDictionary <string, HtmlDataQualityCategory> reportCategories,
            [CanBeNull] IHtmlDataQualityCategoryOptionsProvider optionsProvider = null)
        {
            string key = GetCategoryKey(category);

            HtmlDataQualityCategory 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 = AddDataQualityCategory(category.ParentCategory,
                                                categoryComparer,
                                                elementComparer,
                                                reportCategories,
                                                optionsProvider);

                reportCategories.Add(key, result);
                return(result);
            }

            result = new HtmlDataQualityCategory(category,
                                                 options,
                                                 categoryComparer,
                                                 elementComparer);
            reportCategories.Add(key, result);

            if (category != null && category.ParentCategory != null)
            {
                HtmlDataQualityCategory parent = AddDataQualityCategory(category.ParentCategory,
                                                                        categoryComparer,
                                                                        elementComparer,
                                                                        reportCategories,
                                                                        optionsProvider);
                if (!parent.IsUndefinedCategory)
                {
                    result.ParentCategory = parent;
                    result.ParentCategory.IncludeSubCategory(result);
                }
            }

            return(result);
        }
Example #4
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());
        }
        private static IEnumerable <HtmlDataQualityCategory> GroupByCategories(
            [NotNull] IEnumerable <QualitySpecificationElement> elements,
            [NotNull] IDictionary <TestDescriptor, HtmlTestDescriptor> testDescriptors,
            [NotNull] HtmlDataQualityCategoryComparer categoryComparer,
            [NotNull] HtmlQualitySpecificationElementComparer elementComparer,
            [CanBeNull] IHtmlDataQualityCategoryOptionsProvider optionsProvider,
            [NotNull] out List <HtmlQualitySpecificationElement>
            htmlQualitySpecificationElements)
        {
            List <QualitySpecificationElement> elementsList = elements.ToList();

            IDictionary <string, HtmlDataQualityCategory> reportCategories =
                MapReportCategories(elementsList,
                                    categoryComparer,
                                    elementComparer,
                                    optionsProvider);

            htmlQualitySpecificationElements = new List <HtmlQualitySpecificationElement>();

            foreach (QualitySpecificationElement element in elementsList)
            {
                HtmlDataQualityCategory reportCategory =
                    reportCategories[GetCategoryKey(element.QualityCondition.Category)];

                HtmlTestDescriptor htmlTestDescriptor =
                    testDescriptors[element.QualityCondition.TestDescriptor];

                var htmlQualityCondition = new HtmlQualityCondition(
                    element.QualityCondition, htmlTestDescriptor, reportCategory);

                var htmlElement = new HtmlQualitySpecificationElement(htmlQualityCondition,
                                                                      element);

                reportCategory.AddQualitySpecificationElement(htmlElement);
                htmlQualitySpecificationElements.Add(htmlElement);

                htmlTestDescriptor.AddReferencingElement(htmlElement);
            }

            htmlQualitySpecificationElements.Sort(elementComparer);

            // exclude undefined root category if it does not contain any quality conditions

            return(reportCategories.Values
                   .Where(cat => !cat.IsRoot ||
                          !cat.IsUndefinedCategory ||
                          cat.QualitySpecificationElements.Count > 0)
                   .Distinct()
                   .OrderBy(c => c, categoryComparer)
                   .ToList());
        }
        private static List <HtmlReportDataQualityCategory> GroupByCategories(
            [NotNull] IEnumerable <IssueGroup> issueGroups,
            [CanBeNull] IHtmlDataQualityCategoryOptionsProvider optionsProvider,
            [NotNull] out List <HtmlReportIssueGroup> reportIssueGroups)
        {
            var statistics = new IssueStatistics(issueGroups);

            return(HtmlReportUtils.GroupByCategories(
                       statistics,
                       new HtmlReportDataQualityCategoryComparer(),
                       new HtmlReportQualityConditionComparer(),
                       new HtmlReportIssueGroupComparer(),
                       ig => "testidentifier",
                       optionsProvider,
                       out reportIssueGroups));
        }
        private static Dictionary <string, HtmlDataQualityCategory> MapReportCategories
            ([NotNull] IEnumerable <QualitySpecificationElement> issueGroups,
            [NotNull] HtmlDataQualityCategoryComparer categoryComparer,
            [NotNull] HtmlQualitySpecificationElementComparer qualityConditionComparer,
            [CanBeNull] IHtmlDataQualityCategoryOptionsProvider optionsProvider = null)
        {
            var result = new Dictionary <string, HtmlDataQualityCategory>();

            foreach (QualitySpecificationElement issueGroup in issueGroups)
            {
                // add the next non-ignored category
                AddDataQualityCategory(issueGroup.QualityCondition.Category,
                                       categoryComparer,
                                       qualityConditionComparer,
                                       result,
                                       optionsProvider);
            }

            return(result);
        }
Example #8
0
        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);
        }
Example #9
0
        public HtmlReportModel(
            [NotNull] QualitySpecification qualitySpecification,
            [NotNull] IIssueStatistics statistics,
            [NotNull] XmlVerificationReport verificationReport,
            [NotNull] string outputDirectoryPath,
            [NotNull] string verificationReportName,
            [CanBeNull] string issueGeodatabasePath,
            [CanBeNull] IEnumerable <string> issueMapFilePaths,
            [NotNull] IEnumerable <string> htmlReportFileNames,
            [CanBeNull] IEnumerable <string> qualitySpecificationReportFilePaths,
            [NotNull] IHtmlDataQualityCategoryOptionsProvider categoryOptionsProvider)
        {
            Assert.ArgumentNotNull(qualitySpecification, nameof(qualitySpecification));
            Assert.ArgumentNotNull(statistics, nameof(statistics));
            Assert.ArgumentNotNull(verificationReport, nameof(verificationReport));
            Assert.ArgumentNotNullOrEmpty(outputDirectoryPath, nameof(outputDirectoryPath));
            Assert.ArgumentNotNullOrEmpty(verificationReportName,
                                          nameof(verificationReportName));
            Assert.ArgumentNotNull(categoryOptionsProvider, nameof(categoryOptionsProvider));

            _verificationReport = verificationReport;
            HtmlReportFiles     =
                htmlReportFileNames.Select(
                    fileName =>
                    new OutputFile(
                        Path.Combine(outputDirectoryPath, fileName)))
                .ToList();
            IssueMapFiles = issueMapFilePaths?.Select(path => new OutputFile(path))
                            .ToList() ?? new List <OutputFile>();
            QualitySpecificationReportFiles =
                qualitySpecificationReportFilePaths?.Select(path => new OutputFile(path))
                .ToList() ?? new List <OutputFile>();

            Properties               = new NameValuePairs(GetProperties(verificationReport.Properties));
            QualitySpecification     = qualitySpecification.Name;
            VerificationWasCancelled = verificationReport.Cancelled;
            HasVerificationExtent    = verificationReport.TestExtent != null;

            if (verificationReport.TestExtent != null)
            {
                VerificationExtentString = HtmlReportUtils.FormatExtent(
                    verificationReport.TestExtent);
            }

            if (verificationReport.AreaOfInterest != null)
            {
                AreaOfInterest = HtmlReportUtils.GetAreaOfInterest(
                    verificationReport.AreaOfInterest);
            }

            OutputDirectoryPath        = outputDirectoryPath;
            OutputDirectoryName        = Assert.NotNull(Path.GetFileName(outputDirectoryPath));
            OutputDirectoryRelativeUrl = HtmlReportUtils.GetRelativeUrl(string.Empty);
            OutputDirectoryAbsoluteUrl = outputDirectoryPath;

            VerificationReportName = verificationReportName;
            VerificationReportUrl  = HtmlReportUtils.GetRelativeUrl(verificationReportName);

            if (IssueMapFiles.Count > 0)
            {
                OutputFile issueMapFile = IssueMapFiles[0];

                MapDocumentName = issueMapFile.FileName;
                MapDocumentUrl  = issueMapFile.Url;
            }

            IssueGeodatabaseName = Path.GetFileName(issueGeodatabasePath);

            List <HtmlReportDataQualityCategory> categories =
                HtmlReportUtils.GroupByCategories(
                    statistics,
                    new HtmlReportDataQualityCategoryComparer(),
                    new HtmlReportQualityConditionComparer(),
                    new HtmlReportIssueGroupComparer(),
                    GetTestIdentifier,
                    categoryOptionsProvider,
                    out _issueGroups);

            CategoriesWithIssues = categories.Where(c => c.IssueGroups.Count > 0).ToList();
            RootCategories       = categories.Where(c => c.IsRoot).ToList();

            HasWarnings = statistics.WarningCount > 0;
            HasErrors   = statistics.ErrorCount > 0;
            HasIssues   = !HasWarnings && !HasErrors;

            IssueCount = HtmlReportUtils.Format(statistics.WarningCount +
                                                statistics.ErrorCount);
            WarningCount   = HtmlReportUtils.Format(statistics.WarningCount);
            ErrorCount     = HtmlReportUtils.Format(statistics.ErrorCount);
            ExceptionCount = HtmlReportUtils.Format(statistics.ExceptionCount);

            TimeSpan t = TimeSpan.FromSeconds(verificationReport.ProcessingTimeSeconds);

            ProcessingTime = HtmlReportUtils.FormatTimeSpan(t);
        }