< Summary

Information
Class: ValidateLib.Metadata.Descriptors.TableDescriptor
Assembly: validatelib.dll
File(s): C:\skola_karlovka\RP\code\csv-validator\CSV_Validator\ValidateLib\Metadata\Descriptors\TableDescriptor.cs
Line coverage
100%
Covered lines: 30
Uncovered lines: 0
Coverable lines: 30
Total lines: 92
Line coverage: 100%
Branch coverage
N/A
Covered branches: 0
Total branches: 0
Branch coverage: N/A
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

File(s)

C:\skola_karlovka\RP\code\csv-validator\CSV_Validator\ValidateLib\Metadata\Descriptors\TableDescriptor.cs

#LineLine coverage
 1using Newtonsoft.Json.Linq;
 2using ValidateLib.ErrorsAndWarnings.Errors;
 3using ValidateLib.ErrorsAndWarnings.Warnings;
 4using ValidateLib.Metadata.Descriptors.Interfaces;
 5using ValidateLib.Metadata.Parsers;
 6using ValidateLib.Metadata.Properties;
 7using ValidateLib.Metadata.Properties.AtomicProperties;
 8using ValidateLib.Metadata.PropertyParsers;
 9using ValidateLib.Metadata.PropertyParsers.DescriptorNS;
 10using ValidateLib.Metadata.PropertyParsers.Table;
 11using ValidateLib.TabularData.AnnotatedTabularDataModel;
 12using ValidateLib.TabularData.Parsing;
 13using ValidateLib.UtilityClasses;
 14
 15namespace ValidateLib.Metadata.Descriptors
 16{
 17    public class TableDescriptor : TopLevelObjectDescriptor, INormalize, Interfaces.IParsable<TableDescriptor>, ITypable
 18    {
 119        public Table? table { get; set; } = null;
 120        new public static string getTypeForTypeProperty() => "Table";
 121        public LinkProperty? url { get; set; }
 122        public AtomicPropertyBoolean? suppressOutput { get; set; } = new AtomicPropertyBoolean(false) { IsDefault = true
 23
 24        public Flags? _flags;
 25        public FileWrapper? _fileWrapper;
 26
 27        new public List<Warning> CheckRequiredPropertiesPresent()
 28        {
 129            List<Warning> errors = ((TopLevelObjectDescriptor)this).CheckRequiredPropertiesPresent();
 130            if (url == null) ErrorFactory.ThrowRequiredPropertyMissingError("url", nameof(TableDescriptor));
 131            return errors;
 32        }
 33
 34        public static List<Warning> Normalize(JToken token, Context context, JProperty? property = null)
 35        {
 36
 137            List<Warning> errors = new List<Warning>();
 138            if (token.Type != JTokenType.Object) return errors;
 139            foreach (JProperty jProperty in token)
 40            {
 141                var results = NormalizeProperty(jProperty, context);
 142                MergeTwoList(errors, results);
 43            }
 144            ContextUtilityClass.RemoveContextFromJToken(token);
 145            return errors;
 46        }
 47
 48        new static public List<Warning> NormalizeProperty(JProperty property, Context context)
 49        {
 150            List<Warning> errors = new List<Warning>();
 151            if (CommonProperty.IsCommonProperty(property.Name)) return CommonProperty.Normalize(property.Value, context,
 152            switch (property.Name)
 53            {
 54                case "url":
 155                    return LinkProperty.Normalize(property.Value, context, property);
 56                case "suppressOutput":
 157                    return errors;
 58                default:
 159                    return TopLevelObjectDescriptor.NormalizeProperty(property, context);
 60
 61            }
 62        }
 63
 64
 165        static public IParser<TableDescriptor> GetParser(List<Warning> warnings, TableDescriptor? descriptor = null) => 
 66
 67        new public IPropertyParserBase? GetPropertyParser(JProperty property, List<Warning> warnings)
 68        {
 169            string propertyName = property.Name;
 170            if (CommonProperty.IsCommonProperty(propertyName)) return ((CommonPropertiesDescriptor)this).GetPropertyPars
 71            switch (propertyName)
 72            {
 73                case "url":
 174                    return new UrlPropertyParser(warnings, this);
 75                case "suppressOutput":
 176                    return new SuppresOutputPropertyParser(warnings, this);
 77                case "@type":
 178                    return new TypePropertyParser<TableDescriptor>(warnings, this);
 79                default:
 180                    return ((TopLevelObjectDescriptor)this).GetPropertyParser(property, warnings);
 81
 82            }
 83        }
 84
 85        public override void PassInheritedProperties()
 86        {
 187            if (tableSchema is not null)
 188                tableSchema._value!.ProcessPassedInheritedProperties(this);
 89
 190        }
 91    }
 92}