Skip to content

Commit 980fa6f

Browse files
Fix missing properties in deserializer and WIP POCO Extensions
1 parent 9dab59f commit 980fa6f

File tree

69 files changed

+2756
-21
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

69 files changed

+2756
-21
lines changed

SySML2.NET.REST/IRestClient.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ namespace SySML2.NET.REST
2727

2828
using SysML2.NET.PIM;
2929
using SysML2.NET.PIM.DTO;
30-
using SysML2.NET.Core.DTO;
30+
using SysML2.NET.Core.DTO.Root.Elements;
3131

3232
/// <summary>
3333
/// The purpose of the <see cref="IRestClient"/> is to provide an abstraction over the SysML REST/HTTP PSM protocol

SySML2.NET.REST/RestClient.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ namespace SySML2.NET.REST
3333
using SysML2.NET.PIM;
3434
using SysML2.NET.PIM.DTO;
3535
using SysML2.NET.Common;
36-
using SysML2.NET.Core.DTO;
36+
using SysML2.NET.Core.DTO.Root.Elements;
3737
using SysML2.NET.Serializer.Json;
3838

3939
/// <summary>

SysML2.NET.CodeGenerator.Tests/Expected/UML/Core/AutoGenDeSerializer/DependencyDeSerializer.cs

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,26 @@ internal static IDependency DeSerialize(JsonElement jsonElement, SerializationMo
102102
logger.LogDebug("the aliasIds Json property was not found in the Dependency: { Id }", dtoInstance.Id);
103103
}
104104

