Esempio n. 1
0
        private static DataQualityCategoryItem GetDataQualityCategoryItem(
            [NotNull] Dictionary <DataQualityCategory, DataQualityCategoryItem> itemsByCategory,
            [NotNull] DataQualityCategory category)
        {
            Assert.ArgumentNotNull(itemsByCategory, nameof(itemsByCategory));
            Assert.ArgumentNotNull(category, nameof(category));

            DataQualityCategoryItem item;

            if (itemsByCategory.TryGetValue(category, out item))
            {
                return(item);
            }

            item = new DataQualityCategoryItem(category);
            itemsByCategory.Add(category, item);

            if (category.ParentCategory != null)
            {
                DataQualityCategoryItem parentItem = GetDataQualityCategoryItem(itemsByCategory,
                                                                                category
                                                                                .ParentCategory);
                parentItem.SubCategories.Add(item);
            }

            return(item);
        }
Esempio n. 2
0
        private static IEnumerable <DataQualityCategoryItem> GetDataQualityCategoryHierarchy(
            [NotNull] IEnumerable <SpecificationDataset> qualityConditionVerifications)
        {
            var itemsByCategory =
                new Dictionary <DataQualityCategory, DataQualityCategoryItem>();
            var noCategoryItem = new DataQualityCategoryItem(null);

            foreach (
                SpecificationDataset specificationDataset in
                qualityConditionVerifications)
            {
                QualityCondition qualityCondition = specificationDataset.QualityCondition;
                if (qualityCondition == null || qualityCondition.Category == null)
                {
                    noCategoryItem.SpecificationDatasets.Add(specificationDataset);
                }
                else
                {
                    DataQualityCategoryItem item = GetDataQualityCategoryItem(itemsByCategory,
                                                                              qualityCondition
                                                                              .Category);

                    item.SpecificationDatasets.Add(specificationDataset);
                }
            }

            var rootCategoryItems = new HashSet <DataQualityCategoryItem>();

            foreach (DataQualityCategoryItem item in itemsByCategory.Values)
            {
                if (item.IsRootCategory)
                {
                    rootCategoryItems.Add(item);
                }
            }

            if (noCategoryItem.SpecificationDatasets.Count > 0)
            {
                rootCategoryItems.Add(noCategoryItem);
            }

            return(rootCategoryItems);
        }