From 3292483845a89f2d59695d04b5828daed68ae583 Mon Sep 17 00:00:00 2001 From: Alexander van Delft <56023674+lxatrhea@users.noreply.github.com> Date: Wed, 24 Jan 2024 14:32:33 +0100 Subject: [PATCH] [FIX] ICDPMessageBus inherits IDisposable and accessible from ISession interface (#302) * [FIX] ICDPMessageBus inherits IDisposable [ADD] ISession now implements CDPMessageBus property * Correct semantic versioning * review comments * SQ suggestions --- CDP4Common/CDP4Common.csproj | 2 +- CDP4Dal/CDP4Dal.csproj | 4 +- CDP4Dal/CDPMessageBus.cs | 2 +- CDP4Dal/ICDPMessageBus.cs | 2 +- CDP4Dal/ISession.cs | 5 ++ CDP4Dal/Session.cs | 48 +++++++++---------- CDP4JsonFileDal/CDP4JsonFileDal.csproj | 4 +- CDP4JsonSerializer/CDP4JsonSerializer.csproj | 4 +- .../CDP4MessagePackSerializer.csproj | 4 +- CDP4Reporting/CDP4Reporting.csproj | 4 +- .../CDP4RequirementsVerification.csproj | 4 +- CDP4Rules/CDP4Rules.csproj | 4 +- CDP4ServicesDal/CDP4ServicesDal.csproj | 4 +- CDP4Web/CDP4Web.csproj | 4 +- CDP4WspDal/CDP4WspDal.csproj | 4 +- 15 files changed, 53 insertions(+), 46 deletions(-) diff --git a/CDP4Common/CDP4Common.csproj b/CDP4Common/CDP4Common.csproj index 39b4eab8..5d5571e1 100644 --- a/CDP4Common/CDP4Common.csproj +++ b/CDP4Common/CDP4Common.csproj @@ -4,7 +4,7 @@ net462;net47;net471;net472;net48;netstandard2.0;netstandard2.1 RHEA System S.A. CDP4Common Community Edition - 25.0.0 + 25.1.0 CDP4 Common Class Library that contains DTOs, POCOs Copyright © RHEA System S.A. Sam, Merlin, Alex, Naron, Alexander, Yevhen, Nathanael, Ahmed diff --git a/CDP4Dal/CDP4Dal.csproj b/CDP4Dal/CDP4Dal.csproj index e09051d3..c4a55ab5 100644 --- a/CDP4Dal/CDP4Dal.csproj +++ b/CDP4Dal/CDP4Dal.csproj @@ -4,7 +4,7 @@ net462;net47;net471;net472;net48;netstandard2.0;netstandard2.1 RHEA System S.A. CDP4Dal Community Edition - 25.0.0 + 25.1.0 CDP4 Data Access Layer library, a consumer of an ECSS-E-TM-10-25 Annex C API Copyright © RHEA System S.A. Sam, Merlin, Alex, Naron, Alexander, Yevhen, Nathanael, Ahmed @@ -21,6 +21,8 @@ LGPL-3.0-only [REFACTOR] CDPMessageBus from static class to injectable interface implementation + [ADD] CDPMessageBus property to ISession + [FIX] ICDPMessageBus inherits IDisposable README.md diff --git a/CDP4Dal/CDPMessageBus.cs b/CDP4Dal/CDPMessageBus.cs index 16de858a..233c1e48 100644 --- a/CDP4Dal/CDPMessageBus.cs +++ b/CDP4Dal/CDPMessageBus.cs @@ -52,7 +52,7 @@ namespace CDP4Dal [Export(typeof(ICDPMessageBus))] [PartCreationPolicy(CreationPolicy.Shared)] #endif - public class CDPMessageBus : ICDPMessageBus, IDisposable + public sealed class CDPMessageBus : ICDPMessageBus { /// /// The holding the subscriptions. diff --git a/CDP4Dal/ICDPMessageBus.cs b/CDP4Dal/ICDPMessageBus.cs index 2b833e8c..0866e126 100644 --- a/CDP4Dal/ICDPMessageBus.cs +++ b/CDP4Dal/ICDPMessageBus.cs @@ -33,7 +33,7 @@ namespace CDP4Dal /// /// Defines the properties and methods of the interface /// - public interface ICDPMessageBus + public interface ICDPMessageBus : IDisposable { /// /// Number of currently active Observables in this instance of the ; diff --git a/CDP4Dal/ISession.cs b/CDP4Dal/ISession.cs index 9046539b..5c97f44c 100644 --- a/CDP4Dal/ISession.cs +++ b/CDP4Dal/ISession.cs @@ -116,6 +116,11 @@ public interface ISession /// IReadOnlyDictionary > OpenIterations { get; } + /// + /// Gets the that handles messaging for this session + /// + ICDPMessageBus CDPMessageBus { get; } + /// /// Retrieves the in the context of the current session /// diff --git a/CDP4Dal/Session.cs b/CDP4Dal/Session.cs index b0e2e31f..806222a0 100644 --- a/CDP4Dal/Session.cs +++ b/CDP4Dal/Session.cs @@ -79,11 +79,6 @@ public class Session : ISession /// private readonly Dictionary> openIterations; - /// - /// Gets the that handles messaging for this session - /// - private readonly ICDPMessageBus messageBus; - /// /// Initializes a new instance of the class. /// @@ -98,7 +93,7 @@ public class Session : ISession /// public Session(IDal dal, Credentials credentials, ICDPMessageBus messageBus) { - this.messageBus = messageBus; + this.CDPMessageBus = messageBus; this.Credentials = credentials; this.Dal = dal; this.Dal.Session = this; @@ -167,6 +162,11 @@ public IEnumerable ActivePersonParticipants } } + /// + /// Gets the that handles messaging for this session + /// + public ICDPMessageBus CDPMessageBus { get; } + /// /// Gets the associated with the current containing the Cache /// @@ -344,7 +344,7 @@ public async Task Open(bool activeMessageBus = true) logger.Warn("no data returned upon Open on {0}", this.DataSourceUri); } - this.messageBus.SendMessage(new SessionEvent(this, SessionStatus.BeginUpdate)); + this.CDPMessageBus.SendMessage(new SessionEvent(this, SessionStatus.BeginUpdate)); await this.Assembler.Synchronize(dtoThings, activeMessageBus); @@ -361,12 +361,12 @@ public async Task Open(bool activeMessageBus = true) throw new IncompleteModelException("The Person object that matches the user specified in the Credentials could not be found"); } - this.messageBus.SendMessage(new SessionEvent(this, SessionStatus.EndUpdate)); + this.CDPMessageBus.SendMessage(new SessionEvent(this, SessionStatus.EndUpdate)); logger.Info("Synchronization with the {0} server done in {1} [ms]", this.DataSourceUri, sw.ElapsedMilliseconds); var sessionChange = new SessionEvent(this, SessionStatus.Open); - this.messageBus.SendMessage(sessionChange); + this.CDPMessageBus.SendMessage(sessionChange); logger.Info("Session {0} opened successfully in {1} [ms]", this.DataSourceUri, sw.ElapsedMilliseconds); } @@ -385,7 +385,7 @@ public void SwitchDomain(Guid iterationId, DomainOfExpertise domain) var selectedParticipation = new Tuple(domain, iterationPair.Value.Item2); this.openIterations.Remove(iterationPair.Key); this.openIterations.Add(iterationPair.Key, selectedParticipation); - this.messageBus.SendMessage(new DomainChangedEvent(iterationPair.Key, domain)); + this.CDPMessageBus.SendMessage(new DomainChangedEvent(iterationPair.Key, domain)); } } @@ -453,13 +453,13 @@ public async Task Read(Iteration iteration, DomainOfExpertise domain, bool activ logger.Warn("no data returned upon Read on {0}", this.DataSourceUri); } - this.messageBus.SendMessage(new SessionEvent(this, SessionStatus.BeginUpdate)); + this.CDPMessageBus.SendMessage(new SessionEvent(this, SessionStatus.BeginUpdate)); await this.Assembler.Synchronize(enumerable, activeMessageBus); this.AddIterationToOpenList(iteration.Iid, domain); - this.messageBus.SendMessage(new SessionEvent(this, SessionStatus.EndUpdate)); + this.CDPMessageBus.SendMessage(new SessionEvent(this, SessionStatus.EndUpdate)); logger.Info("Synchronization with the {0} server done", this.DataSourceUri); } @@ -663,9 +663,9 @@ private async Task AfterReadOrWriteOrUpdate(IList things, var sw = new Stopwatch(); logger.Info($"Synchronization of DTOs for {caller} from/to server {0} started", this.DataSourceUri); - this.messageBus.SendMessage(new SessionEvent(this, SessionStatus.BeginUpdate)); + this.CDPMessageBus.SendMessage(new SessionEvent(this, SessionStatus.BeginUpdate)); await this.Assembler.Synchronize(things); - this.messageBus.SendMessage(new SessionEvent(this, SessionStatus.EndUpdate)); + this.CDPMessageBus.SendMessage(new SessionEvent(this, SessionStatus.EndUpdate)); logger.Info($"Synchronization of DTOs for {caller} from/to server {0} done in {1} [ms]", this.DataSourceUri, sw.ElapsedMilliseconds); } @@ -835,7 +835,7 @@ public async Task Close() await this.Assembler.Clear(); var sessionChange = new SessionEvent(this, SessionStatus.Closed); - this.messageBus.SendMessage(sessionChange); + this.CDPMessageBus.SendMessage(sessionChange); logger.Info("Session {0} closed successfully", this.DataSourceUri); this.openReferenceDataLibraries.Clear(); @@ -881,16 +881,16 @@ public async Task CloseRdl(SiteReferenceDataLibrary sRdl) tasks.Add(this.Assembler.CloseRdl(siteReferenceDataLibrary)); } - this.messageBus.SendMessage(new SessionEvent(this, SessionStatus.BeginUpdate)); + this.CDPMessageBus.SendMessage(new SessionEvent(this, SessionStatus.BeginUpdate)); await Task.WhenAll(tasks); - this.messageBus.SendMessage(new SessionEvent(this, SessionStatus.EndUpdate)); + this.CDPMessageBus.SendMessage(new SessionEvent(this, SessionStatus.EndUpdate)); foreach (var siteReferenceDataLibrary in orderedRdlsToClose) { this.openReferenceDataLibraries.Remove(siteReferenceDataLibrary); } - this.messageBus.SendMessage(new SessionEvent(this, SessionStatus.RdlClosed)); + this.CDPMessageBus.SendMessage(new SessionEvent(this, SessionStatus.RdlClosed)); } /// @@ -949,11 +949,11 @@ private async Task Update(Thing thing, bool isRefresh = true) /// public async Task CloseModelRdl(ModelReferenceDataLibrary modelRdl) { - this.messageBus.SendMessage(new SessionEvent(this, SessionStatus.BeginUpdate)); + this.CDPMessageBus.SendMessage(new SessionEvent(this, SessionStatus.BeginUpdate)); await this.Assembler.CloseRdl(modelRdl); - this.messageBus.SendMessage(new SessionEvent(this, SessionStatus.EndUpdate)); + this.CDPMessageBus.SendMessage(new SessionEvent(this, SessionStatus.EndUpdate)); this.openReferenceDataLibraries.Remove(modelRdl); - this.messageBus.SendMessage(new SessionEvent(this, SessionStatus.RdlClosed)); + this.CDPMessageBus.SendMessage(new SessionEvent(this, SessionStatus.RdlClosed)); } /// @@ -964,7 +964,7 @@ public async Task CloseModelRdl(ModelReferenceDataLibrary modelRdl) /// public async Task CloseIterationSetup(IterationSetup iterationSetup) { - this.messageBus.SendMessage(new SessionEvent(this, SessionStatus.BeginUpdate)); + this.CDPMessageBus.SendMessage(new SessionEvent(this, SessionStatus.BeginUpdate)); await this.Assembler.CloseIterationSetup(iterationSetup); @@ -975,7 +975,7 @@ public async Task CloseIterationSetup(IterationSetup iterationSetup) this.openIterations.Remove(iterationToRemove); } - this.messageBus.SendMessage(new SessionEvent(this, SessionStatus.EndUpdate)); + this.CDPMessageBus.SendMessage(new SessionEvent(this, SessionStatus.EndUpdate)); } /// @@ -1057,7 +1057,7 @@ private void AddRdlToOpenList(Thing thing) this.openReferenceDataLibraries.Add(rdl); this.openReferenceDataLibraries.AddRange(rdl.GetRequiredRdls().Except(this.openReferenceDataLibraries)); - this.messageBus.SendMessage(new SessionEvent(this, SessionStatus.RdlOpened)); + this.CDPMessageBus.SendMessage(new SessionEvent(this, SessionStatus.RdlOpened)); } /// diff --git a/CDP4JsonFileDal/CDP4JsonFileDal.csproj b/CDP4JsonFileDal/CDP4JsonFileDal.csproj index de51de02..d9fe76a3 100644 --- a/CDP4JsonFileDal/CDP4JsonFileDal.csproj +++ b/CDP4JsonFileDal/CDP4JsonFileDal.csproj @@ -4,7 +4,7 @@ net462;net47;net471;net472;net48;netstandard2.0;netstandard2.1 RHEA System S.A. CDP4JsonFileDal Community Edition - 25.0.0 + 25.1.0 CDP4 Json File Dal Plugin Copyright © RHEA System S.A. Sam, Merlin, Alex, Naron, Alexander, Yevhen, Nathanael @@ -20,7 +20,7 @@ CDP COMET ECSS-E-TM-10-25 LGPL-3.0-only - [UPGRADE] CDP4Common 25.0.0 + [UPGRADE] CDP4Common 25.1.0 README.md diff --git a/CDP4JsonSerializer/CDP4JsonSerializer.csproj b/CDP4JsonSerializer/CDP4JsonSerializer.csproj index 65db4445..4861ee76 100644 --- a/CDP4JsonSerializer/CDP4JsonSerializer.csproj +++ b/CDP4JsonSerializer/CDP4JsonSerializer.csproj @@ -4,7 +4,7 @@ net462;net47;net471;net472;net48;netstandard2.0;netstandard2.1 RHEA System S.A. CDP4JsonSerializer Community Edition - 25.0.0 + 25.1.0 CDP4 JSON Serialization Library Copyright © RHEA System S.A. Sam, Merlin, Alex, Naron, Alexander, Yevhen, Nathanael @@ -20,7 +20,7 @@ CDP COMET ECSS-E-TM-10-25 JSON LGPL-3.0-only - [UPGRADE] CDP4Common 25.0.0 + [UPGRADE] CDP4Common 25.1.0 README.md diff --git a/CDP4MessagePackSerializer/CDP4MessagePackSerializer.csproj b/CDP4MessagePackSerializer/CDP4MessagePackSerializer.csproj index 788e58af..7ebf5c40 100644 --- a/CDP4MessagePackSerializer/CDP4MessagePackSerializer.csproj +++ b/CDP4MessagePackSerializer/CDP4MessagePackSerializer.csproj @@ -4,7 +4,7 @@ net462;net47;net471;net472;net48;netstandard2.0;netstandard2.1 RHEA System S.A. CDP4MessagePackSerializer Community Edition - 25.0.0 + 25.1.0 CDP4 MessagePack Serialization Library Copyright © RHEA System S.A. Sam, Alex, Alexander, Nathanael, Antoine, Omar @@ -20,7 +20,7 @@ CDP COMET ECSS-E-TM-10-25 MessagePack LGPL-3.0-only - [UPGRADE] CDP4Common 25.0.0 + [UPGRADE] CDP4Common 25.1.0 README.md diff --git a/CDP4Reporting/CDP4Reporting.csproj b/CDP4Reporting/CDP4Reporting.csproj index d08dd59f..bcd34bec 100644 --- a/CDP4Reporting/CDP4Reporting.csproj +++ b/CDP4Reporting/CDP4Reporting.csproj @@ -4,7 +4,7 @@ netstandard2.0 RHEA System S.A. CDP4Reporting Community Edition - 25.0.0 + 25.1.0 CDP4 Reporting Copyright © RHEA System S.A. Sam, Alex, Alexander @@ -20,7 +20,7 @@ CDP COMET ECSS-E-TM-10-25 LGPL-3.0-only - [UPGRADE] CDP4Common 25.0.0 + [UPGRADE] CDP4Common 25.1.0 latest README.md diff --git a/CDP4RequirementsVerification/CDP4RequirementsVerification.csproj b/CDP4RequirementsVerification/CDP4RequirementsVerification.csproj index 3ef2a1cc..d87606d6 100644 --- a/CDP4RequirementsVerification/CDP4RequirementsVerification.csproj +++ b/CDP4RequirementsVerification/CDP4RequirementsVerification.csproj @@ -4,7 +4,7 @@ net462;net47;net471;net472;net48;netstandard2.0;netstandard2.1 RHEA System S.A. CDP4RequirementsVerification Community Edition - 25.0.0 + 25.1.0 CDP4 Class Library that provides requirement verification Copyright © RHEA System S.A. Sam, Alex, Alexander, Yevhen, Nathanael @@ -20,7 +20,7 @@ CDP COMET ECSS-E-TM-10-25 LGPL-3.0-only - [UPGRADE] CDP4Common 25.0.0 + [UPGRADE] CDP4Common 25.1.0 README.md diff --git a/CDP4Rules/CDP4Rules.csproj b/CDP4Rules/CDP4Rules.csproj index 198f8ff1..7dd41542 100644 --- a/CDP4Rules/CDP4Rules.csproj +++ b/CDP4Rules/CDP4Rules.csproj @@ -4,7 +4,7 @@ net462;net47;net471;net472;net48;netstandard2.0;netstandard2.1 RHEA System S.A. CDP4Rules Community Edition - 25.0.0 + 25.1.0 CDP4 Class Library that provides Model Analysis and Rule Checking Copyright © RHEA System S.A. Sam, Alex, Alexander, Yevhen, Nathanael @@ -20,7 +20,7 @@ CDP COMET ECSS-E-TM-10-25 LGPL-3.0-only - [UPGRADE] CDP4Common 25.0.0 + [UPGRADE] CDP4Common 25.1.0 README.md diff --git a/CDP4ServicesDal/CDP4ServicesDal.csproj b/CDP4ServicesDal/CDP4ServicesDal.csproj index 8ce916fd..d088bde3 100644 --- a/CDP4ServicesDal/CDP4ServicesDal.csproj +++ b/CDP4ServicesDal/CDP4ServicesDal.csproj @@ -4,7 +4,7 @@ net462;net47;net471;net472;net48;netstandard2.0;netstandard2.1 RHEA System S.A. CDP4ServicesDal Community Edition - 25.0.0 + 25.1.0 CDP4ServicesDal Dal Plugin Copyright © RHEA System S.A. Sam, Merlin, Alex, Naron, Alexander, Yevhen, Nathanael @@ -20,7 +20,7 @@ CDP COMET ECSS-E-TM-10-25 LGPL-3.0-only - [UPGRADE] CDP4Common 25.0.0 + [UPGRADE] CDP4Common 25.1.0 README.md diff --git a/CDP4Web/CDP4Web.csproj b/CDP4Web/CDP4Web.csproj index 4ec21219..c194fe6d 100644 --- a/CDP4Web/CDP4Web.csproj +++ b/CDP4Web/CDP4Web.csproj @@ -5,7 +5,7 @@ latest RHEA System S.A. CDP4Web Community Edition - 25.0.0 + 25.1.0 CDP4Web Dedicated Sdk for CDPServicesDal Copyright © RHEA System S.A. Sam, Alex, Alexander, Nathanael, Antoine, Omar, Jaime @@ -21,7 +21,7 @@ CDP COMET ECSS-E-TM-10-25 LGPL-3.0-only - [UPGRADE] CDP4Common 25.0.0 + [UPGRADE] CDP4Common 25.1.0 README.md diff --git a/CDP4WspDal/CDP4WspDal.csproj b/CDP4WspDal/CDP4WspDal.csproj index 88769ca8..d346b4c0 100644 --- a/CDP4WspDal/CDP4WspDal.csproj +++ b/CDP4WspDal/CDP4WspDal.csproj @@ -4,7 +4,7 @@ net462;net47;net471;net472;net48;netstandard2.0;netstandard2.1 RHEA System S.A. CDP4WspDal Community Edition - 25.0.0 + 25.1.0 CDP4 WSP Dal Plugin Copyright © RHEA System S.A. Sam, Merlin, Alex, Naron, Alexander, Yevhen, Nathanael @@ -20,7 +20,7 @@ CDP COMET ECSS-E-TM-10-25 LGPL-3.0-only - [UPGRADE] CDP4Common 25.0.0 + [UPGRADE] CDP4Common 25.1.0 README.md