Skip to content

Commit

Permalink
[FIX] DtoValueValidator on unwanted validation of Formula properties (#…
Browse files Browse the repository at this point in the history
…348)

* [FIX] DtoValueValidator on unwanted validation of Formula properties
* [FIX] Session executes StartUpdate, but no EndUpdate on error in Session code
  • Loading branch information
lxatstariongroup authored Jul 16, 2024
1 parent 96556f4 commit 090a4f4
Show file tree
Hide file tree
Showing 17 changed files with 170 additions and 77 deletions.
115 changes: 71 additions & 44 deletions CDP4Common.NetCore.Tests/Validation/DtoValueValidatorTestFixture.cs

Large diffs are not rendered by default.

29 changes: 28 additions & 1 deletion CDP4Common.Tests/Validation/DtoValueValidatorTestFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -106,10 +106,37 @@ public void Setup()
{
Reference = new ValueArray<string>(new List<string>(){ObjectValueValidator.DefaultValue}),
Computed = new ValueArray<string>(new List<string>(){ObjectValueValidator.DefaultValue}),
Manual = new ValueArray<string>(new List<string>(){ObjectValueValidator.DefaultValue})
Manual = new ValueArray<string>(new List<string>(){ObjectValueValidator.DefaultValue}),
Formula = new ValueArray<string>(new List<string>() { ObjectValueValidator.DefaultValue })
};
}

[Test]
public void VerifyQuantityFormula()
{
var parameter = new Parameter(Guid.NewGuid(), 1)
{
ParameterType = this.simpleQuantityKind.Iid,
Scale = this.ratioScale.Iid
};

var classlessDto = new ClasslessDTO()
{
{"Manual", new ValueArray<string>(new List<string>(){"1"})},
{"Computed", new ValueArray<string>(new List<string>(){"2"})},
{"Reference", new ValueArray<string>(new List<string>(){"3"})},
{"Formula", new ValueArray<string>(new List<string>(){"=CELLNAME"})},
};

var things = new List<Thing>();
things.Add(this.simpleQuantityKind);
things.Add(this.ratioScale);

var result = parameter.ValidateAndCleanup(classlessDto, things);

Assert.That(result.ResultKind, Is.EqualTo(ValidationResultKind.Valid));
}

