| | 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.DescriptorNS; |
| | 9 | |
|
| | 10 | | namespace ValidateLib.Metadata.Descriptors |
| | 11 | | { |
| | 12 | | /// <summary> |
| | 13 | | /// Base class for all descriptors. |
| | 14 | | /// Contains properties all descriptors must containt. |
| | 15 | | /// </summary> |
| | 16 | | public class Descriptor : DescriptorBase, Interfaces.IParsable<Descriptor>, ITypable |
| | 17 | | { |
| | 18 | |
|
| | 19 | | public LinkProperty? id; |
| | 20 | | public AtomicPropertyString? type; |
| 0 | 21 | | public static string getTypeForTypeProperty() => "undefined"; |
| | 22 | | static public void MergeTwoList<T>(List<T> toList, List<T> fromList) |
| | 23 | | { |
| 1 | 24 | | toList.AddRange(fromList); |
| | 25 | |
|
| 1 | 26 | | } |
| | 27 | | static protected List<Warning> NormalizeProperty(JProperty property, Context context) |
| | 28 | | { |
| 1 | 29 | | List<Warning> errors = new List<Warning>(); |
| 1 | 30 | | switch (property.Name) |
| | 31 | | { |
| | 32 | | case "@id": |
| 1 | 33 | | if (property.Value.Type == JTokenType.String && property.Value.ToString().StartsWith("_:")) return e |
| 1 | 34 | | return LinkProperty.Normalize(property.Value, context, property); |
| | 35 | | case "@type": |
| 1 | 36 | | return errors; |
| | 37 | | default: |
| 1 | 38 | | return errors; |
| | 39 | |
|
| | 40 | | } |
| | 41 | | } |
| | 42 | | public IPropertyParserBase? GetPropertyParser(JProperty property, List<Warning> warnings) |
| | 43 | | { |
| 1 | 44 | | string propertyName = property.Name; |
| 1 | 45 | | if (CommonProperty.IsCommonProperty(propertyName)) |
| 1 | 46 | | return ((CommonPropertiesDescriptor)this).GetPropertyParser(property, warnings); |
| | 47 | | switch (propertyName) |
| | 48 | | { |
| | 49 | | case "@id": |
| 1 | 50 | | return new IdPropertyParser(warnings, this); |
| | 51 | | case "@type": |
| 0 | 52 | | if (this is TableGroupDescriptor) |
| 0 | 53 | | return new TypePropertyParser<TableGroupDescriptor>(warnings, this); |
| 0 | 54 | | else if (this is TableDescriptor) |
| 0 | 55 | | return new TypePropertyParser<TableDescriptor>(warnings, this); |
| 0 | 56 | | else if (this is ColumnDescriptor) |
| 0 | 57 | | return new TypePropertyParser<ColumnDescriptor>(warnings, this); |
| 0 | 58 | | else if (this is DialectDescriptor) |
| 0 | 59 | | return new TypePropertyParser<DialectDescriptor>(warnings, this); |
| 0 | 60 | | else if (this is TransformationDescriptor) |
| 0 | 61 | | return new TypePropertyParser<TransformationDescriptor>(warnings, this); |
| 0 | 62 | | else if (this is DatatypeDescriptor) |
| 0 | 63 | | return new TypePropertyParser<DatatypeDescriptor>(warnings, this); |
| 0 | 64 | | else return new TypePropertyParser<Descriptor>(warnings, this); |
| | 65 | | default: |
| 1 | 66 | | return null; |
| | 67 | |
|
| | 68 | | } |
| | 69 | | } |
| | 70 | |
|
| | 71 | | public static IParser<Descriptor> GetParser(List<Warning> warnings, Descriptor? descriptor = null) |
| | 72 | | { |
| 0 | 73 | | throw new NotImplementedException(); |
| | 74 | | } |
| | 75 | | } |
| | 76 | | } |