From 2b5db41b92d6c56dad23cda59bfeae5656b8826d Mon Sep 17 00:00:00 2001 From: Neil South Date: Mon, 15 Jan 2024 09:59:21 +0000 Subject: [PATCH] changes around HL7 endpoints Signed-off-by: Neil South --- src/Api/HL7DestinationEntity.cs | 6 +- src/Api/Models/BaseApplicationEntity.cs | 10 +- .../Models/DestinationApplicationEntity.cs | 16 + src/Api/SourceApplicationEntity.cs | 15 + src/Api/Test/HL7DestinationEntityTest.cs | 15 +- ....cs => SourceBaseApplicationEntityTest.cs} | 7 +- src/Configuration/ValidationExtensions.cs | 3 +- .../HL7DestinationEntityConfiguration.cs | 3 +- ...2151448_ApplicationEntityTweek.Designer.cs | 504 ++++++++++++++++++ .../20240112151448_ApplicationEntityTweek.cs | 46 ++ .../InformaticsGatewayContextModelSnapshot.cs | 6 +- .../HL7DestinationEntityRepositoryTest.cs | 12 +- .../Test/SqliteDatabaseFixture.cs | 10 +- .../HL7DestinationEntityRepositoryTest.cs | 12 +- .../Integration.Test/MongoDatabaseFixture.cs | 10 +- .../HL7DestinationEntityRepository.cs | 1 - .../Logging/Log.8000.HttpServices.cs | 8 +- .../Services/Http/HL7DestinationController.cs | 15 +- .../StepDefinitions/Hl7StepDefinitions.cs | 1 - 19 files changed, 621 insertions(+), 79 deletions(-) mode change 100644 => 100755 src/Api/HL7DestinationEntity.cs mode change 100644 => 100755 src/Api/Test/HL7DestinationEntityTest.cs rename src/Api/Test/{BaseApplicationEntityTest.cs => SourceBaseApplicationEntityTest.cs} (87%) mode change 100644 => 100755 src/Database/EntityFramework/Configuration/HL7DestinationEntityConfiguration.cs create mode 100755 src/Database/EntityFramework/Migrations/20240112151448_ApplicationEntityTweek.Designer.cs create mode 100755 src/Database/EntityFramework/Migrations/20240112151448_ApplicationEntityTweek.cs mode change 100644 => 100755 src/Database/EntityFramework/Test/HL7DestinationEntityRepositoryTest.cs mode change 100644 => 100755 src/Database/MongoDB/Integration.Test/HL7DestinationEntityRepositoryTest.cs mode change 100644 => 100755 src/InformaticsGateway/Logging/Log.8000.HttpServices.cs diff --git a/src/Api/HL7DestinationEntity.cs b/src/Api/HL7DestinationEntity.cs old mode 100644 new mode 100755 index 33655bdde..317585934 --- a/src/Api/HL7DestinationEntity.cs +++ b/src/Api/HL7DestinationEntity.cs @@ -25,7 +25,6 @@ namespace Monai.Deploy.InformaticsGateway.Api.Models /// { /// "name": "MYPACS", /// "hostIp": "10.20.100.200", - /// "aeTitle": "MONAIPACS", /// "port": 1104 /// } /// @@ -36,5 +35,10 @@ public class HL7DestinationEntity : BaseApplicationEntity /// Gets or sets the port to connect to. /// public int Port { get; set; } + + public override string ToString() + { + return $"Name: {Name}/Host: {HostIp}/Port: {Port}"; + } } } diff --git a/src/Api/Models/BaseApplicationEntity.cs b/src/Api/Models/BaseApplicationEntity.cs index 0de7a3e39..d9998795b 100755 --- a/src/Api/Models/BaseApplicationEntity.cs +++ b/src/Api/Models/BaseApplicationEntity.cs @@ -35,10 +35,6 @@ public class BaseApplicationEntity : MongoDBEntityBase /// public string Name { get; set; } = default!; - /// - /// Gets or sets the AE Title (AET) used to identify itself in a DICOM association. - /// - public string AeTitle { get; set; } = default!; /// /// Gets or set the host name or IP address of the AE Title. @@ -65,10 +61,8 @@ public BaseApplicationEntity() SetDefaultValues(); } - public void SetDefaultValues() + public virtual void SetDefaultValues() { - if (string.IsNullOrWhiteSpace(Name)) - Name = AeTitle; } public void SetAuthor(ClaimsPrincipal user, EditMode editMode) @@ -90,7 +84,7 @@ public void SetAuthor(ClaimsPrincipal user, EditMode editMode) public override string ToString() { - return $"Name: {Name}/AET: {AeTitle}/Host: {HostIp}"; + return $"Name: {Name} /Host: {HostIp}"; } } } diff --git a/src/Api/Models/DestinationApplicationEntity.cs b/src/Api/Models/DestinationApplicationEntity.cs index 4a7069edd..6ad00ac05 100755 --- a/src/Api/Models/DestinationApplicationEntity.cs +++ b/src/Api/Models/DestinationApplicationEntity.cs @@ -36,5 +36,21 @@ public class DestinationApplicationEntity : BaseApplicationEntity /// Gets or sets the port to connect to. /// public int Port { get; set; } + + /// + /// Gets or sets the AE Title (AET) used to identify itself in a DICOM association. + /// + public string AeTitle { get; set; } = default!; + + public override void SetDefaultValues() + { + if (string.IsNullOrWhiteSpace(Name)) + Name = AeTitle; + } + + public override string ToString() + { + return $"Name: {Name}/AET: {AeTitle}/Host: {HostIp}/Port: {Port}"; + } } } diff --git a/src/Api/SourceApplicationEntity.cs b/src/Api/SourceApplicationEntity.cs index b46a61b8c..09edd983f 100755 --- a/src/Api/SourceApplicationEntity.cs +++ b/src/Api/SourceApplicationEntity.cs @@ -33,5 +33,20 @@ namespace Monai.Deploy.InformaticsGateway.Api /// public class SourceApplicationEntity : BaseApplicationEntity { + /// + /// Gets or sets the AE Title (AET) used to identify itself in a DICOM association. + /// + public string AeTitle { get; set; } = default!; + + public override void SetDefaultValues() + { + if (string.IsNullOrWhiteSpace(Name)) + Name = AeTitle; + } + + public override string ToString() + { + return $"Name: {Name}/AET: {AeTitle}/Host: {HostIp}"; + } } } diff --git a/src/Api/Test/HL7DestinationEntityTest.cs b/src/Api/Test/HL7DestinationEntityTest.cs old mode 100644 new mode 100755 index 181f1fd9e..1a3d1b027 --- a/src/Api/Test/HL7DestinationEntityTest.cs +++ b/src/Api/Test/HL7DestinationEntityTest.cs @@ -21,34 +21,23 @@ namespace Monai.Deploy.InformaticsGateway.Api.Test { public class HL7DestinationEntityTest { - [Fact] - public void GivenAMonaiApplicationEntity_WhenNameIsNotSet_ExepectSetDefaultValuesToBeUsed() - { - var entity = new HL7DestinationEntity - { - AeTitle = "AET", - }; - - entity.SetDefaultValues(); - Assert.Equal(entity.AeTitle, entity.Name); - } [Fact] public void GivenAMonaiApplicationEntity_WhenNameIsSet_ExepectSetDefaultValuesToNotOverwrite() { var entity = new HL7DestinationEntity { - AeTitle = "AET", + Port = 1104, HostIp = "IP", Name = "Name" }; entity.SetDefaultValues(); - Assert.Equal("AET", entity.AeTitle); Assert.Equal("IP", entity.HostIp); Assert.Equal("Name", entity.Name); + Assert.Equal(1104, entity.Port); } } } diff --git a/src/Api/Test/BaseApplicationEntityTest.cs b/src/Api/Test/SourceBaseApplicationEntityTest.cs similarity index 87% rename from src/Api/Test/BaseApplicationEntityTest.cs rename to src/Api/Test/SourceBaseApplicationEntityTest.cs index 6fcfd032c..801fc9049 100755 --- a/src/Api/Test/BaseApplicationEntityTest.cs +++ b/src/Api/Test/SourceBaseApplicationEntityTest.cs @@ -14,17 +14,16 @@ * limitations under the License. */ -using Monai.Deploy.InformaticsGateway.Api.Models; using Xunit; namespace Monai.Deploy.InformaticsGateway.Api.Test { - public class BaseApplicationEntityTest + public class SourceBaseApplicationEntityTest { [Fact] public void GivenABaseApplicationEntity_WhenNameIsNotSet_ExpectSetDefaultValuesToSetName() { - var entity = new BaseApplicationEntity + var entity = new SourceApplicationEntity { AeTitle = "AET", HostIp = "IP" @@ -38,7 +37,7 @@ public void GivenABaseApplicationEntity_WhenNameIsNotSet_ExpectSetDefaultValuesT [Fact] public void GivenABaseApplicationEntity_WhenNameIsSet_ExpectSetDefaultValuesToNotSetName() { - var entity = new BaseApplicationEntity + var entity = new SourceApplicationEntity { AeTitle = "AET", HostIp = "IP", diff --git a/src/Configuration/ValidationExtensions.cs b/src/Configuration/ValidationExtensions.cs index 09e7bc932..a326b6283 100755 --- a/src/Configuration/ValidationExtensions.cs +++ b/src/Configuration/ValidationExtensions.cs @@ -66,8 +66,7 @@ public static bool IsValid(this HL7DestinationEntity hl7destinationEntity, out I var valid = true; valid &= !string.IsNullOrWhiteSpace(hl7destinationEntity.Name); - valid &= IsAeTitleValid(hl7destinationEntity.GetType().Name, hl7destinationEntity.AeTitle, validationErrors); - valid &= IsValidHostNameIp(hl7destinationEntity.AeTitle, hl7destinationEntity.HostIp, validationErrors); + valid &= IsValidHostNameIp(hl7destinationEntity.Name, hl7destinationEntity.HostIp, validationErrors); valid &= IsPortValid(hl7destinationEntity.GetType().Name, hl7destinationEntity.Port, validationErrors); return valid; diff --git a/src/Database/EntityFramework/Configuration/HL7DestinationEntityConfiguration.cs b/src/Database/EntityFramework/Configuration/HL7DestinationEntityConfiguration.cs old mode 100644 new mode 100755 index 703dad6f3..8bffd2a6d --- a/src/Database/EntityFramework/Configuration/HL7DestinationEntityConfiguration.cs +++ b/src/Database/EntityFramework/Configuration/HL7DestinationEntityConfiguration.cs @@ -26,7 +26,6 @@ internal class HL7DestinationEntityConfiguration : IEntityTypeConfiguration builder) { builder.HasKey(j => j.Name); - builder.Property(j => j.AeTitle).IsRequired(); builder.Property(j => j.Port).IsRequired(); builder.Property(j => j.HostIp).IsRequired(); builder.Property(j => j.CreatedBy).IsRequired(false); @@ -35,7 +34,7 @@ public void Configure(EntityTypeBuilder builder) builder.Property(j => j.DateTimeUpdated).IsRequired(false); builder.HasIndex(p => p.Name, "idx_destination_name").IsUnique(); - builder.HasIndex(p => new { p.Name, p.AeTitle, p.HostIp, p.Port }, "idx_source_all").IsUnique(); + builder.HasIndex(p => new { p.Name, p.HostIp, p.Port }, "idx_source_all").IsUnique(); builder.Ignore(p => p.Id); } diff --git a/src/Database/EntityFramework/Migrations/20240112151448_ApplicationEntityTweek.Designer.cs b/src/Database/EntityFramework/Migrations/20240112151448_ApplicationEntityTweek.Designer.cs new file mode 100755 index 000000000..d90ede655 --- /dev/null +++ b/src/Database/EntityFramework/Migrations/20240112151448_ApplicationEntityTweek.Designer.cs @@ -0,0 +1,504 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Monai.Deploy.InformaticsGateway.Database.EntityFramework; + +#nullable disable + +namespace Monai.Deploy.InformaticsGateway.Database.Migrations +{ + [DbContext(typeof(InformaticsGatewayContext))] + [Migration("20240112151448_ApplicationEntityTweek")] + partial class ApplicationEntityTweek + { + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder.HasAnnotation("ProductVersion", "6.0.25"); + + modelBuilder.Entity("Monai.Deploy.InformaticsGateway.Api.Hl7ApplicationConfigEntity", b => + { + b.Property("Name") + .HasColumnType("TEXT") + .HasColumnOrder(0); + + b.Property("DataLink") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("DataMapping") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("DateTimeCreated") + .HasColumnType("TEXT"); + + b.Property("LastModified") + .HasColumnType("TEXT"); + + b.Property("PlugInAssemblies") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("SendingId") + .IsRequired() + .HasColumnType("TEXT"); + + b.HasKey("Name"); + + b.HasIndex(new[] { "Name" }, "idx_hl7_name") + .IsUnique(); + + b.ToTable("Hl7ApplicationConfig"); + }); + + modelBuilder.Entity("Monai.Deploy.InformaticsGateway.Api.Models.DestinationApplicationEntity", b => + { + b.Property("Name") + .HasColumnType("TEXT"); + + b.Property("AeTitle") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("CreatedBy") + .HasColumnType("TEXT"); + + b.Property("DateTimeCreated") + .HasColumnType("TEXT"); + + b.Property("DateTimeUpdated") + .HasColumnType("TEXT"); + + b.Property("HostIp") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("Port") + .HasColumnType("INTEGER"); + + b.Property("UpdatedBy") + .HasColumnType("TEXT"); + + b.HasKey("Name"); + + b.HasIndex(new[] { "Name" }, "idx_destination_name") + .IsUnique(); + + b.HasIndex(new[] { "Name", "AeTitle", "HostIp", "Port" }, "idx_source_all") + .IsUnique(); + + b.ToTable("DestinationApplicationEntities"); + }); + + modelBuilder.Entity("Monai.Deploy.InformaticsGateway.Api.Models.DicomAssociationInfo", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("TEXT"); + + b.Property("CalledAeTitle") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("CallingAeTitle") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("CorrelationId") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("DateTimeCreated") + .HasColumnType("TEXT"); + + b.Property("DateTimeDisconnected") + .HasColumnType("TEXT"); + + b.Property("Duration") + .HasColumnType("TEXT"); + + b.Property("Errors") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("FileCount") + .HasColumnType("INTEGER"); + + b.Property("PayloadIds") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("RemoteHost") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("RemotePort") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.ToTable("DicomAssociationHistories"); + }); + + modelBuilder.Entity("Monai.Deploy.InformaticsGateway.Api.Models.ExternalAppDetails", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("TEXT"); + + b.Property("CorrelationId") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("DateTimeCreated") + .HasColumnType("TEXT"); + + b.Property("DestinationFolder") + .HasColumnType("TEXT"); + + b.Property("ExportTaskID") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("PatientId") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("PatientIdOutBound") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("StudyInstanceUid") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("StudyInstanceUidOutBound") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("WorkflowInstanceId") + .IsRequired() + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.ToTable("ExternalAppDetails"); + }); + + modelBuilder.Entity("Monai.Deploy.InformaticsGateway.Api.Models.HL7DestinationEntity", b => + { + b.Property("Name") + .HasColumnType("TEXT"); + + b.Property("CreatedBy") + .HasColumnType("TEXT"); + + b.Property("DateTimeCreated") + .HasColumnType("TEXT"); + + b.Property("DateTimeUpdated") + .HasColumnType("TEXT"); + + b.Property("HostIp") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("Port") + .HasColumnType("INTEGER"); + + b.Property("UpdatedBy") + .HasColumnType("TEXT"); + + b.HasKey("Name"); + + b.HasIndex(new[] { "Name" }, "idx_destination_name") + .IsUnique() + .HasDatabaseName("idx_destination_name1"); + + b.HasIndex(new[] { "Name", "HostIp", "Port" }, "idx_source_all") + .IsUnique() + .HasDatabaseName("idx_source_all1"); + + b.ToTable("HL7DestinationEntities"); + }); + + modelBuilder.Entity("Monai.Deploy.InformaticsGateway.Api.Models.MonaiApplicationEntity", b => + { + b.Property("Name") + .HasColumnType("TEXT") + .HasColumnOrder(0); + + b.Property("AeTitle") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("AllowedSopClasses") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("CreatedBy") + .HasColumnType("TEXT"); + + b.Property("DateTimeCreated") + .HasColumnType("TEXT"); + + b.Property("DateTimeUpdated") + .HasColumnType("TEXT"); + + b.Property("Grouping") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("IgnoredSopClasses") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("PlugInAssemblies") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("Timeout") + .HasColumnType("INTEGER"); + + b.Property("UpdatedBy") + .HasColumnType("TEXT"); + + b.Property("Workflows") + .IsRequired() + .HasColumnType("TEXT"); + + b.HasKey("Name"); + + b.HasIndex(new[] { "Name" }, "idx_monaiae_name") + .IsUnique(); + + b.ToTable("MonaiApplicationEntities"); + }); + + modelBuilder.Entity("Monai.Deploy.InformaticsGateway.Api.Rest.InferenceRequest", b => + { + b.Property("InferenceRequestId") + .ValueGeneratedOnAdd() + .HasColumnType("TEXT"); + + b.Property("CreatedBy") + .HasColumnType("TEXT"); + + b.Property("DateTimeCreated") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("InputMetadata") + .HasColumnType("TEXT"); + + b.Property("InputResources") + .HasColumnType("TEXT"); + + b.Property("OutputResources") + .HasColumnType("TEXT"); + + b.Property("Priority") + .HasColumnType("INTEGER"); + + b.Property("State") + .HasColumnType("INTEGER"); + + b.Property("Status") + .HasColumnType("INTEGER"); + + b.Property("TransactionId") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("TryCount") + .HasColumnType("INTEGER"); + + b.HasKey("InferenceRequestId"); + + b.HasIndex(new[] { "InferenceRequestId" }, "idx_inferencerequest_inferencerequestid") + .IsUnique(); + + b.HasIndex(new[] { "State" }, "idx_inferencerequest_state"); + + b.HasIndex(new[] { "TransactionId" }, "idx_inferencerequest_transactionid") + .IsUnique(); + + b.ToTable("InferenceRequests"); + }); + + modelBuilder.Entity("Monai.Deploy.InformaticsGateway.Api.SourceApplicationEntity", b => + { + b.Property("Name") + .HasColumnType("TEXT"); + + b.Property("AeTitle") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("CreatedBy") + .HasColumnType("TEXT"); + + b.Property("DateTimeCreated") + .HasColumnType("TEXT"); + + b.Property("DateTimeUpdated") + .HasColumnType("TEXT"); + + b.Property("HostIp") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("UpdatedBy") + .HasColumnType("TEXT"); + + b.HasKey("Name"); + + b.HasIndex(new[] { "Name", "AeTitle", "HostIp" }, "idx_source_all") + .IsUnique() + .HasDatabaseName("idx_source_all2"); + + b.HasIndex(new[] { "Name" }, "idx_source_name") + .IsUnique(); + + b.ToTable("SourceApplicationEntities"); + }); + + modelBuilder.Entity("Monai.Deploy.InformaticsGateway.Api.Storage.Payload", b => + { + b.Property("PayloadId") + .ValueGeneratedOnAdd() + .HasColumnType("TEXT"); + + b.Property("CorrelationId") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("DataOrigins") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("DataTrigger") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("DateTimeCreated") + .HasColumnType("TEXT"); + + b.Property("DestinationFolder") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("Files") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("Key") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("MachineName") + .HasColumnType("TEXT"); + + b.Property("RetryCount") + .HasColumnType("INTEGER"); + + b.Property("State") + .HasColumnType("INTEGER"); + + b.Property("TaskId") + .HasColumnType("TEXT"); + + b.Property("Timeout") + .HasColumnType("INTEGER"); + + b.Property("WorkflowInstanceId") + .HasColumnType("TEXT"); + + b.HasKey("PayloadId"); + + b.HasIndex(new[] { "CorrelationId", "PayloadId" }, "idx_payload_ids") + .IsUnique(); + + b.HasIndex(new[] { "State" }, "idx_payload_state"); + + b.ToTable("Payloads"); + }); + + modelBuilder.Entity("Monai.Deploy.InformaticsGateway.Api.VirtualApplicationEntity", b => + { + b.Property("Name") + .HasColumnType("TEXT") + .HasColumnOrder(0); + + b.Property("CreatedBy") + .HasColumnType("TEXT"); + + b.Property("DateTimeCreated") + .HasColumnType("TEXT"); + + b.Property("DateTimeUpdated") + .HasColumnType("TEXT"); + + b.Property("PlugInAssemblies") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("UpdatedBy") + .HasColumnType("TEXT"); + + b.Property("VirtualAeTitle") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("Workflows") + .IsRequired() + .HasColumnType("TEXT"); + + b.HasKey("Name"); + + b.HasIndex(new[] { "Name" }, "idx_virtualae_name") + .IsUnique(); + + b.ToTable("VirtualApplicationEntities"); + }); + + modelBuilder.Entity("Monai.Deploy.InformaticsGateway.Database.Api.StorageMetadataWrapper", b => + { + b.Property("CorrelationId") + .HasColumnType("TEXT"); + + b.Property("Identity") + .HasColumnType("TEXT"); + + b.Property("DateTimeCreated") + .HasColumnType("TEXT"); + + b.Property("IsUploaded") + .HasColumnType("INTEGER"); + + b.Property("TypeName") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("Value") + .IsRequired() + .HasColumnType("TEXT"); + + b.HasKey("CorrelationId", "Identity"); + + b.HasIndex(new[] { "CorrelationId" }, "idx_storagemetadata_correlation"); + + b.HasIndex(new[] { "CorrelationId", "Identity" }, "idx_storagemetadata_ids"); + + b.HasIndex(new[] { "IsUploaded" }, "idx_storagemetadata_uploaded"); + + b.ToTable("StorageMetadataWrapperEntities"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/src/Database/EntityFramework/Migrations/20240112151448_ApplicationEntityTweek.cs b/src/Database/EntityFramework/Migrations/20240112151448_ApplicationEntityTweek.cs new file mode 100755 index 000000000..380ff2dcc --- /dev/null +++ b/src/Database/EntityFramework/Migrations/20240112151448_ApplicationEntityTweek.cs @@ -0,0 +1,46 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace Monai.Deploy.InformaticsGateway.Database.Migrations +{ + public partial class ApplicationEntityTweek : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropIndex( + name: "idx_source_all1", + table: "HL7DestinationEntities"); + + migrationBuilder.DropColumn( + name: "AeTitle", + table: "HL7DestinationEntities"); + + migrationBuilder.CreateIndex( + name: "idx_source_all1", + table: "HL7DestinationEntities", + columns: new[] { "Name", "HostIp", "Port" }, + unique: true); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropIndex( + name: "idx_source_all1", + table: "HL7DestinationEntities"); + + migrationBuilder.AddColumn( + name: "AeTitle", + table: "HL7DestinationEntities", + type: "TEXT", + nullable: false, + defaultValue: ""); + + migrationBuilder.CreateIndex( + name: "idx_source_all1", + table: "HL7DestinationEntities", + columns: new[] { "Name", "AeTitle", "HostIp", "Port" }, + unique: true); + } + } +} diff --git a/src/Database/EntityFramework/Migrations/InformaticsGatewayContextModelSnapshot.cs b/src/Database/EntityFramework/Migrations/InformaticsGatewayContextModelSnapshot.cs index 8eb10b0df..37b978580 100755 --- a/src/Database/EntityFramework/Migrations/InformaticsGatewayContextModelSnapshot.cs +++ b/src/Database/EntityFramework/Migrations/InformaticsGatewayContextModelSnapshot.cs @@ -192,10 +192,6 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("Name") .HasColumnType("TEXT"); - b.Property("AeTitle") - .IsRequired() - .HasColumnType("TEXT"); - b.Property("CreatedBy") .HasColumnType("TEXT"); @@ -221,7 +217,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) .IsUnique() .HasDatabaseName("idx_destination_name1"); - b.HasIndex(new[] { "Name", "AeTitle", "HostIp", "Port" }, "idx_source_all") + b.HasIndex(new[] { "Name", "HostIp", "Port" }, "idx_source_all") .IsUnique() .HasDatabaseName("idx_source_all1"); diff --git a/src/Database/EntityFramework/Test/HL7DestinationEntityRepositoryTest.cs b/src/Database/EntityFramework/Test/HL7DestinationEntityRepositoryTest.cs old mode 100644 new mode 100755 index 1f24a40f8..e5a76086a --- a/src/Database/EntityFramework/Test/HL7DestinationEntityRepositoryTest.cs +++ b/src/Database/EntityFramework/Test/HL7DestinationEntityRepositoryTest.cs @@ -62,14 +62,13 @@ public HL7DestinationEntityRepositoryTest(SqliteDatabaseFixture databaseFixture) [Fact] public async Task GivenAHL7DestinationEntity_WhenAddingToDatabase_ExpectItToBeSaved() { - var aet = new HL7DestinationEntity { AeTitle = "AET", HostIp = "1.2.3.4", Port = 114, Name = "AET" }; + var aet = new HL7DestinationEntity { HostIp = "1.2.3.4", Port = 114, Name = "AET" }; var store = new HL7DestinationEntityRepository(_serviceScopeFactory.Object, _logger.Object, _options); await store.AddAsync(aet).ConfigureAwait(false); var actual = await _databaseFixture.DatabaseContext.Set().FirstOrDefaultAsync(p => p.Name.Equals(aet.Name)).ConfigureAwait(false); Assert.NotNull(actual); - Assert.Equal(aet.AeTitle, actual!.AeTitle); Assert.Equal(aet.HostIp, actual!.HostIp); Assert.Equal(aet.Port, actual!.Port); Assert.Equal(aet.Name, actual!.Name); @@ -80,11 +79,7 @@ public async Task GivenAExpressionFilter_WhenContainsAsyncIsCalled_ExpectItToRet { var store = new HL7DestinationEntityRepository(_serviceScopeFactory.Object, _logger.Object, _options); - var result = await store.ContainsAsync(p => p.AeTitle == "AET1").ConfigureAwait(false); - Assert.True(result); - result = await store.ContainsAsync(p => p.AeTitle.Equals("AET1", StringComparison.Ordinal)).ConfigureAwait(false); - Assert.True(result); - result = await store.ContainsAsync(p => p.AeTitle != "AET1" && p.Port == 114 && p.HostIp == "1.2.3.4").ConfigureAwait(false); + var result = await store.ContainsAsync(p => p.Port == 114 && p.HostIp == "1.2.3.4").ConfigureAwait(false); Assert.True(result); result = await store.ContainsAsync(p => p.Port == 114 && p.HostIp == "1.2.3.4").ConfigureAwait(false); Assert.True(result); @@ -99,7 +94,6 @@ public async Task GivenAAETitleName_WhenFindByNameAsyncIsCalled_ExpectItToReturn var actual = await store.FindByNameAsync("AET1").ConfigureAwait(false); Assert.NotNull(actual); - Assert.Equal("AET1", actual!.AeTitle); Assert.Equal("1.2.3.4", actual!.HostIp); Assert.Equal(114, actual!.Port); Assert.Equal("AET1", actual!.Name); @@ -142,7 +136,6 @@ public async Task GivenAHL7DestinationEntity_WhenUpdatedIsCalled_ExpectItToSaved var expected = await store.FindByNameAsync("AET3").ConfigureAwait(false); Assert.NotNull(expected); - expected!.AeTitle = "AET100"; expected!.Port = 1000; expected!.HostIp = "loalhost"; @@ -151,7 +144,6 @@ public async Task GivenAHL7DestinationEntity_WhenUpdatedIsCalled_ExpectItToSaved var dbResult = await store.FindByNameAsync("AET3").ConfigureAwait(false); Assert.NotNull(dbResult); - Assert.Equal(expected.AeTitle, dbResult!.AeTitle); Assert.Equal(expected.HostIp, dbResult!.HostIp); Assert.Equal(expected.Port, dbResult!.Port); } diff --git a/src/Database/EntityFramework/Test/SqliteDatabaseFixture.cs b/src/Database/EntityFramework/Test/SqliteDatabaseFixture.cs index 19219a3a3..0205695b7 100755 --- a/src/Database/EntityFramework/Test/SqliteDatabaseFixture.cs +++ b/src/Database/EntityFramework/Test/SqliteDatabaseFixture.cs @@ -62,11 +62,11 @@ public void InitDatabaseWithDestinationApplicationEntities() public void InitDatabaseWithHL7DestinationEntities() { - var aet1 = new HL7DestinationEntity { AeTitle = "AET1", HostIp = "1.2.3.4", Port = 114, Name = "AET1" }; - var aet2 = new HL7DestinationEntity { AeTitle = "AET2", HostIp = "1.2.3.4", Port = 114, Name = "AET2" }; - var aet3 = new HL7DestinationEntity { AeTitle = "AET3", HostIp = "1.2.3.4", Port = 114, Name = "AET3" }; - var aet4 = new HL7DestinationEntity { AeTitle = "AET4", HostIp = "1.2.3.4", Port = 114, Name = "AET4" }; - var aet5 = new HL7DestinationEntity { AeTitle = "AET5", HostIp = "1.2.3.4", Port = 114, Name = "AET5" }; + var aet1 = new HL7DestinationEntity { HostIp = "1.2.3.4", Port = 114, Name = "AET1" }; + var aet2 = new HL7DestinationEntity { HostIp = "1.2.3.4", Port = 114, Name = "AET2" }; + var aet3 = new HL7DestinationEntity { HostIp = "1.2.3.4", Port = 114, Name = "AET3" }; + var aet4 = new HL7DestinationEntity { HostIp = "1.2.3.4", Port = 114, Name = "AET4" }; + var aet5 = new HL7DestinationEntity { HostIp = "1.2.3.4", Port = 114, Name = "AET5" }; var set = DatabaseContext.Set(); set.RemoveRange(set.ToList()); diff --git a/src/Database/MongoDB/Integration.Test/HL7DestinationEntityRepositoryTest.cs b/src/Database/MongoDB/Integration.Test/HL7DestinationEntityRepositoryTest.cs old mode 100644 new mode 100755 index dbdb29251..862dbda63 --- a/src/Database/MongoDB/Integration.Test/HL7DestinationEntityRepositoryTest.cs +++ b/src/Database/MongoDB/Integration.Test/HL7DestinationEntityRepositoryTest.cs @@ -65,7 +65,7 @@ public HL7DestinationEntityRepositoryTest(MongoDatabaseFixture databaseFixture) [Fact] public async Task GivenAHL7DestinationEntity_WhenAddingToDatabase_ExpectItToBeSaved() { - var aet = new HL7DestinationEntity { AeTitle = "AET", HostIp = "1.2.3.4", Port = 114, Name = "AET" }; + var aet = new HL7DestinationEntity { HostIp = "1.2.3.4", Port = 114, Name = "AET" }; var store = new HL7DestinationEntityRepository(_serviceScopeFactory.Object, _logger.Object, _options, _databaseFixture.Options); await store.AddAsync(aet).ConfigureAwait(false); @@ -74,7 +74,6 @@ public async Task GivenAHL7DestinationEntity_WhenAddingToDatabase_ExpectItToBeSa var actual = await collection.Find(p => p.Name == aet.Name).FirstOrDefaultAsync().ConfigureAwait(false); Assert.NotNull(actual); - Assert.Equal(aet.AeTitle, actual!.AeTitle); Assert.Equal(aet.HostIp, actual!.HostIp); Assert.Equal(aet.Port, actual!.Port); Assert.Equal(aet.Name, actual!.Name); @@ -85,11 +84,7 @@ public async Task GivenAExpressionFilter_WhenContainsAsyncIsCalled_ExpectItToRet { var store = new HL7DestinationEntityRepository(_serviceScopeFactory.Object, _logger.Object, _options, _databaseFixture.Options); - var result = await store.ContainsAsync(p => p.AeTitle == "AET1").ConfigureAwait(false); - Assert.True(result); - result = await store.ContainsAsync(p => p.AeTitle.Equals("AET1")).ConfigureAwait(false); - Assert.True(result); - result = await store.ContainsAsync(p => p.AeTitle != "AET1" && p.Port == 114 && p.HostIp == "1.2.3.4").ConfigureAwait(false); + var result = await store.ContainsAsync(p => p.Port == 114 && p.HostIp == "1.2.3.4").ConfigureAwait(false); Assert.True(result); result = await store.ContainsAsync(p => p.Port == 114 && p.HostIp == "1.2.3.4").ConfigureAwait(false); Assert.True(result); @@ -104,7 +99,6 @@ public async Task GivenAAETitleName_WhenFindByNameAsyncIsCalled_ExpectItToReturn var actual = await store.FindByNameAsync("AET1").ConfigureAwait(false); Assert.NotNull(actual); - Assert.Equal("AET1", actual!.AeTitle); Assert.Equal("1.2.3.4", actual!.HostIp); Assert.Equal(114, actual!.Port); Assert.Equal("AET1", actual!.Name); @@ -149,7 +143,6 @@ public async Task GivenAHL7DestinationEntity_WhenUpdatedIsCalled_ExpectItToSaved var expected = await store.FindByNameAsync("AET3").ConfigureAwait(false); Assert.NotNull(expected); - expected!.AeTitle = "AET100"; expected!.Port = 1000; expected!.HostIp = "loalhost"; @@ -158,7 +151,6 @@ public async Task GivenAHL7DestinationEntity_WhenUpdatedIsCalled_ExpectItToSaved var dbResult = await store.FindByNameAsync("AET3").ConfigureAwait(false); Assert.NotNull(dbResult); - Assert.Equal(expected.AeTitle, dbResult!.AeTitle); Assert.Equal(expected.HostIp, dbResult!.HostIp); Assert.Equal(expected.Port, dbResult!.Port); } diff --git a/src/Database/MongoDB/Integration.Test/MongoDatabaseFixture.cs b/src/Database/MongoDB/Integration.Test/MongoDatabaseFixture.cs index f1d48885e..140ea64a8 100755 --- a/src/Database/MongoDB/Integration.Test/MongoDatabaseFixture.cs +++ b/src/Database/MongoDB/Integration.Test/MongoDatabaseFixture.cs @@ -69,11 +69,11 @@ public void InitDatabaseWithHL7DestinationEntities() { var collection = Database.GetCollection(nameof(HL7DestinationEntity)); Clear(collection); - var aet1 = new HL7DestinationEntity { AeTitle = "AET1", HostIp = "1.2.3.4", Port = 114, Name = "AET1", DateTimeCreated = DateTime.UtcNow }; - var aet2 = new HL7DestinationEntity { AeTitle = "AET2", HostIp = "1.2.3.4", Port = 114, Name = "AET2", DateTimeCreated = DateTime.UtcNow }; - var aet3 = new HL7DestinationEntity { AeTitle = "AET3", HostIp = "1.2.3.4", Port = 114, Name = "AET3", DateTimeCreated = DateTime.UtcNow }; - var aet4 = new HL7DestinationEntity { AeTitle = "AET4", HostIp = "1.2.3.4", Port = 114, Name = "AET4", DateTimeCreated = DateTime.UtcNow }; - var aet5 = new HL7DestinationEntity { AeTitle = "AET5", HostIp = "1.2.3.4", Port = 114, Name = "AET5", DateTimeCreated = DateTime.UtcNow }; + var aet1 = new HL7DestinationEntity { HostIp = "1.2.3.4", Port = 114, Name = "AET1", DateTimeCreated = DateTime.UtcNow }; + var aet2 = new HL7DestinationEntity { HostIp = "1.2.3.4", Port = 114, Name = "AET2", DateTimeCreated = DateTime.UtcNow }; + var aet3 = new HL7DestinationEntity { HostIp = "1.2.3.4", Port = 114, Name = "AET3", DateTimeCreated = DateTime.UtcNow }; + var aet4 = new HL7DestinationEntity { HostIp = "1.2.3.4", Port = 114, Name = "AET4", DateTimeCreated = DateTime.UtcNow }; + var aet5 = new HL7DestinationEntity { HostIp = "1.2.3.4", Port = 114, Name = "AET5", DateTimeCreated = DateTime.UtcNow }; collection.InsertOne(aet1); collection.InsertOne(aet2); diff --git a/src/Database/MongoDB/Repositories/HL7DestinationEntityRepository.cs b/src/Database/MongoDB/Repositories/HL7DestinationEntityRepository.cs index feb428f09..de51c885f 100755 --- a/src/Database/MongoDB/Repositories/HL7DestinationEntityRepository.cs +++ b/src/Database/MongoDB/Repositories/HL7DestinationEntityRepository.cs @@ -74,7 +74,6 @@ private void CreateIndexes() var indexDefinitionAll = Builders.IndexKeys.Combine( Builders.IndexKeys.Ascending(_ => _.Name), - Builders.IndexKeys.Ascending(_ => _.AeTitle), Builders.IndexKeys.Ascending(_ => _.HostIp), Builders.IndexKeys.Ascending(_ => _.Port)); _collection.Indexes.CreateOne(new CreateIndexModel(indexDefinitionAll, options)); diff --git a/src/InformaticsGateway/Logging/Log.8000.HttpServices.cs b/src/InformaticsGateway/Logging/Log.8000.HttpServices.cs old mode 100644 new mode 100755 index ec6d41ce8..bd706d8ce --- a/src/InformaticsGateway/Logging/Log.8000.HttpServices.cs +++ b/src/InformaticsGateway/Logging/Log.8000.HttpServices.cs @@ -188,8 +188,8 @@ public static partial class Log // HL7 Destination Controller - [LoggerMessage(EventId = 8401, Level = LogLevel.Information, Message = "HL7 destination added AE Title={aeTitle}, Host/IP={hostIp}.")] - public static partial void HL7DestinationEntityAdded(this ILogger logger, string aeTitle, string hostIp); + [LoggerMessage(EventId = 8401, Level = LogLevel.Information, Message = "HL7 destination added Name={name}, Host/IP={hostIp}.")] + public static partial void HL7DestinationEntityAdded(this ILogger logger, string name, string hostIp); [LoggerMessage(EventId = 8402, Level = LogLevel.Information, Message = "HL7 destination deleted {name}.")] public static partial void HL7DestinationEntityDeleted(this ILogger logger, string name); @@ -206,7 +206,7 @@ public static partial class Log [LoggerMessage(EventId = 8406, Level = LogLevel.Error, Message = "Error C-ECHO to HL7 destination {name}.")] public static partial void ErrorCEechoHL7DestinationEntity(this ILogger logger, string name, Exception ex); - [LoggerMessage(EventId = 8407, Level = LogLevel.Information, Message = "HL7 destination updated {name}: AE Title={aeTitle}, Host/IP={hostIp}, Port={port}.")] - public static partial void HL7DestinationEntityUpdated(this ILogger logger, string name, string aeTitle, string hostIp, int port); + [LoggerMessage(EventId = 8407, Level = LogLevel.Information, Message = "HL7 destination updated {name}: Host/IP={hostIp}, Port={port}.")] + public static partial void HL7DestinationEntityUpdated(this ILogger logger, string name, string hostIp, int port); } } diff --git a/src/InformaticsGateway/Services/Http/HL7DestinationController.cs b/src/InformaticsGateway/Services/Http/HL7DestinationController.cs index 194adb1ed..ee0cce5fe 100755 --- a/src/InformaticsGateway/Services/Http/HL7DestinationController.cs +++ b/src/InformaticsGateway/Services/Http/HL7DestinationController.cs @@ -119,7 +119,7 @@ public async Task> Create(HL7DestinationEntity item) await ValidateCreateAsync(item).ConfigureAwait(false); await _repository.AddAsync(item, HttpContext.RequestAborted).ConfigureAwait(false); - _logger.HL7DestinationEntityAdded(item.AeTitle, item.HostIp); + _logger.HL7DestinationEntityAdded(item.Name, item.HostIp); return CreatedAtAction(nameof(GetAeTitle), new { name = item.Name }, item); } catch (ObjectExistsException ex) @@ -159,7 +159,6 @@ public async Task> Edit(HL7DestinationEntity? item.SetDefaultValues(); - hl7DestinationEntity.AeTitle = item.AeTitle; hl7DestinationEntity.HostIp = item.HostIp; hl7DestinationEntity.Port = item.Port; hl7DestinationEntity.SetAuthor(User, EditMode.Update); @@ -167,7 +166,7 @@ public async Task> Edit(HL7DestinationEntity? await ValidateUpdateAsync(hl7DestinationEntity).ConfigureAwait(false); _ = _repository.UpdateAsync(hl7DestinationEntity, HttpContext.RequestAborted); - _logger.HL7DestinationEntityUpdated(item.Name, item.AeTitle, item.HostIp, item.Port); + _logger.HL7DestinationEntityUpdated(item.Name, item.HostIp, item.Port); return Ok(hl7DestinationEntity); } catch (ConfigurationException ex) @@ -198,7 +197,7 @@ public async Task> Delete(string name) await _repository.RemoveAsync(hl7DestinationEntity, HttpContext.RequestAborted).ConfigureAwait(false); - _logger.HL7DestinationEntityDeleted(name.Substring(0, 10)); + _logger.HL7DestinationEntityDeleted(name); return Ok(hl7DestinationEntity); } catch (Exception ex) @@ -214,9 +213,9 @@ private async Task ValidateCreateAsync(HL7DestinationEntity item) { throw new ObjectExistsException($"A HL7 destination with the same name '{item.Name}' already exists."); } - if (await _repository.ContainsAsync(p => p.AeTitle.Equals(item.AeTitle) && p.HostIp.Equals(item.HostIp) && p.Port.Equals(item.Port), HttpContext.RequestAborted).ConfigureAwait(false)) + if (await _repository.ContainsAsync(p => p.HostIp.Equals(item.HostIp) && p.Port.Equals(item.Port), HttpContext.RequestAborted).ConfigureAwait(false)) { - throw new ObjectExistsException($"A HL7 destination with the same AE Title '{item.AeTitle}', host/IP Address '{item.HostIp}' and port '{item.Port}' already exists."); + throw new ObjectExistsException($"A HL7 destination with the same, host/IP Address '{item.HostIp}' and port '{item.Port}' already exists."); } if (!item.IsValid(out var validationErrors)) { @@ -226,9 +225,9 @@ private async Task ValidateCreateAsync(HL7DestinationEntity item) private async Task ValidateUpdateAsync(HL7DestinationEntity item) { - if (await _repository.ContainsAsync(p => !p.Name.Equals(item.Name) && p.AeTitle.Equals(item.AeTitle) && p.HostIp.Equals(item.HostIp) && p.Port.Equals(item.Port), HttpContext.RequestAborted).ConfigureAwait(false)) + if (await _repository.ContainsAsync(p => !p.Name.Equals(item.Name) && p.HostIp.Equals(item.HostIp) && p.Port.Equals(item.Port), HttpContext.RequestAborted).ConfigureAwait(false)) { - throw new ObjectExistsException($"A HL7 destination with the same AE Title '{item.AeTitle}', host/IP Address '{item.HostIp}' and port '{item.Port}' already exists."); + throw new ObjectExistsException($"A HL7 destination with the same, host/IP Address '{item.HostIp}' and port '{item.Port}' already exists."); } if (!item.IsValid(out var validationErrors)) { diff --git a/tests/Integration.Test/StepDefinitions/Hl7StepDefinitions.cs b/tests/Integration.Test/StepDefinitions/Hl7StepDefinitions.cs index 69887eff2..43394a042 100755 --- a/tests/Integration.Test/StepDefinitions/Hl7StepDefinitions.cs +++ b/tests/Integration.Test/StepDefinitions/Hl7StepDefinitions.cs @@ -90,7 +90,6 @@ public async Task GivenAHLMessageThatIsExportedToTheTestHost() destination = await _informaticsGatewayClient.HL7Destinations.Create(new HL7DestinationEntity { Name = _dicomServer.FeatureScpAeTitle, - AeTitle = _dicomServer.FeatureScpAeTitle, HostIp = _hl7SendAddress, Port = _hl7Port }, CancellationToken.None);