< Summary

Information
Class: ValidateLib.Metadata.Descriptors.SchemaDescriptor
Assembly: validatelib.dll
File(s): C:\skola_karlovka\RP\code\csv-validator\CSV_Validator\ValidateLib\Metadata\Descriptors\SchemaDescriptor.cs
Line coverage
93%
Covered lines: 31
Uncovered lines: 2
Coverable lines: 33
Total lines: 88
Line coverage: 93.9%
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\SchemaDescriptor.cs

#LineLine coverage
 1using Newtonsoft.Json.Linq;
 2using ValidateLib.ErrorsAndWarnings.Warnings;
 3using ValidateLib.Metadata.Descriptors.Interfaces;
 4using ValidateLib.Metadata.Parsers;
 5using ValidateLib.Metadata.Properties;
 6using ValidateLib.Metadata.PropertyParsers;
 7using ValidateLib.Metadata.PropertyParsers.DescriptorNS;
 8using ValidateLib.Metadata.PropertyParsers.Schema;
 9
 10namespace ValidateLib.Metadata.Descriptors
 11{
 12
 13    public class SchemaDescriptor : InheritedPropertiesDescriptor, INormalize, Interfaces.IParsable<SchemaDescriptor>, I
 14    {
 115        public ArrayProperty<ColumnDescriptor>? columns { get; set; }
 116        public ArrayProperty<ForeignKeyDescriptor>? foreignKeys { get; set; }
 117        public ColumnReferenceProperty? rowTitles { get; set; }
 118        public ColumnReferenceProperty? primaryKey { get; set; }
 119        new public static string getTypeForTypeProperty() => "Schema";
 20
 21
 22
 23        public static List<Warning> Normalize(JToken token, Context context, JProperty? property = null)
 24        {
 125            List<Warning> errors = new List<Warning>();
 126            if (token.Type != JTokenType.Object) return errors;
 127            foreach (JProperty jProperty in token)
 28            {
 129                var results = NormalizeProperty(jProperty, context);
 130                MergeTwoList(errors, results);
 31            }
 132            return errors;
 33        }
 34        new static protected List<Warning> NormalizeProperty(JProperty property, Context context)
 35        {
 136            List<Warning> errors = new List<Warning>();
 137            if (CommonProperty.IsCommonProperty(property.Name)) CommonProperty.Normalize(property.Value, context, proper
 138            switch (property.Name)
 39            {
 40                case "columns":
 141                    return ArrayProperty<ColumnDescriptor>.Normalize<ColumnDescriptor>(property.Value, context, property
 42                case "foreignKeys":
 143                    return ArrayProperty<ForeignKeyDescriptor>.Normalize<ForeignKeyDescriptor>(property.Value, context, 
 44                case "primaryKey":
 145                    return errors;
 46                case "rowTitles":
 147                    return errors;
 48                default:
 149                    return InheritedPropertiesDescriptor.NormalizeProperty(property, context);
 50            }
 51        }
 52
 53        new public IPropertyParserBase? GetPropertyParser(JProperty property, List<Warning> warnings)
 54        {
 155            string propertyName = property.Name;
 156            if (CommonProperty.IsCommonProperty(propertyName))
 57            {
 058                ((CommonPropertiesDescriptor)this).GetPropertyParser(property, warnings);
 59            }
 60
 61            switch (propertyName)
 62            {
 63                case "columns":
 164                    return new ColumnsPropertyParser(warnings, this);
 65                case "foreignKeys":
 166                    return new ForeignKeysPropertyParser(warnings, this);
 67                case "primaryKey":
 168                    return new PrimaryKeyPropertyParser(warnings, this);
 69                case "rowTitles":
 170                    return new RowTitlesPropertyParser(warnings, this);
 71                case "@type":
 172                    return new TypePropertyParser<SchemaDescriptor>(warnings, this);
 73                default:
 174                    return ((InheritedPropertiesDescriptor)this).GetPropertyParser(property, warnings);
 75            }
 76        }
 77
 078        public static IParser<SchemaDescriptor> GetParser(List<Warning> warnings, SchemaDescriptor? descriptor = null) =
 79
 80        public override void PassInheritedProperties()
 81        {
 182            if (columns is not null)
 183                foreach (var column in columns._value!)
 184                    column.ProcessPassedInheritedProperties(this);
 185        }
 86
 87    }
 88}