Skip to content

Commit

Permalink
[FIX] ICDPMessageBus inherits IDisposable and accessible from ISessio…
Browse files Browse the repository at this point in the history
…n interface (#302)

* [FIX] ICDPMessageBus inherits IDisposable
[ADD] ISession now implements CDPMessageBus property

* Correct semantic versioning

* review comments

* SQ suggestions
  • Loading branch information
lxatstariongroup authored Jan 24, 2024
1 parent f0b9fb4 commit 3292483
Show file tree
Hide file tree
Showing 15 changed files with 53 additions and 46 deletions.
2 changes: 1 addition & 1 deletion CDP4Common/CDP4Common.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<TargetFrameworks>net462;net47;net471;net472;net48;netstandard2.0;netstandard2.1</TargetFrameworks>
<Company>RHEA System S.A.</Company>
<Title>CDP4Common Community Edition</Title>
<VersionPrefix>25.0.0</VersionPrefix>
<VersionPrefix>25.1.0</VersionPrefix>
<Description>CDP4 Common Class Library that contains DTOs, POCOs</Description>
<Copyright>Copyright © RHEA System S.A.</Copyright>
<Authors>Sam, Merlin, Alex, Naron, Alexander, Yevhen, Nathanael, Ahmed</Authors>
Expand Down
4 changes: 3 additions & 1 deletion CDP4Dal/CDP4Dal.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<TargetFrameworks>net462;net47;net471;net472;net48;netstandard2.0;netstandard2.1</TargetFrameworks>
<Company>RHEA System S.A.</Company>
<Title>CDP4Dal Community Edition</Title>
<VersionPrefix>25.0.0</VersionPrefix>
<VersionPrefix>25.1.0</VersionPrefix>
<Description>CDP4 Data Access Layer library, a consumer of an ECSS-E-TM-10-25 Annex C API</Description>
<Copyright>Copyright © RHEA System S.A.</Copyright>
<Authors>Sam, Merlin, Alex, Naron, Alexander, Yevhen, Nathanael, Ahmed</Authors>
Expand All @@ -21,6 +21,8 @@
<PackageLicenseExpression>LGPL-3.0-only</PackageLicenseExpression>
<PackageReleaseNotes>
[REFACTOR] CDPMessageBus from static class to injectable interface implementation
[ADD] CDPMessageBus property to ISession
[FIX] ICDPMessageBus inherits IDisposable
</PackageReleaseNotes>
<PackageReadmeFile>README.md</PackageReadmeFile>
</PropertyGroup>
Expand Down
2 changes: 1 addition & 1 deletion CDP4Dal/CDPMessageBus.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ namespace CDP4Dal
[Export(typeof(ICDPMessageBus))]
[PartCreationPolicy(CreationPolicy.Shared)]
#endif
public class CDPMessageBus : ICDPMessageBus, IDisposable
public sealed class CDPMessageBus : ICDPMessageBus
{
/// <summary>
/// The <see cref="Dictionary{TKey,TValue}"/> holding the subscriptions.
Expand Down
2 changes: 1 addition & 1 deletion CDP4Dal/ICDPMessageBus.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ namespace CDP4Dal
/// <summary>
/// Defines the properties and methods of the <see cref="ICDPMessageBus"/> interface
/// </summary>
public interface ICDPMessageBus
public interface ICDPMessageBus : IDisposable
{
/// <summary>
/// Number of currently active Observables in this instance of the <see cref="ICDPMessageBus"/>;
Expand Down
5 changes: 5 additions & 0 deletions CDP4Dal/ISession.cs
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,11 @@ public interface ISession
/// </summary>
IReadOnlyDictionary<Iteration, Tuple<DomainOfExpertise,Participant> > OpenIterations { get; }

/// <summary>
/// Gets the <see cref="ICDPMessageBus"/> that handles messaging for this session
/// </summary>
ICDPMessageBus CDPMessageBus { get; }

/// <summary>
/// Retrieves the <see cref="SiteDirectory"/> in the context of the current session
/// </summary>
Expand Down
48 changes: 24 additions & 24 deletions CDP4Dal/Session.cs
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,6 @@ public class Session : ISession
/// </summary>
private readonly Dictionary<Iteration, Tuple<DomainOfExpertise, Participant>> openIterations;

/// <summary>
/// Gets the <see cref="ICDPMessageBus"/> that handles messaging for this session
/// </summary>
private readonly ICDPMessageBus messageBus;

/// <summary>
/// Initializes a new instance of the <see cref="Session"/> class.
/// </summary>
Expand All @@ -98,7 +93,7 @@ public class Session : ISession
/// </param>
public Session(IDal dal, Credentials credentials, ICDPMessageBus messageBus)
{
this.messageBus = messageBus;
this.CDPMessageBus = messageBus;
this.Credentials = credentials;
this.Dal = dal;
this.Dal.Session = this;
Expand Down Expand Up @@ -167,6 +162,11 @@ public IEnumerable<Participant> ActivePersonParticipants
}
}

/// <summary>
/// Gets the <see cref="ICDPMessageBus"/> that handles messaging for this session
/// </summary>
public ICDPMessageBus CDPMessageBus { get; }

/// <summary>
/// Gets the <see cref="CDP4Dal.Assembler"/> associated with the current <see cref="Session"/> containing the Cache
/// </summary>
Expand Down Expand Up @@ -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);

Expand All @@ -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);
}
Expand All @@ -385,7 +385,7 @@ public void SwitchDomain(Guid iterationId, DomainOfExpertise domain)
var selectedParticipation = new Tuple<DomainOfExpertise, Participant>(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));
}
}