[Test]
public void VerifyBooleanParameterTypeValidationAndCleanup()
{
Expand Down
2 changes: 1 addition & 1 deletion CDP4Common/CDP4Common.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<TargetFrameworks>net48;netstandard2.0</TargetFrameworks>
<Company>Starion Group S.A.</Company>
<Title>CDP4Common Community Edition</Title>
<VersionPrefix>27.2.0</VersionPrefix>
<VersionPrefix>27.2.1</VersionPrefix>
<Description>CDP4 Common Class Library that contains DTOs, POCOs</Description>
<Copyright>Copyright © Starion Group S.A.</Copyright>
<Authors>Sam, Merlin, Alex, Naron, Alexander, Yevhen, Nathanael, Ahmed</Authors>
Expand Down
6 changes: 3 additions & 3 deletions CDP4Common/Validation/DtoValueValidator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -404,9 +404,9 @@ public static ValidationResult ValidateAndCleanup(this Parameter parameter, Clas

foreach (var kvp in classlessDto)
{
if (!(kvp.Value is ValueArray<string> valueArray))
if (!(kvp.Value is ValueArray<string> valueArray) || kvp.Key == nameof(ParameterValueSet.Formula))
{
continue;
continue;
}

var validationResult = parameterType.ValidateAndCleanup(valueArray, kvp.Key, parameter.Scale, things, provider);
Expand Down Expand Up @@ -448,7 +448,7 @@ public static ValidationResult ValidateAndCleanup(this ParameterOverride paramet

foreach (var kvp in classlessDto)
{
if (!(kvp.Value is ValueArray<string> valueArray))
if (!(kvp.Value is ValueArray<string> valueArray) || kvp.Key == nameof(ParameterValueSet.Formula))
{
continue;
}
Expand Down
2 changes: 1 addition & 1 deletion CDP4Dal/CDP4Dal.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<TargetFrameworks>net48;netstandard2.0</TargetFrameworks>
<Company>Starion Group S.A.</Company>
<Title>CDP4Dal Community Edition</Title>
<VersionPrefix>27.2.0</VersionPrefix>
<VersionPrefix>27.2.1</VersionPrefix>
<Description>CDP4 Data Access Layer library, a consumer of an ECSS-E-TM-10-25 Annex C API</Description>
<Copyright>Copyright © Starion Group S.A.</Copyright>
<Authors>Sam, Merlin, Alex, Naron, Alexander, Yevhen, Nathanael, Ahmed</Authors>
Expand Down
71 changes: 55 additions & 16 deletions CDP4Dal/Session.cs
Original file line number Diff line number Diff line change
Expand Up @@ -396,10 +396,15 @@ public async Task Open(bool activeMessageBus = true)
// clear cache
await this.Assembler.Clear();

this.CDPMessageBus.SendMessage(new SessionEvent(this, SessionStatus.EndUpdate));

throw new IncompleteModelException("The Person object that matches the user specified in the Credentials could not be found");
}
else
{
this.CDPMessageBus.SendMessage(new SessionEvent(this, SessionStatus.EndUpdate));
}

this.CDPMessageBus.SendMessage(new SessionEvent(this, SessionStatus.EndUpdate));

logger.Info("Synchronization with the {0} server done in {1} [ms]", this.DataSourceUri, sw.ElapsedMilliseconds);

Expand Down Expand Up @@ -493,11 +498,17 @@ public async Task Read(Iteration iteration, DomainOfExpertise domain, bool activ

this.CDPMessageBus.SendMessage(new SessionEvent(this, SessionStatus.BeginUpdate));

await this.Assembler.Synchronize(enumerable, activeMessageBus);
try
{
await this.Assembler.Synchronize(enumerable, activeMessageBus);

this.AddIterationToOpenList(iteration.Iid, domain);
this.AddIterationToOpenList(iteration.Iid, domain);
}
finally
{
this.CDPMessageBus.SendMessage(new SessionEvent(this, SessionStatus.EndUpdate));
}

this.CDPMessageBus.SendMessage(new SessionEvent(this, SessionStatus.EndUpdate));
logger.Info("Synchronization with the {0} server done", this.DataSourceUri);
}

Expand Down Expand Up @@ -838,8 +849,16 @@ private async Task AfterReadOrWriteOrUpdate(IList<CDP4Common.DTO.Thing> things,
var sw = new Stopwatch();
logger.Info($"Synchronization of DTOs for {caller} from/to server {0} started", this.DataSourceUri);
this.CDPMessageBus.SendMessage(new SessionEvent(this, SessionStatus.BeginUpdate));
await this.Assembler.Synchronize(things);
this.CDPMessageBus.SendMessage(new SessionEvent(this, SessionStatus.EndUpdate));

try
{
await this.Assembler.Synchronize(things);
}
finally
{
this.CDPMessageBus.SendMessage(new SessionEvent(this, SessionStatus.EndUpdate));
}

logger.Info($"Synchronization of DTOs for {caller} from/to server {0} done in {1} [ms]", this.DataSourceUri, sw.ElapsedMilliseconds);
}

Expand Down Expand Up @@ -1087,8 +1106,15 @@ public async Task CloseRdl(SiteReferenceDataLibrary sRdl)
}

this.CDPMessageBus.SendMessage(new SessionEvent(this, SessionStatus.BeginUpdate));
await Task.WhenAll(tasks);
this.CDPMessageBus.SendMessage(new SessionEvent(this, SessionStatus.EndUpdate));

try
{
await Task.WhenAll(tasks);
}
finally
{
this.CDPMessageBus.SendMessage(new SessionEvent(this, SessionStatus.EndUpdate));
}

foreach (var siteReferenceDataLibrary in orderedRdlsToClose)
{
Expand Down Expand Up @@ -1155,8 +1181,16 @@ private async Task Update(Thing thing, bool isRefresh = true)
public async Task CloseModelRdl(ModelReferenceDataLibrary modelRdl)
{
this.CDPMessageBus.SendMessage(new SessionEvent(this, SessionStatus.BeginUpdate));
await this.Assembler.CloseRdl(modelRdl);
this.CDPMessageBus.SendMessage(new SessionEvent(this, SessionStatus.EndUpdate));

try
{
await this.Assembler.CloseRdl(modelRdl);
}
finally
{
this.CDPMessageBus.SendMessage(new SessionEvent(this, SessionStatus.EndUpdate));
}

this.openReferenceDataLibraries.Remove(modelRdl);
this.CDPMessageBus.SendMessage(new SessionEvent(this, SessionStatus.RdlClosed));
}
Expand All @@ -1171,16 +1205,21 @@ public async Task CloseIterationSetup(IterationSetup iterationSetup)
{
this.CDPMessageBus.SendMessage(new SessionEvent(this, SessionStatus.BeginUpdate));

await this.Assembler.CloseIterationSetup(iterationSetup);
try
{
await this.Assembler.CloseIterationSetup(iterationSetup);

var iterationToRemove = this.openIterations.Select(x => x.Key).SingleOrDefault(x => x.Iid == iterationSetup.IterationIid);
var iterationToRemove = this.openIterations.Select(x => x.Key).SingleOrDefault(x => x.Iid == iterationSetup.IterationIid);

if (iterationToRemove != null)
if (iterationToRemove != null)
{
this.openIterations.Remove(iterationToRemove);
}
}
finally
{
this.openIterations.Remove(iterationToRemove);
this.CDPMessageBus.SendMessage(new SessionEvent(this, SessionStatus.EndUpdate));
}

this.CDPMessageBus.SendMessage(new SessionEvent(this, SessionStatus.EndUpdate));
}

/// <summary>
Expand Down
2 changes: 1 addition & 1 deletion CDP4DalCommon/CDP4DalCommon.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<Company>Starion Group S.A.</Company>
<Language>latest</Language>
<Title>CDP4DalCommon Community Edition</Title>
<VersionPrefix>27.2.0</VersionPrefix>
<VersionPrefix>27.2.1</VersionPrefix>
<Description>CDP4 Common Class Library that contains common types for any CDP4 server and the CDP4Dal</Description>
<Copyright>Copyright © Starion Group S.A.</Copyright>
<Authors>Sam, Alex, Alexander, Nathanael, Antoine, Omar, Jaime</Authors>
Expand Down
2 changes: 1 addition & 1 deletion CDP4JsonFileDal/CDP4JsonFileDal.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<TargetFrameworks>net48;netstandard2.0</TargetFrameworks>
<Company>Starion Group S.A.</Company>
<Title>CDP4JsonFileDal Community Edition</Title>
<VersionPrefix>27.2.0</VersionPrefix>
<VersionPrefix>27.2.1</VersionPrefix>
<Description>CDP4 Json File Dal Plugin</Description>
<Copyright>Copyright © Starion Group S.A.</Copyright>
<Authors>Sam, Merlin, Alex, Naron, Alexander, Yevhen, Nathanael</Authors>
Expand Down
2 changes: 1 addition & 1 deletion CDP4JsonSerializer/CDP4JsonSerializer.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<TargetFrameworks>net48;netstandard2.0</TargetFrameworks>
<Company>Starion Group S.A.</Company>
<Title>CDP4JsonSerializer Community Edition</Title>
<VersionPrefix>27.2.0</VersionPrefix>
<VersionPrefix>27.2.1</VersionPrefix>
<Description>CDP4 JSON Serialization Library</Description>
<Copyright>Copyright © Starion Group S.A.</Copyright>
<Authors>Sam, Merlin, Alex, Naron, Alexander, Yevhen, Nathanael</Authors>
Expand Down
2 changes: 1 addition & 1 deletion CDP4MessagePackSerializer/CDP4MessagePackSerializer.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<TargetFrameworks>net48;netstandard2.0</TargetFrameworks>
<Company>Starion Group S.A.</Company>
<Title>CDP4MessagePackSerializer Community Edition</Title>
<VersionPrefix>27.2.0</VersionPrefix>
<VersionPrefix>27.2.1</VersionPrefix>
<Description>CDP4 MessagePack Serialization Library</Description>
<Copyright>Copyright © Starion Group S.A.</Copyright>
<Authors>Sam, Alex, Alexander, Nathanael, Antoine, Omar</Authors>
Expand Down
2 changes: 1 addition & 1 deletion CDP4Reporting/CDP4Reporting.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<TargetFrameworks>netstandard2.0</TargetFrameworks>
<Company>Starion Group S.A.</Company>
<Title>CDP4Reporting Community Edition</Title>
<VersionPrefix>27.2.0</VersionPrefix>
<VersionPrefix>27.2.1</VersionPrefix>
<Description>CDP4 Reporting</Description>
<Copyright>Copyright © Starion Group S.A.</Copyright>
<Authors>Sam, Alex, Alexander</Authors>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<TargetFrameworks>net48;netstandard2.0</TargetFrameworks>
<Company>Starion Group S.A.</Company>
<Title>CDP4RequirementsVerification Community Edition</Title>
<VersionPrefix>27.2.0</VersionPrefix>
<VersionPrefix>27.2.1</VersionPrefix>
<Description>CDP4 Class Library that provides requirement verification</Description>
<Copyright>Copyright © Starion Group S.A.</Copyright>
<Authors>Sam, Alex, Alexander, Yevhen, Nathanael</Authors>
Expand Down
2 changes: 1 addition & 1 deletion CDP4Rules/CDP4Rules.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<TargetFrameworks>net48;netstandard2.0</TargetFrameworks>
<Company>Starion Group S.A.</Company>
<Title>CDP4Rules Community Edition</Title>
<VersionPrefix>27.2.0</VersionPrefix>
<VersionPrefix>27.2.1</VersionPrefix>
<Description>CDP4 Class Library that provides Model Analysis and Rule Checking</Description>
<Copyright>Copyright © Starion Group S.A.</Copyright>
<Authors>Sam, Alex, Alexander, Yevhen, Nathanael</Authors>
Expand Down
2 changes: 1 addition & 1 deletion CDP4ServicesDal/CDP4ServicesDal.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<TargetFrameworks>net48;netstandard2.0</TargetFrameworks>
<Company>Starion Group S.A.</Company>
<Title>CDP4ServicesDal Community Edition</Title>
<VersionPrefix>27.2.0</VersionPrefix>
<VersionPrefix>27.2.1</VersionPrefix>
<Description>CDP4ServicesDal Dal Plugin</Description>
<Copyright>Copyright © Starion Group S.A.</Copyright>
<Authors>Sam, Merlin, Alex, Naron, Alexander, Yevhen, Nathanael</Authors>
Expand Down
2 changes: 1 addition & 1 deletion CDP4ServicesMessaging/CDP4ServicesMessaging.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<TargetFrameworks>netstandard2.0</TargetFrameworks>
<Company>Starion Group S.A.</Company>
<Title>CDP4Common Community Edition</Title>
<VersionPrefix>27.2.0</VersionPrefix>
<VersionPrefix>27.2.1</VersionPrefix>
<Description>CDP4 Services Messaging is a Class Library that contains clients and messages class that can be used for inter services communication</Description>
<Copyright>Copyright © Starion Group S.A.</Copyright>
<Authors>Sam, Alex, Alexander, Nathanael, Antoine</Authors>
Expand Down
2 changes: 1 addition & 1 deletion CDP4Web/CDP4Web.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<LangVersion>latest</LangVersion>
<Company>Starion Group S.A.</Company>
<Title>CDP4Web Community Edition</Title>
<VersionPrefix>27.2.0</VersionPrefix>
<VersionPrefix>27.2.1</VersionPrefix>
<Description>CDP4Web Dedicated Sdk for CDPServicesDal</Description>
<Copyright>Copyright © Starion Group S.A.</Copyright>
<Authors>Sam, Alex, Alexander, Nathanael, Antoine, Omar, Jaime</Authors>
Expand Down
2 changes: 1 addition & 1 deletion CDP4WspDal/CDP4WspDal.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<TargetFrameworks>net48;netstandard2.0</TargetFrameworks>
<Company>Starion Group S.A.</Company>
<Title>CDP4WspDal Community Edition</Title>
<VersionPrefix>27.2.0</VersionPrefix>
<VersionPrefix>27.2.1</VersionPrefix>
<Description>CDP4 WSP Dal Plugin</Description>
<Copyright>Copyright © Starion Group S.A.</Copyright>
<Authors>Sam, Merlin, Alex, Naron, Alexander, Yevhen, Nathanael</Authors>
Expand Down

0 comments on commit 090a4f4

Please sign in to comment.