| | | 1 | | using Newtonsoft.Json.Linq; |
| | | 2 | | using ValidateLib.ErrorsAndWarnings.Warnings; |
| | | 3 | | using ValidateLib.Metadata.Descriptors.Interfaces; |
| | | 4 | | using ValidateLib.Metadata.Parsers; |
| | | 5 | | using ValidateLib.Metadata.Properties; |
| | | 6 | | using ValidateLib.Metadata.Properties.AtomicProperties; |
| | | 7 | | using ValidateLib.Metadata.PropertyParsers; |
| | | 8 | | using ValidateLib.Metadata.PropertyParsers.TopLevelObject; |
| | | 9 | | |
| | | 10 | | namespace ValidateLib.Metadata.Descriptors |
| | | 11 | | { |
| | | 12 | | public class TopLevelObjectDescriptor : InheritedPropertiesDescriptor, IRequiredPropertyValidatable, Interfaces.IPar |
| | | 13 | | { |
| | 1 | 14 | | public ObjectProperty<DialectDescriptor>? dialect { get; set; } |
| | 1 | 15 | | public ArrayProperty<NoteDescriptor>? notes { get; set; } |
| | 1 | 16 | | public AtomicPropertyString tableDirection { get; set; } = new AtomicPropertyString("auto") { IsDefault = true } |
| | 1 | 17 | | public ObjectProperty<SchemaDescriptor>? tableSchema { get; set; } |
| | 1 | 18 | | public ArrayProperty<TransformationDescriptor>? transformations { get; set; } |
| | | 19 | | |
| | | 20 | | public List<Warning> CheckRequiredPropertiesPresent() |
| | | 21 | | { |
| | 1 | 22 | | List<Warning> errors = new List<Warning>(); |
| | 1 | 23 | | return errors; |
| | | 24 | | } |
| | | 25 | | |
| | | 26 | | new public static List<Warning> NormalizeProperty(JProperty property, Context context) |
| | | 27 | | { |
| | 1 | 28 | | List<Warning> errors = new List<Warning>(); |
| | 1 | 29 | | if (CommonProperty.IsCommonProperty(property.Name)) CommonProperty.Normalize(property.Value, context, proper |
| | 1 | 30 | | switch (property.Name) |
| | | 31 | | { |
| | | 32 | | case "dialect": |
| | 1 | 33 | | return ObjectProperty<DialectDescriptor>.Normalize(property.Value, context, property); |
| | | 34 | | case "notes": |
| | 1 | 35 | | return CommonProperty.Normalize(property.Value, context, property); |
| | | 36 | | case "tableDirection": |
| | 1 | 37 | | return errors; |
| | | 38 | | case "tableSchema": |
| | 1 | 39 | | return ObjectProperty<SchemaDescriptor>.Normalize(property.Value, context); |
| | | 40 | | case "transformations": |
| | 1 | 41 | | return ArrayProperty<TransformationDescriptor> |
| | 1 | 42 | | .Normalize<TransformationDescriptor>(property.Value, context, property); |
| | | 43 | | default: |
| | 1 | 44 | | return InheritedPropertiesDescriptor.NormalizeProperty(property, context); |
| | | 45 | | } |
| | | 46 | | } |
| | | 47 | | new public IPropertyParserBase? GetPropertyParser(JProperty property, List<Warning> warnings) |
| | | 48 | | { |
| | 1 | 49 | | switch (property.Name) |
| | | 50 | | { |
| | | 51 | | case "dialect": |
| | 1 | 52 | | return new DialectPropertyParser(warnings, this); |
| | | 53 | | case "notes": |
| | 1 | 54 | | return new NotesPropertyParser(warnings, this); |
| | | 55 | | case "tableDirection": |
| | 1 | 56 | | return new TableDirectionPropertyParser(warnings, this); |
| | | 57 | | case "tableSchema": |
| | 1 | 58 | | return new TableSchemaPropertyParser(warnings, this); |
| | | 59 | | case "transformations": |
| | 1 | 60 | | return new TransformationsPropertyParser(warnings, this); |
| | | 61 | | default: |
| | 1 | 62 | | return ((InheritedPropertiesDescriptor)this).GetPropertyParser(property, warnings); |
| | | 63 | | |
| | | 64 | | } |
| | | 65 | | } |
| | | 66 | | |
| | | 67 | | public static IParser<TopLevelObjectDescriptor> GetParser(List<Warning> warnings, TopLevelObjectDescriptor? desc |
| | | 68 | | { |
| | 0 | 69 | | throw new NotImplementedException(); |
| | | 70 | | } |
| | | 71 | | |
| | | 72 | | } |
| | | 73 | | } |