Expand Down Expand Up @@ -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);
}

Expand Down Expand Up @@ -663,9 +663,9 @@ private async Task AfterReadOrWriteOrUpdate(IList<CDP4Common.DTO.Thing> things,

var sw = new Stopwatch();
logger.Info($"Synchronization of DTOs for {caller} from/to server {0} started", this.DataSourceUri);
this.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);
}

Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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));
}

/// <summary>
Expand Down Expand Up @@ -949,11 +949,11 @@ private async Task Update(Thing thing, bool isRefresh = true)
/// </returns>
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));
}

/// <summary>
Expand All @@ -964,7 +964,7 @@ public async Task CloseModelRdl(ModelReferenceDataLibrary modelRdl)
/// </param>
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);

Expand All @@ -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));
}

/// <summary>
Expand Down Expand Up @@ -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));
}

/// <summary>
Expand Down
4 changes: 2 additions & 2 deletions CDP4JsonFileDal/CDP4JsonFileDal.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<TargetFrameworks>net462;net47;net471;net472;net48;netstandard2.0;netstandard2.1</TargetFrameworks>
<Company>RHEA System S.A.</Company>
<Title>CDP4JsonFileDal Community Edition</Title>
<VersionPrefix>25.0.0</VersionPrefix>
<VersionPrefix>25.1.0</VersionPrefix>
<Description>CDP4 Json File Dal Plugin</Description>
<Copyright>Copyright © RHEA System S.A.</Copyright>
<Authors>Sam, Merlin, Alex, Naron, Alexander, Yevhen, Nathanael</Authors>
Expand All @@ -20,7 +20,7 @@
<PackageTags>CDP COMET ECSS-E-TM-10-25</PackageTags>
<PackageLicenseExpression>LGPL-3.0-only</PackageLicenseExpression>
<PackageReleaseNotes>
[UPGRADE] CDP4Common 25.0.0
[UPGRADE] CDP4Common 25.1.0
</PackageReleaseNotes>
<PackageReadmeFile>README.md</PackageReadmeFile>
</PropertyGroup>
Expand Down
4 changes: 2 additions & 2 deletions CDP4JsonSerializer/CDP4JsonSerializer.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<TargetFrameworks>net462;net47;net471;net472;net48;netstandard2.0;netstandard2.1</TargetFrameworks>
<Company>RHEA System S.A.</Company>
<Title>CDP4JsonSerializer Community Edition</Title>
<VersionPrefix>25.0.0</VersionPrefix>
<VersionPrefix>25.1.0</VersionPrefix>
<Description>CDP4 JSON Serialization Library</Description>
<Copyright>Copyright © RHEA System S.A.</Copyright>
<Authors>Sam, Merlin, Alex, Naron, Alexander, Yevhen, Nathanael</Authors>
Expand All @@ -20,7 +20,7 @@
<PackageTags>CDP COMET ECSS-E-TM-10-25 JSON</PackageTags>
<PackageLicenseExpression>LGPL-3.0-only</PackageLicenseExpression>
<PackageReleaseNotes>
[UPGRADE] CDP4Common 25.0.0
[UPGRADE] CDP4Common 25.1.0
</PackageReleaseNotes>
<PackageReadmeFile>README.md</PackageReadmeFile>
</PropertyGroup>
Expand Down
4 changes: 2 additions & 2 deletions CDP4MessagePackSerializer/CDP4MessagePackSerializer.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<TargetFrameworks>net462;net47;net471;net472;net48;netstandard2.0;netstandard2.1</TargetFrameworks>
<Company>RHEA System S.A.</Company>
<Title>CDP4MessagePackSerializer Community Edition</Title>
<VersionPrefix>25.0.0</VersionPrefix>
<VersionPrefix>25.1.0</VersionPrefix>
<Description>CDP4 MessagePack Serialization Library</Description>
<Copyright>Copyright © RHEA System S.A.</Copyright>
<Authors>Sam, Alex, Alexander, Nathanael, Antoine, Omar</Authors>
Expand All @@ -20,7 +20,7 @@
<PackageTags>CDP COMET ECSS-E-TM-10-25 MessagePack</PackageTags>
<PackageLicenseExpression>LGPL-3.0-only</PackageLicenseExpression>
<PackageReleaseNotes>
[UPGRADE] CDP4Common 25.0.0
[UPGRADE] CDP4Common 25.1.0
</PackageReleaseNotes>
<PackageReadmeFile>README.md</PackageReadmeFile>
</PropertyGroup>
Expand Down
4 changes: 2 additions & 2 deletions CDP4Reporting/CDP4Reporting.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<TargetFrameworks>netstandard2.0</TargetFrameworks>
<Company>RHEA System S.A.</Company>
<Title>CDP4Reporting Community Edition</Title>
<VersionPrefix>25.0.0</VersionPrefix>
<VersionPrefix>25.1.0</VersionPrefix>
<Description>CDP4 Reporting</Description>
<Copyright>Copyright © RHEA System S.A.</Copyright>
<Authors>Sam, Alex, Alexander</Authors>
Expand All @@ -20,7 +20,7 @@
<PackageTags>CDP COMET ECSS-E-TM-10-25</PackageTags>
<PackageLicenseExpression>LGPL-3.0-only</PackageLicenseExpression>
<PackageReleaseNotes>
[UPGRADE] CDP4Common 25.0.0
[UPGRADE] CDP4Common 25.1.0
</PackageReleaseNotes>
<LangVersion>latest</LangVersion>
<PackageReadmeFile>README.md</PackageReadmeFile>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<TargetFrameworks>net462;net47;net471;net472;net48;netstandard2.0;netstandard2.1</TargetFrameworks>
<Company>RHEA System S.A.</Company>
<Title>CDP4RequirementsVerification Community Edition</Title>
<VersionPrefix>25.0.0</VersionPrefix>
<VersionPrefix>25.1.0</VersionPrefix>
<Description>CDP4 Class Library that provides requirement verification</Description>
<Copyright>Copyright © RHEA System S.A.</Copyright>
<Authors>Sam, Alex, Alexander, Yevhen, Nathanael</Authors>
Expand All @@ -20,7 +20,7 @@
<PackageTags>CDP COMET ECSS-E-TM-10-25</PackageTags>
<PackageLicenseExpression>LGPL-3.0-only</PackageLicenseExpression>
<PackageReleaseNotes>
[UPGRADE] CDP4Common 25.0.0
[UPGRADE] CDP4Common 25.1.0
</PackageReleaseNotes>
<PackageReadmeFile>README.md</PackageReadmeFile>
</PropertyGroup>
Expand Down
4 changes: 2 additions & 2 deletions CDP4Rules/CDP4Rules.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<TargetFrameworks>net462;net47;net471;net472;net48;netstandard2.0;netstandard2.1</TargetFrameworks>
<Company>RHEA System S.A.</Company>
<Title>CDP4Rules Community Edition</Title>
<VersionPrefix>25.0.0</VersionPrefix>
<VersionPrefix>25.1.0</VersionPrefix>
<Description>CDP4 Class Library that provides Model Analysis and Rule Checking</Description>
<Copyright>Copyright © RHEA System S.A.</Copyright>
<Authors>Sam, Alex, Alexander, Yevhen, Nathanael</Authors>
Expand All @@ -20,7 +20,7 @@
<PackageTags>CDP COMET ECSS-E-TM-10-25</PackageTags>
<PackageLicenseExpression>LGPL-3.0-only</PackageLicenseExpression>
<PackageReleaseNotes>
[UPGRADE] CDP4Common 25.0.0
[UPGRADE] CDP4Common 25.1.0
</PackageReleaseNotes>
<PackageReadmeFile>README.md</PackageReadmeFile>
</PropertyGroup>
Expand Down
4 changes: 2 additions & 2 deletions CDP4ServicesDal/CDP4ServicesDal.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<TargetFrameworks>net462;net47;net471;net472;net48;netstandard2.0;netstandard2.1</TargetFrameworks>
<Company>RHEA System S.A.</Company>
<Title>CDP4ServicesDal Community Edition</Title>
<VersionPrefix>25.0.0</VersionPrefix>
<VersionPrefix>25.1.0</VersionPrefix>
<Description>CDP4ServicesDal Dal Plugin</Description>
<Copyright>Copyright © RHEA System S.A.</Copyright>
<Authors>Sam, Merlin, Alex, Naron, Alexander, Yevhen, Nathanael</Authors>
Expand All @@ -20,7 +20,7 @@
<PackageTags>CDP COMET ECSS-E-TM-10-25</PackageTags>
<PackageLicenseExpression>LGPL-3.0-only</PackageLicenseExpression>
<PackageReleaseNotes>
[UPGRADE] CDP4Common 25.0.0
[UPGRADE] CDP4Common 25.1.0
</PackageReleaseNotes>
<PackageReadmeFile>README.md</PackageReadmeFile>
</PropertyGroup>
Expand Down
4 changes: 2 additions & 2 deletions CDP4Web/CDP4Web.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<LangVersion>latest</LangVersion>
<Company>RHEA System S.A.</Company>
<Title>CDP4Web Community Edition</Title>
<VersionPrefix>25.0.0</VersionPrefix>
<VersionPrefix>25.1.0</VersionPrefix>
<Description>CDP4Web Dedicated Sdk for CDPServicesDal</Description>
<Copyright>Copyright © RHEA System S.A.</Copyright>
<Authors>Sam, Alex, Alexander, Nathanael, Antoine, Omar, Jaime</Authors>
Expand All @@ -21,7 +21,7 @@
<PackageTags>CDP COMET ECSS-E-TM-10-25</PackageTags>
<PackageLicenseExpression>LGPL-3.0-only</PackageLicenseExpression>
<PackageReleaseNotes>
[UPGRADE] CDP4Common 25.0.0
[UPGRADE] CDP4Common 25.1.0
</PackageReleaseNotes>
<PackageReadmeFile>README.md</PackageReadmeFile>
</PropertyGroup>
Expand Down
4 changes: 2 additions & 2 deletions CDP4WspDal/CDP4WspDal.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<TargetFrameworks>net462;net47;net471;net472;net48;netstandard2.0;netstandard2.1</TargetFrameworks>
<Company>RHEA System S.A.</Company>
<Title>CDP4WspDal Community Edition</Title>
<VersionPrefix>25.0.0</VersionPrefix>
<VersionPrefix>25.1.0</VersionPrefix>
<Description>CDP4 WSP Dal Plugin</Description>
<Copyright>Copyright © RHEA System S.A.</Copyright>
<Authors>Sam, Merlin, Alex, Naron, Alexander, Yevhen, Nathanael</Authors>
Expand All @@ -20,7 +20,7 @@
<PackageTags>CDP COMET ECSS-E-TM-10-25</PackageTags>
<PackageLicenseExpression>LGPL-3.0-only</PackageLicenseExpression>
<PackageReleaseNotes>
[UPGRADE] CDP4Common 25.0.0
[UPGRADE] CDP4Common 25.1.0
</PackageReleaseNotes>
<PackageReadmeFile>README.md</PackageReadmeFile>
</PropertyGroup>
Expand Down

0 comments on commit 3292483

Please sign in to comment.