105+
if (jsonElement.TryGetProperty("client"u8, out var clientProperty))
106+
{
107+
foreach (var arrayItem in clientProperty.EnumerateArray())
108+
{
109+
if (arrayItem.TryGetProperty("@id"u8, out var clientIdProperty))
110+
{
111+
var propertyValue = clientIdProperty.GetString();
112+
113+
if (propertyValue != null)
114+
{
115+
dtoInstance.Client.Add(Guid.Parse(propertyValue));
116+
}
117+
}
118+
}
119+
}
120+
else
121+
{
122+
logger.LogDebug("the client Json property was not found in the Dependency: { Id }", dtoInstance.Id);
123+
}
124+
105125
if (jsonElement.TryGetProperty("declaredName"u8, out var declaredNameProperty))
106126
{
107127
dtoInstance.DeclaredName = declaredNameProperty.GetString();
@@ -266,6 +286,26 @@ internal static IDependency DeSerialize(JsonElement jsonElement, SerializationMo
266286
logger.LogDebug("the source Json property was not found in the Dependency: { Id }", dtoInstance.Id);
267287
}
268288

289+
if (jsonElement.TryGetProperty("supplier"u8, out var supplierProperty))
290+
{
291+
foreach (var arrayItem in supplierProperty.EnumerateArray())
292+
{
293+
if (arrayItem.TryGetProperty("@id"u8, out var supplierIdProperty))
294+
{
295+
var propertyValue = supplierIdProperty.GetString();
296+
297+
if (propertyValue != null)
298+
{
299+
dtoInstance.Supplier.Add(Guid.Parse(propertyValue));
300+
}
301+
}
302+
}
303+
}
304+
else
305+
{
306+
logger.LogDebug("the supplier Json property was not found in the Dependency: { Id }", dtoInstance.Id);
307+
}
308+
269309
if (jsonElement.TryGetProperty("target"u8, out var targetProperty))
270310
{
271311
foreach (var arrayItem in targetProperty.EnumerateArray())

SysML2.NET.CodeGenerator.Tests/Expected/UML/Core/AutoGenDeSerializer/FeatureTypingDeSerializer.cs

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,31 @@ internal static IFeatureTyping DeSerialize(JsonElement jsonElement, Serializatio
134134
logger.LogDebug("the elementId Json property was not found in the FeatureTyping: { Id }", dtoInstance.Id);
135135
}
136136

137+
if (jsonElement.TryGetProperty("general"u8, out var generalProperty))
138+
{
139+
if (generalProperty.ValueKind == JsonValueKind.Null)
140+
{
141+
dtoInstance.General = Guid.Empty;
142+
logger.LogDebug($"the FeatureTyping.General property was not found in the Json. The value is set to Guid.Empty");
143+
}
144+
else
145+
{
146+
if (generalProperty.TryGetProperty("@id"u8, out var generalIdProperty))
147+
{
148+
var propertyValue = generalIdProperty.GetString();
149+
150+
if (propertyValue != null)
151+
{
152+
dtoInstance.General = Guid.Parse(propertyValue);
153+
}
154+
}
155+
}
156+
}
157+
else
158+
{
159+
logger.LogDebug("the general Json property was not found in the FeatureTyping: { Id }", dtoInstance.Id);
160+
}
161+
137162
if (jsonElement.TryGetProperty("isImplied"u8, out var isImpliedProperty))
138163
{
139164
if (isImpliedProperty.ValueKind != JsonValueKind.Null)
@@ -266,6 +291,31 @@ internal static IFeatureTyping DeSerialize(JsonElement jsonElement, Serializatio
266291
logger.LogDebug("the source Json property was not found in the FeatureTyping: { Id }", dtoInstance.Id);
267292
}
268293

294+
if (jsonElement.TryGetProperty("specific"u8, out var specificProperty))
295+
{
296+
if (specificProperty.ValueKind == JsonValueKind.Null)
297+
{
298+
dtoInstance.Specific = Guid.Empty;
299+
logger.LogDebug($"the FeatureTyping.Specific property was not found in the Json. The value is set to Guid.Empty");
300+
}
301+
else
302+
{
303+
if (specificProperty.TryGetProperty("@id"u8, out var specificIdProperty))
304+
{
305+
var propertyValue = specificIdProperty.GetString();
306+
307+
if (propertyValue != null)
308+
{
309+
dtoInstance.Specific = Guid.Parse(propertyValue);
310+
}
311+
}
312+
}
313+
}
314+
else
315+
{
316+
logger.LogDebug("the specific Json property was not found in the FeatureTyping: { Id }", dtoInstance.Id);
317+
}
318+
269319
if (jsonElement.TryGetProperty("target"u8, out var targetProperty))
270320
{
271321
foreach (var arrayItem in targetProperty.EnumerateArray())
@@ -286,6 +336,56 @@ internal static IFeatureTyping DeSerialize(JsonElement jsonElement, Serializatio
286336
logger.LogDebug("the target Json property was not found in the FeatureTyping: { Id }", dtoInstance.Id);
287337
}
288338

339+
if (jsonElement.TryGetProperty("type"u8, out var typeProperty))
340+
{
341+
if (typeProperty.ValueKind == JsonValueKind.Null)
342+
{
343+
dtoInstance.Type = Guid.Empty;
344+
logger.LogDebug($"the FeatureTyping.Type property was not found in the Json. The value is set to Guid.Empty");
345+
}
346+
else
347+
{
348+
if (typeProperty.TryGetProperty("@id"u8, out var typeIdProperty))
349+
{
350+
var propertyValue = typeIdProperty.GetString();
351+
352+
if (propertyValue != null)
353+
{
354+
dtoInstance.Type = Guid.Parse(propertyValue);
355+
}
356+
}
357+
}
358+
}
359+
else
360+
{
361+
logger.LogDebug("the type Json property was not found in the FeatureTyping: { Id }", dtoInstance.Id);
362+
}
363+
364+
if (jsonElement.TryGetProperty("typedFeature"u8, out var typedFeatureProperty))
365+
{
366+
if (typedFeatureProperty.ValueKind == JsonValueKind.Null)
367+
{
368+
dtoInstance.TypedFeature = Guid.Empty;
369+
logger.LogDebug($"the FeatureTyping.TypedFeature property was not found in the Json. The value is set to Guid.Empty");
370+
}
371+
else
372+
{
373+
if (typedFeatureProperty.TryGetProperty("@id"u8, out var typedFeatureIdProperty))
374+
{
375+
var propertyValue = typedFeatureIdProperty.GetString();
376+
377+
if (propertyValue != null)
378+
{
379+
dtoInstance.TypedFeature = Guid.Parse(propertyValue);
380+
}
381+
}
382+
}
383+
}
384+
else
385+
{
386+
logger.LogDebug("the typedFeature Json property was not found in the FeatureTyping: { Id }", dtoInstance.Id);
387+
}
388+
289389

290390
return dtoInstance;
291391
}

SysML2.NET.CodeGenerator.Tests/Expected/UML/Core/AutoGenDeSerializer/FramedConcernMembershipDeSerializer.cs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,31 @@ internal static IFramedConcernMembership DeSerialize(JsonElement jsonElement, Se
167167
logger.LogDebug("the kind Json property was not found in the FramedConcernMembership: { Id }", dtoInstance.Id);
168168
}
169169

170+
if (jsonElement.TryGetProperty("memberElement"u8, out var memberElementProperty))
171+
{
172+
if (memberElementProperty.ValueKind == JsonValueKind.Null)
173+
{
174+
dtoInstance.MemberElement = Guid.Empty;
175+
logger.LogDebug($"the FramedConcernMembership.MemberElement property was not found in the Json. The value is set to Guid.Empty");
176+
}
177+
else
178+
{
179+
if (memberElementProperty.TryGetProperty("@id"u8, out var memberElementIdProperty))
180+
{
181+
var propertyValue = memberElementIdProperty.GetString();
182+
183+
if (propertyValue != null)
184+
{
185+
dtoInstance.MemberElement = Guid.Parse(propertyValue);
186+
}
187+
}
188+
}
189+
}
190+
else
191+
{
192+
logger.LogDebug("the memberElement Json property was not found in the FramedConcernMembership: { Id }", dtoInstance.Id);
193+
}
194+
170195
if (jsonElement.TryGetProperty("memberName"u8, out var memberNameProperty))
171196
{
172197
dtoInstance.MemberName = memberNameProperty.GetString();

SysML2.NET.CodeGenerator.Tests/Expected/UML/Core/AutoGenDeSerializer/MembershipDeSerializer.cs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,31 @@ internal static IMembership DeSerialize(JsonElement jsonElement, SerializationMo
158158
logger.LogDebug("the isImpliedIncluded Json property was not found in the Membership: { Id }", dtoInstance.Id);
159159
}
160160

161+
if (jsonElement.TryGetProperty("memberElement"u8, out var memberElementProperty))
162+
{
163+
if (memberElementProperty.ValueKind == JsonValueKind.Null)
164+
{
165+
dtoInstance.MemberElement = Guid.Empty;
166+
logger.LogDebug($"the Membership.MemberElement property was not found in the Json. The value is set to Guid.Empty");
167+
}
168+
else
169+
{
170+
if (memberElementProperty.TryGetProperty("@id"u8, out var memberElementIdProperty))
171+
{
172+
var propertyValue = memberElementIdProperty.GetString();
173+
174+
if (propertyValue != null)
175+
{
176+
dtoInstance.MemberElement = Guid.Parse(propertyValue);
177+
}
178+
}
179+
}
180+
}
181+
else
182+
{
183+
logger.LogDebug("the memberElement Json property was not found in the Membership: { Id }", dtoInstance.Id);
184+
}
185+
161186
if (jsonElement.TryGetProperty("memberName"u8, out var memberNameProperty))
162187
{
163188
dtoInstance.MemberName = memberNameProperty.GetString();

SysML2.NET.CodeGenerator.Tests/Expected/UML/Core/AutoGenDeSerializer/OwningMembershipDeSerializer.cs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,31 @@ internal static IOwningMembership DeSerialize(JsonElement jsonElement, Serializa
158158
logger.LogDebug("the isImpliedIncluded Json property was not found in the OwningMembership: { Id }", dtoInstance.Id);
159159
}
160160

161+
if (jsonElement.TryGetProperty("memberElement"u8, out var memberElementProperty))
162+
{
163+
if (memberElementProperty.ValueKind == JsonValueKind.Null)
164+
{
165+
dtoInstance.MemberElement = Guid.Empty;
166+
logger.LogDebug($"the OwningMembership.MemberElement property was not found in the Json. The value is set to Guid.Empty");
167+
}
168+
else
169+
{
170+
if (memberElementProperty.TryGetProperty("@id"u8, out var memberElementIdProperty))
171+
{
172+
var propertyValue = memberElementIdProperty.GetString();
173+
174+
if (propertyValue != null)
175+
{
176+
dtoInstance.MemberElement = Guid.Parse(propertyValue);
177+
}
178+
}
179+
}
180+
}
181+
else
182+
{
183+
logger.LogDebug("the memberElement Json property was not found in the OwningMembership: { Id }", dtoInstance.Id);
184+
}
185+
161186
if (jsonElement.TryGetProperty("memberName"u8, out var memberNameProperty))
162187
{
163188
dtoInstance.MemberName = memberNameProperty.GetString();

0 commit comments

Comments
 (0)