Skip to content

Commit

Permalink
chore(deps): update metamodel to support maps and scalars (#26)
Browse files Browse the repository at this point in the history
Signed-off-by: Jamie Shorten <[email protected]>
  • Loading branch information
jamieshorten authored Oct 24, 2023
1 parent 1178bab commit 4d73a08
Show file tree
Hide file tree
Showing 8 changed files with 957 additions and 325 deletions.
180 changes: 90 additions & 90 deletions AccordProject.Concerto.Tests/data/patent.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions AccordProject.Concerto/AccordProject.Concerto.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
<PackageReference Include="System.ComponentModel.Annotations" Version="5.0.0" />
</ItemGroup>

<Target Name="Codegen" BeforeTargets="PreBuildEvent">
Expand Down
139 changes: 129 additions & 10 deletions AccordProject.Concerto/ConcertoMetamodelTypes.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public class Range : Concept {
[Newtonsoft.Json.JsonProperty("end")]
public Position End { get; set; }
[Newtonsoft.Json.JsonProperty("source")]
public string Source { get; set; }
public string? Source { get; set; }
}
[AccordProject.Concerto.Type(Namespace = "concerto.metamodel", Version = "1.0.0", Name = "TypeIdentifier")]
[Newtonsoft.Json.JsonConverter(typeof(AccordProject.Concerto.ConcertoConverterNewtonsoft))]
Expand All @@ -46,7 +46,7 @@ public class TypeIdentifier : Concept {
[Newtonsoft.Json.JsonProperty("name")]
public string Name { get; set; }
[Newtonsoft.Json.JsonProperty("namespace")]
public string Namespace { get; set; }
public string? Namespace { get; set; }
}
[AccordProject.Concerto.Type(Namespace = "concerto.metamodel", Version = "1.0.0", Name = "DecoratorLiteral")]
[Newtonsoft.Json.JsonConverter(typeof(AccordProject.Concerto.ConcertoConverterNewtonsoft))]
Expand Down Expand Up @@ -121,13 +121,116 @@ public class IdentifiedBy : Identified {
public abstract class Declaration : Concept {
[Newtonsoft.Json.JsonProperty("$class")]
public override string _Class { get; } = "[email protected]";
[System.ComponentModel.DataAnnotations.RegularExpression(@"^(\p{Lu}|\p{Ll}|\p{Lt}|\p{Lm}|\p{Lo}|\p{Nl}|\$|_|\\u[0-9A-Fa-f]{4})(?:\p{Lu}|\p{Ll}|\p{Lt}|\p{Lm}|\p{Lo}|\p{Nl}|\$|_|\\u[0-9A-Fa-f]{4}|\p{Mn}|\p{Mc}|\p{Nd}|\p{Pc}|\u200C|\u200D)*$", ErrorMessage = "Invalid characters")]
[Newtonsoft.Json.JsonProperty("name")]
public string Name { get; set; }
[Newtonsoft.Json.JsonProperty("decorators")]
public Decorator?[] Decorators { get; set; }
[Newtonsoft.Json.JsonProperty("location")]
public Range? Location { get; set; }
}
[AccordProject.Concerto.Type(Namespace = "concerto.metamodel", Version = "1.0.0", Name = "MapKeyType")]
[Newtonsoft.Json.JsonConverter(typeof(AccordProject.Concerto.ConcertoConverterNewtonsoft))]
public abstract class MapKeyType : Concept {
[Newtonsoft.Json.JsonProperty("$class")]
public override string _Class { get; } = "[email protected]";
[Newtonsoft.Json.JsonProperty("decorators")]
public Decorator?[] Decorators { get; set; }
[Newtonsoft.Json.JsonProperty("location")]
public Range? Location { get; set; }
}
[AccordProject.Concerto.Type(Namespace = "concerto.metamodel", Version = "1.0.0", Name = "MapValueType")]
[Newtonsoft.Json.JsonConverter(typeof(AccordProject.Concerto.ConcertoConverterNewtonsoft))]
public abstract class MapValueType : Concept {
[Newtonsoft.Json.JsonProperty("$class")]
public override string _Class { get; } = "[email protected]";
[Newtonsoft.Json.JsonProperty("decorators")]
public Decorator?[] Decorators { get; set; }
[Newtonsoft.Json.JsonProperty("location")]
public Range? Location { get; set; }
}
[AccordProject.Concerto.Type(Namespace = "concerto.metamodel", Version = "1.0.0", Name = "MapDeclaration")]
[Newtonsoft.Json.JsonConverter(typeof(AccordProject.Concerto.ConcertoConverterNewtonsoft))]
public class MapDeclaration : Declaration {
[Newtonsoft.Json.JsonProperty("$class")]
public override string _Class { get; } = "[email protected]";
[Newtonsoft.Json.JsonProperty("key")]
public MapKeyType Key { get; set; }
[Newtonsoft.Json.JsonProperty("value")]
public MapValueType Value { get; set; }
}
[AccordProject.Concerto.Type(Namespace = "concerto.metamodel", Version = "1.0.0", Name = "StringMapKeyType")]
[Newtonsoft.Json.JsonConverter(typeof(AccordProject.Concerto.ConcertoConverterNewtonsoft))]
public class StringMapKeyType : MapKeyType {
[Newtonsoft.Json.JsonProperty("$class")]
public override string _Class { get; } = "[email protected]";
}
[AccordProject.Concerto.Type(Namespace = "concerto.metamodel", Version = "1.0.0", Name = "DateTimeMapKeyType")]
[Newtonsoft.Json.JsonConverter(typeof(AccordProject.Concerto.ConcertoConverterNewtonsoft))]
public class DateTimeMapKeyType : MapKeyType {
[Newtonsoft.Json.JsonProperty("$class")]
public override string _Class { get; } = "[email protected]";
}
[AccordProject.Concerto.Type(Namespace = "concerto.metamodel", Version = "1.0.0", Name = "ObjectMapKeyType")]
[Newtonsoft.Json.JsonConverter(typeof(AccordProject.Concerto.ConcertoConverterNewtonsoft))]
public class ObjectMapKeyType : MapKeyType {
[Newtonsoft.Json.JsonProperty("$class")]
public override string _Class { get; } = "[email protected]";
[Newtonsoft.Json.JsonProperty("type")]
public TypeIdentifier Type { get; set; }
}
[AccordProject.Concerto.Type(Namespace = "concerto.metamodel", Version = "1.0.0", Name = "BooleanMapValueType")]
[Newtonsoft.Json.JsonConverter(typeof(AccordProject.Concerto.ConcertoConverterNewtonsoft))]
public class BooleanMapValueType : MapValueType {
[Newtonsoft.Json.JsonProperty("$class")]
public override string _Class { get; } = "[email protected]";
}
[AccordProject.Concerto.Type(Namespace = "concerto.metamodel", Version = "1.0.0", Name = "DateTimeMapValueType")]
[Newtonsoft.Json.JsonConverter(typeof(AccordProject.Concerto.ConcertoConverterNewtonsoft))]
public class DateTimeMapValueType : MapValueType {
[Newtonsoft.Json.JsonProperty("$class")]
public override string _Class { get; } = "[email protected]";
}
[AccordProject.Concerto.Type(Namespace = "concerto.metamodel", Version = "1.0.0", Name = "StringMapValueType")]
[Newtonsoft.Json.JsonConverter(typeof(AccordProject.Concerto.ConcertoConverterNewtonsoft))]
public class StringMapValueType : MapValueType {
[Newtonsoft.Json.JsonProperty("$class")]
public override string _Class { get; } = "[email protected]";
}
[AccordProject.Concerto.Type(Namespace = "concerto.metamodel", Version = "1.0.0", Name = "IntegerMapValueType")]
[Newtonsoft.Json.JsonConverter(typeof(AccordProject.Concerto.ConcertoConverterNewtonsoft))]
public class IntegerMapValueType : MapValueType {
[Newtonsoft.Json.JsonProperty("$class")]
public override string _Class { get; } = "[email protected]";
}
[AccordProject.Concerto.Type(Namespace = "concerto.metamodel", Version = "1.0.0", Name = "LongMapValueType")]
[Newtonsoft.Json.JsonConverter(typeof(AccordProject.Concerto.ConcertoConverterNewtonsoft))]
public class LongMapValueType : MapValueType {
[Newtonsoft.Json.JsonProperty("$class")]
public override string _Class { get; } = "[email protected]";
}
[AccordProject.Concerto.Type(Namespace = "concerto.metamodel", Version = "1.0.0", Name = "DoubleMapValueType")]
[Newtonsoft.Json.JsonConverter(typeof(AccordProject.Concerto.ConcertoConverterNewtonsoft))]
public class DoubleMapValueType : MapValueType {
[Newtonsoft.Json.JsonProperty("$class")]
public override string _Class { get; } = "[email protected]";
}
[AccordProject.Concerto.Type(Namespace = "concerto.metamodel", Version = "1.0.0", Name = "ObjectMapValueType")]
[Newtonsoft.Json.JsonConverter(typeof(AccordProject.Concerto.ConcertoConverterNewtonsoft))]
public class ObjectMapValueType : MapValueType {
[Newtonsoft.Json.JsonProperty("$class")]
public override string _Class { get; } = "[email protected]";
[Newtonsoft.Json.JsonProperty("type")]
public TypeIdentifier Type { get; set; }
}
[AccordProject.Concerto.Type(Namespace = "concerto.metamodel", Version = "1.0.0", Name = "RelationshipMapValueType")]
[Newtonsoft.Json.JsonConverter(typeof(AccordProject.Concerto.ConcertoConverterNewtonsoft))]
public class RelationshipMapValueType : MapValueType {
[Newtonsoft.Json.JsonProperty("$class")]
public override string _Class { get; } = "[email protected]";
[Newtonsoft.Json.JsonProperty("type")]
public TypeIdentifier Type { get; set; }
}
[AccordProject.Concerto.Type(Namespace = "concerto.metamodel", Version = "1.0.0", Name = "EnumDeclaration")]
[Newtonsoft.Json.JsonConverter(typeof(AccordProject.Concerto.ConcertoConverterNewtonsoft))]
public class EnumDeclaration : Declaration {
Expand All @@ -141,6 +244,7 @@ public class EnumDeclaration : Declaration {
public class EnumProperty : Concept {
[Newtonsoft.Json.JsonProperty("$class")]
public override string _Class { get; } = "[email protected]";
[System.ComponentModel.DataAnnotations.RegularExpression(@"^(\p{Lu}|\p{Ll}|\p{Lt}|\p{Lm}|\p{Lo}|\p{Nl}|\$|_|\\u[0-9A-Fa-f]{4})(?:\p{Lu}|\p{Ll}|\p{Lt}|\p{Lm}|\p{Lo}|\p{Nl}|\$|_|\\u[0-9A-Fa-f]{4}|\p{Mn}|\p{Mc}|\p{Nd}|\p{Pc}|\u200C|\u200D)*$", ErrorMessage = "Invalid characters")]
[Newtonsoft.Json.JsonProperty("name")]
public string Name { get; set; }
[Newtonsoft.Json.JsonProperty("decorators")]
Expand Down Expand Up @@ -191,6 +295,7 @@ public class EventDeclaration : ConceptDeclaration {
public abstract class Property : Concept {
[Newtonsoft.Json.JsonProperty("$class")]
public override string _Class { get; } = "[email protected]";
[System.ComponentModel.DataAnnotations.RegularExpression(@"^(\p{Lu}|\p{Ll}|\p{Lt}|\p{Lm}|\p{Lo}|\p{Nl}|\$|_|\\u[0-9A-Fa-f]{4})(?:\p{Lu}|\p{Ll}|\p{Lt}|\p{Lm}|\p{Lo}|\p{Nl}|\$|_|\\u[0-9A-Fa-f]{4}|\p{Mn}|\p{Mc}|\p{Nd}|\p{Pc}|\u200C|\u200D)*$", ErrorMessage = "Invalid characters")]
[Newtonsoft.Json.JsonProperty("name")]
public string Name { get; set; }
[Newtonsoft.Json.JsonProperty("isArray")]
Expand All @@ -216,7 +321,7 @@ public class ObjectProperty : Property {
[Newtonsoft.Json.JsonProperty("$class")]
public override string _Class { get; } = "[email protected]";
[Newtonsoft.Json.JsonProperty("defaultValue")]
public string DefaultValue { get; set; }
public string? DefaultValue { get; set; }
[Newtonsoft.Json.JsonProperty("type")]
public TypeIdentifier Type { get; set; }
}
Expand All @@ -240,9 +345,11 @@ public class StringProperty : Property {
[Newtonsoft.Json.JsonProperty("$class")]
public override string _Class { get; } = "[email protected]";
[Newtonsoft.Json.JsonProperty("defaultValue")]
public string DefaultValue { get; set; }
public string? DefaultValue { get; set; }
[Newtonsoft.Json.JsonProperty("validator")]
public StringRegexValidator? Validator { get; set; }
[Newtonsoft.Json.JsonProperty("lengthValidator")]
public StringLengthValidator? LengthValidator { get; set; }
}
[AccordProject.Concerto.Type(Namespace = "concerto.metamodel", Version = "1.0.0", Name = "StringRegexValidator")]
[Newtonsoft.Json.JsonConverter(typeof(AccordProject.Concerto.ConcertoConverterNewtonsoft))]
Expand All @@ -254,6 +361,16 @@ public class StringRegexValidator : Concept {
[Newtonsoft.Json.JsonProperty("flags")]
public string Flags { get; set; }
}
[AccordProject.Concerto.Type(Namespace = "concerto.metamodel", Version = "1.0.0", Name = "StringLengthValidator")]
[Newtonsoft.Json.JsonConverter(typeof(AccordProject.Concerto.ConcertoConverterNewtonsoft))]
public class StringLengthValidator : Concept {
[Newtonsoft.Json.JsonProperty("$class")]
public override string _Class { get; } = "[email protected]";
[Newtonsoft.Json.JsonProperty("minLength")]
public int? MinLength { get; set; }
[Newtonsoft.Json.JsonProperty("maxLength")]
public int? MaxLength { get; set; }
}
[AccordProject.Concerto.Type(Namespace = "concerto.metamodel", Version = "1.0.0", Name = "DoubleProperty")]
[Newtonsoft.Json.JsonConverter(typeof(AccordProject.Concerto.ConcertoConverterNewtonsoft))]
public class DoubleProperty : Property {
Expand Down Expand Up @@ -322,7 +439,7 @@ public abstract class Import : Concept {
[Newtonsoft.Json.JsonProperty("namespace")]
public string Namespace { get; set; }
[Newtonsoft.Json.JsonProperty("uri")]
public string Uri { get; set; }
public string? Uri { get; set; }
}
[AccordProject.Concerto.Type(Namespace = "concerto.metamodel", Version = "1.0.0", Name = "ImportAll")]
[Newtonsoft.Json.JsonConverter(typeof(AccordProject.Concerto.ConcertoConverterNewtonsoft))]
Expand Down Expand Up @@ -354,9 +471,9 @@ public class Model : Concept {
[Newtonsoft.Json.JsonProperty("namespace")]
public string Namespace { get; set; }

Check warning on line 472 in AccordProject.Concerto/ConcertoMetamodelTypes.cs

View workflow job for this annotation

GitHub Actions / Build and test (6.0.x, ubuntu-latest)

Non-nullable property 'Namespace' must contain a non-null value when exiting constructor. Consider declaring the property as nullable.

Check warning on line 472 in AccordProject.Concerto/ConcertoMetamodelTypes.cs

View workflow job for this annotation

GitHub Actions / Build and test (6.0.x, ubuntu-latest)

Non-nullable property 'Namespace' must contain a non-null value when exiting constructor. Consider declaring the property as nullable.
[Newtonsoft.Json.JsonProperty("sourceUri")]
public string SourceUri { get; set; }
public string? SourceUri { get; set; }
[Newtonsoft.Json.JsonProperty("concertoVersion")]
public string ConcertoVersion { get; set; }
public string? ConcertoVersion { get; set; }
[Newtonsoft.Json.JsonProperty("imports")]
public Import?[] Imports { get; set; }

Check warning on line 478 in AccordProject.Concerto/ConcertoMetamodelTypes.cs

View workflow job for this annotation

GitHub Actions / Build and test (6.0.x, ubuntu-latest)

Non-nullable property 'Imports' must contain a non-null value when exiting constructor. Consider declaring the property as nullable.

Check warning on line 478 in AccordProject.Concerto/ConcertoMetamodelTypes.cs

View workflow job for this annotation

GitHub Actions / Build and test (6.0.x, ubuntu-latest)

Non-nullable property 'Imports' must contain a non-null value when exiting constructor. Consider declaring the property as nullable.
[Newtonsoft.Json.JsonProperty("declarations")]
Expand Down Expand Up @@ -384,7 +501,7 @@ public class BooleanScalar : ScalarDeclaration {
[Newtonsoft.Json.JsonProperty("$class")]
public override string _Class { get; } = "[email protected]";
[Newtonsoft.Json.JsonProperty("defaultValue")]
public bool DefaultValue { get; set; }
public bool? DefaultValue { get; set; }
}
[AccordProject.Concerto.Type(Namespace = "concerto.metamodel", Version = "1.0.0", Name = "IntegerScalar")]
[Newtonsoft.Json.JsonConverter(typeof(AccordProject.Concerto.ConcertoConverterNewtonsoft))]
Expand Down Expand Up @@ -422,15 +539,17 @@ public class StringScalar : ScalarDeclaration {
[Newtonsoft.Json.JsonProperty("$class")]
public override string _Class { get; } = "[email protected]";
[Newtonsoft.Json.JsonProperty("defaultValue")]
public string DefaultValue { get; set; }
public string? DefaultValue { get; set; }
[Newtonsoft.Json.JsonProperty("validator")]
public StringRegexValidator? Validator { get; set; }
[Newtonsoft.Json.JsonProperty("lengthValidator")]
public StringLengthValidator? LengthValidator { get; set; }
}
[AccordProject.Concerto.Type(Namespace = "concerto.metamodel", Version = "1.0.0", Name = "DateTimeScalar")]
[Newtonsoft.Json.JsonConverter(typeof(AccordProject.Concerto.ConcertoConverterNewtonsoft))]
public class DateTimeScalar : ScalarDeclaration {
[Newtonsoft.Json.JsonProperty("$class")]
public override string _Class { get; } = "[email protected]";
[Newtonsoft.Json.JsonProperty("defaultValue")]
public string DefaultValue { get; set; }
public string? DefaultValue { get; set; }
}
1 change: 1 addition & 0 deletions ConcertoJsonConverter/ConcertoJsonConverter.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
<PackageReference Include="System.ComponentModel.Annotations" Version="5.0.0" />
<PackageReference Include="System.Text.Json" Version="7.0.2" />
</ItemGroup>

Expand Down
79 changes: 40 additions & 39 deletions ConcertoJsonConverter/concerto.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,44 +3,45 @@
using Concerto.Serialization;
using NewtonsoftJson = Newtonsoft.Json;
using NewtonsoftConcerto = Concerto.Serialization.Newtonsoft;

namespace Concerto.Models.concerto {
[NewtonsoftJson.JsonConverter(typeof(NewtonsoftConcerto.ConcertoConverter))]
public abstract class Concept {
[JsonPropertyName("$class")]
[NewtonsoftJson.JsonProperty("$class")]
public virtual string _class { get;} = "concerto.Concept";
}
public abstract class Asset : Concept {
[JsonPropertyName("$class")]
[NewtonsoftJson.JsonProperty("$class")]
public override string _class { get;} = "concerto.Asset";
[JsonPropertyName("$identifier")]
[NewtonsoftJson.JsonProperty("$identifier")]
public string _identifier { get; set; }
}
[NewtonsoftJson.JsonConverter(typeof(NewtonsoftConcerto.ConcertoConverter))]
public abstract class Participant : Concept {
[JsonPropertyName("$class")]
[NewtonsoftJson.JsonProperty("$class")]
public override string _class { get;} = "concerto.Participant";
[JsonPropertyName("$identifier")]
[NewtonsoftJson.JsonProperty("$identifier")]
public string _identifier { get; set; }
}
public abstract class Transaction : Concept {
[JsonPropertyName("$class")]
[NewtonsoftJson.JsonProperty("$class")]
public override string _class { get;} = "concerto.Transaction";
[JsonPropertyName("$timestamp")]
[NewtonsoftJson.JsonProperty("$timestamp")]
public DateTime _timestamp { get; set; }
}
public abstract class Event : Concept {
[JsonPropertyName("$class")]
[NewtonsoftJson.JsonProperty("$class")]
public override string _class { get;} = "concerto.Event";
[JsonPropertyName("$timestamp")]
[NewtonsoftJson.JsonProperty("$timestamp")]
public DateTime _timestamp { get; set; }
}
[NewtonsoftJson.JsonConverter(typeof(NewtonsoftConcerto.ConcertoConverter))]
public abstract class Concept {
[JsonPropertyName("$class")]
[NewtonsoftJson.JsonProperty("$class")]
public virtual string _class { get; } = "concerto@1.0.0.Concept";
}
public abstract class Asset : Concept {
[JsonPropertyName("$class")]
[NewtonsoftJson.JsonProperty("$class")]
public override string _class { get; } = "concerto@1.0.0.Asset";
[JsonPropertyName("$identifier")]
[NewtonsoftJson.JsonProperty("$identifier")]
public string _identifier { get; set; }
}
[NewtonsoftJson.JsonConverter(typeof(NewtonsoftConcerto.ConcertoConverter))]
public abstract class Participant : Concept {
[JsonPropertyName("$class")]
[NewtonsoftJson.JsonProperty("$class")]
public override string _class { get; } = "concerto@1.0.0.Participant";
[JsonPropertyName("$identifier")]
[NewtonsoftJson.JsonProperty("$identifier")]
public string _identifier { get; set; }
}
public abstract class Transaction : Concept {
[JsonPropertyName("$class")]
[NewtonsoftJson.JsonProperty("$class")]
public override string _class { get; } = "concerto@1.0.0.Transaction";
[JsonPropertyName("$timestamp")]
[NewtonsoftJson.JsonProperty("$timestamp")]
public System.DateTime _timestamp { get; set; }
}
public abstract class Event : Concept {
[JsonPropertyName("$class")]
[NewtonsoftJson.JsonProperty("$class")]
public override string _class { get; } = "concerto@1.0.0.Event";
[JsonPropertyName("$timestamp")]
[NewtonsoftJson.JsonProperty("$timestamp")]
public System.DateTime _timestamp { get; set; }
}
}
Loading

0 comments on commit 4d73a08

Please sign in to comment.