diff --git a/CDP4-SDK.sln.DotSettings b/CDP4-SDK.sln.DotSettings
index 3e8a67ef4..64ed4378d 100644
--- a/CDP4-SDK.sln.DotSettings
+++ b/CDP4-SDK.sln.DotSettings
@@ -246,7 +246,7 @@
<copyright file="${File.FileName}" company="Starion Group S.A.">
Copyright (c) 2015-${CurrentDate.Year} Starion Group S.A.
- Author: Sam Gerené, Alex Vorobiev, Alexander van Delft, Nathanael Smiechowski, Antoine Théate, Omar Elebiary, Jaime Bernar
+ Authors: Sam Gerené, Alex Vorobiev, Alexander van Delft, Nathanael Smiechowski, Antoine Théate, Omar Elebiary, Jaime Bernar
This file is part of CDP4-COMET SDK Community Edition
diff --git a/CDP4Common.NetCore.Tests/CDP4Common.NetCore.Tests.csproj b/CDP4Common.NetCore.Tests/CDP4Common.NetCore.Tests.csproj
index 258bb07ed..a0049ddd5 100644
--- a/CDP4Common.NetCore.Tests/CDP4Common.NetCore.Tests.csproj
+++ b/CDP4Common.NetCore.Tests/CDP4Common.NetCore.Tests.csproj
@@ -14,7 +14,7 @@
-
+
diff --git a/CDP4Common.Tests/CDP4Common.Tests.csproj b/CDP4Common.Tests/CDP4Common.Tests.csproj
index 643e8d26c..8fbce3656 100644
--- a/CDP4Common.Tests/CDP4Common.Tests.csproj
+++ b/CDP4Common.Tests/CDP4Common.Tests.csproj
@@ -17,7 +17,7 @@
-
+
diff --git a/CDP4Common/CDP4Common.csproj b/CDP4Common/CDP4Common.csproj
index ac05277d4..20a4713f0 100644
--- a/CDP4Common/CDP4Common.csproj
+++ b/CDP4Common/CDP4Common.csproj
@@ -4,7 +4,7 @@
net48;netstandard2.0
Starion Group S.A.
CDP4Common Community Edition
- 27.4.0
+ 28.0.0
CDP4 Common Class Library that contains DTOs, POCOs
Copyright © Starion Group S.A.
Sam, Merlin, Alex, Naron, Alexander, Yevhen, Nathanael, Ahmed
@@ -20,7 +20,7 @@
CDP COMET ECSS-E-TM-10-25
LGPL-3.0-only
- [ADD] SharpZipLibExtension Methods
+ [Refactor] Newtonsoft to System.Text.Json
README.md
diff --git a/CDP4Dal.NetCore.Tests/CDP4Dal.NetCore.Tests.csproj b/CDP4Dal.NetCore.Tests/CDP4Dal.NetCore.Tests.csproj
index 032f1813d..a8b5dc3de 100644
--- a/CDP4Dal.NetCore.Tests/CDP4Dal.NetCore.Tests.csproj
+++ b/CDP4Dal.NetCore.Tests/CDP4Dal.NetCore.Tests.csproj
@@ -16,7 +16,7 @@
-
+
diff --git a/CDP4Dal.NetCore.Tests/DAL/DalTestFixture.cs b/CDP4Dal.NetCore.Tests/DAL/DalTestFixture.cs
index b59f1a5c6..d8d55bfd0 100644
--- a/CDP4Dal.NetCore.Tests/DAL/DalTestFixture.cs
+++ b/CDP4Dal.NetCore.Tests/DAL/DalTestFixture.cs
@@ -10,17 +10,17 @@
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 3 of the License, or (at your option) any later version.
-//
-// The CDP4-SDK Community Edition is distributed in the hope that it will be useful,
+//
+// The CDP4-COMET SDK Community Edition is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
-//
+//
// You should have received a copy of the GNU Lesser General Public License
// along with this program; if not, write to the Free Software Foundation,
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
//
-// --------------------------------------------------------------------------------------------------------------------
+// -------------------------------------------------------------------------------------------------------------------------------
namespace CDP4Dal.Tests.DAL
{
@@ -36,11 +36,12 @@ namespace CDP4Dal.Tests.DAL
using CDP4Common.Helpers;
using CDP4Dal.Composition;
+ using CDP4Dal.DAL;
using CDP4Dal.Exceptions;
using CDP4Dal.Operations;
- using CDP4Dal.DAL;
- using CDP4DalCommon.Tasks;
+ using CDP4DalCommon.Protocol.Operations;
+ using CDP4DalCommon.Protocol.Tasks;
using NUnit.Framework;
@@ -140,6 +141,7 @@ public void Verify_That_SetIterationId_Works_as_expected()
var iteration = new Iteration();
var elementDefinition = new ElementDefinition();
var parameter = new Parameter();
+
var list = new List
{
model,
@@ -303,7 +305,10 @@ public void Verify_that_OperationContainerFileVerification_throws_no_exception_w
[CDPVersion("1.1.0")]
internal class TestDal : Dal
{
- public override bool IsReadOnly { get { return false; } }
+ public override bool IsReadOnly
+ {
+ get { return false; }
+ }
public TestDal(Credentials credentials)
: base()
@@ -451,6 +456,7 @@ public override Task> CherryPick(Guid engineeringModelId, Gui
internal class DecoratedDal : Dal
{
public override bool IsReadOnly { get; }
+
public override Task> Write(IEnumerable operationContainer, IEnumerable files = null)
{
throw new NotImplementedException();
@@ -566,4 +572,4 @@ public override Task> CherryPick(Guid engineeringModelId, Gui
throw new NotSupportedException();
}
}
-}
\ No newline at end of file
+}
diff --git a/CDP4Dal.NetCore.Tests/Operations/OperationContainerTestFixture.cs b/CDP4Dal.NetCore.Tests/Operations/OperationContainerTestFixture.cs
index a24abc35e..8db7f0950 100644
--- a/CDP4Dal.NetCore.Tests/Operations/OperationContainerTestFixture.cs
+++ b/CDP4Dal.NetCore.Tests/Operations/OperationContainerTestFixture.cs
@@ -10,17 +10,17 @@
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 3 of the License, or (at your option) any later version.
-//
-// The CDP4-SDK Community Edition is distributed in the hope that it will be useful,
+//
+// The CDP4-COMET SDK Community Edition is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
-//
+//
// You should have received a copy of the GNU Lesser General Public License
// along with this program; if not, write to the Free Software Foundation,
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
//
-// --------------------------------------------------------------------------------------------------------------------
+// -------------------------------------------------------------------------------------------------------------------------------
namespace CDP4Dal.Tests
{
@@ -28,10 +28,14 @@ namespace CDP4Dal.Tests
using System.Linq;
using CDP4Common.CommonData;
- using CDP4Common.DTO;
+ using CDP4Common.DTO;
+
using CDP4Dal.Operations;
+
+ using CDP4DalCommon.Protocol.Operations;
+
using NUnit.Framework;
-
+
[TestFixture]
public class OperationContainerTestFixture
{
@@ -42,7 +46,7 @@ public class OperationContainerTestFixture
[SetUp]
public void SetUp()
{
- this.siteDirectoryContext = "/SiteDirectory/47363f0d-eb6d-4a58-95f5-fa7854995650";
+ this.siteDirectoryContext = "/SiteDirectory/47363f0d-eb6d-4a58-95f5-fa7854995650";
this.iterationContext = "/EngineeringModel/5e5dc7f8-833d-4331-b421-eb2c64fcf64b/iteration/b58ea73d-350d-4520-b9d9-a52c75ac2b5d";
}
@@ -98,9 +102,9 @@ public void VerifyExecutionOfOperationAddAndRemove()
var elementDefinition = new ElementDefinition(Guid.NewGuid(), 0);
elementDefinition.PartialRoutes.Add("iteration/b58ea73d-350d-4520-b9d9-a52c75ac2b5d");
elementDefinition.PartialRoutes.Add("EngineeringModel/5e5dc7f8-833d-4331-b421-eb2c64fcf64b");
-
+
var clone = elementDefinition.DeepClone();
- var operation = new Operation(elementDefinition, clone, OperationKind.Update);
+ var operation = new Operation(elementDefinition, clone, OperationKind.Update);
var operationContainer = new OperationContainer(this.iterationContext);
diff --git a/CDP4Dal.NetCore.Tests/Operations/OperationTestFixture.cs b/CDP4Dal.NetCore.Tests/Operations/OperationTestFixture.cs
index f0e46dd64..b226b6a3a 100644
--- a/CDP4Dal.NetCore.Tests/Operations/OperationTestFixture.cs
+++ b/CDP4Dal.NetCore.Tests/Operations/OperationTestFixture.cs
@@ -10,12 +10,12 @@
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 3 of the License, or (at your option) any later version.
-//
-// The CDP4-SDK Community Edition is distributed in the hope that it will be useful,
+//
+// The CDP4-COMET SDK Community Edition is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
-//
+//
// You should have received a copy of the GNU Lesser General Public License
// along with this program; if not, write to the Free Software Foundation,
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
@@ -26,7 +26,7 @@ namespace CDP4Dal.Tests
{
using CDP4Common.DTO;
- using CDP4Dal.Operations;
+ using CDP4DalCommon.Protocol.Operations;
using NUnit.Framework;
diff --git a/CDP4Dal.NetCore.Tests/Operations/PostOperationTestFixture.cs b/CDP4Dal.NetCore.Tests/Operations/PostOperationTestFixture.cs
index 29bda68f0..4eaec5265 100644
--- a/CDP4Dal.NetCore.Tests/Operations/PostOperationTestFixture.cs
+++ b/CDP4Dal.NetCore.Tests/Operations/PostOperationTestFixture.cs
@@ -10,17 +10,17 @@
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 3 of the License, or (at your option) any later version.
-//
-// The CDP4-SDK Community Edition is distributed in the hope that it will be useful,
+//
+// The CDP4-COMET SDK Community Edition is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
-//
+//
// You should have received a copy of the GNU Lesser General Public License
// along with this program; if not, write to the Free Software Foundation,
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
//
-// --------------------------------------------------------------------------------------------------------------------
+// -------------------------------------------------------------------------------------------------------------------------------
namespace CDP4Dal.Tests
{
@@ -29,9 +29,9 @@ namespace CDP4Dal.Tests
using CDP4Common;
using CDP4Common.Dto;
using CDP4Common.DTO;
-
- using CDP4Dal.Operations;
-
+
+ using CDP4DalCommon.Protocol.Operations;
+
using NUnit.Framework;
[TestFixture]
@@ -50,13 +50,5 @@ public void VerifyThatConstructorSetsLists()
internal class TestPostOperation : PostOperation
{
- public override List Delete { get; set; }
- public override List Create { get; set; }
- public override List Update { get; set; }
- public override List Copy { get; set; }
- public override void ConstructFromOperation(Operation operation)
- {
- throw new System.NotImplementedException();
- }
}
}
diff --git a/CDP4Dal.NetCore.Tests/Operations/ThingTransactionTestFixture.cs b/CDP4Dal.NetCore.Tests/Operations/ThingTransactionTestFixture.cs
index 848587a43..9abeaa4b9 100644
--- a/CDP4Dal.NetCore.Tests/Operations/ThingTransactionTestFixture.cs
+++ b/CDP4Dal.NetCore.Tests/Operations/ThingTransactionTestFixture.cs
@@ -10,17 +10,17 @@
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 3 of the License, or (at your option) any later version.
-//
-// The CDP4-SDK Community Edition is distributed in the hope that it will be useful,
+//
+// The CDP4-COMET SDK Community Edition is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
-//
+//
// You should have received a copy of the GNU Lesser General Public License
// along with this program; if not, write to the Free Software Foundation,
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
//
-// --------------------------------------------------------------------------------------------------------------------
+// -------------------------------------------------------------------------------------------------------------------------------
namespace CDP4Dal.Tests
{
@@ -34,9 +34,11 @@ namespace CDP4Dal.Tests
using CDP4Common.EngineeringModelData;
using CDP4Common.SiteDirectoryData;
using CDP4Common.Types;
-
+
using CDP4Dal.Operations;
-
+
+ using CDP4DalCommon.Protocol.Operations;
+
using NUnit.Framework;
///
@@ -131,6 +133,7 @@ public void VerifyThatCreateThingWorksWithAbstractContainer()
{
Container = this.siteDirectory
};
+
this.cache.TryAdd(new CacheKey(siteRdl.Iid, null), new Lazy(() => siteRdl));
var cloneRdl = siteRdl.Clone(false);
@@ -183,7 +186,7 @@ public void VerifyThatCreateThingTwiceDoesntThrowException()
var transaction = new ThingTransaction(transactionContext, this.siteDirectory.Clone(false));
var phone = new TelephoneNumber(Guid.NewGuid(), this.cache, this.uri);
- Assert.That(() =>
+ Assert.That(() =>
{
transaction.Create(phone);
transaction.Create(phone);
@@ -246,7 +249,6 @@ public void VerifyThatDeleteThingAlreadyDeletedWorks()
[Test]
public void VerifyThatUpdateContainerWorks()
{
-
var iterationClone = this.iteration.Clone(false);
var option1 = new Option(Guid.NewGuid(), this.cache, this.uri);
@@ -328,6 +330,7 @@ public void FunctionalTestCase1()
emailTrans.Create(email);
emailTrans.FinalizeSubTransaction(email, person1_1);
+
// end add email, verify that email is added to person1_1, (the clone of person1)
Assert.That(2, Is.EqualTo(person1_1Tr.AddedThing.Count()));
@@ -339,6 +342,7 @@ public void FunctionalTestCase1()
var phone_1Trans = new ThingTransaction(phone_1, person1_1Tr, person1_1);
phone_1Trans.CreateOrUpdate(phone_1);
phone_1Trans.FinalizeSubTransaction(phone_1, person1_1);
+
// end update phone
// verify that the new reference is used
@@ -354,7 +358,6 @@ public void FunctionalTestCase1()
Assert.That(rootTransaction.AddedThing.Contains(phone_1), Is.True);
Assert.That(1, Is.EqualTo(cloneSiteDir.Person.Count));
-
// Create new person
var person2 = new Person();
var person2Trans = new ThingTransaction(person2, rootTransaction, cloneSiteDir);
@@ -828,6 +831,7 @@ public void VerifyThatCascadeDeleteWorksOnAddedThing()
transaction.Delete(person.Clone(false));
var operationContainer = transaction.FinalizeTransaction();
+
// Update sitedir
Assert.That(1, Is.EqualTo(operationContainer.Operations.Count()));
}
diff --git a/CDP4Dal.NetCore.Tests/SessionTestFixture.cs b/CDP4Dal.NetCore.Tests/SessionTestFixture.cs
index b978e39e5..77734e5e4 100644
--- a/CDP4Dal.NetCore.Tests/SessionTestFixture.cs
+++ b/CDP4Dal.NetCore.Tests/SessionTestFixture.cs
@@ -20,7 +20,7 @@
// along with this program; if not, write to the Free Software Foundation,
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
//
-// --------------------------------------------------------------------------------------------------------------------
+// -------------------------------------------------------------------------------------------------------------------------------
namespace CDP4Dal.NetCore.Tests
{
@@ -37,17 +37,18 @@ namespace CDP4Dal.NetCore.Tests
using CDP4Common.Types;
using CDP4Dal.Composition;
- using CDP4Dal.Operations;
using CDP4Dal.DAL;
using CDP4Dal.Events;
using CDP4Dal.Exceptions;
+ using CDP4Dal.Operations;
- using CDP4DalCommon.Tasks;
+ using CDP4DalCommon.Protocol.Operations;
+ using CDP4DalCommon.Protocol.Tasks;
using Moq;
-
+
using NUnit.Framework;
-
+
using DomainOfExpertise = CDP4Common.SiteDirectoryData.DomainOfExpertise;
using EngineeringModelSetup = CDP4Common.DTO.EngineeringModelSetup;
using ModelReferenceDataLibrary = CDP4Common.SiteDirectoryData.ModelReferenceDataLibrary;
@@ -129,10 +130,7 @@ public void TearDown()
public async Task VerifythatOpenCallAssemblerSynchronizeWithDtos()
{
var eventReceived = false;
- this.messageBus.Listen(typeof(TelephoneNumber)).Subscribe(x =>
- {
- eventReceived = true;
- });
+ this.messageBus.Listen(typeof(TelephoneNumber)).Subscribe(x => { eventReceived = true; });
await this.session.Open();
@@ -149,20 +147,20 @@ public async Task VerifyThatWriteWithEmptyResponseSendsMessages()
writeWithNoResultsTaskCompletionSource.SetResult(new List());
this.mockedDal.Setup(x => x.Open(It.IsAny(), It.IsAny())).Returns(writeWithNoResultsTaskCompletionSource.Task);
- this.messageBus.Listen()
- .Subscribe(x =>
- {
- if (x.Status == SessionStatus.BeginUpdate)
+ this.messageBus.Listen()
+ .Subscribe(x =>
{
- beginUpdateReceived = true;
- return;
- }
+ if (x.Status == SessionStatus.BeginUpdate)
+ {
+ beginUpdateReceived = true;
+ return;
+ }
- if (x.Status == SessionStatus.EndUpdate)
- {
- endUpdateReceived = true;
- }
- });
+ if (x.Status == SessionStatus.EndUpdate)
+ {
+ endUpdateReceived = true;
+ }
+ });
var context = $"/SiteDirectory/{Guid.NewGuid()}";
@@ -186,13 +184,10 @@ public async Task VerifythatRefreshSynchronizeTheAssembler()
var readTaskCompletionSource = new TaskCompletionSource>();
readTaskCompletionSource.SetResult(this.dalOutputs);
this.mockedDal.Setup(x => x.Read(It.IsAny(), It.IsAny(), It.Is(query => query.RevisionNumber == 0))).Returns(readTaskCompletionSource.Task);
-
+
await this.session.Open();
- this.messageBus.Listen(typeof(TelephoneNumber)).Subscribe(x =>
- {
- eventReceived = true;
- });
+ this.messageBus.Listen(typeof(TelephoneNumber)).Subscribe(x => { eventReceived = true; });
// refresh shouldnt do anything
await this.session.Refresh();
@@ -216,10 +211,7 @@ public async Task VerifythatReloadSynchronizeTheAssembler()
await this.session.Open();
- this.messageBus.Listen(typeof(TelephoneNumber)).Subscribe(x =>
- {
- eventReceived = true;
- });
+ this.messageBus.Listen(typeof(TelephoneNumber)).Subscribe(x => { eventReceived = true; });
await this.session.Reload();
@@ -277,10 +269,10 @@ public async Task VerifyThatCloseRdlWorks()
var rdlDto = new CDP4Common.DTO.SiteReferenceDataLibrary { Iid = Guid.NewGuid() };
var rdlPoco = new CDP4Common.SiteDirectoryData.SiteReferenceDataLibrary { Iid = rdlDto.Iid, Name = rdlDto.Name, ShortName = rdlDto.ShortName, Container = siteDirectoryPoco };
-
+
var requiredSiteReferenceDataLibraryDto = new CDP4Common.DTO.SiteReferenceDataLibrary() { Iid = Guid.NewGuid() };
var requiredSiteReferenceDataLibraryPoco = new CDP4Common.SiteDirectoryData.SiteReferenceDataLibrary(requiredSiteReferenceDataLibraryDto.Iid, this.session.Assembler.Cache, this.uri);
-
+
rdlDto.RequiredRdl = requiredSiteReferenceDataLibraryDto.Iid;
rdlPoco.RequiredRdl = requiredSiteReferenceDataLibraryPoco;
@@ -319,7 +311,7 @@ public async Task VerifyThatSiteRdlRequiredByModelRdlCannotBeClosed()
rdlDto.RequiredRdl = requiredRdlDto.Iid;
siteDirDto.SiteReferenceDataLibrary.Add(rdlDto.Iid);
siteDirDto.SiteReferenceDataLibrary.Add(requiredRdlDto.Iid);
-
+
siteDirDto.Person.Add(this.person.Iid);
var mrdl = new CDP4Common.DTO.ModelReferenceDataLibrary(Guid.NewGuid(), 0) { RequiredRdl = requiredRdlDto.Iid };
@@ -348,14 +340,15 @@ public async Task VerifyThatSiteRdlRequiredByModelRdlCannotBeClosed()
var participant = new CDP4Common.DTO.Participant(Guid.NewGuid(), 0) { Person = this.person.Iid };
modelsetup.Participant.Add(participant.Iid);
- var modelPoco = new CDP4Common.EngineeringModelData.EngineeringModel(model.Iid, null, null){EngineeringModelSetup = modelsetuppoco};
+ var modelPoco = new CDP4Common.EngineeringModelData.EngineeringModel(model.Iid, null, null) { EngineeringModelSetup = modelsetuppoco };
var iterationPoco = new CDP4Common.EngineeringModelData.Iteration(iteration.Iid, null, null);
modelPoco.Iteration.Add(iterationPoco);
var readTaskCompletionSource = new TaskCompletionSource>();
readTaskCompletionSource.SetResult(readReturn);
+
this.mockedDal.Setup(
- x => x.Read(It.IsAny(), It.IsAny(), null))
+ x => x.Read(It.IsAny(), It.IsAny(), null))
.Returns(readTaskCompletionSource.Task);
var thingsToAdd = new List() { siteDirDto, requiredRdlDto, rdlDto, this.person, participant, modelsetup };
@@ -449,6 +442,7 @@ public async Task VerifyThatReadRdlWorks()
{
var siteDir = new CDP4Common.SiteDirectoryData.SiteDirectory(Guid.NewGuid(), this.session.Assembler.Cache, this.uri);
var JohnDoe = new CDP4Common.SiteDirectoryData.Person(this.person.Iid, this.session.Assembler.Cache, this.uri) { ShortName = "John" };
+
this.session.Assembler.Cache.TryAdd(new CacheKey(siteDir.Iid, null),
new Lazy(() => siteDir));
@@ -518,14 +512,14 @@ public async Task Verify_that_EngineeringModel_returns_result()
await this.session.Read(iids);
- Assert.That(this.session.Assembler.Cache.ContainsKey(new CacheKey(engineeringModel.Iid, null)), Is.True);
+ Assert.That(this.session.Assembler.Cache.ContainsKey(new CacheKey(engineeringModel.Iid, null)), Is.True);
}
[Test]
public async Task VerifyThatReadIterationWorks()
{
var siteDir = new CDP4Common.SiteDirectoryData.SiteDirectory(Guid.NewGuid(), this.session.Assembler.Cache, this.uri);
- var JohnDoe = new CDP4Common.SiteDirectoryData.Person(this.person.Iid, this.session.Assembler.Cache, this.uri) {ShortName = "John"};
+ var JohnDoe = new CDP4Common.SiteDirectoryData.Person(this.person.Iid, this.session.Assembler.Cache, this.uri) { ShortName = "John" };
var modelSetup = new CDP4Common.SiteDirectoryData.EngineeringModelSetup(Guid.NewGuid(), this.session.Assembler.Cache, this.uri);
var iterationSetup = new CDP4Common.SiteDirectoryData.IterationSetup(Guid.NewGuid(), this.session.Assembler.Cache, this.uri) { FrozenOn = DateTime.Now, IterationIid = Guid.NewGuid() };
var mrdl = new ModelReferenceDataLibrary(Guid.NewGuid(), this.session.Assembler.Cache, this.uri);
@@ -570,7 +564,7 @@ public async Task VerifyThatReadIterationWorks()
var iterationToOpen = new CDP4Common.EngineeringModelData.Iteration(iteration.Iid, null, null);
var modelToOpen = new CDP4Common.EngineeringModelData.EngineeringModel(model.Iid, null, null);
iterationToOpen.Container = modelToOpen;
-
+
await this.session.Read(iterationToOpen, activeDomain);
this.mockedDal.Verify(x => x.Read(It.Is(i => i.Iid == iterationToOpen.Iid), It.IsAny(), It.IsAny()), Times.Once);
@@ -607,7 +601,7 @@ public void Verify_that_when_active_person_is_null_Iteration_is_not_read()
var activeDomain = new DomainOfExpertise(Guid.NewGuid(), null, null);
var model = new EngineeringModel(Guid.NewGuid(), 1);
var iteration = new Iteration(Guid.NewGuid(), 10) { IterationSetup = iterationSetup.Iid };
-
+
var iterationToOpen = new CDP4Common.EngineeringModelData.Iteration(iteration.Iid, null, null);
var modelToOpen = new CDP4Common.EngineeringModelData.EngineeringModel(model.Iid, null, null);
iterationToOpen.Container = modelToOpen;
@@ -664,10 +658,7 @@ public async Task VerifyThatWriteWorksWithEventHandler()
var johnDoe = new CDP4Common.SiteDirectoryData.Person(this.person.Iid, this.session.Assembler.Cache, this.uri) { ShortName = "John" };
this.session.GetType().GetProperty("ActivePerson")?.SetValue(this.session, johnDoe, null);
- this.session.BeforeWrite += (o, args) =>
- {
- args.Cancelled = false;
- };
+ this.session.BeforeWrite += (o, args) => { args.Cancelled = false; };
await this.session.Write(new OperationContainer(context));
@@ -681,10 +672,7 @@ public void VerifyThatCancelWriteWorks()
var johnDoe = new CDP4Common.SiteDirectoryData.Person(this.person.Iid, this.session.Assembler.Cache, this.uri) { ShortName = "John" };
this.session.GetType().GetProperty("ActivePerson")?.SetValue(this.session, johnDoe, null);
- this.session.BeforeWrite += (o, args) =>
- {
- args.Cancelled = true;
- };
+ this.session.BeforeWrite += (o, args) => { args.Cancelled = true; };
Assert.ThrowsAsync(async () => await this.session.Write(new OperationContainer(context)));
@@ -746,11 +734,11 @@ public async Task VerifyCanReadCometTasks()
var returnedCometTasks = new List()
{
- new ()
+ new()
{
Id = Guid.NewGuid()
},
- new ()
+ new()
{
Id = Guid.NewGuid()
},
@@ -788,7 +776,7 @@ public async Task VerifyWritePossibleLongRunningTask()
this.mockedDal.Setup(x => x.Write(It.IsAny(), It.IsAny(), It.IsAny>()))
.ReturnsAsync(new LongRunningTaskResult(new CometTask() { Id = Guid.Empty }));
-
+
var cometTask = await this.session.Write(new OperationContainer(context), 1);
Assert.Multiple(() =>
@@ -817,7 +805,7 @@ public async Task VerifyWritePossibleLongRunningTask()
this.mockedDal.Setup(x => x.Write(It.IsAny(), It.IsAny(), It.IsAny>()))
.ThrowsAsync(new DalReadException());
- Assert.That(() =>this.session.Write(new OperationContainer(context), 1), Throws.Exception.TypeOf());
+ Assert.That(() => this.session.Write(new OperationContainer(context), 1), Throws.Exception.TypeOf());
}
private void AssignActivePerson()
@@ -830,17 +818,21 @@ private void AssignActivePerson()
[DalExport("test dal", "test dal description", "1.1.0", DalType.Web)]
internal class TestDal : IDal
{
- public Version SupportedVersion { get {return new Version(1, 0, 0);} }
+ public static Version SupportedVersion => new (1, 0, 0);
- public Version DalVersion { get {return new Version("1.1.0");} }
- public IMetaDataProvider MetaDataProvider { get {return new MetaDataProvider();} }
+ public Version DalVersion => new(1, 1, 0);
+
+ public IMetaDataProvider MetaDataProvider => new MetaDataProvider();
///
/// Gets or sets the that uses this
///
public ISession Session { get; set; }
- public bool IsReadOnly { get { return false; } }
+ public bool IsReadOnly
+ {
+ get { return false; }
+ }
///
/// Write all the s from all the s asynchronously.
@@ -958,7 +950,7 @@ public Task> Read(Iteration iteration, CancellationToken canc
/// A list of s
///
///
- /// Only those s are retunred that the is a in
+ /// Only those s are retunred that the is a in
///
public Task> Read(IEnumerable engineeringModels, CancellationToken cancellationToken)
{
@@ -1097,4 +1089,4 @@ public Task> CherryPick(Guid engineeringModelId, Guid iterati
throw new System.NotImplementedException();
}
}
-}
\ No newline at end of file
+}
diff --git a/CDP4Dal.Tests/CDP4Dal.Tests.csproj b/CDP4Dal.Tests/CDP4Dal.Tests.csproj
index 9b1f57b17..bda4c0dce 100644
--- a/CDP4Dal.Tests/CDP4Dal.Tests.csproj
+++ b/CDP4Dal.Tests/CDP4Dal.Tests.csproj
@@ -17,7 +17,7 @@
-
+
diff --git a/CDP4Dal.Tests/DAL/DalTestFixture.cs b/CDP4Dal.Tests/DAL/DalTestFixture.cs
index 536f3b888..a2d012d56 100644
--- a/CDP4Dal.Tests/DAL/DalTestFixture.cs
+++ b/CDP4Dal.Tests/DAL/DalTestFixture.cs
@@ -10,17 +10,17 @@
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 3 of the License, or (at your option) any later version.
-//
-// The CDP4-SDK Community Edition is distributed in the hope that it will be useful,
+//
+// The CDP4-COMET SDK Community Edition is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
-//
+//
// You should have received a copy of the GNU Lesser General Public License
// along with this program; if not, write to the Free Software Foundation,
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
//
-// --------------------------------------------------------------------------------------------------------------------
+// -------------------------------------------------------------------------------------------------------------------------------
namespace CDP4Dal.Tests.DAL
{
@@ -36,11 +36,11 @@ namespace CDP4Dal.Tests.DAL
using CDP4Common.Helpers;
using CDP4Dal.Composition;
+ using CDP4Dal.DAL;
using CDP4Dal.Exceptions;
using CDP4Dal.Operations;
- using CDP4Dal.DAL;
- using CDP4DalCommon.Tasks;
+ using CDP4DalCommon.Protocol.Tasks;
using NUnit.Framework;
@@ -64,7 +64,7 @@ public void SetUp()
[Test]
public void Verify_that_the_credentials_are_set_to_Null_when_closed()
{
- var dal = new TestDal(this.credentials);
+ var dal = new TestDal(this.credentials);
dal.CloseSession();
Assert.That(dal.Credentials, Is.Null);
}
@@ -140,6 +140,7 @@ public void Verify_That_SetIterationId_Works_as_expected()
var iteration = new Iteration();
var elementDefinition = new ElementDefinition();
var parameter = new Parameter();
+
var list = new List
{
model,
@@ -216,7 +217,7 @@ public void Verify_That_QueryRequestContext_Returns_Expected_Result()
public void Verify_that_for_a_decorated_dal_the_version_is_set()
{
var dal = new DecoratedDal();
- Assert.That(dal.DalVersion, Is.EqualTo(new Version(1,1,0)));
+ Assert.That(dal.DalVersion, Is.EqualTo(new Version(1, 1, 0)));
}
[Test]
@@ -238,7 +239,7 @@ public void Verify_that_OperationContainerFileVerification_throws_an_exception_w
var commonFileStore = new CDP4Common.EngineeringModelData.CommonFileStore(Guid.NewGuid(), null, null);
engineeringModel.Iteration.Add(iteration);
engineeringModel.CommonFileStore.Add(commonFileStore);
-
+
var context = TransactionContextResolver.ResolveContext(commonFileStore);
var transaction = new ThingTransaction(context);
@@ -246,13 +247,13 @@ public void Verify_that_OperationContainerFileVerification_throws_an_exception_w
var file = new CDP4Common.EngineeringModelData.File(Guid.NewGuid(), null, null);
var fileRevision = new CDP4Common.EngineeringModelData.FileRevision(Guid.NewGuid(), null, null);
-
+
transaction.Create(file, commonFileStoreClone);
transaction.Create(fileRevision, file);
var operationContainer = transaction.FinalizeTransaction();
- var files = new List {this.filePath};
+ var files = new List { this.filePath };
var testDal = new TestDal(this.credentials);
Assert.Throws(() => testDal.TestOperationContainerFileVerification(operationContainer, files));
@@ -277,7 +278,7 @@ public void Verify_that_OperationContainerFileVerification_throws_no_exception_w
var commonFileStore = new CDP4Common.EngineeringModelData.CommonFileStore(Guid.NewGuid(), null, null);
engineeringModel.Iteration.Add(iteration);
engineeringModel.CommonFileStore.Add(commonFileStore);
-
+
var context = TransactionContextResolver.ResolveContext(commonFileStore);
var transaction = new ThingTransaction(context);
@@ -286,13 +287,13 @@ public void Verify_that_OperationContainerFileVerification_throws_no_exception_w
var file = new CDP4Common.EngineeringModelData.File(Guid.NewGuid(), null, null);
var fileRevision = new CDP4Common.EngineeringModelData.FileRevision(Guid.NewGuid(), null, null);
fileRevision.ContentHash = "1B686ADFA2CAE870A96E5885087337C032781BE6";
-
+
transaction.Create(file, commonFileStoreClone);
transaction.Create(fileRevision, file);
var operationContainer = transaction.FinalizeTransaction();
- var files = new List {this.filePath};
+ var files = new List { this.filePath };
var testDal = new TestDal(this.credentials);
@@ -300,10 +301,13 @@ public void Verify_that_OperationContainerFileVerification_throws_no_exception_w
}
}
- [CDPVersion("1.1.0")]
+ [CDPVersion("1.1.0")]
internal class TestDal : Dal
{
- public override bool IsReadOnly { get { return false; } }
+ public override bool IsReadOnly
+ {
+ get { return false; }
+ }
public TestDal(Credentials credentials)
: base()
@@ -410,7 +414,7 @@ public override IEnumerable Update(T thing)
{
throw new System.NotImplementedException();
}
-
+
public override IEnumerable Delete(T thing)
{
throw new System.NotImplementedException();
@@ -447,10 +451,11 @@ public override Task> CherryPick(Guid engineeringModelId, Gui
}
}
- [DalExportAttribute("decorateddal","a decorated dal","1.1.0",DalType.Web)]
+ [DalExportAttribute("decorateddal", "a decorated dal", "1.1.0", DalType.Web)]
internal class DecoratedDal : Dal
{
public override bool IsReadOnly { get; }
+
public override Task> Write(IEnumerable operationContainer, IEnumerable files = null)
{
throw new NotImplementedException();
@@ -566,4 +571,4 @@ public override Task> CherryPick(Guid engineeringModelId, Gui
throw new NotSupportedException();
}
}
-}
\ No newline at end of file
+}
diff --git a/CDP4Dal.Tests/Operations/OperationContainerTestFixture.cs b/CDP4Dal.Tests/Operations/OperationContainerTestFixture.cs
index a24abc35e..8db7f0950 100644
--- a/CDP4Dal.Tests/Operations/OperationContainerTestFixture.cs
+++ b/CDP4Dal.Tests/Operations/OperationContainerTestFixture.cs
@@ -10,17 +10,17 @@
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 3 of the License, or (at your option) any later version.
-//
-// The CDP4-SDK Community Edition is distributed in the hope that it will be useful,
+//
+// The CDP4-COMET SDK Community Edition is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
-//
+//
// You should have received a copy of the GNU Lesser General Public License
// along with this program; if not, write to the Free Software Foundation,
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
//
-// --------------------------------------------------------------------------------------------------------------------
+// -------------------------------------------------------------------------------------------------------------------------------
namespace CDP4Dal.Tests
{
@@ -28,10 +28,14 @@ namespace CDP4Dal.Tests
using System.Linq;
using CDP4Common.CommonData;
- using CDP4Common.DTO;
+ using CDP4Common.DTO;
+
using CDP4Dal.Operations;
+
+ using CDP4DalCommon.Protocol.Operations;
+
using NUnit.Framework;
-
+
[TestFixture]
public class OperationContainerTestFixture
{
@@ -42,7 +46,7 @@ public class OperationContainerTestFixture
[SetUp]
public void SetUp()
{
- this.siteDirectoryContext = "/SiteDirectory/47363f0d-eb6d-4a58-95f5-fa7854995650";
+ this.siteDirectoryContext = "/SiteDirectory/47363f0d-eb6d-4a58-95f5-fa7854995650";
this.iterationContext = "/EngineeringModel/5e5dc7f8-833d-4331-b421-eb2c64fcf64b/iteration/b58ea73d-350d-4520-b9d9-a52c75ac2b5d";
}
@@ -98,9 +102,9 @@ public void VerifyExecutionOfOperationAddAndRemove()
var elementDefinition = new ElementDefinition(Guid.NewGuid(), 0);
elementDefinition.PartialRoutes.Add("iteration/b58ea73d-350d-4520-b9d9-a52c75ac2b5d");
elementDefinition.PartialRoutes.Add("EngineeringModel/5e5dc7f8-833d-4331-b421-eb2c64fcf64b");
-
+
var clone = elementDefinition.DeepClone();
- var operation = new Operation(elementDefinition, clone, OperationKind.Update);
+ var operation = new Operation(elementDefinition, clone, OperationKind.Update);
var operationContainer = new OperationContainer(this.iterationContext);
diff --git a/CDP4Dal.Tests/Operations/OperationTestFixture.cs b/CDP4Dal.Tests/Operations/OperationTestFixture.cs
index f0e46dd64..5048f43bb 100644
--- a/CDP4Dal.Tests/Operations/OperationTestFixture.cs
+++ b/CDP4Dal.Tests/Operations/OperationTestFixture.cs
@@ -10,12 +10,12 @@
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 3 of the License, or (at your option) any later version.
-//
-// The CDP4-SDK Community Edition is distributed in the hope that it will be useful,
+//
+// The CDP4-COMET SDK Community Edition is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
-//
+//
// You should have received a copy of the GNU Lesser General Public License
// along with this program; if not, write to the Free Software Foundation,
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
@@ -28,6 +28,8 @@ namespace CDP4Dal.Tests
using CDP4Dal.Operations;
+ using CDP4DalCommon.Protocol.Operations;
+
using NUnit.Framework;
[TestFixture]
diff --git a/CDP4Dal.Tests/Operations/PostOperationTestFixture.cs b/CDP4Dal.Tests/Operations/PostOperationTestFixture.cs
index 6da8350cb..235d9ce5a 100644
--- a/CDP4Dal.Tests/Operations/PostOperationTestFixture.cs
+++ b/CDP4Dal.Tests/Operations/PostOperationTestFixture.cs
@@ -10,26 +10,28 @@
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 3 of the License, or (at your option) any later version.
-//
-// The CDP4-SDK Community Edition is distributed in the hope that it will be useful,
+//
+// The CDP4-COMET SDK Community Edition is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
-//
+//
// You should have received a copy of the GNU Lesser General Public License
// along with this program; if not, write to the Free Software Foundation,
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
//
// --------------------------------------------------------------------------------------------------------------------
-using CDP4Common;
-
namespace CDP4Dal.Tests
{
using System.Collections.Generic;
+
+ using CDP4Common;
using CDP4Common.Dto;
using CDP4Common.DTO;
- using CDP4Dal.Operations;
+
+ using CDP4DalCommon.Protocol.Operations;
+
using NUnit.Framework;
[TestFixture]
@@ -48,13 +50,5 @@ public void VerifyThatConstructorSetsLists()
internal class TestPostOperation : PostOperation
{
- public override List Delete { get; set; }
- public override List Create { get; set; }
- public override List Update { get; set; }
- public override List Copy { get; set; }
- public override void ConstructFromOperation(Operation operation)
- {
- throw new System.NotImplementedException();
- }
}
}
diff --git a/CDP4Dal.Tests/Operations/ThingTransactionTestFixture.cs b/CDP4Dal.Tests/Operations/ThingTransactionTestFixture.cs
index 4ed2d35c7..31ae676cf 100644
--- a/CDP4Dal.Tests/Operations/ThingTransactionTestFixture.cs
+++ b/CDP4Dal.Tests/Operations/ThingTransactionTestFixture.cs
@@ -10,17 +10,17 @@
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 3 of the License, or (at your option) any later version.
-//
-// The CDP4-SDK Community Edition is distributed in the hope that it will be useful,
+//
+// The CDP4-COMET SDK Community Edition is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
-//
+//
// You should have received a copy of the GNU Lesser General Public License
// along with this program; if not, write to the Free Software Foundation,
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
//
-// --------------------------------------------------------------------------------------------------------------------
+// -------------------------------------------------------------------------------------------------------------------------------
namespace CDP4Dal.Tests
{
@@ -31,12 +31,14 @@ namespace CDP4Dal.Tests
using System.Text;
using CDP4Common.CommonData;
- using CDP4Common.EngineeringModelData;
+ using CDP4Common.EngineeringModelData;
using CDP4Common.SiteDirectoryData;
using CDP4Common.Types;
-
+
using CDP4Dal.Operations;
+ using CDP4DalCommon.Protocol.Operations;
+
using NUnit.Framework;
///
@@ -65,7 +67,7 @@ public void Setup()
iterationSetup.IterationIid = this.iteration.Iid;
this.engineeringModel.Iteration.Add(this.iteration);
-
+
this.cache.TryAdd(new CacheKey(this.siteDirectory.Iid, null), new Lazy(() => this.siteDirectory));
this.cache.TryAdd(new CacheKey(this.engineeringModel.Iid, null), new Lazy(() => this.engineeringModel));
this.cache.TryAdd(new CacheKey(this.iteration.Iid, null), new Lazy(() => this.iteration));
@@ -95,7 +97,7 @@ public void VerifyThatCanOnlyUseThingTransactionOnOneTopContainer()
var person = new Person(Guid.NewGuid(), this.cache, this.uri) { Container = this.siteDirectory };
var transaction = new ThingTransaction(transactionContext, person);
-
+
var duplicateSiteDirectory = new SiteDirectory(this.siteDirectory.Iid, this.cache, this.uri);
var anotherPerson = new Person(Guid.NewGuid(), this.cache, this.uri) { Container = duplicateSiteDirectory };
transaction.CreateOrUpdate(anotherPerson);
@@ -109,7 +111,7 @@ public void VerifyThatCanOnlyUseThingTransactionOnOneTopContainer()
[Test]
public void VerifyThatCreateThingWorks()
{
- var person = new Person(Guid.NewGuid(), this.cache, this.uri) {Container = this.siteDirectory};
+ var person = new Person(Guid.NewGuid(), this.cache, this.uri) { Container = this.siteDirectory };
this.cache.TryAdd(new CacheKey(person.Iid, null), new Lazy(() => person));
var clonePerson = person.Clone(false);
@@ -131,6 +133,7 @@ public void VerifyThatCreateThingWorksWithAbstractContainer()
{
Container = this.siteDirectory
};
+
this.cache.TryAdd(new CacheKey(siteRdl.Iid, null), new Lazy(() => siteRdl));
var cloneRdl = siteRdl.Clone(false);
@@ -152,7 +155,7 @@ public void VerifyThatCreateModelDoesNotWorks()
var newModel = new EngineeringModel(Guid.NewGuid(), this.cache, this.uri);
var transactionContext = TransactionContextResolver.ResolveContext(this.siteDirectory);
-
+
Assert.Throws(() => new ThingTransaction(transactionContext, newModel));
}
@@ -162,7 +165,7 @@ public void VerifyThatCreateSiteDirDoesNotWorks()
var newSiteDirectory = new SiteDirectory(Guid.NewGuid(), this.cache, this.uri);
var transactionContext = TransactionContextResolver.ResolveContext(this.siteDirectory);
-
+
Assert.Throws(() => new ThingTransaction(transactionContext, newSiteDirectory));
}
@@ -195,7 +198,7 @@ public void VerifyThatUpdateThingWorks()
{
var phone = new TelephoneNumber(Guid.NewGuid(), this.cache, this.uri);
this.cache.TryAdd(new CacheKey(phone.Iid, null), new Lazy(() => phone));
-
+
var clone = phone.Clone(false);
var transactionContext = TransactionContextResolver.ResolveContext(this.siteDirectory);
@@ -208,9 +211,9 @@ public void VerifyThatUpdateThingWorks()
[Test]
public void VerifyThatUpdateThingThrowsExceptionUponUpdatingExistingCloneWithAnotherClone()
{
- var phone = new TelephoneNumber(Guid.NewGuid(), this.cache, this.uri);
+ var phone = new TelephoneNumber(Guid.NewGuid(), this.cache, this.uri);
this.cache.TryAdd(new CacheKey(phone.Iid, null), new Lazy(() => phone));
-
+
var clone1 = phone.Clone(false);
var clone2 = phone.Clone(false);
@@ -246,10 +249,9 @@ public void VerifyThatDeleteThingAlreadyDeletedWorks()
[Test]
public void VerifyThatUpdateContainerWorks()
{
-
var iterationClone = this.iteration.Clone(false);
var option1 = new Option(Guid.NewGuid(), this.cache, this.uri);
-
+
var transactionContext = TransactionContextResolver.ResolveContext(this.iteration);
var transaction = new ThingTransaction(transactionContext, iterationClone);
transaction.CreateOrUpdate(iterationClone);
@@ -272,7 +274,7 @@ public void VerifyThatUpdateContainerWorks()
Assert.That(0, Is.EqualTo(this.iteration.Option.Count));
Assert.That(2, Is.EqualTo(clone.Option.Count));
}
-
+
///
/// Create a containment tree under site directory and update
///
@@ -328,6 +330,7 @@ public void FunctionalTestCase1()
emailTrans.Create(email);
emailTrans.FinalizeSubTransaction(email, person1_1);
+
// end add email, verify that email is added to person1_1, (the clone of person1)
Assert.That(2, Is.EqualTo(person1_1Tr.AddedThing.Count()));
@@ -339,6 +342,7 @@ public void FunctionalTestCase1()
var phone_1Trans = new ThingTransaction(phone_1, person1_1Tr, person1_1);
phone_1Trans.CreateOrUpdate(phone_1);
phone_1Trans.FinalizeSubTransaction(phone_1, person1_1);
+
// end update phone
// verify that the new reference is used
@@ -577,7 +581,7 @@ public void VerifyThatCreateDeepWorks()
enumValue.Definition.Add(enumValueDef);
enumPt.ValueDefinition.Add(enumValue);
-
+
var transactionContext = TransactionContextResolver.ResolveContext(this.siteDirectory);
var transaction = new ThingTransaction(transactionContext);
transaction.CreateDeep(enumPt);
@@ -827,6 +831,7 @@ public void VerifyThatCascadeDeleteWorksOnAddedThing()
transaction.Delete(person.Clone(false));
var operationContainer = transaction.FinalizeTransaction();
+
// Update sitedir
Assert.That(1, Is.EqualTo(operationContainer.Operations.Count()));
}
@@ -852,8 +857,8 @@ public void VerifyThatDryCopyWorks()
var elementDefinitionClone = elementDefinition.Clone(false);
var targetIterationClone = targetIteration.Clone(false);
-
- var transactionContext = TransactionContextResolver.ResolveContext(targetIteration);
+
+ var transactionContext = TransactionContextResolver.ResolveContext(targetIteration);
var transaction = new ThingTransaction(transactionContext);
transaction.Copy(elementDefinitionClone, targetIterationClone, OperationKind.CopyDefaultValuesChangeOwner);
@@ -886,7 +891,7 @@ public void VerifyThatCtrlCopyWorks()
var elementDefinitionClone = elementDefinition.Clone(false);
var targetIterationClone = targetIteration.Clone(false);
-
+
var transactionContext = TransactionContextResolver.ResolveContext(targetIteration);
var transaction = new ThingTransaction(transactionContext);
transaction.Copy(elementDefinitionClone, targetIterationClone, OperationKind.CopyKeepValuesChangeOwner);
@@ -994,7 +999,7 @@ public void VerifyThatWhenCopyOperationIsInvokedWithNonCopyOperationExceptionIsT
Assert.Throws(() => transaction.Copy(elementDefinitionClone, targetIterationClone, OperationKind.Create));
}
- [Test]
+ [Test]
public void VerifyThatCopyThrowsExcpetionCloneThatIsToBeCopiedIsNull()
{
var sourceModel = new EngineeringModel(Guid.NewGuid(), this.cache, this.uri);
@@ -1019,7 +1024,7 @@ public void VerifyThatCopyThrowsExcpetionCloneThatIsToBeCopiedIsNull()
Assert.Throws(() => transaction.Copy(null, OperationKind.Copy));
}
- [Test]
+ [Test]
public void VerifyThatCopyThrowsExceptionWhenDestinationIsNull()
{
var sourceModel = new EngineeringModel(Guid.NewGuid(), this.cache, this.uri);
@@ -1050,9 +1055,9 @@ public void VerifyThatGetLastCloneCreatedThrowsExceptionWhenThingIsNullOrGuidIsE
{
var model = new EngineeringModel(Guid.NewGuid(), this.cache, this.uri);
var iteration = new Iteration(Guid.NewGuid(), this.cache, this.uri);
-
+
model.Iteration.Add(iteration);
-
+
var transactionContext = TransactionContextResolver.ResolveContext(iteration);
var transaction = new ThingTransaction(transactionContext);
@@ -1066,9 +1071,9 @@ public void VerifyThatGetLastCloneCreatedThrowsExceptionWhenThingIsNullOrGuidIsE
[Test]
public void VerifyThatArgumentNullExceptionIsThrownWhenContextIsNull()
{
- Assert.Throws(() => new ThingTransaction(null));
+ Assert.Throws(() => new ThingTransaction(null));
}
-
+
[Test]
public void VerifyThatArgumentNullExceptionIsThrownWhenCloneIsNull()
{
@@ -1084,7 +1089,7 @@ public void VerifyThatArgumentNullExceptionIsThrownWhenCloneIsNull()
var iterationClone = iteration.Clone(false);
var elementDefinitionClone = elementDefinition.Clone(false);
- Assert.Throws(() => new ThingTransaction(null, null, iterationClone));
+ Assert.Throws(() => new ThingTransaction(null, null, iterationClone));
}
}
}
diff --git a/CDP4Dal.Tests/SessionTestFixture.cs b/CDP4Dal.Tests/SessionTestFixture.cs
index fbce86254..3bd36e4a8 100644
--- a/CDP4Dal.Tests/SessionTestFixture.cs
+++ b/CDP4Dal.Tests/SessionTestFixture.cs
@@ -20,7 +20,7 @@
// along with this program; if not, write to the Free Software Foundation,
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
//
-// --------------------------------------------------------------------------------------------------------------------
+// -------------------------------------------------------------------------------------------------------------------------------
namespace CDP4Dal.Tests
{
@@ -37,12 +37,12 @@ namespace CDP4Dal.Tests
using CDP4Common.Types;
using CDP4Dal.Composition;
- using CDP4Dal.Operations;
using CDP4Dal.DAL;
using CDP4Dal.Events;
using CDP4Dal.Exceptions;
+ using CDP4Dal.Operations;
- using CDP4DalCommon.Tasks;
+ using CDP4DalCommon.Protocol.Tasks;
using Moq;
@@ -130,10 +130,7 @@ public void TearDown()
public async Task VerifythatOpenCallAssemblerSynchronizeWithDtos()
{
var eventReceived = false;
- this.messageBus.Listen(typeof(TelephoneNumber)).Subscribe(x =>
- {
- eventReceived = true;
- });
+ this.messageBus.Listen(typeof(TelephoneNumber)).Subscribe(x => { eventReceived = true; });
await this.session.Open();
@@ -178,10 +175,7 @@ public void VerifyThatOpenCallMightBeCancelled()
}));
}
- Assert.DoesNotThrowAsync(async () =>
- {
- await Task.WhenAll(tasks.ToArray());
- });
+ Assert.DoesNotThrowAsync(async () => { await Task.WhenAll(tasks.ToArray()); });
}
[Test]
@@ -196,18 +190,18 @@ public async Task VerifyThatWriteWithEmptyResponseSendsMessages()
this.messageBus.Listen()
.Subscribe(x =>
- {
- if (x.Status == SessionStatus.BeginUpdate)
{
- beginUpdateReceived = true;
- return;
- }
+ if (x.Status == SessionStatus.BeginUpdate)
+ {
+ beginUpdateReceived = true;
+ return;
+ }
- if (x.Status == SessionStatus.EndUpdate)
- {
- endUpdateReceived = true;
- }
- });
+ if (x.Status == SessionStatus.EndUpdate)
+ {
+ endUpdateReceived = true;
+ }
+ });
var context = $"/SiteDirectory/{Guid.NewGuid()}";
@@ -234,10 +228,7 @@ public async Task VerifythatRefreshSynchronizeTheAssembler()
await this.session.Open();
- this.messageBus.Listen(typeof(TelephoneNumber)).Subscribe(x =>
- {
- eventReceived = true;
- });
+ this.messageBus.Listen(typeof(TelephoneNumber)).Subscribe(x => { eventReceived = true; });
// refresh shouldnt do anything
await this.session.Refresh();
@@ -267,10 +258,7 @@ public async Task VerifythatReloadSynchronizeTheAssembler()
await this.session.Open();
- this.messageBus.Listen(typeof(TelephoneNumber)).Subscribe(x =>
- {
- eventReceived = true;
- });
+ this.messageBus.Listen(typeof(TelephoneNumber)).Subscribe(x => { eventReceived = true; });
await this.session.Reload();
@@ -467,14 +455,15 @@ public async Task VerifyThatSiteRdlRequiredByModelRdlCannotBeClosed()
var participant = new CDP4Common.DTO.Participant(Guid.NewGuid(), 0) { Person = this.person.Iid };
modelsetup.Participant.Add(participant.Iid);
- var modelPoco = new CDP4Common.EngineeringModelData.EngineeringModel(model.Iid, null, null){EngineeringModelSetup = modelsetuppoco};
+ var modelPoco = new CDP4Common.EngineeringModelData.EngineeringModel(model.Iid, null, null) { EngineeringModelSetup = modelsetuppoco };
var iterationPoco = new CDP4Common.EngineeringModelData.Iteration(iteration.Iid, null, null);
modelPoco.Iteration.Add(iterationPoco);
var readTaskCompletionSource = new TaskCompletionSource>();
readTaskCompletionSource.SetResult(readReturn);
+
this.mockedDal.Setup(
- x => x.Read(It.IsAny(), It.IsAny(), null))
+ x => x.Read(It.IsAny(), It.IsAny(), null))
.Returns(readTaskCompletionSource.Task);
var thingsToAdd = new List() { siteDirDto, requiredRdlDto, rdlDto, this.person, participant, modelsetup };
@@ -568,6 +557,7 @@ public async Task VerifyThatReadRdlWorks()
{
var siteDir = new CDP4Common.SiteDirectoryData.SiteDirectory(Guid.NewGuid(), this.session.Assembler.Cache, this.uri);
var JohnDoe = new CDP4Common.SiteDirectoryData.Person(this.person.Iid, this.session.Assembler.Cache, this.uri) { ShortName = "John" };
+
this.session.Assembler.Cache.TryAdd(new CacheKey(siteDir.Iid, null),
new Lazy(() => siteDir));
@@ -599,7 +589,7 @@ public async Task VerifyThatReadRdlWorks()
public async Task VerifyThatReadIterationWorks()
{
var siteDir = new CDP4Common.SiteDirectoryData.SiteDirectory(Guid.NewGuid(), this.session.Assembler.Cache, this.uri);
- var JohnDoe = new CDP4Common.SiteDirectoryData.Person(this.person.Iid, this.session.Assembler.Cache, this.uri) {ShortName = "John"};
+ var JohnDoe = new CDP4Common.SiteDirectoryData.Person(this.person.Iid, this.session.Assembler.Cache, this.uri) { ShortName = "John" };
var modelSetup = new CDP4Common.SiteDirectoryData.EngineeringModelSetup(Guid.NewGuid(), this.session.Assembler.Cache, this.uri);
var iterationSetup = new CDP4Common.SiteDirectoryData.IterationSetup(Guid.NewGuid(), this.session.Assembler.Cache, this.uri) { FrozenOn = DateTime.Now, IterationIid = Guid.NewGuid() };
var mrdl = new ModelReferenceDataLibrary(Guid.NewGuid(), this.session.Assembler.Cache, this.uri);
@@ -738,10 +728,7 @@ public async Task VerifyThatWriteWorksWithEventHandler()
var johnDoe = new CDP4Common.SiteDirectoryData.Person(this.person.Iid, this.session.Assembler.Cache, this.uri) { ShortName = "John" };
this.session.GetType().GetProperty("ActivePerson")?.SetValue(this.session, johnDoe, null);
- this.session.BeforeWrite += (o, args) =>
- {
- args.Cancelled = false;
- };
+ this.session.BeforeWrite += (o, args) => { args.Cancelled = false; };
await this.session.Write(new OperationContainer(context));
@@ -755,10 +742,7 @@ public void VerifyThatCancelWriteWorks()
var johnDoe = new CDP4Common.SiteDirectoryData.Person(this.person.Iid, this.session.Assembler.Cache, this.uri) { ShortName = "John" };
this.session.GetType().GetProperty("ActivePerson")?.SetValue(this.session, johnDoe, null);
- this.session.BeforeWrite += (o, args) =>
- {
- args.Cancelled = true;
- };
+ this.session.BeforeWrite += (o, args) => { args.Cancelled = true; };
Assert.ThrowsAsync(async () => await this.session.Write(new OperationContainer(context)));
@@ -784,11 +768,11 @@ public async Task VerifyCanCherryPick()
categoriesId.Add(Guid.NewGuid());
var elementDefinitionId = Guid.NewGuid();
- cherryPickedThings.Add(new Iteration(){Iid = engineeringModelId, Element = new List{elementDefinitionId}});
- cherryPickedThings.Add(new ElementDefinition(){Iid = elementDefinitionId, Category = new List { categoriesId[0] }});
+ cherryPickedThings.Add(new Iteration() { Iid = engineeringModelId, Element = new List { elementDefinitionId } });
+ cherryPickedThings.Add(new ElementDefinition() { Iid = elementDefinitionId, Category = new List { categoriesId[0] } });
readThings = (await this.session.CherryPick(engineeringModelId, iterationId, classKinds, categoriesId)).ToList();
-
+
Assert.Multiple(() =>
{
Assert.That(readThings, Is.Not.Empty);
@@ -893,7 +877,7 @@ public async Task VerifyWritePossibleLongRunningTask()
this.mockedDal.Setup(x => x.Write(It.IsAny(), It.IsAny(), It.IsAny>()))
.ReturnsAsync(new LongRunningTaskResult(new CometTask() { Id = Guid.Empty }));
-
+
var cometTask = await this.session.Write(new OperationContainer(context), 1);
Assert.Multiple(() =>
@@ -922,8 +906,9 @@ public async Task VerifyWritePossibleLongRunningTask()
this.mockedDal.Setup(x => x.Write(It.IsAny(), It.IsAny(), It.IsAny>()))
.ThrowsAsync(new DalReadException());
- Assert.That(() =>this.session.Write(new OperationContainer(context), 1), Throws.Exception.TypeOf());
+ Assert.That(() => this.session.Write(new OperationContainer(context), 1), Throws.Exception.TypeOf());
}
+
private void AssignActivePerson()
{
var johnDoe = new Person(this.person.Iid, this.session.Assembler.Cache, this.uri) { ShortName = "John" };
@@ -934,16 +919,30 @@ private void AssignActivePerson()
[DalExport("test dal", "test dal description", "1.1.0", DalType.Web)]
internal class TestDal : IDal
{
- public Version SupportedVersion { get {return new Version(1, 0, 0);} }
- public Version DalVersion { get {return new Version("1.1.0");} }
- public IMetaDataProvider MetaDataProvider { get {return new MetaDataProvider();} }
+ public Version SupportedVersion
+ {
+ get { return new Version(1, 0, 0); }
+ }
+
+ public Version DalVersion
+ {
+ get { return new Version("1.1.0"); }
+ }
+
+ public IMetaDataProvider MetaDataProvider
+ {
+ get { return new MetaDataProvider(); }
+ }
///
/// Gets or sets the that uses this
///
public ISession Session { get; set; }
- public bool IsReadOnly { get { return false; } }
+ public bool IsReadOnly
+ {
+ get { return false; }
+ }
///
/// Write all the s from all the s asynchronously.
@@ -1184,4 +1183,4 @@ public Task> CherryPick(Guid engineeringModelId, Guid iterati
throw new NotImplementedException();
}
}
-}
\ No newline at end of file
+}
diff --git a/CDP4Dal/Assembler.cs b/CDP4Dal/Assembler.cs
index c96136dca..5b855584d 100644
--- a/CDP4Dal/Assembler.cs
+++ b/CDP4Dal/Assembler.cs
@@ -143,9 +143,7 @@ public async Task Synchronize(IEnumerable dtoThings, bool
logger.Info("Start Synchronization of {0}", this.IDalUri);
var existentGuid =
- this.Cache.Select(
- x => new Tuple(x.Value.Value.CacheKey, x.Value.Value.RevisionNumber))
- .ToList();
+ new Dictionary(this.Cache.ToDictionary(x => x.Value.Value.CacheKey, y => y.Value.Value.RevisionNumber));
this.CheckPartitionDependentContainmentContainerIds(dtoThings);
@@ -224,17 +222,14 @@ public async Task Synchronize(IEnumerable dtoThings, bool
if (succeed)
{
var thingObject = updatedLazyThing.Value;
- var cacheId = new CacheKey(dtoThing.Iid, dtoThing.IterationContainerId);
-
- if (!existentGuid.Select(x => x.Item1).Contains(cacheId))
+
+ if (!existentGuid.TryGetValue(cacheKey, out var cacheThingRevisionNumber))
{
this.messageBus.SendObjectChangeEvent(thingObject, EventKind.Added);
messageCounter++;
}
else
{
- var cacheThingRevisionNumber = existentGuid.Single(x => x.Item1.Equals(cacheId)).Item2;
-
if (dtoThing.RevisionNumber > cacheThingRevisionNumber)
{
// send event if revision number has increased from the old cached version
@@ -243,7 +238,7 @@ public async Task Synchronize(IEnumerable dtoThings, bool
}
else if (dtoThing.RevisionNumber < cacheThingRevisionNumber)
{
- if (this.Cache.TryGetValue(cacheId, out var cacheThing))
+ if (this.Cache.TryGetValue(cacheKey, out var cacheThing))
{
// send event if revision number is lower. That means that the original cached item was changed (revision was added!) ICDPMessageBus.Current.SendObjectChangeEvent(cacheThing.Value, EventKind.Updated);
this.messageBus.SendObjectChangeEvent(cacheThing.Value, EventKind.Updated);
diff --git a/CDP4Dal/CDP4Dal.csproj b/CDP4Dal/CDP4Dal.csproj
index cc693e52b..1b78dc814 100644
--- a/CDP4Dal/CDP4Dal.csproj
+++ b/CDP4Dal/CDP4Dal.csproj
@@ -4,7 +4,7 @@
net48;netstandard2.0
Starion Group S.A.
CDP4Dal Community Edition
- 27.4.0
+ 28.0.0
CDP4 Data Access Layer library, a consumer of an ECSS-E-TM-10-25 Annex C API
Copyright © Starion Group S.A.
Sam, Merlin, Alex, Naron, Alexander, Yevhen, Nathanael, Ahmed
@@ -20,13 +20,13 @@
CDP COMET ECSS-E-TM-10-25
LGPL-3.0-only
- [BUMP] To CDP4Common 27.4.0
+ [Refactor] Newtonsoft to System.Text.Json
README.md
-
+
@@ -50,4 +50,4 @@
-
\ No newline at end of file
+
diff --git a/CDP4Dal/DAL/Dal.cs b/CDP4Dal/DAL/Dal.cs
index fb562484b..28c88814b 100644
--- a/CDP4Dal/DAL/Dal.cs
+++ b/CDP4Dal/DAL/Dal.cs
@@ -1,26 +1,26 @@
-// --------------------------------------------------------------------------------------------------------------------
+// -------------------------------------------------------------------------------------------------------------------------------
//
// Copyright (c) 2015-2024 Starion Group S.A.
-//
-// Author: Sam Gerené, Merlin Bieze, Alex Vorobiev, Naron Phou, Alexander van Delft
-//
-// This file is part of COMET-SDK Community Edition
-//
-// The COMET-SDK Community Edition is free software; you can redistribute it and/or
+//
+// Authors: Sam Gerené, Alex Vorobiev, Alexander van Delft, Nathanael Smiechowski, Antoine Théate, Omar Elebiary, Jaime Bernar
+//
+// This file is part of CDP4-COMET SDK Community Edition
+//
+// The CDP4-COMET SDK Community Edition is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 3 of the License, or (at your option) any later version.
-//
-// The COMET-SDK Community Edition is distributed in the hope that it will be useful,
+//
+// The CDP4-COMET SDK Community Edition is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
-//
+//
// You should have received a copy of the GNU Lesser General Public License
// along with this program; if not, write to the Free Software Foundation,
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
//
-// --------------------------------------------------------------------------------------------------------------------
+// -------------------------------------------------------------------------------------------------------------------------------
namespace CDP4Dal.DAL
{
@@ -36,15 +36,16 @@ namespace CDP4Dal.DAL
using CDP4Common.DTO;
using CDP4Common.Helpers;
using CDP4Common.MetaInfo;
-
- using CDP4Dal.Operations;
+
using CDP4Dal.Composition;
using CDP4Dal.Exceptions;
+ using CDP4Dal.Operations;
- using CDP4DalCommon.Tasks;
+ using CDP4DalCommon.Protocol.Operations;
+ using CDP4DalCommon.Protocol.Tasks;
using NLog;
-
+
using Iteration = CDP4Common.DTO.Iteration;
using Thing = CDP4Common.DTO.Thing;
@@ -217,7 +218,7 @@ protected Dal()
/// The
///
/// an await-able that returns a array.
- public abstract Task ReadFile(Thing thing, CancellationToken cancellationToken) ;
+ public abstract Task ReadFile(Thing thing, CancellationToken cancellationToken);
///
/// Creates the specified on a data source
@@ -438,7 +439,7 @@ public bool TryExtractIterationIdfromUri(Uri uri, out Guid iterationId)
}
catch (Exception ex)
{
- Logger.Warn(ex,"The Iteration identifier could not be exracted from {0}", uri);
+ Logger.Warn(ex, "The Iteration identifier could not be exracted from {0}", uri);
iterationId = Guid.Empty;
return false;
@@ -543,4 +544,4 @@ protected virtual void SetCdpVersion()
}
}
}
-}
\ No newline at end of file
+}
diff --git a/CDP4Dal/DAL/IDal.cs b/CDP4Dal/DAL/IDal.cs
index 0ff6a7f3c..3e4c8dd7f 100644
--- a/CDP4Dal/DAL/IDal.cs
+++ b/CDP4Dal/DAL/IDal.cs
@@ -1,26 +1,26 @@
-// --------------------------------------------------------------------------------------------------------------------
+// -------------------------------------------------------------------------------------------------------------------------------
//
// Copyright (c) 2015-2024 Starion Group S.A.
-//
-// Author: Sam Gerené, Merlin Bieze, Alex Vorobiev, Naron Phou, Alexander van Delft
-//
-// This file is part of CDP4-SDK Community Edition
-//
-// The CDP4-SDK Community Edition is free software; you can redistribute it and/or
+//
+// Authors: Sam Gerené, Alex Vorobiev, Alexander van Delft, Nathanael Smiechowski, Antoine Théate, Omar Elebiary, Jaime Bernar
+//
+// This file is part of CDP4-COMET SDK Community Edition
+//
+// The CDP4-COMET SDK Community Edition is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 3 of the License, or (at your option) any later version.
-//
-// The CDP4-SDK Community Edition is distributed in the hope that it will be useful,
+//
+// The CDP4-COMET SDK Community Edition is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
-//
+//
// You should have received a copy of the GNU Lesser General Public License
// along with this program; if not, write to the Free Software Foundation,
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
//
-// --------------------------------------------------------------------------------------------------------------------
+// -------------------------------------------------------------------------------------------------------------------------------
namespace CDP4Dal.DAL
{
@@ -35,7 +35,8 @@ namespace CDP4Dal.DAL
using CDP4Dal.Operations;
- using CDP4DalCommon.Tasks;
+ using CDP4DalCommon.Protocol.Operations;
+ using CDP4DalCommon.Protocol.Tasks;
using Thing = CDP4Common.DTO.Thing;
@@ -63,7 +64,7 @@ public interface IDal
/// Gets the value indicating whether this is read only
///
bool IsReadOnly { get; }
-
+
///
/// Write all the s from all the s asynchronously.
///
@@ -91,7 +92,7 @@ public interface IDal
/// A list of s that has been created or updated since the last Read or Write operation.
///
Task> Write(OperationContainer operationContainer, IEnumerable files = null);
-
+
///
/// Write all the s from an asynchronously for a possible long running task.
///
@@ -276,7 +277,7 @@ public interface IDal
/// A collection of s
/// The
/// A of type of read
- Task> CherryPick(Guid engineeringModelId, Guid iterationId, IEnumerable classKinds,
+ Task> CherryPick(Guid engineeringModelId, Guid iterationId, IEnumerable classKinds,
IEnumerable categoriesId, CancellationToken cancellationToken);
}
-}
\ No newline at end of file
+}
diff --git a/CDP4Dal/Exceptions/InvalidOperationContainerException.cs b/CDP4Dal/Exceptions/InvalidOperationContainerException.cs
index 5240da47e..3a8e2bad5 100644
--- a/CDP4Dal/Exceptions/InvalidOperationContainerException.cs
+++ b/CDP4Dal/Exceptions/InvalidOperationContainerException.cs
@@ -1,21 +1,21 @@
// -------------------------------------------------------------------------------------------------------------------------------
//
// Copyright (c) 2015-2024 Starion Group S.A.
-//
-// Author: Sam Gerené, Merlin Bieze, Alex Vorobiev, Naron Phou, Alexandervan Delft, Nathanael Smiechowski, Ahmed Abulwafa Ahmed
-//
-// This file is part of COMET-SDK Community Edition
-//
-// The COMET-SDK Community Edition is free software; you can redistribute it and/or
+//
+// Authors: Sam Gerené, Alex Vorobiev, Alexander van Delft, Nathanael Smiechowski, Antoine Théate, Omar Elebiary, Jaime Bernar
+//
+// This file is part of CDP4-COMET SDK Community Edition
+//
+// The CDP4-COMET SDK Community Edition is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 3 of the License, or (at your option) any later version.
-//
-// The COMET-SDK Community Edition is distributed in the hope that it will be useful,
+//
+// The CDP4-COMET SDK Community Edition is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
-//
+//
// You should have received a copy of the GNU Lesser General Public License
// along with this program; if not, write to the Free Software Foundation,
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
@@ -28,6 +28,8 @@ namespace CDP4Dal.Exceptions
using CDP4Dal.Operations;
+ using CDP4DalCommon.Protocol.Operations;
+
///
/// A is thrown when an is invalid or incomplete,
/// or one of the contained s is invalid or incomplete.
diff --git a/CDP4Dal/Exceptions/InvalidOperationKindException.cs b/CDP4Dal/Exceptions/InvalidOperationKindException.cs
index 21fc6d120..b616feee3 100644
--- a/CDP4Dal/Exceptions/InvalidOperationKindException.cs
+++ b/CDP4Dal/Exceptions/InvalidOperationKindException.cs
@@ -1,21 +1,21 @@
// -------------------------------------------------------------------------------------------------------------------------------
//
// Copyright (c) 2015-2024 Starion Group S.A.
-//
-// Author: Sam Gerené, Merlin Bieze, Alex Vorobiev, Naron Phou, Alexandervan Delft, Nathanael Smiechowski, Ahmed Abulwafa Ahmed
-//
-// This file is part of COMET-SDK Community Edition
-//
-// The COMET-SDK Community Edition is free software; you can redistribute it and/or
+//
+// Authors: Sam Gerené, Alex Vorobiev, Alexander van Delft, Nathanael Smiechowski, Antoine Théate, Omar Elebiary, Jaime Bernar
+//
+// This file is part of CDP4-COMET SDK Community Edition
+//
+// The CDP4-COMET SDK Community Edition is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 3 of the License, or (at your option) any later version.
-//
-// The COMET-SDK Community Edition is distributed in the hope that it will be useful,
+//
+// The CDP4-COMET SDK Community Edition is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
-//
+//
// You should have received a copy of the GNU Lesser General Public License
// along with this program; if not, write to the Free Software Foundation,
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
@@ -28,9 +28,11 @@ namespace CDP4Dal.Exceptions
using CDP4Dal.DAL;
+ using CDP4DalCommon.Protocol.Operations;
+
///
/// A InvalidOperationKindException is thrown whenever an contains
- /// that are not supported by the implementation of an
+ /// that are not supported by the implementation of an
///
public class InvalidOperationKindException : Exception
{
diff --git a/CDP4Dal/ISession.cs b/CDP4Dal/ISession.cs
index 8f3014022..3139414fb 100644
--- a/CDP4Dal/ISession.cs
+++ b/CDP4Dal/ISession.cs
@@ -20,7 +20,7 @@
// along with this program; if not, write to the Free Software Foundation,
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
//
-// --------------------------------------------------------------------------------------------------------------------
+// -------------------------------------------------------------------------------------------------------------------------------
namespace CDP4Dal
{
@@ -34,13 +34,13 @@ namespace CDP4Dal
using CDP4Common.ExceptionHandlerService;
using CDP4Common.SiteDirectoryData;
- using CDP4Dal.Operations;
using CDP4Dal.DAL;
using CDP4Dal.Events;
+ using CDP4Dal.Operations;
+ using CDP4Dal.Permission;
- using CDP4DalCommon.Tasks;
-
- using Permission;
+ using CDP4DalCommon.Protocol.Operations;
+ using CDP4DalCommon.Protocol.Tasks;
///
/// The interface encapsulates an and
@@ -56,7 +56,7 @@ public interface ISession
///
/// Gets the that are use to connect to the data source
///
- Credentials Credentials { get; }
+ Credentials Credentials { get; }
///
/// Gets all the s that the active person is linked with.
@@ -112,7 +112,7 @@ public interface ISession
///
/// Gets the name of the session which is the concatentation of the data-source uri and the active person
///
- string Name { get; }
+ string Name { get; }
///
/// Gets the list of that are currently open in the running application.
@@ -122,7 +122,7 @@ public interface ISession
///
/// Gets the list of s that are currently open with the active and
///
- IReadOnlyDictionary > OpenIterations { get; }
+ IReadOnlyDictionary> OpenIterations { get; }
///
/// Gets the that handles messaging for this session
diff --git a/CDP4Dal/Operations/IThingTransaction.cs b/CDP4Dal/Operations/IThingTransaction.cs
index 6d04848cb..5bdd8f5d0 100644
--- a/CDP4Dal/Operations/IThingTransaction.cs
+++ b/CDP4Dal/Operations/IThingTransaction.cs
@@ -1,35 +1,38 @@
-// --------------------------------------------------------------------------------------------------------------------
+// -------------------------------------------------------------------------------------------------------------------------------
//
// Copyright (c) 2015-2024 Starion Group S.A.
-//
-// Author: Sam Gerené, Merlin Bieze, Alex Vorobiev, Naron Phou, Alexander van Delft
-//
-// This file is part of CDP4-SDK Community Edition
-//
-// The CDP4-SDK Community Edition is free software; you can redistribute it and/or
+//
+// Authors: Sam Gerené, Alex Vorobiev, Alexander van Delft, Nathanael Smiechowski, Antoine Théate, Omar Elebiary, Jaime Bernar
+//
+// This file is part of CDP4-COMET SDK Community Edition
+//
+// The CDP4-COMET SDK Community Edition is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 3 of the License, or (at your option) any later version.
-//
-// The CDP4-SDK Community Edition is distributed in the hope that it will be useful,
+//
+// The CDP4-COMET SDK Community Edition is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
-//
+//
// You should have received a copy of the GNU Lesser General Public License
// along with this program; if not, write to the Free Software Foundation,
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
//
-// --------------------------------------------------------------------------------------------------------------------
+// -------------------------------------------------------------------------------------------------------------------------------
namespace CDP4Dal.Operations
{
using System;
using System.Collections.Generic;
+
using CDP4Common.CommonData;
using CDP4Common.EngineeringModelData;
using CDP4Common.Types;
+ using CDP4DalCommon.Protocol.Operations;
+
///
/// The interface operations
///
@@ -190,4 +193,4 @@ public interface IThingTransaction
/// The sub-
void Merge(IThingTransaction subTransaction);
}
-}
\ No newline at end of file
+}
diff --git a/CDP4Dal/Operations/LongRunningTaskResult.cs b/CDP4Dal/Operations/LongRunningTaskResult.cs
index d9e6bf8d4..19c1221b6 100644
--- a/CDP4Dal/Operations/LongRunningTaskResult.cs
+++ b/CDP4Dal/Operations/LongRunningTaskResult.cs
@@ -2,7 +2,7 @@
//
// Copyright (c) 2015-2024 Starion Group S.A.
//
-// Author: Sam Gerené, Alex Vorobiev, Alexander van Delft, Nathanael Smiechowski, Antoine Théate, Omar Elebiary, Jaime Bernar
+// Authors: Sam Gerené, Alex Vorobiev, Alexander van Delft, Nathanael Smiechowski, Antoine Théate, Omar Elebiary, Jaime Bernar
//
// This file is part of CDP4-COMET SDK Community Edition
//
@@ -28,7 +28,7 @@ namespace CDP4Dal.Operations
using CDP4Common.DTO;
- using CDP4DalCommon.Tasks;
+ using CDP4DalCommon.Protocol.Tasks;
///
/// Handle the returned data of a possible long running task
diff --git a/CDP4Dal/Operations/OperationContainer.cs b/CDP4Dal/Operations/OperationContainer.cs
index 86b6b785f..71cdd1f39 100644
--- a/CDP4Dal/Operations/OperationContainer.cs
+++ b/CDP4Dal/Operations/OperationContainer.cs
@@ -1,26 +1,26 @@
-// --------------------------------------------------------------------------------------------------------------------
+// -------------------------------------------------------------------------------------------------------------------------------
//
// Copyright (c) 2015-2024 Starion Group S.A.
-//
-// Author: Sam Gerené, Merlin Bieze, Alex Vorobiev, Naron Phou, Alexander van Delft
-//
-// This file is part of CDP4-SDK Community Edition
-//
-// The CDP4-SDK Community Edition is free software; you can redistribute it and/or
+//
+// Authors: Sam Gerené, Alex Vorobiev, Alexander van Delft, Nathanael Smiechowski, Antoine Théate, Omar Elebiary, Jaime Bernar
+//
+// This file is part of CDP4-COMET SDK Community Edition
+//
+// The CDP4-COMET SDK Community Edition is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 3 of the License, or (at your option) any later version.
-//
-// The CDP4-SDK Community Edition is distributed in the hope that it will be useful,
+//
+// The CDP4-COMET SDK Community Edition is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
-//
+//
// You should have received a copy of the GNU Lesser General Public License
// along with this program; if not, write to the Free Software Foundation,
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
//
-// --------------------------------------------------------------------------------------------------------------------
+// -------------------------------------------------------------------------------------------------------------------------------
namespace CDP4Dal.Operations
{
@@ -30,6 +30,8 @@ namespace CDP4Dal.Operations
using CDP4Common.DTO;
using CDP4Common.Helpers;
+ using CDP4DalCommon.Protocol.Operations;
+
///
/// A container for the s that need to be executed on a data source using an implementation of
///
@@ -62,7 +64,7 @@ public OperationContainer(string context, int? topContainerRevNumber = null)
this.Token = TokenGenerator.GenerateRandomToken();
this.Context = context;
-
+
this.operations = new List();
this.TopContainerRevisionNumber = topContainerRevNumber;
}
@@ -94,10 +96,7 @@ public OperationContainer(string context, int? topContainerRevNumber = null)
///
public IEnumerable Operations
{
- get
- {
- return this.operations;
- }
+ get { return this.operations; }
}
///
@@ -136,7 +135,7 @@ private void ValidateContextOfOperation(Operation operation)
///
public void RemoveOperation(Operation operation)
{
- this.operations.Remove(operation);
+ this.operations.Remove(operation);
}
}
-}
\ No newline at end of file
+}
diff --git a/CDP4Dal/Operations/OperationKindExtensions.cs b/CDP4Dal/Operations/OperationKindExtensions.cs
index 8cdb67486..ce7f45cfa 100644
--- a/CDP4Dal/Operations/OperationKindExtensions.cs
+++ b/CDP4Dal/Operations/OperationKindExtensions.cs
@@ -1,31 +1,33 @@
-// --------------------------------------------------------------------------------------------------------------------
+// -------------------------------------------------------------------------------------------------------------------------------
//
// Copyright (c) 2015-2024 Starion Group S.A.
-//
-// Author: Sam Gerené, Merlin Bieze, Alex Vorobiev, Naron Phou, Nathanael Smiechowski
-//
-// This file is part of CDP4-SDK Community Edition
-//
-// The CDP4-SDK Community Edition is free software; you can redistribute it and/or
+//
+// Authors: Sam Gerené, Alex Vorobiev, Alexander van Delft, Nathanael Smiechowski, Antoine Théate, Omar Elebiary, Jaime Bernar
+//
+// This file is part of CDP4-COMET SDK Community Edition
+//
+// The CDP4-COMET SDK Community Edition is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 3 of the License, or (at your option) any later version.
-//
-// The CDP4-SDK Community Edition is distributed in the hope that it will be useful,
+//
+// The CDP4-COMET SDK Community Edition is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
-//
+//
// You should have received a copy of the GNU Lesser General Public License
// along with this program; if not, write to the Free Software Foundation,
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
//
-// --------------------------------------------------------------------------------------------------------------------
+// -------------------------------------------------------------------------------------------------------------------------------
namespace CDP4Dal.Operations
{
using CDP4Common.DTO;
+ using CDP4DalCommon.Protocol.Operations;
+
///
/// Utils class to provide OperationKind Extensions to CDP4Dal
///
diff --git a/CDP4Dal/Operations/ThingTransaction.cs b/CDP4Dal/Operations/ThingTransaction.cs
index bc6cb4758..9286973e3 100644
--- a/CDP4Dal/Operations/ThingTransaction.cs
+++ b/CDP4Dal/Operations/ThingTransaction.cs
@@ -1,26 +1,26 @@
-// --------------------------------------------------------------------------------------------------------------------
+// -------------------------------------------------------------------------------------------------------------------------------
//
// Copyright (c) 2015-2024 Starion Group S.A.
-//
-// Author: Sam Gerené, Merlin Bieze, Alex Vorobiev, Naron Phou, Alexander van Delft
-//
-// This file is part of CDP4-SDK Community Edition
-//
-// The CDP4-SDK Community Edition is free software; you can redistribute it and/or
+//
+// Authors: Sam Gerené, Alex Vorobiev, Alexander van Delft, Nathanael Smiechowski, Antoine Théate, Omar Elebiary, Jaime Bernar
+//
+// This file is part of CDP4-COMET SDK Community Edition
+//
+// The CDP4-COMET SDK Community Edition is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 3 of the License, or (at your option) any later version.
-//
-// The CDP4-SDK Community Edition is distributed in the hope that it will be useful,
+//
+// The CDP4-COMET SDK Community Edition is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.copy
-//
+// Lesser General Public License for more details.
+//
// You should have received a copy of the GNU Lesser General Public License
// along with this program; if not, write to the Free Software Foundation,
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
//
-// --------------------------------------------------------------------------------------------------------------------
+// -------------------------------------------------------------------------------------------------------------------------------
namespace CDP4Dal.Operations
{
@@ -31,15 +31,17 @@ namespace CDP4Dal.Operations
using System.Reflection;
using CDP4Common;
+ using CDP4Common.CommonData;
using CDP4Common.EngineeringModelData;
using CDP4Common.Extensions;
using CDP4Common.Polyfills;
using CDP4Common.SiteDirectoryData;
- using CDP4Common.CommonData;
using CDP4Common.Types;
using CDP4Dal.Exceptions;
+ using CDP4DalCommon.Protocol.Operations;
+
using NLog;
///
@@ -92,10 +94,10 @@ public class ThingTransaction : IThingTransaction
///
public ThingTransaction(TransactionContext transactionContext, Thing clone = null)
{
- this.TransactionContext =
- transactionContext ??
+ this.TransactionContext =
+ transactionContext ??
throw new ArgumentNullException(nameof(transactionContext), $"The {nameof(transactionContext)} may not be null");
-
+
this.addedThing = new List();
this.updatedThing = new Dictionary();
this.deletedThing = new List();
@@ -137,7 +139,7 @@ public ThingTransaction(Thing clone, IThingTransaction parentTransaction, Thing
{
throw new ArgumentNullException(nameof(clone), $"The {nameof(clone)} may not be null.");
}
-
+
this.TransactionContext = parentTransaction.TransactionContext;
this.addedThing = new List();
@@ -299,18 +301,19 @@ public void CreateOrUpdate(Thing clone)
throw new ArgumentNullException(nameof(clone), $"The {nameof(clone)} may not be null");
}
- if(this.UpdatedThing.Values.Any(x => x == clone) || this.AddedThing.Any(x => x == clone))
+ if (this.UpdatedThing.Values.Any(x => x == clone) || this.AddedThing.Any(x => x == clone))
{
return;
}
- if(this.UpdatedThing.Values.Any(x => x.Iid == clone.Iid) || this.AddedThing.Any(x => x.Iid == clone.Iid))
+ if (this.UpdatedThing.Values.Any(x => x.Iid == clone.Iid) || this.AddedThing.Any(x => x.Iid == clone.Iid))
{
return;
}
var UpdatedThing = this.GetUpdatedThing(clone);
- if(UpdatedThing != null)
+
+ if (UpdatedThing != null)
{
if (clone.Iid == Guid.Empty)
{
@@ -337,7 +340,7 @@ public void Delete(Thing clone, Thing containerClone = null)
{
throw new ArgumentNullException(nameof(clone), $"The {nameof(clone)} may not be null.");
}
-
+
if (this.DeletedThing.Any(x => x.Iid == clone.Iid))
{
return;
@@ -363,6 +366,7 @@ public void Delete(Thing clone, Thing containerClone = null)
{
// remove potential reference from the list of updated thing in the current transaction
var updatedThingKey = this.UpdatedThing.Keys.SingleOrDefault(x => x.Iid == clone.Iid);
+
if (updatedThingKey != null)
{
this.updatedThing.Remove(updatedThingKey);
@@ -375,6 +379,7 @@ public void Delete(Thing clone, Thing containerClone = null)
{
// remove from the list of added thing
var thingInAddedList = this.AddedThing.SingleOrDefault(x => x.Iid == clone.Iid);
+
if (thingInAddedList != null)
{
this.addedThing.Remove(thingInAddedList);
@@ -434,7 +439,7 @@ public void Copy(Thing clone, OperationKind operationKind)
{
throw new ArgumentException("The copy operation may only be performed with Copy or CopyDefaultValuesChangeOwner or CopyKeepValues or CopyKeepValuesChangeOwner", nameof(operationKind));
}
-
+
var original = this.GetUpdatedThing(clone);
// setting a new iid for the copy
@@ -445,7 +450,7 @@ public void Copy(Thing clone, OperationKind operationKind)
{
return;
}
-
+
// setting a new iid for the copy
clone.Iid = Guid.NewGuid();
this.copiedThing.Add(originalCopyPair, operationKind);
@@ -469,13 +474,14 @@ public Thing GetClone(Thing thing)
}
var clone = this.UpdatedThing.Values.SingleOrDefault(x => x.Iid == thing.Iid);
+
if (clone != null)
{
return clone;
}
clone = this.AddedThing.SingleOrDefault(x => x.Iid == thing.Iid);
-
+
return clone;
}
@@ -498,6 +504,7 @@ public Thing GetLastCloneCreated(Thing thing)
var allAddedThing = this.GetAllAddedThings().ToList();
var clone = allAddedThing.SingleOrDefault(x => x.Iid == thing.Iid);
+
if (clone != null)
{
return clone;
@@ -505,7 +512,7 @@ public Thing GetLastCloneCreated(Thing thing)
var allUpdatedThing = this.GetAllUpdatedThings().ToList();
clone = allUpdatedThing.SingleOrDefault(x => x.Iid == thing.Iid);
-
+
return clone;
}
@@ -549,8 +556,8 @@ public void FinalizeSubTransaction(Thing clone, Thing containerclone, Thing next
foreach (
var addedThing in
- this.AddedThing.Where(
- x => x != this.AssociatedClone && x.GetContainerInformation().Item1 == cloneTypeToUpdate))
+ this.AddedThing.Where(
+ x => x != this.AssociatedClone && x.GetContainerInformation().Item1 == cloneTypeToUpdate))
{
if (!addedThing.IsContainedBy(rootClone.Iid))
{
@@ -560,6 +567,7 @@ var addedThing in
// the clone should have been added
var containerOfAddedThing = this.GetClone(addedThing.Container);
+
if (containerOfAddedThing == null)
{
throw new TransactionException("could not find the corresponding clone for the container of the added thing added outside the chain of transaction.");
@@ -570,8 +578,8 @@ var addedThing in
foreach (
var updatedThing in
- this.UpdatedThing.Values.Where(
- x => x != this.AssociatedClone && x.GetContainerInformation().Item1 == cloneTypeToUpdate))
+ this.UpdatedThing.Values.Where(
+ x => x != this.AssociatedClone && x.GetContainerInformation().Item1 == cloneTypeToUpdate))
{
if (!updatedThing.IsContainedBy(rootClone.Iid))
{
@@ -581,6 +589,7 @@ var updatedThing in
// the clone should have been added
var containerOfUpdatedThing = this.GetClone(updatedThing.Container);
+
if (containerOfUpdatedThing == null)
{
throw new TransactionException(
@@ -605,7 +614,7 @@ public OperationContainer FinalizeTransaction()
}
this.FilterOperationCausedByDelete();
-
+
var context = this.TransactionContext.ContextRoute();
var operationContainer = new OperationContainer(context, this.GetTopContainerRevisionNumber());
@@ -629,7 +638,7 @@ public string[] GetFiles()
{
if (string.IsNullOrWhiteSpace(thing.ContentHash))
{
- throw new InvalidOperationException($"File {thing.LocalPath} cannot be saved because of an empty ContentHash" );
+ throw new InvalidOperationException($"File {thing.LocalPath} cannot be saved because of an empty ContentHash");
}
files.Add(thing.LocalPath);
@@ -649,7 +658,8 @@ private Thing GetUpdatedThing(Thing clone)
var allUpdatedThings = this.GetAllUpdatedThings().ToList();
var updatedThing = allUpdatedThings.SingleOrDefault(x => x.Iid == clone.Iid);
- if(updatedThing != null)
+
+ if (updatedThing != null)
{
if (updatedThing == clone)
{
@@ -662,6 +672,7 @@ private Thing GetUpdatedThing(Thing clone)
// case2: the updated thing is already in the transaction as an added thing
var allAddedThings = this.GetAllAddedThings().ToList();
updatedThing = allAddedThings.SingleOrDefault(x => x.Iid == clone.Iid);
+
if (updatedThing != null)
{
if (updatedThing == clone)
@@ -681,6 +692,7 @@ private Thing GetUpdatedThing(Thing clone)
// case3: the cache does not contain the key, its a new
var lazy = clone.Cache.SingleOrDefault(x => Equals(x.Key, clone.CacheKey)).Value;
+
if (lazy == null)
{
return null;
@@ -688,6 +700,7 @@ private Thing GetUpdatedThing(Thing clone)
// case4: the updated thing is the original
updatedThing = lazy.Value;
+
if (updatedThing == clone)
{
throw new InvalidOperationException("The transaction only accepts clones.");
@@ -703,6 +716,7 @@ private Thing GetUpdatedThing(Thing clone)
private IEnumerable GetAllAddedThings()
{
var allAddedThing = this.AddedThing.ToList();
+
if (this.ParentTransaction != null)
{
this.PopulateAllAddedThingsList(this.ParentTransaction, allAddedThing);
@@ -720,6 +734,7 @@ private void PopulateAllAddedThingsList(IThingTransaction transaction, List allAddedThing.All(y => y.Iid != x.Iid));
allAddedThing.AddRange(thingsToAdd);
+
if (transaction.ParentTransaction != null)
{
this.PopulateAllAddedThingsList(transaction.ParentTransaction, allAddedThing);
@@ -733,6 +748,7 @@ private void PopulateAllAddedThingsList(IThingTransaction transaction, List GetAllUpdatedThings()
{
var allUpdatedThings = this.UpdatedThing.Values.ToList();
+
if (this.ParentTransaction != null)
{
this.PopulateAllUpdatedThingsList(this.ParentTransaction, allUpdatedThings);
@@ -750,6 +766,7 @@ private void PopulateAllUpdatedThingsList(IThingTransaction transaction, List allUpdatedThing.All(y => y.Iid != x.Iid));
allUpdatedThing.AddRange(thingsToAdd);
+
if (transaction.ParentTransaction != null)
{
this.PopulateAllUpdatedThingsList(transaction.ParentTransaction, allUpdatedThing);
@@ -765,14 +782,15 @@ private void PopulateAllUpdatedThingsList(IThingTransaction transaction, List | ) });
+ var findIndexMethod = containerProperty.PropertyType.GetMethod("FindIndex", new[] { typeof(Predicate) });
Predicate predicate = x => x.Iid == thing.Iid;
- var index = (int)(findIndexMethod?.Invoke(containerList, new object[] { predicate })??-1);
+ var index = (int)(findIndexMethod?.Invoke(containerList, new object[] { predicate }) ?? -1);
+
if (index != -1)
{
// Get the indexer property, by default the indexer property name is "Item"
@@ -809,6 +827,7 @@ private void UpdateOrderedItemList(Thing thing, Thing containerClone, Thing next
Predicate predicate = x => x.Iid == thing.Iid;
var index = (int)findIndexMethod.Invoke(containerList, new object[] { predicate });
+
if (index != -1)
{
// Get the indexer property, by default the indexer property name is "Item"
@@ -822,7 +841,7 @@ private void UpdateOrderedItemList(Thing thing, Thing containerClone, Thing next
{
// normal add
var addMethod = orderedListProperty.PropertyType.GetMethod("Add");
- addMethod.Invoke(containerList, new object[] {thing});
+ addMethod.Invoke(containerList, new object[] { thing });
}
else
{
@@ -830,6 +849,7 @@ private void UpdateOrderedItemList(Thing thing, Thing containerClone, Thing next
var indexOfMethod = orderedListProperty.PropertyType.GetMethod("IndexOf");
var index = indexOfMethod.Invoke(containerList, new object[] { nextThing }) as int?;
+
if (index == -1 || !index.HasValue)
{
throw new InvalidOperationException("The Thing before which the new item needs to be inserted does not exist.");
@@ -850,14 +870,15 @@ private void UpdateOrderedItemList(Thing thing, Thing containerClone, Thing next
private void RemoveThingFromContainer(Thing thing)
{
var containers = this.AddedThing.Concat(this.UpdatedThing.Values);
-
+
var thingType = thing.GetType();
Thing originalThing = null;
+
if (thing.Cache != null && thing.Cache.ContainsKey(thing.CacheKey))
{
var result = thing.Cache.TryGetValue(thing.CacheKey, out var lazyThing);
- originalThing = (result)? lazyThing.Value : null;
+ originalThing = (result) ? lazyThing.Value : null;
}
// Find in all the thing in the transaction the potential container that contains the current thing
@@ -877,7 +898,7 @@ private void RemoveThingFromContainer(Thing thing)
var matchingPropertyInfos = containerType.GetProperties().Where(x =>
x.PropertyType.QueryIsGenericType() &&
(x.PropertyType.GetGenericTypeDefinition() == typeof(ContainerList<>) ||
- x.PropertyType.GetGenericTypeDefinition() == typeof(OrderedItemList<>)) &&
+ x.PropertyType.GetGenericTypeDefinition() == typeof(OrderedItemList<>)) &&
x.PropertyType.GetGenericArguments().Single().QueryIsAssignableFrom(thingType)).ToList();
foreach (var propertyInfo in matchingPropertyInfos)
@@ -886,6 +907,7 @@ private void RemoveThingFromContainer(Thing thing)
var containerList = propertyInfo.GetValue(container) as IEnumerable;
Thing thingToRemove = null;
+
foreach (Thing containedThing in containerList)
{
if (containedThing.Iid == thing.Iid)
@@ -900,6 +922,7 @@ private void RemoveThingFromContainer(Thing thing)
}
var success = (bool)removeMethod.Invoke(containerList, new object[] { thingToRemove });
+
if (success)
{
thingToRemove.Container = null;
@@ -921,6 +944,7 @@ private void InitializeSubTransaction(ThingTransaction subTransaction, Thing con
if (containerClone != null)
{
var currentContainertype = containerClone.GetType();
+
if (!containerType.QueryIsAssignableFrom(currentContainertype))
{
throw new InvalidOperationException("The specified container is not allowed as a container.");
@@ -949,6 +973,7 @@ private void InitializeSubTransaction(ThingTransaction subTransaction, Thing con
private void AddChainOfContainers(Thing clone)
{
var topOperationClone = this.GetOperationRootClone();
+
if (!clone.IsContainedBy(topOperationClone.Iid))
{
return;
@@ -972,6 +997,7 @@ private void AddChainOfContainers(Thing clone)
// add a new clone if newContainerClone is not contained by the current operation's chain of clones
var containerType = transaction.AssociatedClone.GetType();
var container = clone.GetContainerOfType(containerType);
+
if (container == null)
{
return;
@@ -992,6 +1018,7 @@ private Thing GetOperationRootClone()
{
var rootClone = this.AssociatedClone;
var parent = this.ParentTransaction;
+
while (parent != null)
{
rootClone = parent.AssociatedClone ?? rootClone;
@@ -1008,9 +1035,11 @@ private Thing GetOperationRootClone()
private IEnumerable GetChainOfSubTransactions()
{
var parent = this.ParentTransaction;
+
while (parent != null)
{
yield return parent;
+
parent = parent.ParentTransaction;
}
}
@@ -1027,6 +1056,7 @@ private IEnumerable GetChainOfSubTransactions()
private void UpdateContainer(Thing clone, Thing containerclone, Thing nextThing = null)
{
var containerInformation = clone.GetContainerInformation();
+
if (!containerInformation.Item1.IsInstanceOfType(containerclone))
{
throw new InvalidOperationException("The containerClone does not have the right type");
@@ -1055,6 +1085,7 @@ private void UpdateContainer(Thing clone, Thing containerclone, Thing nextThing
private void AddCloneToContainer(Thing clone, Thing containerclone, Thing nextThing = null)
{
var containerInformation = clone.GetContainerInformation();
+
if (!containerInformation.Item1.IsInstanceOfType(containerclone))
{
throw new InvalidOperationException("The containerClone does not have the right type");
@@ -1095,6 +1126,7 @@ public void Merge(IThingTransaction subTransaction)
}
var existingThing = this.AddedThing.SingleOrDefault(t => t.Iid == thing.Iid);
+
if (existingThing != null)
{
// replace the current thing with the one from the sub-transaction
@@ -1112,6 +1144,7 @@ public void Merge(IThingTransaction subTransaction)
if (this.UpdatedThing.ContainsKey(keyValuePair.Key))
{
var parentKeyValue = this.UpdatedThing.Single(x => x.Key == keyValuePair.Key);
+
if (parentKeyValue.Value != keyValuePair.Value)
{
throw new InvalidOperationException("2 clones have been created for the same thing.");
@@ -1122,6 +1155,7 @@ public void Merge(IThingTransaction subTransaction)
// check if the key in a sub-transaction correspond to a value in the current one
var existingKeyValue = this.UpdatedThing.SingleOrDefault(x => x.Value == keyValuePair.Key);
+
if (existingKeyValue.Key != null)
{
this.updatedThing[existingKeyValue.Key] = keyValuePair.Value;
@@ -1249,7 +1283,7 @@ private void CreateCopyThingOperation(OperationContainer operationContainer)
if (copyOperationKind.IsCopyOperation())
{
operationContainer.AddOperation(new Operation(original, copy, copyOperationKind));
- }
+ }
}
}
@@ -1273,7 +1307,8 @@ private int GetTopContainerRevisionNumber()
things.AddRange(this.DeletedThing);
things.AddRange(this.CopiedThing.Select(x => x.Key.Item2));
- var distinctTopContainer = things.Select(x => x.TopContainer).DistinctBy(t => t.Iid).ToList();
+ var distinctTopContainer = things.Select(x => x.TopContainer).DistinctBy(t => t.Iid).ToList();
+
if (distinctTopContainer.Count != 1)
{
throw new InvalidOperationException("multiple top container updates in one transaction, operation not allowed.");
@@ -1290,18 +1325,21 @@ private void FilterOperationCausedByDelete()
// filter out the added thing or updated thing that have been marked as deleted
// filter out the contained thing of a deleted thing
var markedForDeletion = this.DeletedThing.ToList();
+
foreach (var thing in markedForDeletion)
{
var cloneType = thing.GetType();
+
var containersInfo = cloneType.GetProperties().Where(x =>
- x.PropertyType.QueryIsGenericType() &&
- (x.PropertyType.GetGenericTypeDefinition() == typeof(ContainerList<>) ||
- x.PropertyType.GetGenericTypeDefinition() == typeof(OrderedItemList<>)) &&
- typeof(Thing).QueryIsAssignableFrom(x.PropertyType.GetGenericArguments().Single())).ToList();
+ x.PropertyType.QueryIsGenericType() &&
+ (x.PropertyType.GetGenericTypeDefinition() == typeof(ContainerList<>) ||
+ x.PropertyType.GetGenericTypeDefinition() == typeof(OrderedItemList<>)) &&
+ typeof(Thing).QueryIsAssignableFrom(x.PropertyType.GetGenericArguments().Single())).ToList();
foreach (var containerInfo in containersInfo)
{
var container = (IEnumerable)containerInfo.GetValue(thing);
+
foreach (Thing containedThing in container)
{
this.RemoveThingFromOperationLists(containedThing);
@@ -1320,6 +1358,7 @@ private void RemoveThingFromOperationLists(Thing thingToRemove)
{
// remove it from the list of updated thing in the current transaction
var updatedThingKey = this.UpdatedThing.Keys.SingleOrDefault(x => x.Iid == thingToRemove.Iid);
+
if (updatedThingKey != null)
{
this.updatedThing.Remove(updatedThingKey);
@@ -1327,6 +1366,7 @@ private void RemoveThingFromOperationLists(Thing thingToRemove)
// remove from the list of added thing
var thingInAddedList = this.AddedThing.SingleOrDefault(x => x.Iid == thingToRemove.Iid);
+
if (thingInAddedList != null)
{
this.addedThing.Remove(thingInAddedList);
@@ -1336,6 +1376,7 @@ private void RemoveThingFromOperationLists(Thing thingToRemove)
if (!thingToRemove.IsCached())
{
var thingInDeletedList = this.DeletedThing.SingleOrDefault(x => x.Iid == thingToRemove.Iid);
+
if (thingInDeletedList != null)
{
this.deletedThing.Remove(thingInDeletedList);
@@ -1343,4 +1384,4 @@ private void RemoveThingFromOperationLists(Thing thingToRemove)
}
}
}
-}
\ No newline at end of file
+}
diff --git a/CDP4Dal/Session.cs b/CDP4Dal/Session.cs
index d7fec261c..5d2378bda 100644
--- a/CDP4Dal/Session.cs
+++ b/CDP4Dal/Session.cs
@@ -20,7 +20,7 @@
// along with this program; if not, write to the Free Software Foundation,
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
//
-// --------------------------------------------------------------------------------------------------------------------
+// -------------------------------------------------------------------------------------------------------------------------------
namespace CDP4Dal
{
@@ -48,7 +48,8 @@ namespace CDP4Dal
using CDP4Dal.Operations;
using CDP4Dal.Permission;
- using CDP4DalCommon.Tasks;
+ using CDP4DalCommon.Protocol.Operations;
+ using CDP4DalCommon.Protocol.Tasks;
using NLog;
@@ -529,7 +530,7 @@ public async Task Read(ReferenceDataLibrary rdl)
throw new InvalidOperationException("The ReferenceDataLibrary cannot be read when the ActivePerson is null; The Open method must be called prior to any of the Read methods");
}
- await this.Read((Thing) rdl);
+ await this.Read((Thing)rdl);
this.AddRdlToOpenList(rdl);
}
@@ -559,7 +560,7 @@ public async Task Read(IEnumerable engineeringModels)
}
logger.Info("Session.Read {EngineeringModel} {0}", !engineeringModels.Any() ? "*" : $"EngineeringModel/{engineeringModels.ToShortGuidArray()}");
-
+
// Create the token source
var cancellationTokenSource = new CancellationTokenSource();
var cancellationTokenKey = Guid.NewGuid();
@@ -1265,7 +1266,7 @@ private IEnumerable GetSiteDirectoryAndActiveIterations()
.Select(x => x.Value.Value)
.Where(x =>
x is SiteDirectory
- || x is Iteration && ((Iteration) x).IterationSetup.FrozenOn == null && this.OpenIterations.ContainsKey((Iteration) x)
+ || x is Iteration && ((Iteration)x).IterationSetup.FrozenOn == null && this.OpenIterations.ContainsKey((Iteration)x)
)
.ToList();
}
@@ -1332,7 +1333,7 @@ private void AddIterationToOpenList(Guid iterationId, DomainOfExpertise activeDo
return;
}
- var activeParticipant = ((EngineeringModel) iteration.Container).EngineeringModelSetup.Participant.SingleOrDefault(p => p.Person == this.ActivePerson);
+ var activeParticipant = ((EngineeringModel)iteration.Container).EngineeringModelSetup.Participant.SingleOrDefault(p => p.Person == this.ActivePerson);
if (activeParticipant == null)
{
@@ -1341,7 +1342,7 @@ private void AddIterationToOpenList(Guid iterationId, DomainOfExpertise activeDo
this.openIterations.Add(iteration, new Tuple(activeDomain, activeParticipant));
- var modelRdl = ((EngineeringModel) iteration.Container).EngineeringModelSetup.RequiredRdl.Single();
+ var modelRdl = ((EngineeringModel)iteration.Container).EngineeringModelSetup.RequiredRdl.Single();
this.AddRdlToOpenList(modelRdl);
}
diff --git a/CDP4DalCommon/CDP4DalCommon.csproj b/CDP4DalCommon/CDP4DalCommon.csproj
index 65793335c..8c40d62df 100644
--- a/CDP4DalCommon/CDP4DalCommon.csproj
+++ b/CDP4DalCommon/CDP4DalCommon.csproj
@@ -5,7 +5,7 @@
Starion Group S.A.
latest
CDP4DalCommon Community Edition
- 27.4.0
+ 28.0.0
CDP4 Common Class Library that contains common types for any CDP4 server and the CDP4Dal
Copyright © Starion Group S.A.
Sam, Alex, Alexander, Nathanael, Antoine, Omar, Jaime
@@ -21,7 +21,7 @@
CDP COMET ECSS-E-TM-10-25
LGPL-3.0-only
- [BUMP] To CDP4Common 27.4.0
+ [Refactor] Newtonsoft to System.Text.Json
README.md
true
diff --git a/CDP4Dal/Operations/Operation.cs b/CDP4DalCommon/Protocol/Operations/Operation.cs
similarity index 90%
rename from CDP4Dal/Operations/Operation.cs
rename to CDP4DalCommon/Protocol/Operations/Operation.cs
index 7adfa43f3..a7a258167 100644
--- a/CDP4Dal/Operations/Operation.cs
+++ b/CDP4DalCommon/Protocol/Operations/Operation.cs
@@ -10,19 +10,19 @@
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 3 of the License, or (at your option) any later version.
-//
-// The CDP4-SDK Community Edition is distributed in the hope that it will be useful,
+//
+// The CDP4-COMET SDK Community Edition is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
-//
+//
// You should have received a copy of the GNU Lesser General Public License
// along with this program; if not, write to the Free Software Foundation,
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
//
-// --------------------------------------------------------------------------------------------------------------------
+// -------------------------------------------------------------------------------------------------------------------------------
-namespace CDP4Dal.Operations
+namespace CDP4DalCommon.Protocol.Operations
{
using CDP4Common.DTO;
diff --git a/CDP4Dal/Operations/OperationKind.cs b/CDP4DalCommon/Protocol/Operations/OperationKind.cs
similarity index 92%
rename from CDP4Dal/Operations/OperationKind.cs
rename to CDP4DalCommon/Protocol/Operations/OperationKind.cs
index 40150f475..a35f69463 100644
--- a/CDP4Dal/Operations/OperationKind.cs
+++ b/CDP4DalCommon/Protocol/Operations/OperationKind.cs
@@ -10,19 +10,19 @@
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 3 of the License, or (at your option) any later version.
-//
-// The CDP4-SDK Community Edition is distributed in the hope that it will be useful,
+//
+// The CDP4-COMET SDK Community Edition is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
-//
+//
// You should have received a copy of the GNU Lesser General Public License
// along with this program; if not, write to the Free Software Foundation,
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
//
-// --------------------------------------------------------------------------------------------------------------------
+// -------------------------------------------------------------------------------------------------------------------------------
-namespace CDP4Dal.Operations
+namespace CDP4DalCommon.Protocol.Operations
{
using CDP4Common.DTO;
@@ -87,4 +87,4 @@ public enum OperationKind
///
CopyKeepValues
}
-}
\ No newline at end of file
+}
diff --git a/CDP4Dal/Operations/PostOperation.cs b/CDP4DalCommon/Protocol/Operations/PostOperation.cs
similarity index 63%
rename from CDP4Dal/Operations/PostOperation.cs
rename to CDP4DalCommon/Protocol/Operations/PostOperation.cs
index 74acb4d1b..d73009864 100644
--- a/CDP4Dal/Operations/PostOperation.cs
+++ b/CDP4DalCommon/Protocol/Operations/PostOperation.cs
@@ -10,21 +10,23 @@
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 3 of the License, or (at your option) any later version.
-//
-// The CDP4-SDK Community Edition is distributed in the hope that it will be useful,
+//
+// The CDP4-COMET SDK Community Edition is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
-//
+//
// You should have received a copy of the GNU Lesser General Public License
// along with this program; if not, write to the Free Software Foundation,
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
//
-// --------------------------------------------------------------------------------------------------------------------
+// -------------------------------------------------------------------------------------------------------------------------------
-namespace CDP4Dal.Operations
+namespace CDP4DalCommon.Protocol.Operations
{
+ using System;
using System.Collections.Generic;
+
using CDP4Common;
using CDP4Common.Dto;
using CDP4Common.DTO;
@@ -32,38 +34,48 @@ namespace CDP4Dal.Operations
///
/// The abstract super class from which all POST operations derive.
///
- public abstract class PostOperation
+ public class PostOperation
{
- ///
- /// Initializes a new instance of the class
- ///
- protected PostOperation()
- {
- this.Delete = new List();
- this.Create = new List();
- this.Update = new List();
- this.Copy = new List();
- }
+ private List delete = [];
+ private List create = [];
+ private List update = [];
+ private List copy = [];
///
/// Gets or sets the collection of DTOs to delete.
///
- public abstract List Delete { get; set; }
+ public List Delete
+ {
+ get => this.delete ?? [];
+ set => this.delete = value ?? [];
+ }
///
/// Gets or sets the collection of DTOs to create.
///
- public abstract List Create { get; set; }
+ public List Create
+ {
+ get => this.create ?? [];
+ set => this.create = value ?? [];
+ }
///
/// Gets or sets the collection of DTOs to update.
///
- public abstract List Update { get; set; }
+ public List Update
+ {
+ get => this.update ?? [];
+ set => this.update = value ?? [];
+ }
///
/// Gets or sets the collection of DTOs to copy.
///
- public abstract List Copy { get; set; }
+ public List Copy
+ {
+ get => this.copy ?? [];
+ set => this.copy = value ?? [];
+ }
///
/// Populate the current with the content based on the
@@ -73,6 +85,9 @@ protected PostOperation()
/// The that contains all the s that need to be
/// updated to the data-source
///
- public abstract void ConstructFromOperation(Operation operation);
+ public virtual void ConstructFromOperation(Operation operation)
+ {
+ throw new NotSupportedException("Cannot construct a PostOperation based on Operation");
+ }
}
}
diff --git a/CDP4DalCommon/Tasks/CometTask.cs b/CDP4DalCommon/Protocol/Tasks/CometTask.cs
similarity index 96%
rename from CDP4DalCommon/Tasks/CometTask.cs
rename to CDP4DalCommon/Protocol/Tasks/CometTask.cs
index 9016cdee8..e25e78f49 100644
--- a/CDP4DalCommon/Tasks/CometTask.cs
+++ b/CDP4DalCommon/Protocol/Tasks/CometTask.cs
@@ -2,7 +2,7 @@
//
// Copyright (c) 2015-2024 Starion Group S.A.
//
-// Author: Sam Gerené, Alex Vorobiev, Alexander van Delft, Nathanael Smiechowski, Antoine Théate, Omar Elebiary, Jaime Bernar
+// Authors: Sam Gerené, Alex Vorobiev, Alexander van Delft, Nathanael Smiechowski, Antoine Théate, Omar Elebiary, Jaime Bernar
//
// This file is part of CDP4-COMET SDK Community Edition
//
@@ -22,7 +22,7 @@
//
// -------------------------------------------------------------------------------------------------------------------------------
-namespace CDP4DalCommon.Tasks
+namespace CDP4DalCommon.Protocol.Tasks
{
using System;
diff --git a/CDP4DalCommon/Tasks/StatusKind.cs b/CDP4DalCommon/Protocol/Tasks/StatusKind.cs
similarity index 69%
rename from CDP4DalCommon/Tasks/StatusKind.cs
rename to CDP4DalCommon/Protocol/Tasks/StatusKind.cs
index 639b6ff14..fa05f1ebb 100644
--- a/CDP4DalCommon/Tasks/StatusKind.cs
+++ b/CDP4DalCommon/Protocol/Tasks/StatusKind.cs
@@ -2,28 +2,29 @@
//
// Copyright (c) 2015-2024 Starion Group S.A.
//
-// Author: Sam Gerené, Alex Vorobiev, Alexander van Delft, Nathanael Smiechowski, Antoine Théate
+// Authors: Sam Gerené, Alex Vorobiev, Alexander van Delft, Nathanael Smiechowski, Antoine Théate, Omar Elebiary, Jaime Bernar
//
// This file is part of CDP4-COMET Webservices Community Edition.
// The CDP4-COMET Web Services Community Edition is the Starion implementation of ECSS-E-TM-10-25 Annex A and Annex C.
// This is an auto-generated class. Any manual changes to this file will be overwritten!
//
-// The CDP4-COMET Web Services Community Edition is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Affero General Public
+// The CDP4-COMET SDK Community Edition is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 3 of the License, or (at your option) any later version.
//
-// The CDP4-COMET Web Services Community Edition is distributed in the hope that it will be useful,
+// The CDP4-COMET SDK Community Edition is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
-// You should have received a copy of the GNU Affero General Public License
-// along with this program. If not, see .
+// You should have received a copy of the GNU Lesser General Public License
+// along with this program; if not, write to the Free Software Foundation,
+// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
//
-// --------------------------------------------------------------------------------------------------------------------
+// -------------------------------------------------------------------------------------------------------------------------------
-namespace CDP4DalCommon.Tasks
+namespace CDP4DalCommon.Protocol.Tasks
{
using System.Threading.Tasks;
@@ -52,4 +53,4 @@ public enum StatusKind
///
CANCELLED
}
-}
\ No newline at end of file
+}
diff --git a/CDP4JsonFileDal.NetCore.Tests/CDP4JsonFileDal.NetCore.Tests.csproj b/CDP4JsonFileDal.NetCore.Tests/CDP4JsonFileDal.NetCore.Tests.csproj
index 37be5d683..65118c357 100644
--- a/CDP4JsonFileDal.NetCore.Tests/CDP4JsonFileDal.NetCore.Tests.csproj
+++ b/CDP4JsonFileDal.NetCore.Tests/CDP4JsonFileDal.NetCore.Tests.csproj
@@ -17,12 +17,12 @@
-
+
-
+
diff --git a/CDP4JsonFileDal.NetCore.Tests/JsonFileDalTestFixture.cs b/CDP4JsonFileDal.NetCore.Tests/JsonFileDalTestFixture.cs
index 441ecee16..12bcab025 100644
--- a/CDP4JsonFileDal.NetCore.Tests/JsonFileDalTestFixture.cs
+++ b/CDP4JsonFileDal.NetCore.Tests/JsonFileDalTestFixture.cs
@@ -20,7 +20,7 @@
// along with this program; if not, write to the Free Software Foundation,
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
//
-// --------------------------------------------------------------------------------------------------------------------
+// -------------------------------------------------------------------------------------------------------------------------------
namespace CDP4JsonFileDal.NetCore.Tests
{
@@ -32,6 +32,7 @@ namespace CDP4JsonFileDal.NetCore.Tests
using System.Threading;
using System.Threading.Tasks;
+ using CDP4Common;
using CDP4Common.CommonData;
using CDP4Common.DTO;
using CDP4Common.Types;
@@ -41,7 +42,7 @@ namespace CDP4JsonFileDal.NetCore.Tests
using CDP4Dal.Exceptions;
using CDP4Dal.Operations;
- using CDP4JsonFileDal;
+ using CDP4DalCommon.Protocol.Operations;
using Moq;
@@ -69,9 +70,6 @@ namespace CDP4JsonFileDal.NetCore.Tests
using SampledFunctionParameterType = CDP4Common.SiteDirectoryData.SampledFunctionParameterType;
using ElementDefinition = CDP4Common.EngineeringModelData.ElementDefinition;
using Parameter = CDP4Common.EngineeringModelData.Parameter;
-
- using CDP4Common;
-
using OrganizationalParticipant = CDP4Common.SiteDirectoryData.OrganizationalParticipant;
[TestFixture]
@@ -530,7 +528,7 @@ public async Task VerifyWriteOfIncompatibleVersionFile()
var domain = siteDirectory.Domain.First();
var model = new CDP4Common.EngineeringModelData.EngineeringModel(modelSetup.EngineeringModelIid, newSession.Assembler.Cache, newDal.Credentials.Uri)
- { EngineeringModelSetup = modelSetup };
+ { EngineeringModelSetup = modelSetup };
var iteration = new CDP4Common.EngineeringModelData.Iteration(this.iterationIid, newSession.Assembler.Cache, newDal.Credentials.Uri);
@@ -590,7 +588,7 @@ public async Task VerifyWriteOfCompatibleVersionFile()
var domain = siteDirectory.Domain.First();
var model = new CDP4Common.EngineeringModelData.EngineeringModel(modelSetup.EngineeringModelIid, newSession.Assembler.Cache, newDal.Credentials.Uri)
- { EngineeringModelSetup = modelSetup };
+ { EngineeringModelSetup = modelSetup };
var iteration = new CDP4Common.EngineeringModelData.Iteration(this.iterationIid, newSession.Assembler.Cache, newDal.Credentials.Uri);
@@ -690,6 +688,7 @@ private void CreateBasicModel()
iterationSetup.IterationIid = this.iterationIid;
iterationSetupPoco.IterationIid = this.iterationIid;
+
// EngineeringModel
this.model = new EngineeringModel(Guid.NewGuid(), this.cache, this.credentials.Uri);
this.modelSetupId = Guid.NewGuid();
diff --git a/CDP4JsonFileDal.Tests/CDP4JsonFileDal.Tests.csproj b/CDP4JsonFileDal.Tests/CDP4JsonFileDal.Tests.csproj
index 329ba1735..2654a5b64 100644
--- a/CDP4JsonFileDal.Tests/CDP4JsonFileDal.Tests.csproj
+++ b/CDP4JsonFileDal.Tests/CDP4JsonFileDal.Tests.csproj
@@ -22,7 +22,7 @@
-
+
diff --git a/CDP4JsonFileDal.Tests/JsonFileDalTestFixture.cs b/CDP4JsonFileDal.Tests/JsonFileDalTestFixture.cs
index c9e23a607..fdcfb68e5 100644
--- a/CDP4JsonFileDal.Tests/JsonFileDalTestFixture.cs
+++ b/CDP4JsonFileDal.Tests/JsonFileDalTestFixture.cs
@@ -20,7 +20,7 @@
// along with this program; if not, write to the Free Software Foundation,
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
//
-// --------------------------------------------------------------------------------------------------------------------
+// -------------------------------------------------------------------------------------------------------------------------------
namespace CDP4JsonFileDal.Tests
{
@@ -32,6 +32,7 @@ namespace CDP4JsonFileDal.Tests
using System.Threading;
using System.Threading.Tasks;
+ using CDP4Common;
using CDP4Common.CommonData;
using CDP4Common.DTO;
using CDP4Common.Types;
@@ -41,7 +42,7 @@ namespace CDP4JsonFileDal.Tests
using CDP4Dal.Exceptions;
using CDP4Dal.Operations;
- using CDP4JsonFileDal;
+ using CDP4DalCommon.Protocol.Operations;
using Moq;
@@ -69,9 +70,6 @@ namespace CDP4JsonFileDal.Tests
using SampledFunctionParameterType = CDP4Common.SiteDirectoryData.SampledFunctionParameterType;
using ElementDefinition = CDP4Common.EngineeringModelData.ElementDefinition;
using Parameter = CDP4Common.EngineeringModelData.Parameter;
-
- using CDP4Common;
-
using OrganizationalParticipant = CDP4Common.SiteDirectoryData.OrganizationalParticipant;
[TestFixture]
@@ -252,7 +250,7 @@ public async Task VerifyThatReadReturnsCorrectDTO()
// General assertions for any kind of Thing we read
Assert.That(readResult, Is.Not.Null);
Assert.That(readResult.Count, Is.Not.EqualTo(1));
-
+
var iter1 = readResult.Single(d => d.ClassKind == ClassKind.Iteration);
Assert.That(iter1.ClassKind, Is.EqualTo(iterObject.ClassKind));
Assert.That(iter1.Iid, Is.EqualTo(iterObject.Iid));
@@ -436,7 +434,7 @@ public void VerifyCtorWithVersionAndCopyright()
Assert.That(this.dal.Serializer.RequestDataModelVersion.Major, Is.EqualTo(1));
Assert.That(this.dal.Serializer.RequestDataModelVersion.Minor, Is.EqualTo(0));
Assert.That(this.dal.Serializer.RequestDataModelVersion.Build, Is.EqualTo(0));
-
+
this.dal.UpdateExchangeFileHeader(new Person { ShortName = "admin" });
Assert.That(this.dal.FileHeader, Is.InstanceOf());
@@ -689,6 +687,7 @@ private void CreateBasicModel()
iterationSetup.IterationIid = this.iterationIid;
iterationSetupPoco.IterationIid = this.iterationIid;
+
// EngineeringModel
this.model = new EngineeringModel(Guid.NewGuid(), this.cache, this.credentials.Uri);
this.modelSetupId = Guid.NewGuid();
@@ -732,10 +731,10 @@ private void AddExtraThingsForExportFilteringTests()
var elementDefinition2 = new ElementDefinition(Guid.NewGuid(), this.cache, this.credentials.Uri);
elementDefinition2.ShortName = "ED2";
elementDefinition2.Owner = this.model.EngineeringModelSetup.ActiveDomain.First();
-
+
var elementDefinition3 = new ElementDefinition(Guid.NewGuid(), this.cache, this.credentials.Uri);
elementDefinition3.ShortName = "ED3";
-
+
var elementDefinition4 = new ElementDefinition(Guid.NewGuid(), this.cache, this.credentials.Uri);
elementDefinition4.ShortName = "ED4";
elementDefinition4.Owner = new DomainOfExpertise(Guid.NewGuid(), this.cache, this.credentials.Uri); //Not in file
@@ -754,7 +753,7 @@ private void AddExtraThingsForExportFilteringTests()
elementDefinition1.Parameter.Add(sampledFunctionParameter1);
elementDefinition2.Parameter.Add(sampledFunctionParameter2);
-
+
this.iterationPoco.Element.Add(elementDefinition1);
this.iterationPoco.Element.Add(elementDefinition2);
this.iterationPoco.Element.Add(elementDefinition3);
@@ -770,7 +769,7 @@ private void AddExtraThingsForExportFilteringTests()
parameterOverride.ValueSet.Add(new CDP4Common.EngineeringModelData.ParameterOverrideValueSet(Guid.NewGuid(), this.cache, this.credentials.Uri));
parameterOverride.ValueSet.First().ParameterValueSet = sampledFunctionParameter2.ValueSet.First();
elementUsage.ParameterOverride.Add(parameterOverride);
-
+
elementDefinition1.ContainedElement.Add(elementUsage);
var citation = new CDP4Common.CommonData.Citation(Guid.NewGuid(), this.cache, this.credentials.Uri);
diff --git a/CDP4JsonFileDal/CDP4JsonFileDal.csproj b/CDP4JsonFileDal/CDP4JsonFileDal.csproj
index 3b71d3674..5656ccdce 100644
--- a/CDP4JsonFileDal/CDP4JsonFileDal.csproj
+++ b/CDP4JsonFileDal/CDP4JsonFileDal.csproj
@@ -4,7 +4,7 @@
net48;netstandard2.0
Starion Group S.A.
CDP4JsonFileDal Community Edition
- 27.4.0
+ 28.0.0
CDP4 Json File Dal Plugin
Copyright © Starion Group S.A.
Sam, Merlin, Alex, Naron, Alexander, Yevhen, Nathanael
@@ -20,7 +20,7 @@
CDP COMET ECSS-E-TM-10-25
LGPL-3.0-only
- - Remove DotNetZip and use SharpZipLib
+ [Refactor] Newtonsoft to System.Text.Json
README.md
diff --git a/CDP4JsonFileDal/JsonFileDal.cs b/CDP4JsonFileDal/JsonFileDal.cs
index 6780ecad5..dc1020d14 100644
--- a/CDP4JsonFileDal/JsonFileDal.cs
+++ b/CDP4JsonFileDal/JsonFileDal.cs
@@ -10,12 +10,12 @@
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 3 of the License, or (at your option) any later version.
-//
-// The CDP4-COMET-SDK Community Edition is distributed in the hope that it will be useful,
+//
+// The CDP4-COMET SDK Community Edition is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
-//
+//
// You should have received a copy of the GNU Lesser General Public License
// along with this program; if not, write to the Free Software Foundation,
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
@@ -45,7 +45,8 @@ namespace CDP4JsonFileDal
using CDP4Dal.Exceptions;
using CDP4Dal.Operations;
- using CDP4DalCommon.Tasks;
+ using CDP4DalCommon.Protocol.Operations;
+ using CDP4DalCommon.Protocol.Tasks;
using CDP4JsonFileDal.Json;
@@ -122,7 +123,7 @@ public class JsonFileDal : Dal
///
public JsonFileDal()
{
- this.Serializer = new Cdp4JsonSerializer(this.MetaDataProvider, this.DalVersion);
+ this.Serializer = new Cdp4DalJsonSerializer(this.MetaDataProvider, this.DalVersion, false);
}
///
@@ -141,7 +142,7 @@ public JsonFileDal(Version dalVersion)
this.DalVersion = dalVersion;
}
- this.Serializer = new Cdp4JsonSerializer(this.MetaDataProvider, this.DalVersion);
+ this.Serializer = new Cdp4DalJsonSerializer(this.MetaDataProvider, this.DalVersion, false);
}
///
@@ -160,9 +161,9 @@ public void UpdateExchangeFileHeader(Person person, string headerCopyright = nul
}
///
- /// Gets the
+ /// Gets the
///
- public Cdp4JsonSerializer Serializer { get; private set; }
+ public Cdp4DalJsonSerializer Serializer { get; private set; }
///
/// Gets the value indicating whether this is read only
diff --git a/CDP4JsonSerializer.NetCore.Tests/CDP4JsonSerializer.NetCore.Tests.csproj b/CDP4JsonSerializer.NetCore.Tests/CDP4JsonSerializer.NetCore.Tests.csproj
index be855025d..f7de3a262 100644
--- a/CDP4JsonSerializer.NetCore.Tests/CDP4JsonSerializer.NetCore.Tests.csproj
+++ b/CDP4JsonSerializer.NetCore.Tests/CDP4JsonSerializer.NetCore.Tests.csproj
@@ -16,7 +16,7 @@
-
+
@@ -41,6 +41,12 @@
+
+ Always
+
+
+ Always
+
Always
diff --git a/CDP4JsonSerializer.NetCore.Tests/Helper/SerializerHelperTestFixture.cs b/CDP4JsonSerializer.NetCore.Tests/Helper/SerializerHelperTestFixture.cs
index ab90ec5bf..94d1f2894 100644
--- a/CDP4JsonSerializer.NetCore.Tests/Helper/SerializerHelperTestFixture.cs
+++ b/CDP4JsonSerializer.NetCore.Tests/Helper/SerializerHelperTestFixture.cs
@@ -5,28 +5,31 @@
// Author: Sam Gerené, Merlin Bieze, Alex Vorobiev, Naron Phou, Alexander van Delft
//
// This file is part of CDP4-COMET SDK Community Edition
-//
+//
// The CDP4-COMET SDK Community Edition is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 3 of the License, or (at your option) any later version.
-//
+//
// The CDP4-COMET SDK Community Edition is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
-//
+//
// You should have received a copy of the GNU Lesser General Public License
// along with this program; if not, write to the Free Software Foundation,
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
//
-// --------------------------------------------------------------------------------------------------------------------
+// -------------------------------------------------------------------------------------------------------------------------------
namespace CDP4JsonSerializer.Tests.Helper
{
using System;
using System.Collections.Generic;
+ using System.IO;
using System.Linq;
+ using System.Text.Json;
+ using System.Text.Json.Nodes;
using CDP4Common.EngineeringModelData;
using CDP4Common.MetaInfo;
@@ -54,17 +57,23 @@ public void VerifyThatToJsonObjectOfOrderedItemReturnsJObject()
object value = null;
value = System.Convert.ChangeType(123, Nullable.GetUnderlyingType(propertyInfo.PropertyType));
propertyInfo.SetValue(orderedItem, value);
+ var stream = new MemoryStream();
+ var utf8Writer = new Utf8JsonWriter(stream);
+ utf8Writer.WriteOrderedItem(orderedItem);
+ utf8Writer.Flush();
+ stream.Position = 0;
+ var ut8Reader = new Utf8JsonReader(stream.ToArray());
- var jObject = SerializerHelper.ToJsonObject(orderedItem);
- Assert.That(jObject.Properties().Count(), Is.EqualTo(3));
+ var jObject = JsonObject.Create(JsonElement.ParseValue(ref ut8Reader));
+ Assert.That(jObject.AsEnumerable().Count(), Is.EqualTo(3));
- var k = jObject.Property("k");
+ jObject.TryGetPropertyValue("k", out var k);
Assert.That(k, Is.Not.Null);
- var v = jObject.Property("v");
+ jObject.TryGetPropertyValue("v", out var v);
Assert.That(v, Is.Not.Null);
- var m = jObject.Property("m");
+ jObject.TryGetPropertyValue("m", out var m);
Assert.That(m, Is.Not.Null);
}
@@ -75,10 +84,11 @@ public void Verify_that_ParameterValueSet_is_serialized_and_deserialized()
values.Add("this is a\nnewline");
values.Add("this is another\nnewline");
- var engineeringModel = new EngineeringModel {Iid = Guid.Parse("5643764e-f880-44bf-90ae-361f6661ceae")};
- var iteration = new Iteration {Iid = Guid.Parse("f744ae63-cf36-4cc4-8d76-e83edd44f6d2")};
- var elementDefinition = new ElementDefinition {Iid = Guid.Parse("f7f173ea-a742-42a5-81f1-59da2f470f16") };
- var parameter = new Parameter {Iid = Guid.Parse("607764de-7598-4be2-9a95-34669de273e3") };
+ var engineeringModel = new EngineeringModel { Iid = Guid.Parse("5643764e-f880-44bf-90ae-361f6661ceae") };
+ var iteration = new Iteration { Iid = Guid.Parse("f744ae63-cf36-4cc4-8d76-e83edd44f6d2") };
+ var elementDefinition = new ElementDefinition { Iid = Guid.Parse("f7f173ea-a742-42a5-81f1-59da2f470f16") };
+ var parameter = new Parameter { Iid = Guid.Parse("607764de-7598-4be2-9a95-34669de273e3") };
+
var parameterValueSet = new ParameterValueSet
{
Iid = Guid.Parse("2366c662-b857-4313-85ea-51f9bf4588b1"), Manual = new ValueArray(values)
@@ -171,7 +181,7 @@ the CEND sequence.If I need to use CEND I must escape one of the
";
- private static readonly string[] TestStrings =
+ private static readonly string[] TestStrings =
{
"value with trailing spaces ",
"value with trailing space ",
diff --git a/CDP4JsonSerializer.NetCore.Tests/JsonSerializerTestFixture.cs b/CDP4JsonSerializer.NetCore.Tests/JsonSerializerTestFixture.cs
index 81f841d5b..bbd8505e9 100644
--- a/CDP4JsonSerializer.NetCore.Tests/JsonSerializerTestFixture.cs
+++ b/CDP4JsonSerializer.NetCore.Tests/JsonSerializerTestFixture.cs
@@ -1,26 +1,26 @@
-// --------------------------------------------------------------------------------------------------------------------
+// --------------------------------------------------------------------------------------------------------------------
//
// Copyright (c) 2015-2024 Starion Group S.A.
//
// Author: Sam Gerené, Merlin Bieze, Alex Vorobiev, Naron Phou, Alexander van Delft
//
// This file is part of CDP4-COMET SDK Community Edition
-//
+//
// The CDP4-COMET SDK Community Edition is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 3 of the License, or (at your option) any later version.
-//
+//
// The CDP4-COMET SDK Community Edition is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
-//
+//
// You should have received a copy of the GNU Lesser General Public License
// along with this program; if not, write to the Free Software Foundation,
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
//
-// --------------------------------------------------------------------------------------------------------------------
+// -------------------------------------------------------------------------------------------------------------------------------
namespace CDP4JsonSerializer.Tests
{
@@ -41,8 +41,6 @@ namespace CDP4JsonSerializer.Tests
using CDP4JsonSerializer.Tests.Helper;
- using Newtonsoft.Json;
-
using NUnit.Framework;
using Dto = CDP4Common.DTO;
@@ -117,7 +115,7 @@ public void VerifyThatSerializeTimeCorrectly()
using var reader = new StreamReader(memoryStream);
var txt = reader.ReadToEnd();
-
+
Assert.That(txt, Does.Not.Contain("2222-02-02T22:22:22.222222"));
Assert.That(txt, Does.Contain("2222-02-02T22:22:22.222Z"));
}
@@ -407,7 +405,7 @@ public void VerifyThatSerializationofOperationsWorks()
result.Update.Single(x => x["Iid"].ToString() == subscriptionValueset.Iid.ToString());
var valueArray = (ValueArray)subscriptionValueSetClasslessDto["Manual"];
-
+
Assert.That(subscriptionValueSetClasslessDto["Iid"] is Guid, Is.True);
Assert.That(subscriptionValueSetClasslessDto["ClassKind"] is ClassKind, Is.True);
@@ -457,7 +455,7 @@ public void VerifyThatSerializeGiveSameInput()
using var reader = new StreamReader(stream);
var serializerResult = reader.ReadToEnd().Replace("\r", string.Empty).Replace("\n", string.Empty).Replace("\t", string.Empty).Replace(" ", string.Empty).Trim();
-
+
Assert.That(response.Length, Is.EqualTo(serializerResult.Length));
}
}
@@ -498,7 +496,7 @@ public void VerifyThatValueSetDeserializationIsCorrectForStringThatRepresentEsca
using var reader = new StreamReader(stream);
var serializerResult = reader.ReadToEnd().Replace("\r", string.Empty).Replace("\n", string.Empty).Replace("\t", string.Empty).Replace(" ", string.Empty).Trim();
-
+
Assert.That(serializedParameterValueSet.Length, Is.EqualTo(serializerResult.Length));
}
}
@@ -611,19 +609,16 @@ private class TestPostOperation
///
/// Gets or sets the collection of DTOs to delete.
///
- [JsonProperty("_delete")]
public List Delete { get; set; }
///
/// Gets or sets the collection of DTOs to create.
///
- [JsonProperty("_create")]
public List Create { get; set; }
///
/// Gets or sets the collection of DTOs to update.
///
- [JsonProperty("_update")]
public List Update { get; set; }
///
diff --git a/CDP4JsonSerializer.NetCore.Tests/PostOperation/CreateDerivedQuantityKindPostMessage.json b/CDP4JsonSerializer.NetCore.Tests/PostOperation/CreateDerivedQuantityKindPostMessage.json
new file mode 100644
index 000000000..11e51e3de
--- /dev/null
+++ b/CDP4JsonSerializer.NetCore.Tests/PostOperation/CreateDerivedQuantityKindPostMessage.json
@@ -0,0 +1,62 @@
+{
+ "_delete": [],
+ "_create": [
+ {
+ "alias": [],
+ "category": [],
+ "classKind": "DerivedQuantityKind",
+ "defaultScale": "56863161-fa3a-47b8-a3cd-16465f734b27",
+ "definition": [],
+ "excludedDomain": [],
+ "excludedPerson": [],
+ "hyperLink": [],
+ "iid": "08c130ca-a270-408f-8069-b7e1d00659f0",
+ "isDeprecated": false,
+ "modifiedOn": "2018-08-12T14:10:55.560Z",
+ "name": "derivedQuantityKind",
+ "possibleScale": [ "56863161-fa3a-47b8-a3cd-16465f734b27" ],
+ "quantityDimensionSymbol": "dqk",
+ "quantityKindFactor": [
+ {
+ "k": -12551680,
+ "v": "11aa4db6-40ef-4368-92ac-bda8af9b27a9"
+ },
+ {
+ "k": 77606679,
+ "v": "125abfbd-f717-42c0-91da-738316159ea5"
+ }
+ ],
+ "revisionNumber": 0,
+ "shortName": "derivedQuantityKind",
+ "symbol": "derivedQuantityKind"
+ },
+ {
+ "classKind": "QuantityKindFactor",
+ "excludedDomain": [],
+ "excludedPerson": [],
+ "exponent": "1",
+ "iid": "11aa4db6-40ef-4368-92ac-bda8af9b27a9",
+ "modifiedOn": "2018-08-12T14:10:45.476Z",
+ "quantityKind": "9513aca9-5397-48a1-8187-1683490bdb4f",
+ "revisionNumber": 0
+ },
+ {
+ "classKind": "QuantityKindFactor",
+ "excludedDomain": [],
+ "excludedPerson": [],
+ "exponent": "2",
+ "iid": "125abfbd-f717-42c0-91da-738316159ea5",
+ "modifiedOn": "2018-08-12T14:10:50.681Z",
+ "quantityKind": "1c53f8f4-024b-4f42-987a-439901a4bcb2",
+ "revisionNumber": 0
+ }
+ ],
+ "_update": [
+ {
+ "classKind": "SiteReferenceDataLibrary",
+ "iid": "bff9f871-3b7f-4e57-ac82-5ab499f9baf5",
+ "parameterType": [ "08c130ca-a270-408f-8069-b7e1d00659f0" ]
+ }
+ ],
+ "_copy": []
+}
\ No newline at end of file
diff --git a/CDP4JsonSerializer.NetCore.Tests/PostOperation/JsonSerializerPostOperationTestFixture.cs b/CDP4JsonSerializer.NetCore.Tests/PostOperation/JsonSerializerPostOperationTestFixture.cs
new file mode 100644
index 000000000..9833beaf3
--- /dev/null
+++ b/CDP4JsonSerializer.NetCore.Tests/PostOperation/JsonSerializerPostOperationTestFixture.cs
@@ -0,0 +1,106 @@
+// --------------------------------------------------------------------------------------------------------------------
+//
+// Copyright (c) 2015-2024 Starion Group S.A.
+//
+// Author: Sam Gerené, Merlin Bieze, Alex Vorobiev, Naron Phou
+//
+// This file is part of CDP4-COMET SDK Community Edition
+//
+// The CDP4-COMET SDK Community Edition is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 3 of the License, or (at your option) any later version.
+//
+// The CDP4-COMET SDK Community Edition is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this program; if not, write to the Free Software Foundation,
+// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+//
+// --------------------------------------------------------------------------------------------------------------------
+
+namespace CDP4JsonSerializer.NetCore.Tests.PostOperation
+{
+ using System;
+ using System.Collections.Generic;
+ using System.IO;
+ using System.Linq;
+ using System.Text;
+
+ using CDP4Common.DTO;
+ using CDP4Common.MetaInfo;
+ using CDP4Common.Types;
+
+ using CDP4DalCommon.Protocol.Operations;
+
+ using NUnit.Framework;
+
+ ///
+ /// Suite of tests to verify that PostOperation deserialization works as expected
+ ///
+ [TestFixture]
+ public class JsonSerializerPostOperationTestFixture
+ {
+ private IMetaDataProvider metaDataProvider;
+
+ private Version supportedVersion;
+
+ [SetUp]
+ public void SetUp()
+ {
+ this.metaDataProvider = new MetaDataProvider();
+ this.supportedVersion = new Version(1,1,0);
+ }
+
+ [Test]
+ public void Verify_that_post_message_with_move_keys_can_be_deserialized()
+ {
+ var postMessage = System.IO.File.ReadAllText(Path.Combine(TestContext.CurrentContext.TestDirectory, "PostOperation/ReOderFactorsOfDerivedQuantityKindPostMessage.json"));
+ var byteArray = Encoding.UTF8.GetBytes(postMessage);
+ var stream = new MemoryStream(byteArray);
+
+ var cdp4JsonSerializer = new Cdp4DalJsonSerializer(this.metaDataProvider, this.supportedVersion, false);
+
+ var cdpPostOperation = cdp4JsonSerializer.Deserialize(stream);
+
+ Assert.That(cdpPostOperation.Create, Is.Empty);
+ Assert.That(cdpPostOperation.Delete, Is.Empty);
+ Assert.That(cdpPostOperation.Copy, Is.Empty);
+
+ var classlessDto = cdpPostOperation.Update.First();
+
+ var orderedItems = classlessDto["QuantityKindFactor"] as IEnumerable;
+
+ var orderedItem_1 = orderedItems.First();
+ orderedItem_1.M = 77606679;
+
+ var orderedItem_2 = orderedItems.Last();
+ orderedItem_2.M = -12551680;
+ }
+
+ [Test]
+ public void Verify_that_post_message_can_be_deserialized()
+ {
+ var postMessage = System.IO.File.ReadAllText(Path.Combine(TestContext.CurrentContext.TestDirectory, "PostOperation/CreateDerivedQuantityKindPostMessage.json"));
+ var byteArray = Encoding.UTF8.GetBytes(postMessage);
+ var stream = new MemoryStream(byteArray);
+
+ var cdp4JsonSerializer = new Cdp4DalJsonSerializer(this.metaDataProvider, this.supportedVersion, false);
+
+ var cdpPostOperation = cdp4JsonSerializer.Deserialize(stream);
+
+ Assert.That(cdpPostOperation.Delete, Is.Empty);
+ Assert.That(cdpPostOperation.Copy, Is.Empty);
+
+ var derivedQuantityKind = cdpPostOperation.Create.First() as DerivedQuantityKind;
+ var qkf_1 = derivedQuantityKind.QuantityKindFactor.Single(x => x.K == -12551680);
+
+ Assert.That(qkf_1.V, Is.Not.Null);
+
+ Assert.That(qkf_1.M, Is.Null);
+ }
+ }
+}
\ No newline at end of file
diff --git a/CDP4JsonSerializer.NetCore.Tests/PostOperation/ReOderFactorsOfDerivedQuantityKindPostMessage.json b/CDP4JsonSerializer.NetCore.Tests/PostOperation/ReOderFactorsOfDerivedQuantityKindPostMessage.json
new file mode 100644
index 000000000..5b7161c8f
--- /dev/null
+++ b/CDP4JsonSerializer.NetCore.Tests/PostOperation/ReOderFactorsOfDerivedQuantityKindPostMessage.json
@@ -0,0 +1,24 @@
+{
+ "_delete": [],
+ "_create": [],
+ "_update": [
+ {
+ "classKind": "DerivedQuantityKind",
+ "iid": "08c130ca-a270-408f-8069-b7e1d00659f0",
+ "modifiedOn": "2018-08-12T14:11:56.580Z",
+ "quantityKindFactor": [
+ {
+ "k": -12551680,
+ "m": 77606679,
+ "v": "11aa4db6-40ef-4368-92ac-bda8af9b27a9"
+ },
+ {
+ "k": 77606679,
+ "m": -12551680,
+ "v": "125abfbd-f717-42c0-91da-738316159ea5"
+ }
+ ]
+ }
+ ],
+ "_copy": []
+}
\ No newline at end of file
diff --git a/CDP4JsonSerializer.Tests/CDP4JsonSerializer.Tests.csproj b/CDP4JsonSerializer.Tests/CDP4JsonSerializer.Tests.csproj
index 7617d3d16..098fc4c00 100644
--- a/CDP4JsonSerializer.Tests/CDP4JsonSerializer.Tests.csproj
+++ b/CDP4JsonSerializer.Tests/CDP4JsonSerializer.Tests.csproj
@@ -16,7 +16,7 @@
-
+
diff --git a/CDP4JsonSerializer.Tests/Helper/SerializerHelperTestFixture.cs b/CDP4JsonSerializer.Tests/Helper/SerializerHelperTestFixture.cs
index bd785bddb..c01d93151 100644
--- a/CDP4JsonSerializer.Tests/Helper/SerializerHelperTestFixture.cs
+++ b/CDP4JsonSerializer.Tests/Helper/SerializerHelperTestFixture.cs
@@ -5,29 +5,32 @@
// Author: Sam Gerené, Merlin Bieze, Alex Vorobiev, Naron Phou, Alexander van Delft
//
// This file is part of CDP4-COMET SDK Community Edition
-//
+//
// The CDP4-COMET SDK Community Edition is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 3 of the License, or (at your option) any later version.
-//
+//
// The CDP4-COMET SDK Community Edition is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
-//
+//
// You should have received a copy of the GNU Lesser General Public License
// along with this program; if not, write to the Free Software Foundation,
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
//
-// --------------------------------------------------------------------------------------------------------------------
+// -------------------------------------------------------------------------------------------------------------------------------
namespace CDP4JsonSerializer.Tests.Helper
{
using System;
using System.Collections.Generic;
+ using System.IO;
using System.Linq;
-
+ using System.Text.Json;
+ using System.Text.Json.Nodes;
+
using CDP4Common.EngineeringModelData;
using CDP4Common.MetaInfo;
using CDP4Common.Types;
@@ -45,23 +48,30 @@ public void VerifyThatToJsonObjectOfOrderedItemReturnsJObject()
{
var uniqueIdentifier = Guid.NewGuid();
- var orderedItem = new OrderedItem {K = 1, V = uniqueIdentifier};
+ var orderedItem = new OrderedItem { K = 1, V = uniqueIdentifier };
var propertyInfo = orderedItem.GetType().GetProperty("M");
- var value = System.Convert.ChangeType(123, Nullable.GetUnderlyingType(propertyInfo.PropertyType));
+ object value = null;
+ value = System.Convert.ChangeType(123, Nullable.GetUnderlyingType(propertyInfo.PropertyType));
propertyInfo.SetValue(orderedItem, value);
+ var stream = new MemoryStream();
+ var utf8Writer = new Utf8JsonWriter(stream);
+ utf8Writer.WriteOrderedItem(orderedItem);
+ utf8Writer.Flush();
+ stream.Position = 0;
+ var ut8Reader = new Utf8JsonReader(stream.ToArray());
- var jObject = orderedItem.ToJsonObject();
- Assert.That(jObject.Properties().Count(), Is.EqualTo(3));
+ var jObject = JsonObject.Create(JsonElement.ParseValue(ref ut8Reader));
+ Assert.That(jObject.AsEnumerable().Count(), Is.EqualTo(3));
- var k = jObject.Property("k");
+ jObject.TryGetPropertyValue("k", out var k);
Assert.That(k, Is.Not.Null);
- var v = jObject.Property("v");
+ jObject.TryGetPropertyValue("v", out var v);
Assert.That(v, Is.Not.Null);
- var m = jObject.Property("m");
+ jObject.TryGetPropertyValue("m", out var m);
Assert.That(m, Is.Not.Null);
}
@@ -113,7 +123,7 @@ public void Verify_that_a_ValueArray_is_serialized_and_deserialized([ValueSource
Assert.That(resultjson, Is.EqualTo(json), $"Json creation failed for string \"{input}\".");
}
-
+
private const string JsonString = @"{""widget"": {
""debug"": ""on"",
""window"": {
@@ -170,7 +180,7 @@ the CEND sequence.If I need to use CEND I must escape one of the
";
- private static readonly string[] TestStrings =
+ private static readonly string[] TestStrings =
{
"value with trailing spaces ",
"value with trailing space ",
@@ -212,4 +222,4 @@ the CEND sequence.If I need to use CEND I must escape one of the
JsonString
};
}
-}
\ No newline at end of file
+}
diff --git a/CDP4JsonSerializer.Tests/JsonSerializerTestFixture.cs b/CDP4JsonSerializer.Tests/JsonSerializerTestFixture.cs
index 146a70369..0a5013739 100644
--- a/CDP4JsonSerializer.Tests/JsonSerializerTestFixture.cs
+++ b/CDP4JsonSerializer.Tests/JsonSerializerTestFixture.cs
@@ -5,22 +5,22 @@
// Author: Sam Gerené, Merlin Bieze, Alex Vorobiev, Naron Phou, Alexander van Delft
//
// This file is part of CDP4-COMET SDK Community Edition
-//
+//
// The CDP4-COMET SDK Community Edition is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 3 of the License, or (at your option) any later version.
-//
+//
// The CDP4-COMET SDK Community Edition is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
-//
+//
// You should have received a copy of the GNU Lesser General Public License
// along with this program; if not, write to the Free Software Foundation,
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
//
-// --------------------------------------------------------------------------------------------------------------------
+// -------------------------------------------------------------------------------------------------------------------------------
namespace CDP4JsonSerializer.Tests
{
@@ -30,6 +30,7 @@ namespace CDP4JsonSerializer.Tests
using System.Diagnostics;
using System.IO;
using System.Linq;
+ using System.Text.Json.Serialization;
using CDP4Common;
using CDP4Common.CommonData;
@@ -41,8 +42,6 @@ namespace CDP4JsonSerializer.Tests
using CDP4JsonSerializer.Tests.Helper;
- using Newtonsoft.Json;
-
using NUnit.Framework;
using Dto = CDP4Common.DTO;
@@ -170,7 +169,7 @@ public void VerifyThatValueArrayAreSerializedCorrectly()
var txt = reader.ReadToEnd();
// output: "manual":"[\"123\",\"abc\"]"
- Assert.That(txt, Does.Contain("\"manual\":\"[\\\"123\\\",\\\"abc\\\"]\""));
+ Assert.That(txt, Does.Contain("\"manual\":\"[\\\"123\\\",\\\"abc\\\"]\""));
}
}
}
@@ -412,9 +411,10 @@ public void VerifyThatSerializationofOperationsWorks()
// necessary
memoryStream.Position = 0;
-
+ var content = new StreamReader(memoryStream).ReadToEnd();
+ memoryStream.Position = 0;
var result = this.serializer.Deserialize(memoryStream);
-
+
Assert.That(result.Delete.Count, Is.EqualTo(1));
Assert.That(result.Create.Count, Is.EqualTo(1));
Assert.That(result.Update.Count, Is.EqualTo(2));
@@ -617,19 +617,19 @@ private class TestPostOperation
///
/// Gets or sets the collection of DTOs to delete.
///
- [JsonProperty("_delete")]
+ [JsonPropertyName("_delete")]
public List Delete { get; set; }
///
/// Gets or sets the collection of DTOs to create.
///
- [JsonProperty("_create")]
+ [JsonPropertyName("_create")]
public List Create { get; set; }
///
/// Gets or sets the collection of DTOs to update.
///
- [JsonProperty("_update")]
+ [JsonPropertyName("_update")]
public List Update { get; set; }
///
diff --git a/CDP4JsonSerializer.Tests/PostOperation/CdpPostOperation.cs b/CDP4JsonSerializer.Tests/PostOperation/CdpPostOperation.cs
deleted file mode 100644
index 607c8e50b..000000000
--- a/CDP4JsonSerializer.Tests/PostOperation/CdpPostOperation.cs
+++ /dev/null
@@ -1,51 +0,0 @@
-// --------------------------------------------------------------------------------------------------------------------
-//
-// Copyright (c) 2015-2024 Starion Group S.A.
-//
-// Author: Sam Gerené, Merlin Bieze, Alex Vorobiev, Naron Phou, Alexander van Delft
-//
-// This file is part of CDP4-COMET SDK Community Edition
-//
-// The CDP4-COMET SDK Community Edition is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 3 of the License, or (at your option) any later version.
-//
-// The CDP4-COMET SDK Community Edition is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public License
-// along with this program; if not, write to the Free Software Foundation,
-// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-//
-// --------------------------------------------------------------------------------------------------------------------
-
-namespace CDP4JsonSerializer.Tests.Cdp4PostOperation
-{
- using System.Collections.Generic;
-
- using CDP4Common;
- using CDP4Common.DTO;
-
- using Newtonsoft.Json;
-
- ///
- /// A CdpPostOperation class used for testing purposes
- ///
- public class CdpPostOperation
- {
- [JsonProperty("_delete")]
- public List Delete { get; set; }
-
- [JsonProperty("_create")]
- public List Create { get; set; }
-
- [JsonProperty("_update")]
- public List Update { get; set; }
-
- [JsonProperty("_copy")]
- public List Copy { get; set; }
- }
-}
\ No newline at end of file
diff --git a/CDP4JsonSerializer.Tests/PostOperation/JsonSerializerPostOperationTestFixture.cs b/CDP4JsonSerializer.Tests/PostOperation/JsonSerializerPostOperationTestFixture.cs
index 8c654209f..96a623eac 100644
--- a/CDP4JsonSerializer.Tests/PostOperation/JsonSerializerPostOperationTestFixture.cs
+++ b/CDP4JsonSerializer.Tests/PostOperation/JsonSerializerPostOperationTestFixture.cs
@@ -34,7 +34,7 @@ namespace CDP4JsonSerializer.Tests.PostOperation
using CDP4Common.MetaInfo;
using CDP4Common.Types;
- using CDP4JsonSerializer.Tests.Cdp4PostOperation;
+ using CDP4DalCommon.Protocol.Operations;
using NUnit.Framework;
@@ -62,9 +62,9 @@ public void Verify_that_post_message_with_move_keys_can_be_deserialized()
var byteArray = Encoding.UTF8.GetBytes(postMessage);
var stream = new MemoryStream(byteArray);
- var cdp4JsonSerializer = new Cdp4JsonSerializer(this.metaDataProvider, this.supportedVersion);
+ var cdp4JsonSerializer = new Cdp4DalJsonSerializer(this.metaDataProvider, this.supportedVersion, false);
- var cdpPostOperation = cdp4JsonSerializer.Deserialize(stream);
+ var cdpPostOperation = cdp4JsonSerializer.Deserialize(stream);
Assert.That(cdpPostOperation.Create, Is.Empty);
Assert.That(cdpPostOperation.Delete, Is.Empty);
@@ -88,9 +88,9 @@ public void Verify_that_post_message_can_be_deserialized()
var byteArray = Encoding.UTF8.GetBytes(postMessage);
var stream = new MemoryStream(byteArray);
- var cdp4JsonSerializer = new Cdp4JsonSerializer(this.metaDataProvider, this.supportedVersion);
+ var cdp4JsonSerializer = new Cdp4DalJsonSerializer(this.metaDataProvider, this.supportedVersion, false);
- var cdpPostOperation = cdp4JsonSerializer.Deserialize(stream);
+ var cdpPostOperation = cdp4JsonSerializer.Deserialize(stream);
Assert.That(cdpPostOperation.Delete, Is.Empty);
Assert.That(cdpPostOperation.Copy, Is.Empty);
diff --git a/CDP4JsonSerializer/AutoGenDtoDeserializer/ActionItemResolver.cs b/CDP4JsonSerializer/AutoGenDtoDeserializer/ActionItemResolver.cs
index f4815aad3..81ac2b50b 100644
--- a/CDP4JsonSerializer/AutoGenDtoDeserializer/ActionItemResolver.cs
+++ b/CDP4JsonSerializer/AutoGenDtoDeserializer/ActionItemResolver.cs
@@ -1,27 +1,26 @@
-// --------------------------------------------------------------------------------------------------------------------
+// -------------------------------------------------------------------------------------------------------------------------------
//
// Copyright (c) 2015-2024 Starion Group S.A.
//
-// Author: Sam Gerené, Alex Vorobiev, Alexander van Delft, Nathanael Smiechowski,
-// Antoine Théate, Omar Elebiary, Jaime Bernar
-//
+// Authors: Sam Gerené, Alex Vorobiev, Alexander van Delft, Nathanael Smiechowski, Antoine Théate, Omar Elebiary, Jaime Bernar
+//
// This file is part of CDP4-COMET SDK Community Edition
-// This is an auto-generated class. Any manual changes to this file will be overwritten!
-//
+//
// The CDP4-COMET SDK Community Edition is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 3 of the License, or (at your option) any later version.
-//
+//
// The CDP4-COMET SDK Community Edition is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
-//
+//
// You should have received a copy of the GNU Lesser General Public License
// along with this program; if not, write to the Free Software Foundation,
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-// --------------------------------------------------------------------------------------------------------------------
+//
+// -------------------------------------------------------------------------------------------------------------------------------
// ------------------------------------------------------------------------------------------------
// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!--------
@@ -29,151 +28,290 @@
namespace CDP4JsonSerializer
{
- using System;
using System.Collections.Generic;
+ using System.Text.Json;
- using CDP4Common.CommonData;
- using CDP4Common.DiagramData;
- using CDP4Common.EngineeringModelData;
- using CDP4Common.ReportingData;
- using CDP4Common.SiteDirectoryData;
+ using CDP4Common.Types;
- using Newtonsoft.Json.Linq;
+ using NLog;
///
- /// The purpose of the is to deserialize a JSON object to a
+ /// The purpose of the is to deserialize a JSON object to a
///
public static class ActionItemResolver
{
///
- /// Instantiate and deserialize the properties of a
+ /// The NLog logger
+ ///
+ private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
+
+ ///
+ /// Instantiate and deserialize the properties of a
///
- /// The containing the data
- /// The to instantiate
- public static CDP4Common.DTO.ActionItem FromJsonObject(JObject jObject)
+ /// The containing the data
+ /// The to instantiate
+ public static CDP4Common.DTO.ActionItem FromJsonObject(JsonElement jsonElement)
{
- var iid = jObject["iid"].ToObject();
- var revisionNumber = jObject["revisionNumber"].IsNullOrEmpty() ? 0 : jObject["revisionNumber"].ToObject();
- var actionItem = new CDP4Common.DTO.ActionItem(iid, revisionNumber);
+ if (!jsonElement.TryGetProperty("iid"u8, out var iid))
+ {
+ throw new DeSerializationException("the mandatory iid property is not available, the ActionItemResolver cannot be used to deserialize this JsonElement");
+ }
+
+ var revisionNumberValue = 0;
- if (!jObject["actionee"].IsNullOrEmpty())
+ if (jsonElement.TryGetProperty("revisionNumber"u8, out var revisionNumber))
{
- actionItem.Actionee = jObject["actionee"].ToObject();
+ revisionNumberValue = revisionNumber.GetInt32();
}
- if (!jObject["actor"].IsNullOrEmpty())
+ var actionItem = new CDP4Common.DTO.ActionItem(iid.GetGuid(), revisionNumberValue);
+
+ if (jsonElement.TryGetProperty("actionee"u8, out var actioneeProperty))
{
- actionItem.Actor = jObject["actor"].ToObject();
+ if(actioneeProperty.ValueKind == JsonValueKind.Null)
+ {
+ Logger.Trace("The non-nullabale actionee property of the actionItem {id} is null", actionItem.Iid);
+ }
+ else
+ {
+ actionItem.Actionee = actioneeProperty.GetGuid();
+ }
}
- if (!jObject["approvedBy"].IsNullOrEmpty())
+ if (jsonElement.TryGetProperty("approvedBy"u8, out var approvedByProperty) && approvedByProperty.ValueKind != JsonValueKind.Null)
{
- actionItem.ApprovedBy.AddRange(jObject["approvedBy"].ToObject>());
+ foreach(var element in approvedByProperty.EnumerateArray())
+ {
+ actionItem.ApprovedBy.Add(element.GetGuid());
+ }
}
- if (!jObject["author"].IsNullOrEmpty())
+ if (jsonElement.TryGetProperty("author"u8, out var authorProperty))
{
- actionItem.Author = jObject["author"].ToObject();
+ if(authorProperty.ValueKind == JsonValueKind.Null)
+ {
+ Logger.Trace("The non-nullabale author property of the actionItem {id} is null", actionItem.Iid);
+ }
+ else
+ {
+ actionItem.Author = authorProperty.GetGuid();
+ }
}
- if (!jObject["category"].IsNullOrEmpty())
+ if (jsonElement.TryGetProperty("category"u8, out var categoryProperty) && categoryProperty.ValueKind != JsonValueKind.Null)
{
- actionItem.Category.AddRange(jObject["category"].ToObject>());
+ foreach(var element in categoryProperty.EnumerateArray())
+ {
+ actionItem.Category.Add(element.GetGuid());
+ }
}
- if (!jObject["classification"].IsNullOrEmpty())
+ if (jsonElement.TryGetProperty("classification"u8, out var classificationProperty))
{
- actionItem.Classification = jObject["classification"].ToObject();
+ if(classificationProperty.ValueKind == JsonValueKind.Null)
+ {
+ Logger.Trace("The non-nullabale classification property of the actionItem {id} is null", actionItem.Iid);
+ }
+ else
+ {
+ actionItem.Classification = AnnotationClassificationKindDeserializer.Deserialize(classificationProperty);
+ }
}
- if (!jObject["closeOutDate"].IsNullOrEmpty())
+ if (jsonElement.TryGetProperty("closeOutDate"u8, out var closeOutDateProperty))
{
- actionItem.CloseOutDate = jObject["closeOutDate"].ToObject();
+ if(closeOutDateProperty.ValueKind == JsonValueKind.Null)
+ {
+ actionItem.CloseOutDate = null;
+ }
+ else
+ {
+ actionItem.CloseOutDate = closeOutDateProperty.GetDateTime();
+ }
}
- if (!jObject["closeOutStatement"].IsNullOrEmpty())
+ if (jsonElement.TryGetProperty("closeOutStatement"u8, out var closeOutStatementProperty))
{
- actionItem.CloseOutStatement = jObject["closeOutStatement"].ToObject();
+ if(closeOutStatementProperty.ValueKind == JsonValueKind.Null)
+ {
+ Logger.Trace("The non-nullabale closeOutStatement property of the actionItem {id} is null", actionItem.Iid);
+ }
+ else
+ {
+ actionItem.CloseOutStatement = closeOutStatementProperty.GetString();
+ }
}
- if (!jObject["content"].IsNullOrEmpty())
+ if (jsonElement.TryGetProperty("content"u8, out var contentProperty))
{
- actionItem.Content = jObject["content"].ToObject();
+ if(contentProperty.ValueKind == JsonValueKind.Null)
+ {
+ Logger.Trace("The non-nullabale content property of the actionItem {id} is null", actionItem.Iid);
+ }
+ else
+ {
+ actionItem.Content = contentProperty.GetString();
+ }
}
- if (!jObject["createdOn"].IsNullOrEmpty())
+ if (jsonElement.TryGetProperty("createdOn"u8, out var createdOnProperty))
{
- actionItem.CreatedOn = jObject["createdOn"].ToObject();
+ if(createdOnProperty.ValueKind == JsonValueKind.Null)
+ {
+ Logger.Trace("The non-nullabale createdOn property of the actionItem {id} is null", actionItem.Iid);
+ }
+ else
+ {
+ actionItem.CreatedOn = createdOnProperty.GetDateTime();
+ }
}
- if (!jObject["discussion"].IsNullOrEmpty())
+ if (jsonElement.TryGetProperty("discussion"u8, out var discussionProperty) && discussionProperty.ValueKind != JsonValueKind.Null)
{
- actionItem.Discussion.AddRange(jObject["discussion"].ToObject>());
+ foreach(var element in discussionProperty.EnumerateArray())
+ {
+ actionItem.Discussion.Add(element.GetGuid());
+ }
}
- if (!jObject["dueDate"].IsNullOrEmpty())
+ if (jsonElement.TryGetProperty("dueDate"u8, out var dueDateProperty))
{
- actionItem.DueDate = jObject["dueDate"].ToObject();
+ if(dueDateProperty.ValueKind == JsonValueKind.Null)
+ {
+ Logger.Trace("The non-nullabale dueDate property of the actionItem {id} is null", actionItem.Iid);
+ }
+ else
+ {
+ actionItem.DueDate = dueDateProperty.GetDateTime();
+ }
}
- if (!jObject["excludedDomain"].IsNullOrEmpty())
+ if (jsonElement.TryGetProperty("excludedDomain"u8, out var excludedDomainProperty) && excludedDomainProperty.ValueKind != JsonValueKind.Null)
{
- actionItem.ExcludedDomain.AddRange(jObject["excludedDomain"].ToObject>());
+ foreach(var element in excludedDomainProperty.EnumerateArray())
+ {
+ actionItem.ExcludedDomain.Add(element.GetGuid());
+ }
}
- if (!jObject["excludedPerson"].IsNullOrEmpty())
+ if (jsonElement.TryGetProperty("excludedPerson"u8, out var excludedPersonProperty) && excludedPersonProperty.ValueKind != JsonValueKind.Null)
{
- actionItem.ExcludedPerson.AddRange(jObject["excludedPerson"].ToObject>());
+ foreach(var element in excludedPersonProperty.EnumerateArray())
+ {
+ actionItem.ExcludedPerson.Add(element.GetGuid());
+ }
}
- if (!jObject["languageCode"].IsNullOrEmpty())
+ if (jsonElement.TryGetProperty("languageCode"u8, out var languageCodeProperty))
{
- actionItem.LanguageCode = jObject["languageCode"].ToObject();
+ if(languageCodeProperty.ValueKind == JsonValueKind.Null)
+ {
+ Logger.Trace("The non-nullabale languageCode property of the actionItem {id} is null", actionItem.Iid);
+ }
+ else
+ {
+ actionItem.LanguageCode = languageCodeProperty.GetString();
+ }
}
- if (!jObject["modifiedOn"].IsNullOrEmpty())
+ if (jsonElement.TryGetProperty("modifiedOn"u8, out var modifiedOnProperty))
{
- actionItem.ModifiedOn = jObject["modifiedOn"].ToObject();
+ if(modifiedOnProperty.ValueKind == JsonValueKind.Null)
+ {
+ Logger.Trace("The non-nullabale modifiedOn property of the actionItem {id} is null", actionItem.Iid);
+ }
+ else
+ {
+ actionItem.ModifiedOn = modifiedOnProperty.GetDateTime();
+ }
}
- if (!jObject["owner"].IsNullOrEmpty())
+ if (jsonElement.TryGetProperty("owner"u8, out var ownerProperty))
{
- actionItem.Owner = jObject["owner"].ToObject();
+ if(ownerProperty.ValueKind == JsonValueKind.Null)
+ {
+ Logger.Trace("The non-nullabale owner property of the actionItem {id} is null", actionItem.Iid);
+ }
+ else
+ {
+ actionItem.Owner = ownerProperty.GetGuid();
+ }
}
- if (!jObject["primaryAnnotatedThing"].IsNullOrEmpty())
+ if (jsonElement.TryGetProperty("primaryAnnotatedThing"u8, out var primaryAnnotatedThingProperty))
{
- actionItem.PrimaryAnnotatedThing = jObject["primaryAnnotatedThing"].ToObject();
+ if(primaryAnnotatedThingProperty.ValueKind == JsonValueKind.Null)
+ {
+ actionItem.PrimaryAnnotatedThing = null;
+ }
+ else
+ {
+ actionItem.PrimaryAnnotatedThing = primaryAnnotatedThingProperty.GetGuid();
+ }
}
- if (!jObject["relatedThing"].IsNullOrEmpty())
+ if (jsonElement.TryGetProperty("relatedThing"u8, out var relatedThingProperty) && relatedThingProperty.ValueKind != JsonValueKind.Null)
{
- actionItem.RelatedThing.AddRange(jObject["relatedThing"].ToObject>());
+ foreach(var element in relatedThingProperty.EnumerateArray())
+ {
+ actionItem.RelatedThing.Add(element.GetGuid());
+ }
}
- if (!jObject["shortName"].IsNullOrEmpty())
+ if (jsonElement.TryGetProperty("shortName"u8, out var shortNameProperty))
{
- actionItem.ShortName = jObject["shortName"].ToObject();
+ if(shortNameProperty.ValueKind == JsonValueKind.Null)
+ {
+ Logger.Trace("The non-nullabale shortName property of the actionItem {id} is null", actionItem.Iid);
+ }
+ else
+ {
+ actionItem.ShortName = shortNameProperty.GetString();
+ }
}
- if (!jObject["sourceAnnotation"].IsNullOrEmpty())
+ if (jsonElement.TryGetProperty("sourceAnnotation"u8, out var sourceAnnotationProperty) && sourceAnnotationProperty.ValueKind != JsonValueKind.Null)
{
- actionItem.SourceAnnotation.AddRange(jObject["sourceAnnotation"].ToObject>());
+ foreach(var element in sourceAnnotationProperty.EnumerateArray())
+ {
+ actionItem.SourceAnnotation.Add(element.GetGuid());
+ }
}
- if (!jObject["status"].IsNullOrEmpty())
+ if (jsonElement.TryGetProperty("status"u8, out var statusProperty))
{
- actionItem.Status = jObject["status"].ToObject();
+ if(statusProperty.ValueKind == JsonValueKind.Null)
+ {
+ Logger.Trace("The non-nullabale status property of the actionItem {id} is null", actionItem.Iid);
+ }
+ else
+ {
+ actionItem.Status = AnnotationStatusKindDeserializer.Deserialize(statusProperty);
+ }
}
- if (!jObject["thingPreference"].IsNullOrEmpty())
+ if (jsonElement.TryGetProperty("thingPreference"u8, out var thingPreferenceProperty))
{
- actionItem.ThingPreference = jObject["thingPreference"].ToObject();
+ if(thingPreferenceProperty.ValueKind == JsonValueKind.Null)
+ {
+ Logger.Trace("The non-nullabale thingPreference property of the actionItem {id} is null", actionItem.Iid);
+ }
+ else
+ {
+ actionItem.ThingPreference = thingPreferenceProperty.GetString();
+ }
}
- if (!jObject["title"].IsNullOrEmpty())
+ if (jsonElement.TryGetProperty("title"u8, out var titleProperty))
{
- actionItem.Title = jObject["title"].ToObject();
+ if(titleProperty.ValueKind == JsonValueKind.Null)
+ {
+ Logger.Trace("The non-nullabale title property of the actionItem {id} is null", actionItem.Iid);
+ }
+ else
+ {
+ actionItem.Title = titleProperty.GetString();
+ }
}
return actionItem;
diff --git a/CDP4JsonSerializer/AutoGenDtoDeserializer/ActualFiniteStateListResolver.cs b/CDP4JsonSerializer/AutoGenDtoDeserializer/ActualFiniteStateListResolver.cs
index c840513ae..b4e715a54 100644
--- a/CDP4JsonSerializer/AutoGenDtoDeserializer/ActualFiniteStateListResolver.cs
+++ b/CDP4JsonSerializer/AutoGenDtoDeserializer/ActualFiniteStateListResolver.cs
@@ -1,27 +1,26 @@
-// --------------------------------------------------------------------------------------------------------------------
+// -------------------------------------------------------------------------------------------------------------------------------
//
// Copyright (c) 2015-2024 Starion Group S.A.
//
-// Author: Sam Gerené, Alex Vorobiev, Alexander van Delft, Nathanael Smiechowski,
-// Antoine Théate, Omar Elebiary, Jaime Bernar
-//
+// Authors: Sam Gerené, Alex Vorobiev, Alexander van Delft, Nathanael Smiechowski, Antoine Théate, Omar Elebiary, Jaime Bernar
+//
// This file is part of CDP4-COMET SDK Community Edition
-// This is an auto-generated class. Any manual changes to this file will be overwritten!
-//
+//
// The CDP4-COMET SDK Community Edition is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 3 of the License, or (at your option) any later version.
-//
+//
// The CDP4-COMET SDK Community Edition is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
-//
+//
// You should have received a copy of the GNU Lesser General Public License
// along with this program; if not, write to the Free Software Foundation,
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-// --------------------------------------------------------------------------------------------------------------------
+//
+// -------------------------------------------------------------------------------------------------------------------------------
// ------------------------------------------------------------------------------------------------
// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!--------
@@ -29,76 +28,115 @@
namespace CDP4JsonSerializer
{
- using System;
using System.Collections.Generic;
+ using System.Text.Json;
- using CDP4Common.CommonData;
- using CDP4Common.DiagramData;
- using CDP4Common.EngineeringModelData;
- using CDP4Common.ReportingData;
- using CDP4Common.SiteDirectoryData;
+ using CDP4Common.Types;
- using Newtonsoft.Json.Linq;
+ using NLog;
///
- /// The purpose of the is to deserialize a JSON object to a
+ /// The purpose of the is to deserialize a JSON object to a
///
public static class ActualFiniteStateListResolver
{
///
- /// Instantiate and deserialize the properties of a
+ /// The NLog logger
+ ///
+ private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
+
+ ///
+ /// Instantiate and deserialize the properties of a
///
- /// The containing the data
- /// The to instantiate
- public static CDP4Common.DTO.ActualFiniteStateList FromJsonObject(JObject jObject)
+ /// The containing the data
+ /// The to instantiate
+ public static CDP4Common.DTO.ActualFiniteStateList FromJsonObject(JsonElement jsonElement)
{
- var iid = jObject["iid"].ToObject();
- var revisionNumber = jObject["revisionNumber"].IsNullOrEmpty() ? 0 : jObject["revisionNumber"].ToObject();
- var actualFiniteStateList = new CDP4Common.DTO.ActualFiniteStateList(iid, revisionNumber);
+ if (!jsonElement.TryGetProperty("iid"u8, out var iid))
+ {
+ throw new DeSerializationException("the mandatory iid property is not available, the ActualFiniteStateListResolver cannot be used to deserialize this JsonElement");
+ }
+
+ var revisionNumberValue = 0;
- if (!jObject["actor"].IsNullOrEmpty())
+ if (jsonElement.TryGetProperty("revisionNumber"u8, out var revisionNumber))
{
- actualFiniteStateList.Actor = jObject["actor"].ToObject();
+ revisionNumberValue = revisionNumber.GetInt32();
}
- if (!jObject["actualState"].IsNullOrEmpty())
+ var actualFiniteStateList = new CDP4Common.DTO.ActualFiniteStateList(iid.GetGuid(), revisionNumberValue);
+
+ if (jsonElement.TryGetProperty("actualState"u8, out var actualStateProperty) && actualStateProperty.ValueKind != JsonValueKind.Null)
{
- actualFiniteStateList.ActualState.AddRange(jObject["actualState"].ToObject>());
+ foreach(var element in actualStateProperty.EnumerateArray())
+ {
+ actualFiniteStateList.ActualState.Add(element.GetGuid());
+ }
}
- if (!jObject["excludedDomain"].IsNullOrEmpty())
+ if (jsonElement.TryGetProperty("excludedDomain"u8, out var excludedDomainProperty) && excludedDomainProperty.ValueKind != JsonValueKind.Null)
{
- actualFiniteStateList.ExcludedDomain.AddRange(jObject["excludedDomain"].ToObject>());
+ foreach(var element in excludedDomainProperty.EnumerateArray())
+ {
+ actualFiniteStateList.ExcludedDomain.Add(element.GetGuid());
+ }
}
- if (!jObject["excludedPerson"].IsNullOrEmpty())
+ if (jsonElement.TryGetProperty("excludedPerson"u8, out var excludedPersonProperty) && excludedPersonProperty.ValueKind != JsonValueKind.Null)
{
- actualFiniteStateList.ExcludedPerson.AddRange(jObject["excludedPerson"].ToObject>());
+ foreach(var element in excludedPersonProperty.EnumerateArray())
+ {
+ actualFiniteStateList.ExcludedPerson.Add(element.GetGuid());
+ }
}
- if (!jObject["excludeOption"].IsNullOrEmpty())
+ if (jsonElement.TryGetProperty("excludeOption"u8, out var excludeOptionProperty) && excludeOptionProperty.ValueKind != JsonValueKind.Null)
{
- actualFiniteStateList.ExcludeOption.AddRange(jObject["excludeOption"].ToObject>());
+ foreach(var element in excludeOptionProperty.EnumerateArray())
+ {
+ actualFiniteStateList.ExcludeOption.Add(element.GetGuid());
+ }
}
- if (!jObject["modifiedOn"].IsNullOrEmpty())
+ if (jsonElement.TryGetProperty("modifiedOn"u8, out var modifiedOnProperty))
{
- actualFiniteStateList.ModifiedOn = jObject["modifiedOn"].ToObject();
+ if(modifiedOnProperty.ValueKind == JsonValueKind.Null)
+ {
+ Logger.Trace("The non-nullabale modifiedOn property of the actualFiniteStateList {id} is null", actualFiniteStateList.Iid);
+ }
+ else
+ {
+ actualFiniteStateList.ModifiedOn = modifiedOnProperty.GetDateTime();
+ }
}
- if (!jObject["owner"].IsNullOrEmpty())
+ if (jsonElement.TryGetProperty("owner"u8, out var ownerProperty))
{
- actualFiniteStateList.Owner = jObject["owner"].ToObject();
+ if(ownerProperty.ValueKind == JsonValueKind.Null)
+ {
+ Logger.Trace("The non-nullabale owner property of the actualFiniteStateList {id} is null", actualFiniteStateList.Iid);
+ }
+ else
+ {
+ actualFiniteStateList.Owner = ownerProperty.GetGuid();
+ }
}
- if (!jObject["possibleFiniteStateList"].IsNullOrEmpty())
+ if (jsonElement.TryGetProperty("possibleFiniteStateList"u8, out var possibleFiniteStateListProperty))
{
- actualFiniteStateList.PossibleFiniteStateList.AddRange(jObject["possibleFiniteStateList"].ToOrderedItemCollection());
+ actualFiniteStateList.PossibleFiniteStateList.AddRange(possibleFiniteStateListProperty.ToOrderedItemCollection());
}
- if (!jObject["thingPreference"].IsNullOrEmpty())
+ if (jsonElement.TryGetProperty("thingPreference"u8, out var thingPreferenceProperty))
{
- actualFiniteStateList.ThingPreference = jObject["thingPreference"].ToObject();
+ if(thingPreferenceProperty.ValueKind == JsonValueKind.Null)
+ {
+ Logger.Trace("The non-nullabale thingPreference property of the actualFiniteStateList {id} is null", actualFiniteStateList.Iid);
+ }
+ else
+ {
+ actualFiniteStateList.ThingPreference = thingPreferenceProperty.GetString();
+ }
}
return actualFiniteStateList;
diff --git a/CDP4JsonSerializer/AutoGenDtoDeserializer/ActualFiniteStateResolver.cs b/CDP4JsonSerializer/AutoGenDtoDeserializer/ActualFiniteStateResolver.cs
index ee6f1001d..e4bfb8917 100644
--- a/CDP4JsonSerializer/AutoGenDtoDeserializer/ActualFiniteStateResolver.cs
+++ b/CDP4JsonSerializer/AutoGenDtoDeserializer/ActualFiniteStateResolver.cs
@@ -1,27 +1,26 @@
-// --------------------------------------------------------------------------------------------------------------------
+// -------------------------------------------------------------------------------------------------------------------------------
//
// Copyright (c) 2015-2024 Starion Group S.A.
//
-// Author: Sam Gerené, Alex Vorobiev, Alexander van Delft, Nathanael Smiechowski,
-// Antoine Théate, Omar Elebiary, Jaime Bernar
-//
+// Authors: Sam Gerené, Alex Vorobiev, Alexander van Delft, Nathanael Smiechowski, Antoine Théate, Omar Elebiary, Jaime Bernar
+//
// This file is part of CDP4-COMET SDK Community Edition
-// This is an auto-generated class. Any manual changes to this file will be overwritten!
-//
+//
// The CDP4-COMET SDK Community Edition is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 3 of the License, or (at your option) any later version.
-//
+//
// The CDP4-COMET SDK Community Edition is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
-//
+//
// You should have received a copy of the GNU Lesser General Public License
// along with this program; if not, write to the Free Software Foundation,
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-// --------------------------------------------------------------------------------------------------------------------
+//
+// -------------------------------------------------------------------------------------------------------------------------------
// ------------------------------------------------------------------------------------------------
// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!--------
@@ -29,66 +28,102 @@
namespace CDP4JsonSerializer
{
- using System;
using System.Collections.Generic;
+ using System.Text.Json;
- using CDP4Common.CommonData;
- using CDP4Common.DiagramData;
- using CDP4Common.EngineeringModelData;
- using CDP4Common.ReportingData;
- using CDP4Common.SiteDirectoryData;
+ using CDP4Common.Types;
- using Newtonsoft.Json.Linq;
+ using NLog;
///
- /// The purpose of the is to deserialize a JSON object to a
+ /// The purpose of the is to deserialize a JSON object to a
///
public static class ActualFiniteStateResolver
{
///
- /// Instantiate and deserialize the properties of a
+ /// The NLog logger
+ ///
+ private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
+
+ ///
+ /// Instantiate and deserialize the properties of a
///
- /// The containing the data
- /// The to instantiate
- public static CDP4Common.DTO.ActualFiniteState FromJsonObject(JObject jObject)
+ /// The containing the data
+ /// The to instantiate
+ public static CDP4Common.DTO.ActualFiniteState FromJsonObject(JsonElement jsonElement)
{
- var iid = jObject["iid"].ToObject();
- var revisionNumber = jObject["revisionNumber"].IsNullOrEmpty() ? 0 : jObject["revisionNumber"].ToObject();
- var actualFiniteState = new CDP4Common.DTO.ActualFiniteState(iid, revisionNumber);
+ if (!jsonElement.TryGetProperty("iid"u8, out var iid))
+ {
+ throw new DeSerializationException("the mandatory iid property is not available, the ActualFiniteStateResolver cannot be used to deserialize this JsonElement");
+ }
+
+ var revisionNumberValue = 0;
- if (!jObject["actor"].IsNullOrEmpty())
+ if (jsonElement.TryGetProperty("revisionNumber"u8, out var revisionNumber))
{
- actualFiniteState.Actor = jObject["actor"].ToObject();
+ revisionNumberValue = revisionNumber.GetInt32();
}
- if (!jObject["excludedDomain"].IsNullOrEmpty())
+ var actualFiniteState = new CDP4Common.DTO.ActualFiniteState(iid.GetGuid(), revisionNumberValue);
+
+ if (jsonElement.TryGetProperty("excludedDomain"u8, out var excludedDomainProperty) && excludedDomainProperty.ValueKind != JsonValueKind.Null)
{
- actualFiniteState.ExcludedDomain.AddRange(jObject["excludedDomain"].ToObject>());
+ foreach(var element in excludedDomainProperty.EnumerateArray())
+ {
+ actualFiniteState.ExcludedDomain.Add(element.GetGuid());
+ }
}
- if (!jObject["excludedPerson"].IsNullOrEmpty())
+ if (jsonElement.TryGetProperty("excludedPerson"u8, out var excludedPersonProperty) && excludedPersonProperty.ValueKind != JsonValueKind.Null)
{
- actualFiniteState.ExcludedPerson.AddRange(jObject["excludedPerson"].ToObject>());
+ foreach(var element in excludedPersonProperty.EnumerateArray())
+ {
+ actualFiniteState.ExcludedPerson.Add(element.GetGuid());
+ }
}
- if (!jObject["kind"].IsNullOrEmpty())
+ if (jsonElement.TryGetProperty("kind"u8, out var kindProperty))
{
- actualFiniteState.Kind = jObject["kind"].ToObject();
+ if(kindProperty.ValueKind == JsonValueKind.Null)
+ {
+ Logger.Trace("The non-nullabale kind property of the actualFiniteState {id} is null", actualFiniteState.Iid);
+ }
+ else
+ {
+ actualFiniteState.Kind = ActualFiniteStateKindDeserializer.Deserialize(kindProperty);
+ }
}
- if (!jObject["modifiedOn"].IsNullOrEmpty())
+ if (jsonElement.TryGetProperty("modifiedOn"u8, out var modifiedOnProperty))
{
- actualFiniteState.ModifiedOn = jObject["modifiedOn"].ToObject();
+ if(modifiedOnProperty.ValueKind == JsonValueKind.Null)
+ {
+ Logger.Trace("The non-nullabale modifiedOn property of the actualFiniteState {id} is null", actualFiniteState.Iid);
+ }
+ else
+ {
+ actualFiniteState.ModifiedOn = modifiedOnProperty.GetDateTime();
+ }
}
- if (!jObject["possibleState"].IsNullOrEmpty())
+ if (jsonElement.TryGetProperty("possibleState"u8, out var possibleStateProperty) && possibleStateProperty.ValueKind != JsonValueKind.Null)
{
- actualFiniteState.PossibleState.AddRange(jObject["possibleState"].ToObject>());
+ foreach(var element in possibleStateProperty.EnumerateArray())
+ {
+ actualFiniteState.PossibleState.Add(element.GetGuid());
+ }
}
- if (!jObject["thingPreference"].IsNullOrEmpty())
+ if (jsonElement.TryGetProperty("thingPreference"u8, out var thingPreferenceProperty))
{
- actualFiniteState.ThingPreference = jObject["thingPreference"].ToObject |