| | 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.Column; |
| | 9 | | using ValidateLib.Metadata.PropertyParsers.DescriptorNS; |
| | 10 | |
|
| | 11 | | namespace ValidateLib.Metadata.Descriptors |
| | 12 | | { |
| | 13 | | public class ColumnDescriptor : InheritedPropertiesDescriptor, INormalize, Interfaces.IParsable<ColumnDescriptor>, I |
| | 14 | | { |
| 1 | 15 | | public AtomicPropertyString? name { get; set; } |
| 1 | 16 | | public AtomicPropertyBoolean? suppresOutput { get; set; } = new AtomicPropertyBoolean(false); |
| 1 | 17 | | public NaturalLanguageProperty? titles { get; set; } |
| 1 | 18 | | public AtomicPropertyBoolean? _virtual { get; set; } = new AtomicPropertyBoolean(false); |
| 1 | 19 | | new public static string getTypeForTypeProperty() => "Column"; |
| | 20 | | public static List<Warning> Normalize(JToken token, Context context, JProperty? property = null) |
| | 21 | | { |
| 1 | 22 | | List<Warning> errors = new List<Warning>(); |
| 1 | 23 | | if (token.Type != JTokenType.Object) return new List<Warning> { WarningFactory.GetObjectPropertyWrongValueWa |
| 1 | 24 | | foreach (JProperty jProperty in token) |
| | 25 | | { |
| 1 | 26 | | var results = NormalizeProperty(jProperty, context); |
| 1 | 27 | | MergeTwoList(errors, results); |
| | 28 | | } |
| 1 | 29 | | return errors; |
| | 30 | | } |
| | 31 | |
|
| | 32 | | new static protected List<Warning> NormalizeProperty(JProperty property, Context context) |
| | 33 | | { |
| 1 | 34 | | List<Warning> errors = new List<Warning>(); |
| 1 | 35 | | if (CommonProperty.IsCommonProperty(property.Name)) CommonProperty.Normalize(property.Value, context, proper |
| 1 | 36 | | switch (property.Name) |
| | 37 | | { |
| | 38 | | case "name": |
| | 39 | | case "suppresOutput": |
| | 40 | | case "virtual": |
| 1 | 41 | | return errors; |
| | 42 | | case "titles": |
| 1 | 43 | | return NaturalLanguageProperty.Normalize(property.Value, context, property); |
| | 44 | | default: |
| 1 | 45 | | return InheritedPropertiesDescriptor.NormalizeProperty(property, context); |
| | 46 | |
|
| | 47 | | } |
| | 48 | | } |
| | 49 | |
|
| 1 | 50 | | public static IParser<ColumnDescriptor> GetParser(List<Warning> warnings, ColumnDescriptor? descriptor = null) = |
| | 51 | | new public IPropertyParserBase? GetPropertyParser(JProperty property, List<Warning> warnings) |
| | 52 | | { |
| 1 | 53 | | string propertyName = property.Name; |
| 1 | 54 | | if (CommonProperty.IsCommonProperty(propertyName)) |
| | 55 | | { |
| 1 | 56 | | ((CommonPropertiesDescriptor)this).GetPropertyParser(property, warnings); |
| | 57 | | } |
| | 58 | | switch (propertyName) |
| | 59 | | { |
| | 60 | | case "name": |
| 1 | 61 | | return new NamePropertyParser(warnings, this); |
| | 62 | | case "suppressOutput": |
| 1 | 63 | | return new SuppresOutputPropertyParser(warnings, this); |
| | 64 | | case "titles": |
| 1 | 65 | | return new TitlesPropertyParser(warnings, this); |
| | 66 | | case "virtual": |
| 1 | 67 | | return new VirtualPropertyParser(warnings, this); |
| | 68 | | case "@type": |
| 1 | 69 | | return new TypePropertyParser<ColumnDescriptor>(warnings, this); |
| | 70 | | default: |
| 1 | 71 | | return ((InheritedPropertiesDescriptor)this).GetPropertyParser(property, warnings); |
| | 72 | | } |
| | 73 | | } |
| | 74 | | } |
| | 75 | |
|
| | 76 | |
|
| | 77 | | } |