From fa9dbeb0845dc7c18335b4c96d543044f99504d9 Mon Sep 17 00:00:00 2001 From: Victor Chang Date: Wed, 16 Aug 2023 14:05:31 -0700 Subject: [PATCH] Regenerate EF DB migration code --- src/Api/DestinationApplicationEntity.cs | 8 + ...tionApplicationEntityRemoteAppExecution.cs | 28 ++ src/Api/{Storage => }/RemoteAppExecution.cs | 22 +- .../InformaticsGatewayConfiguration.cs | 7 + src/Configuration/PluginConfiguration.cs | 4 +- .../IRemoteAppExecutionRepository.cs | 2 +- ...onEntityRemoteAppExecutionConfiguration.cs | 39 ++ .../RemoteAppExecutionConfiguration.cs | 24 +- .../InformaticsGatewayContext.cs | 2 + .../Migrations/20230808233742_R4_0.4.0.cs | 46 --- .../20230811165855_R4_0.4.0.Designer.cs | 370 ------------------ .../Migrations/20230811165855_R4_0.4.0.cs | 53 --- ...cs => 20230816201637_R4_0.4.0.Designer.cs} | 122 +++++- .../Migrations/20230816201637_R4_0.4.0.cs | 166 ++++++++ .../InformaticsGatewayContextModelSnapshot.cs | 120 ++++++ .../RemoteAppExecutionRepository.cs | 2 +- .../RemoteAppRepositoryTest.cs | 2 +- .../RemoteAppExecutionRepository.cs | 2 +- .../VirtualApplicationEntityRepository.cs | 2 +- .../ExecutionPlugins/ExternalAppIncoming.cs | 7 +- .../ExecutionPlugins/ExternalAppOutgoing.cs | 9 +- src/InformaticsGateway/Program.cs | 2 +- .../Services/Common/ExternalAppPluginTest.cs | 8 +- src/InformaticsGateway/appsettings.json | 4 +- 24 files changed, 552 insertions(+), 499 deletions(-) create mode 100755 src/Api/DestinationApplicationEntityRemoteAppExecution.cs rename src/Api/{Storage => }/RemoteAppExecution.cs (72%) create mode 100644 src/Database/EntityFramework/Configuration/DestinationApplicationEntityRemoteAppExecutionConfiguration.cs delete mode 100644 src/Database/EntityFramework/Migrations/20230808233742_R4_0.4.0.cs delete mode 100644 src/Database/EntityFramework/Migrations/20230811165855_R4_0.4.0.Designer.cs delete mode 100644 src/Database/EntityFramework/Migrations/20230811165855_R4_0.4.0.cs rename src/Database/EntityFramework/Migrations/{20230808233742_R4_0.4.0.Designer.cs => 20230816201637_R4_0.4.0.Designer.cs} (72%) create mode 100644 src/Database/EntityFramework/Migrations/20230816201637_R4_0.4.0.cs diff --git a/src/Api/DestinationApplicationEntity.cs b/src/Api/DestinationApplicationEntity.cs index 6599591fa..fcc7a6a02 100644 --- a/src/Api/DestinationApplicationEntity.cs +++ b/src/Api/DestinationApplicationEntity.cs @@ -15,6 +15,8 @@ * limitations under the License. */ +using System.Collections.Generic; + namespace Monai.Deploy.InformaticsGateway.Api { /// @@ -36,5 +38,11 @@ public class DestinationApplicationEntity : BaseApplicationEntity /// Gets or sets the port to connect to. /// public int Port { get; set; } + + /// + /// Gets or sets remote application executions. + /// + public virtual List RemoteAppExecutions { get; set; } = new(); + public virtual List DestinationApplicationEntityRemoteAppExecutions { get; set; } = new(); } } diff --git a/src/Api/DestinationApplicationEntityRemoteAppExecution.cs b/src/Api/DestinationApplicationEntityRemoteAppExecution.cs new file mode 100755 index 000000000..2ca6e4fe0 --- /dev/null +++ b/src/Api/DestinationApplicationEntityRemoteAppExecution.cs @@ -0,0 +1,28 @@ +/* + * Copyright 2023 MONAI Consortium + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +namespace Monai.Deploy.InformaticsGateway.Api +{ + public class DestinationApplicationEntityRemoteAppExecution + { + public string DestinationApplicationEntityName { get; set; } = default!; + public DestinationApplicationEntity DestinationApplicationEntity { get; set; } = default!; + + public string RemoteAppExecutionId { get; set; } = default!; + public RemoteAppExecution RemoteAppExecution { get; set; } = default!; + } +} diff --git a/src/Api/Storage/RemoteAppExecution.cs b/src/Api/RemoteAppExecution.cs similarity index 72% rename from src/Api/Storage/RemoteAppExecution.cs rename to src/Api/RemoteAppExecution.cs index a842749b9..b57da21be 100755 --- a/src/Api/Storage/RemoteAppExecution.cs +++ b/src/Api/RemoteAppExecution.cs @@ -1,5 +1,5 @@ /* - * Copyright 2021-2023 MONAI Consortium + * Copyright 2023 MONAI Consortium * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,26 +17,38 @@ using System; using System.Collections.Generic; using System.Text.Json.Serialization; -using Monai.Deploy.Messaging.Events; -namespace Monai.Deploy.InformaticsGateway.Api.Storage +namespace Monai.Deploy.InformaticsGateway.Api { + /// + /// TODO: include description of class and all properties + /// /// public class RemoteAppExecution { [JsonPropertyName("_id")] public string Id { get; set; } = default!; + + /// + /// Gets or sets exported destinations + /// + public virtual List ExportDetails { get; set; } = new(); + public virtual List DestinationApplicationEntityRemoteAppExecutions { get; set; } = new(); + public DateTime RequestTime { get; set; } = DateTime.UtcNow; public string ExportTaskId { get; set; } = string.Empty; public string WorkflowInstanceId { get; set; } = string.Empty; public string CorrelationId { get; set; } = string.Empty; public string? StudyUid { get; set; } public string? OutgoingUid { get { return Id; } set { Id = value ?? ""; } } - public List ExportDetails { get; set; } = new(); + public List Files { get; set; } = new(); - public FileExportStatus Status { get; set; } public Dictionary OriginalValues { get; set; } = new(); public Dictionary ProxyValues { get; set; } = new(); } + + /// + /// TODO: maybe use internal for testing? + /// public class RemoteAppExecutionTest { [JsonPropertyName("_id")] diff --git a/src/Configuration/InformaticsGatewayConfiguration.cs b/src/Configuration/InformaticsGatewayConfiguration.cs index f2a466087..e77c65a37 100644 --- a/src/Configuration/InformaticsGatewayConfiguration.cs +++ b/src/Configuration/InformaticsGatewayConfiguration.cs @@ -76,6 +76,12 @@ public class InformaticsGatewayConfiguration [ConfigurationKeyName("database")] public DatabaseConfiguration Database { get; set; } + /// + /// Represents the pluginConfiguration section of the configuration file. + /// + [ConfigurationKeyName("plugins")] + public PluginConfiguration PluginConfigurations { get; set; } + public InformaticsGatewayConfiguration() { Dicom = new DicomConfiguration(); @@ -86,6 +92,7 @@ public InformaticsGatewayConfiguration() Messaging = new MessageBrokerConfiguration(); Database = new DatabaseConfiguration(); Hl7 = new Hl7Configuration(); + PluginConfigurations = new PluginConfiguration(); } } } diff --git a/src/Configuration/PluginConfiguration.cs b/src/Configuration/PluginConfiguration.cs index 665b76a4e..e6a4063b1 100755 --- a/src/Configuration/PluginConfiguration.cs +++ b/src/Configuration/PluginConfiguration.cs @@ -15,11 +15,13 @@ */ using System.Collections.Generic; +using Microsoft.Extensions.Configuration; namespace Monai.Deploy.InformaticsGateway.Configuration { public class PluginConfiguration { - public Dictionary Configuration { get; set; } = new(); + [ConfigurationKeyName("remoteApp")] + public Dictionary RemoteAppConfigurations { get; set; } = new(); } } diff --git a/src/Database/Api/Repositories/IRemoteAppExecutionRepository.cs b/src/Database/Api/Repositories/IRemoteAppExecutionRepository.cs index 7e4d45ec3..732db97dd 100755 --- a/src/Database/Api/Repositories/IRemoteAppExecutionRepository.cs +++ b/src/Database/Api/Repositories/IRemoteAppExecutionRepository.cs @@ -14,7 +14,7 @@ * limitations under the License. */ -using Monai.Deploy.InformaticsGateway.Api.Storage; +using Monai.Deploy.InformaticsGateway.Api; namespace Monai.Deploy.InformaticsGateway.Database.Api.Repositories { diff --git a/src/Database/EntityFramework/Configuration/DestinationApplicationEntityRemoteAppExecutionConfiguration.cs b/src/Database/EntityFramework/Configuration/DestinationApplicationEntityRemoteAppExecutionConfiguration.cs new file mode 100644 index 000000000..d8536fde1 --- /dev/null +++ b/src/Database/EntityFramework/Configuration/DestinationApplicationEntityRemoteAppExecutionConfiguration.cs @@ -0,0 +1,39 @@ +/* + * Copyright 2021-2022 MONAI Consortium + * Copyright 2021 NVIDIA Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Metadata.Builders; +using Monai.Deploy.InformaticsGateway.Api; + +namespace Monai.Deploy.InformaticsGateway.Database.EntityFramework.Configuration +{ + + internal class DestinationApplicationEntityRemoteAppExecutionConfiguration : IEntityTypeConfiguration + { + public void Configure(EntityTypeBuilder builder) + { + builder.HasKey(dr => new { dr.DestinationApplicationEntityName, dr.RemoteAppExecutionId }); + builder.HasOne(bc => bc.RemoteAppExecution) + .WithMany(b => b.DestinationApplicationEntityRemoteAppExecutions) + .HasForeignKey(bc => bc.RemoteAppExecutionId); + builder.HasOne(bc => bc.DestinationApplicationEntity) + .WithMany(c => c.DestinationApplicationEntityRemoteAppExecutions) + .HasForeignKey(bc => bc.DestinationApplicationEntityName); + + } + } +} diff --git a/src/Database/EntityFramework/Configuration/RemoteAppExecutionConfiguration.cs b/src/Database/EntityFramework/Configuration/RemoteAppExecutionConfiguration.cs index 2b0d2bf96..8832e52f0 100755 --- a/src/Database/EntityFramework/Configuration/RemoteAppExecutionConfiguration.cs +++ b/src/Database/EntityFramework/Configuration/RemoteAppExecutionConfiguration.cs @@ -19,6 +19,7 @@ using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.ChangeTracking; using Microsoft.EntityFrameworkCore.Metadata.Builders; +using Monai.Deploy.InformaticsGateway.Api; using Monai.Deploy.InformaticsGateway.Api.Storage; namespace Monai.Deploy.InformaticsGateway.Database.EntityFramework.Configuration @@ -29,6 +30,18 @@ internal class RemoteAppExecutionConfiguration : IEntityTypeConfiguration builder) { + var stringValueComparer = new ValueComparer>( + (c1, c2) => c1.SequenceEqual(c2), + c => c.Aggregate(0, (a, v) => HashCode.Combine(a, v.GetHashCode())), + c => c.ToList()); + var destAeValueComparer = new ValueComparer>( + (c1, c2) => c1.SequenceEqual(c2), + c => c.Aggregate(0, (a, v) => HashCode.Combine(a, v.GetHashCode())), + c => c.ToList()); + var dictValueComparer = new ValueComparer>( + (c1, c2) => c1!.Equals(c2), + c => c.GetHashCode(), + c => c.ToDictionary(entry => entry.Key, entry => entry.Value)); var jsonSerializerSettings = new JsonSerializerOptions { DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull @@ -38,24 +51,25 @@ public void Configure(EntityTypeBuilder builder) builder.Property(j => j.OutgoingUid).IsRequired(); builder.Property(j => j.ExportTaskId).IsRequired(); - //builder.Property(j => j.Status).IsRequired(); builder.Property(j => j.CorrelationId).IsRequired(); builder.Property(j => j.OriginalValues) .HasConversion( v => JsonSerializer.Serialize(v, jsonSerializerSettings), - v => JsonSerializer.Deserialize>(v, jsonSerializerSettings)); + v => JsonSerializer.Deserialize>(v, jsonSerializerSettings)) + .Metadata.SetValueComparer(dictValueComparer); builder.Property(j => j.ProxyValues) .HasConversion( v => JsonSerializer.Serialize(v, jsonSerializerSettings), - v => JsonSerializer.Deserialize>(v, jsonSerializerSettings)); + v => JsonSerializer.Deserialize>(v, jsonSerializerSettings)) + .Metadata.SetValueComparer(dictValueComparer); builder.Property(j => j.Files) .HasConversion( v => JsonSerializer.Serialize(v, jsonSerializerSettings), - v => JsonSerializer.Deserialize>(v, jsonSerializerSettings)); + v => JsonSerializer.Deserialize>(v, jsonSerializerSettings)) + .Metadata.SetValueComparer(stringValueComparer); builder.HasIndex(p => p.OutgoingUid, "idx_outgoing_key"); - } } diff --git a/src/Database/EntityFramework/InformaticsGatewayContext.cs b/src/Database/EntityFramework/InformaticsGatewayContext.cs index 62ed3e4d1..98c5b691c 100755 --- a/src/Database/EntityFramework/InformaticsGatewayContext.cs +++ b/src/Database/EntityFramework/InformaticsGatewayContext.cs @@ -42,6 +42,7 @@ public InformaticsGatewayContext(DbContextOptions opt public virtual DbSet DicomAssociationHistories { get; set; } public virtual DbSet VirtualApplicationEntities { get; set; } public virtual DbSet RemoteAppExecutions { get; set; } + public virtual DbSet RemtoeAppExecutionDestinations { get; set; } protected override void OnModelCreating(ModelBuilder modelBuilder) { @@ -56,6 +57,7 @@ protected override void OnModelCreating(ModelBuilder modelBuilder) modelBuilder.ApplyConfiguration(new DicomAssociationInfoConfiguration()); modelBuilder.ApplyConfiguration(new VirtualApplicationEntityConfiguration()); modelBuilder.ApplyConfiguration(new RemoteAppExecutionConfiguration()); + modelBuilder.ApplyConfiguration(new DestinationApplicationEntityRemoteAppExecutionConfiguration()); } protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) diff --git a/src/Database/EntityFramework/Migrations/20230808233742_R4_0.4.0.cs b/src/Database/EntityFramework/Migrations/20230808233742_R4_0.4.0.cs deleted file mode 100644 index 3b012b596..000000000 --- a/src/Database/EntityFramework/Migrations/20230808233742_R4_0.4.0.cs +++ /dev/null @@ -1,46 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace Monai.Deploy.InformaticsGateway.Database.Migrations -{ - public partial class R4_040 : Migration - { - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.AddColumn( - name: "TaskId", - table: "Payloads", - type: "TEXT", - nullable: true); - - migrationBuilder.AddColumn( - name: "WorkflowInstanceId", - table: "Payloads", - type: "TEXT", - nullable: true); - - migrationBuilder.AddColumn( - name: "PluginAssemblies", - table: "MonaiApplicationEntities", - type: "TEXT", - nullable: false, - defaultValue: ""); - } - - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropColumn( - name: "TaskId", - table: "Payloads"); - - migrationBuilder.DropColumn( - name: "WorkflowInstanceId", - table: "Payloads"); - - migrationBuilder.DropColumn( - name: "PluginAssemblies", - table: "MonaiApplicationEntities"); - } - } -} diff --git a/src/Database/EntityFramework/Migrations/20230811165855_R4_0.4.0.Designer.cs b/src/Database/EntityFramework/Migrations/20230811165855_R4_0.4.0.Designer.cs deleted file mode 100644 index 786375ce4..000000000 --- a/src/Database/EntityFramework/Migrations/20230811165855_R4_0.4.0.Designer.cs +++ /dev/null @@ -1,370 +0,0 @@ -// -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("20230811165855_R4_0.4.0")] - partial class R4_040 - { - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder.HasAnnotation("ProductVersion", "6.0.21"); - - modelBuilder.Entity("Monai.Deploy.InformaticsGateway.Api.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.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("RemoteHost") - .IsRequired() - .HasColumnType("TEXT"); - - b.Property("RemotePort") - .HasColumnType("INTEGER"); - - b.HasKey("Id"); - - b.ToTable("DicomAssociationHistories"); - }); - - modelBuilder.Entity("Monai.Deploy.InformaticsGateway.Api.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_all1"); - - 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("DateTimeCreated") - .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/20230811165855_R4_0.4.0.cs b/src/Database/EntityFramework/Migrations/20230811165855_R4_0.4.0.cs deleted file mode 100644 index 60365fedd..000000000 --- a/src/Database/EntityFramework/Migrations/20230811165855_R4_0.4.0.cs +++ /dev/null @@ -1,53 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace Monai.Deploy.InformaticsGateway.Database.Migrations -{ - public partial class R4_040 : Migration - { - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.AddColumn( - name: "PluginAssemblies", - table: "MonaiApplicationEntities", - type: "TEXT", - nullable: false, - defaultValue: ""); - - migrationBuilder.CreateTable( - name: "VirtualApplicationEntities", - columns: table => new - { - Name = table.Column(type: "TEXT", nullable: false), - VirtualAeTitle = table.Column(type: "TEXT", nullable: false), - Workflows = table.Column(type: "TEXT", nullable: false), - PluginAssemblies = table.Column(type: "TEXT", nullable: false), - CreatedBy = table.Column(type: "TEXT", nullable: true), - UpdatedBy = table.Column(type: "TEXT", nullable: true), - DateTimeUpdated = table.Column(type: "TEXT", nullable: true), - DateTimeCreated = table.Column(type: "TEXT", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_VirtualApplicationEntities", x => x.Name); - }); - - migrationBuilder.CreateIndex( - name: "idx_virtualae_name", - table: "VirtualApplicationEntities", - column: "Name", - unique: true); - } - - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropTable( - name: "VirtualApplicationEntities"); - - migrationBuilder.DropColumn( - name: "PluginAssemblies", - table: "MonaiApplicationEntities"); - } - } -} diff --git a/src/Database/EntityFramework/Migrations/20230808233742_R4_0.4.0.Designer.cs b/src/Database/EntityFramework/Migrations/20230816201637_R4_0.4.0.Designer.cs similarity index 72% rename from src/Database/EntityFramework/Migrations/20230808233742_R4_0.4.0.Designer.cs rename to src/Database/EntityFramework/Migrations/20230816201637_R4_0.4.0.Designer.cs index 786375ce4..2d24518ef 100644 --- a/src/Database/EntityFramework/Migrations/20230808233742_R4_0.4.0.Designer.cs +++ b/src/Database/EntityFramework/Migrations/20230816201637_R4_0.4.0.Designer.cs @@ -11,7 +11,7 @@ namespace Monai.Deploy.InformaticsGateway.Database.Migrations { [DbContext(typeof(InformaticsGatewayContext))] - [Migration("20230811165855_R4_0.4.0")] + [Migration("20230816201637_R4_0.4.0")] partial class R4_040 { protected override void BuildTargetModel(ModelBuilder modelBuilder) @@ -19,6 +19,21 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) #pragma warning disable 612, 618 modelBuilder.HasAnnotation("ProductVersion", "6.0.21"); + modelBuilder.Entity("DestinationApplicationEntityRemoteAppExecution", b => + { + b.Property("ExportDetailsName") + .HasColumnType("TEXT"); + + b.Property("RemoteAppExecutionsId") + .HasColumnType("TEXT"); + + b.HasKey("ExportDetailsName", "RemoteAppExecutionsId"); + + b.HasIndex("RemoteAppExecutionsId"); + + b.ToTable("DestinationApplicationEntityRemoteAppExecution"); + }); + modelBuilder.Entity("Monai.Deploy.InformaticsGateway.Api.DestinationApplicationEntity", b => { b.Property("Name") @@ -58,6 +73,21 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) b.ToTable("DestinationApplicationEntities"); }); + modelBuilder.Entity("Monai.Deploy.InformaticsGateway.Api.DestinationApplicationEntityRemoteAppExecution", b => + { + b.Property("DestinationApplicationEntityName") + .HasColumnType("TEXT"); + + b.Property("RemoteAppExecutionId") + .HasColumnType("TEXT"); + + b.HasKey("DestinationApplicationEntityName", "RemoteAppExecutionId"); + + b.HasIndex("RemoteAppExecutionId"); + + b.ToTable("RemtoeAppExecutionDestinations"); + }); + modelBuilder.Entity("Monai.Deploy.InformaticsGateway.Api.DicomAssociationInfo", b => { b.Property("Id") @@ -157,6 +187,52 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) b.ToTable("MonaiApplicationEntities"); }); + modelBuilder.Entity("Monai.Deploy.InformaticsGateway.Api.RemoteAppExecution", b => + { + b.Property("Id") + .HasColumnType("TEXT"); + + b.Property("CorrelationId") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("ExportTaskId") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("Files") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("OriginalValues") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("OutgoingUid") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("ProxyValues") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("RequestTime") + .HasColumnType("TEXT"); + + b.Property("StudyUid") + .HasColumnType("TEXT"); + + b.Property("WorkflowInstanceId") + .IsRequired() + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex(new[] { "OutgoingUid" }, "idx_outgoing_key"); + + b.ToTable("RemoteAppExecutions"); + }); + modelBuilder.Entity("Monai.Deploy.InformaticsGateway.Api.Rest.InferenceRequest", b => { b.Property("InferenceRequestId") @@ -364,6 +440,50 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) b.ToTable("StorageMetadataWrapperEntities"); }); + + modelBuilder.Entity("DestinationApplicationEntityRemoteAppExecution", b => + { + b.HasOne("Monai.Deploy.InformaticsGateway.Api.DestinationApplicationEntity", null) + .WithMany() + .HasForeignKey("ExportDetailsName") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Monai.Deploy.InformaticsGateway.Api.RemoteAppExecution", null) + .WithMany() + .HasForeignKey("RemoteAppExecutionsId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Monai.Deploy.InformaticsGateway.Api.DestinationApplicationEntityRemoteAppExecution", b => + { + b.HasOne("Monai.Deploy.InformaticsGateway.Api.DestinationApplicationEntity", "DestinationApplicationEntity") + .WithMany("DestinationApplicationEntityRemoteAppExecutions") + .HasForeignKey("DestinationApplicationEntityName") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Monai.Deploy.InformaticsGateway.Api.RemoteAppExecution", "RemoteAppExecution") + .WithMany("DestinationApplicationEntityRemoteAppExecutions") + .HasForeignKey("RemoteAppExecutionId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("DestinationApplicationEntity"); + + b.Navigation("RemoteAppExecution"); + }); + + modelBuilder.Entity("Monai.Deploy.InformaticsGateway.Api.DestinationApplicationEntity", b => + { + b.Navigation("DestinationApplicationEntityRemoteAppExecutions"); + }); + + modelBuilder.Entity("Monai.Deploy.InformaticsGateway.Api.RemoteAppExecution", b => + { + b.Navigation("DestinationApplicationEntityRemoteAppExecutions"); + }); #pragma warning restore 612, 618 } } diff --git a/src/Database/EntityFramework/Migrations/20230816201637_R4_0.4.0.cs b/src/Database/EntityFramework/Migrations/20230816201637_R4_0.4.0.cs new file mode 100644 index 000000000..aebc3fc58 --- /dev/null +++ b/src/Database/EntityFramework/Migrations/20230816201637_R4_0.4.0.cs @@ -0,0 +1,166 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace Monai.Deploy.InformaticsGateway.Database.Migrations +{ + public partial class R4_040 : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AddColumn( + name: "TaskId", + table: "Payloads", + type: "TEXT", + nullable: true); + + migrationBuilder.AddColumn( + name: "WorkflowInstanceId", + table: "Payloads", + type: "TEXT", + nullable: true); + + migrationBuilder.AddColumn( + name: "PluginAssemblies", + table: "MonaiApplicationEntities", + type: "TEXT", + nullable: false, + defaultValue: ""); + + migrationBuilder.CreateTable( + name: "RemoteAppExecutions", + columns: table => new + { + Id = table.Column(type: "TEXT", nullable: false), + RequestTime = table.Column(type: "TEXT", nullable: false), + ExportTaskId = table.Column(type: "TEXT", nullable: false), + WorkflowInstanceId = table.Column(type: "TEXT", nullable: false), + CorrelationId = table.Column(type: "TEXT", nullable: false), + StudyUid = table.Column(type: "TEXT", nullable: true), + OutgoingUid = table.Column(type: "TEXT", nullable: false), + Files = table.Column(type: "TEXT", nullable: false), + OriginalValues = table.Column(type: "TEXT", nullable: false), + ProxyValues = table.Column(type: "TEXT", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_RemoteAppExecutions", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "VirtualApplicationEntities", + columns: table => new + { + Name = table.Column(type: "TEXT", nullable: false), + VirtualAeTitle = table.Column(type: "TEXT", nullable: false), + Workflows = table.Column(type: "TEXT", nullable: false), + PluginAssemblies = table.Column(type: "TEXT", nullable: false), + CreatedBy = table.Column(type: "TEXT", nullable: true), + UpdatedBy = table.Column(type: "TEXT", nullable: true), + DateTimeUpdated = table.Column(type: "TEXT", nullable: true), + DateTimeCreated = table.Column(type: "TEXT", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_VirtualApplicationEntities", x => x.Name); + }); + + migrationBuilder.CreateTable( + name: "DestinationApplicationEntityRemoteAppExecution", + columns: table => new + { + ExportDetailsName = table.Column(type: "TEXT", nullable: false), + RemoteAppExecutionsId = table.Column(type: "TEXT", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_DestinationApplicationEntityRemoteAppExecution", x => new { x.ExportDetailsName, x.RemoteAppExecutionsId }); + table.ForeignKey( + name: "FK_DestinationApplicationEntityRemoteAppExecution_DestinationApplicationEntities_ExportDetailsName", + column: x => x.ExportDetailsName, + principalTable: "DestinationApplicationEntities", + principalColumn: "Name", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_DestinationApplicationEntityRemoteAppExecution_RemoteAppExecutions_RemoteAppExecutionsId", + column: x => x.RemoteAppExecutionsId, + principalTable: "RemoteAppExecutions", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "RemtoeAppExecutionDestinations", + columns: table => new + { + DestinationApplicationEntityName = table.Column(type: "TEXT", nullable: false), + RemoteAppExecutionId = table.Column(type: "TEXT", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_RemtoeAppExecutionDestinations", x => new { x.DestinationApplicationEntityName, x.RemoteAppExecutionId }); + table.ForeignKey( + name: "FK_RemtoeAppExecutionDestinations_DestinationApplicationEntities_DestinationApplicationEntityName", + column: x => x.DestinationApplicationEntityName, + principalTable: "DestinationApplicationEntities", + principalColumn: "Name", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_RemtoeAppExecutionDestinations_RemoteAppExecutions_RemoteAppExecutionId", + column: x => x.RemoteAppExecutionId, + principalTable: "RemoteAppExecutions", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateIndex( + name: "IX_DestinationApplicationEntityRemoteAppExecution_RemoteAppExecutionsId", + table: "DestinationApplicationEntityRemoteAppExecution", + column: "RemoteAppExecutionsId"); + + migrationBuilder.CreateIndex( + name: "idx_outgoing_key", + table: "RemoteAppExecutions", + column: "OutgoingUid"); + + migrationBuilder.CreateIndex( + name: "IX_RemtoeAppExecutionDestinations_RemoteAppExecutionId", + table: "RemtoeAppExecutionDestinations", + column: "RemoteAppExecutionId"); + + migrationBuilder.CreateIndex( + name: "idx_virtualae_name", + table: "VirtualApplicationEntities", + column: "Name", + unique: true); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "DestinationApplicationEntityRemoteAppExecution"); + + migrationBuilder.DropTable( + name: "RemtoeAppExecutionDestinations"); + + migrationBuilder.DropTable( + name: "VirtualApplicationEntities"); + + migrationBuilder.DropTable( + name: "RemoteAppExecutions"); + + migrationBuilder.DropColumn( + name: "TaskId", + table: "Payloads"); + + migrationBuilder.DropColumn( + name: "WorkflowInstanceId", + table: "Payloads"); + + migrationBuilder.DropColumn( + name: "PluginAssemblies", + table: "MonaiApplicationEntities"); + } + } +} diff --git a/src/Database/EntityFramework/Migrations/InformaticsGatewayContextModelSnapshot.cs b/src/Database/EntityFramework/Migrations/InformaticsGatewayContextModelSnapshot.cs index c9f1b4b9c..c4624dbe4 100644 --- a/src/Database/EntityFramework/Migrations/InformaticsGatewayContextModelSnapshot.cs +++ b/src/Database/EntityFramework/Migrations/InformaticsGatewayContextModelSnapshot.cs @@ -17,6 +17,21 @@ protected override void BuildModel(ModelBuilder modelBuilder) #pragma warning disable 612, 618 modelBuilder.HasAnnotation("ProductVersion", "6.0.21"); + modelBuilder.Entity("DestinationApplicationEntityRemoteAppExecution", b => + { + b.Property("ExportDetailsName") + .HasColumnType("TEXT"); + + b.Property("RemoteAppExecutionsId") + .HasColumnType("TEXT"); + + b.HasKey("ExportDetailsName", "RemoteAppExecutionsId"); + + b.HasIndex("RemoteAppExecutionsId"); + + b.ToTable("DestinationApplicationEntityRemoteAppExecution"); + }); + modelBuilder.Entity("Monai.Deploy.InformaticsGateway.Api.DestinationApplicationEntity", b => { b.Property("Name") @@ -56,6 +71,21 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.ToTable("DestinationApplicationEntities"); }); + modelBuilder.Entity("Monai.Deploy.InformaticsGateway.Api.DestinationApplicationEntityRemoteAppExecution", b => + { + b.Property("DestinationApplicationEntityName") + .HasColumnType("TEXT"); + + b.Property("RemoteAppExecutionId") + .HasColumnType("TEXT"); + + b.HasKey("DestinationApplicationEntityName", "RemoteAppExecutionId"); + + b.HasIndex("RemoteAppExecutionId"); + + b.ToTable("RemtoeAppExecutionDestinations"); + }); + modelBuilder.Entity("Monai.Deploy.InformaticsGateway.Api.DicomAssociationInfo", b => { b.Property("Id") @@ -155,6 +185,52 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.ToTable("MonaiApplicationEntities"); }); + modelBuilder.Entity("Monai.Deploy.InformaticsGateway.Api.RemoteAppExecution", b => + { + b.Property("Id") + .HasColumnType("TEXT"); + + b.Property("CorrelationId") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("ExportTaskId") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("Files") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("OriginalValues") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("OutgoingUid") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("ProxyValues") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("RequestTime") + .HasColumnType("TEXT"); + + b.Property("StudyUid") + .HasColumnType("TEXT"); + + b.Property("WorkflowInstanceId") + .IsRequired() + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex(new[] { "OutgoingUid" }, "idx_outgoing_key"); + + b.ToTable("RemoteAppExecutions"); + }); + modelBuilder.Entity("Monai.Deploy.InformaticsGateway.Api.Rest.InferenceRequest", b => { b.Property("InferenceRequestId") @@ -362,6 +438,50 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.ToTable("StorageMetadataWrapperEntities"); }); + + modelBuilder.Entity("DestinationApplicationEntityRemoteAppExecution", b => + { + b.HasOne("Monai.Deploy.InformaticsGateway.Api.DestinationApplicationEntity", null) + .WithMany() + .HasForeignKey("ExportDetailsName") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Monai.Deploy.InformaticsGateway.Api.RemoteAppExecution", null) + .WithMany() + .HasForeignKey("RemoteAppExecutionsId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Monai.Deploy.InformaticsGateway.Api.DestinationApplicationEntityRemoteAppExecution", b => + { + b.HasOne("Monai.Deploy.InformaticsGateway.Api.DestinationApplicationEntity", "DestinationApplicationEntity") + .WithMany("DestinationApplicationEntityRemoteAppExecutions") + .HasForeignKey("DestinationApplicationEntityName") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Monai.Deploy.InformaticsGateway.Api.RemoteAppExecution", "RemoteAppExecution") + .WithMany("DestinationApplicationEntityRemoteAppExecutions") + .HasForeignKey("RemoteAppExecutionId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("DestinationApplicationEntity"); + + b.Navigation("RemoteAppExecution"); + }); + + modelBuilder.Entity("Monai.Deploy.InformaticsGateway.Api.DestinationApplicationEntity", b => + { + b.Navigation("DestinationApplicationEntityRemoteAppExecutions"); + }); + + modelBuilder.Entity("Monai.Deploy.InformaticsGateway.Api.RemoteAppExecution", b => + { + b.Navigation("DestinationApplicationEntityRemoteAppExecutions"); + }); #pragma warning restore 612, 618 } } diff --git a/src/Database/EntityFramework/Repositories/RemoteAppExecutionRepository.cs b/src/Database/EntityFramework/Repositories/RemoteAppExecutionRepository.cs index 377b7b81f..1a12e1da3 100755 --- a/src/Database/EntityFramework/Repositories/RemoteAppExecutionRepository.cs +++ b/src/Database/EntityFramework/Repositories/RemoteAppExecutionRepository.cs @@ -20,7 +20,7 @@ using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Options; -using Monai.Deploy.InformaticsGateway.Api.Storage; +using Monai.Deploy.InformaticsGateway.Api; using Monai.Deploy.InformaticsGateway.Configuration; using Monai.Deploy.InformaticsGateway.Database.Api.Logging; using Monai.Deploy.InformaticsGateway.Database.Api.Repositories; diff --git a/src/Database/MongoDB/Integration.Test/RemoteAppRepositoryTest.cs b/src/Database/MongoDB/Integration.Test/RemoteAppRepositoryTest.cs index 080a0c9be..828aca142 100755 --- a/src/Database/MongoDB/Integration.Test/RemoteAppRepositoryTest.cs +++ b/src/Database/MongoDB/Integration.Test/RemoteAppRepositoryTest.cs @@ -20,7 +20,7 @@ using Microsoft.Extensions.Logging; using Microsoft.Extensions.Options; using Microsoft.VisualBasic; -using Monai.Deploy.InformaticsGateway.Api.Storage; +using Monai.Deploy.InformaticsGateway.Api; using Monai.Deploy.InformaticsGateway.Configuration; using Monai.Deploy.InformaticsGateway.Database.EntityFramework.Test; using Monai.Deploy.InformaticsGateway.Database.MongoDB.Repositories; diff --git a/src/Database/MongoDB/Repositories/RemoteAppExecutionRepository.cs b/src/Database/MongoDB/Repositories/RemoteAppExecutionRepository.cs index f79d97e0a..16c921de2 100755 --- a/src/Database/MongoDB/Repositories/RemoteAppExecutionRepository.cs +++ b/src/Database/MongoDB/Repositories/RemoteAppExecutionRepository.cs @@ -18,7 +18,7 @@ using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Options; -using Monai.Deploy.InformaticsGateway.Api.Storage; +using Monai.Deploy.InformaticsGateway.Api; using Monai.Deploy.InformaticsGateway.Configuration; using Monai.Deploy.InformaticsGateway.Database.Api.Logging; using Monai.Deploy.InformaticsGateway.Database.Api.Repositories; diff --git a/src/Database/MongoDB/Repositories/VirtualApplicationEntityRepository.cs b/src/Database/MongoDB/Repositories/VirtualApplicationEntityRepository.cs index 02817828c..462803fd0 100644 --- a/src/Database/MongoDB/Repositories/VirtualApplicationEntityRepository.cs +++ b/src/Database/MongoDB/Repositories/VirtualApplicationEntityRepository.cs @@ -57,7 +57,7 @@ public VirtualApplicationEntityRepository( (exception, timespan, count, context) => _logger.DatabaseErrorRetry(timespan, count, exception)); var mongoDbClient = _scope.ServiceProvider.GetRequiredService(); - var mongoDatabase = mongoDbClient.GetDatabase(mongoDbOptions.Value.DaatabaseName); + var mongoDatabase = mongoDbClient.GetDatabase(mongoDbOptions.Value.DatabaseName); _collection = mongoDatabase.GetCollection(nameof(VirtualApplicationEntity)); CreateIndexes(); } diff --git a/src/InformaticsGateway/ExecutionPlugins/ExternalAppIncoming.cs b/src/InformaticsGateway/ExecutionPlugins/ExternalAppIncoming.cs index 114a4ce57..b5f99087a 100755 --- a/src/InformaticsGateway/ExecutionPlugins/ExternalAppIncoming.cs +++ b/src/InformaticsGateway/ExecutionPlugins/ExternalAppIncoming.cs @@ -29,12 +29,14 @@ namespace Monai.Deploy.InformaticsGateway.ExecutionPlugins { + [PluginName("Remote App Execution Incoming")] public class ExternalAppIncoming : IInputDataPlugin { private readonly ILogger _logger; private readonly IServiceScopeFactory _serviceScopeFactory; private readonly PluginConfiguration _options; + public string Name => "Remote App Execution Incoming"; public ExternalAppIncoming( ILogger logger, IServiceScopeFactory serviceScopeFactory, @@ -43,15 +45,16 @@ public ExternalAppIncoming( _logger = logger ?? throw new ArgumentNullException(nameof(logger)); _serviceScopeFactory = serviceScopeFactory ?? throw new ArgumentNullException(nameof(serviceScopeFactory)); _options = configuration.Value ?? throw new ArgumentNullException(nameof(configuration)); - if (_options.Configuration.ContainsKey("ReplaceTags") is false) { throw new ArgumentNullException(nameof(configuration)); } + if (_options.RemoteAppConfigurations.ContainsKey("ReplaceTags") is false) { throw new ArgumentNullException(nameof(configuration)); } } + public async Task<(DicomFile dicomFile, FileStorageMetadata fileMetadata)> Execute(DicomFile dicomFile, FileStorageMetadata fileMetadata) { var scope = _serviceScopeFactory.CreateScope(); var repository = scope.ServiceProvider.GetRequiredService(); - var tagUsedAsKey = IDicomToolkit.GetTagArrayFromStringArray(_options.Configuration["ReplaceTags"])[0]; + var tagUsedAsKey = IDicomToolkit.GetTagArrayFromStringArray(_options.RemoteAppConfigurations["ReplaceTags"])[0]; var incommingUid = dicomFile.Dataset.GetString(tagUsedAsKey); var remoteAppExecution = await repository.GetAsync(incommingUid).ConfigureAwait(false); diff --git a/src/InformaticsGateway/ExecutionPlugins/ExternalAppOutgoing.cs b/src/InformaticsGateway/ExecutionPlugins/ExternalAppOutgoing.cs index 3eabf7f60..4cba5b0bb 100755 --- a/src/InformaticsGateway/ExecutionPlugins/ExternalAppOutgoing.cs +++ b/src/InformaticsGateway/ExecutionPlugins/ExternalAppOutgoing.cs @@ -22,7 +22,6 @@ using Microsoft.Extensions.Logging; using Microsoft.Extensions.Options; using Monai.Deploy.InformaticsGateway.Api; -using Monai.Deploy.InformaticsGateway.Api.Storage; using Monai.Deploy.InformaticsGateway.Common; using Monai.Deploy.InformaticsGateway.Configuration; using Monai.Deploy.InformaticsGateway.Database.Api.Repositories; @@ -30,12 +29,15 @@ namespace Monai.Deploy.InformaticsGateway.ExecutionPlugins { + [PluginName("Remote App Execution Outgoing")] public class ExternalAppOutgoing : IOutputDataPlugin { private readonly ILogger _logger; private readonly IServiceScopeFactory _serviceScopeFactory; private readonly PluginConfiguration _options; + public string Name => "Remote App Execution Outgoing"; + public ExternalAppOutgoing( ILogger logger, IServiceScopeFactory serviceScopeFactory, @@ -44,12 +46,12 @@ public ExternalAppOutgoing( _logger = logger ?? throw new ArgumentNullException(nameof(logger)); _serviceScopeFactory = serviceScopeFactory ?? throw new ArgumentNullException(nameof(serviceScopeFactory)); _options = configuration.Value ?? throw new ArgumentNullException(nameof(configuration)); - if (_options.Configuration.ContainsKey("ReplaceTags") is false) { throw new ArgumentNullException(nameof(configuration)); } + if (_options.RemoteAppConfigurations.ContainsKey("ReplaceTags") is false) { throw new ArgumentNullException(nameof(configuration)); } } public async Task<(DicomFile dicomFile, ExportRequestDataMessage exportRequestDataMessage)> Execute(DicomFile dicomFile, ExportRequestDataMessage exportRequestDataMessage) { - var tags = IDicomToolkit.GetTagArrayFromStringArray(_options.Configuration["ReplaceTags"]); + var tags = IDicomToolkit.GetTagArrayFromStringArray(_options.RemoteAppConfigurations["ReplaceTags"]); var outgoingUid = dicomFile.Dataset.GetString(tags[0]); var scope = _serviceScopeFactory.CreateScope(); @@ -109,7 +111,6 @@ private async Task GetRemoteAppExecution(ExportRequestDataMe WorkflowInstanceId = request.WorkflowInstanceId, ExportTaskId = request.ExportTaskId, Files = new System.Collections.Generic.List { request.Filename }, - Status = request.ExportStatus }; diff --git a/src/InformaticsGateway/Program.cs b/src/InformaticsGateway/Program.cs index 17d882c18..3a4645168 100755 --- a/src/InformaticsGateway/Program.cs +++ b/src/InformaticsGateway/Program.cs @@ -98,7 +98,7 @@ internal static IHostBuilder CreateHostBuilder(string[] args) => services.AddOptions().Bind(hostContext.Configuration.GetSection("InformaticsGateway:messaging")); services.AddOptions().Bind(hostContext.Configuration.GetSection("InformaticsGateway:storage")); services.AddOptions().Bind(hostContext.Configuration.GetSection("MonaiDeployAuthentication")); - services.AddOptions().Bind(hostContext.Configuration.GetSection("InformaticsGateway:PluginConfiguration")); + services.AddOptions().Bind(hostContext.Configuration.GetSection("InformaticsGateway:plugins")); services.TryAddEnumerable(ServiceDescriptor.Singleton, ConfigurationValidator>()); services.ConfigureDatabase(hostContext.Configuration?.GetSection("ConnectionStrings")); diff --git a/src/InformaticsGateway/Test/Services/Common/ExternalAppPluginTest.cs b/src/InformaticsGateway/Test/Services/Common/ExternalAppPluginTest.cs index a46eeb26a..0102874d2 100755 --- a/src/InformaticsGateway/Test/Services/Common/ExternalAppPluginTest.cs +++ b/src/InformaticsGateway/Test/Services/Common/ExternalAppPluginTest.cs @@ -57,7 +57,7 @@ public ExternalAppPluginTest() _destRepo.Setup(d => d.FindByNameAsync(It.IsAny(), It.IsAny())) .Returns(Task.FromResult(new DestinationApplicationEntity())); - _pluginOptions = new PluginConfiguration { Configuration = { { "ReplaceTags", "SOPClassUID, StudyInstanceUID, AccessionNumber, SeriesInstanceUID, SOPInstanceUID" } } }; + _pluginOptions = new PluginConfiguration { RemoteAppConfigurations = { { "ReplaceTags", "SOPClassUID, StudyInstanceUID, AccessionNumber, SeriesInstanceUID, SOPInstanceUID" } } }; _serviceCollection = new ServiceCollection(); _serviceCollection.AddScoped(p => _logger.Object); @@ -67,7 +67,7 @@ public ExternalAppPluginTest() _serviceCollection.AddOptions().Configure(options => options = _pluginOptions); _serviceCollection.PostConfigure(opts => { - opts.Configuration = _pluginOptions.Configuration; + opts.RemoteAppConfigurations = _pluginOptions.RemoteAppConfigurations; }); _serviceProvider = _serviceCollection.BuildServiceProvider(); @@ -83,7 +83,7 @@ public void GivenAnExternalAppIncoming_WhenInitialized_ExpectParametersToBeValid { var options = Options.Create(new PluginConfiguration { - Configuration = { { "ReplaceTags", "SOPClassUID" } } + RemoteAppConfigurations = { { "ReplaceTags", "SOPClassUID" } } }); Assert.Throws(() => new ExternalAppIncoming(null, null, null)); Assert.Throws(() => new ExternalAppIncoming(null, _serviceScopeFactory.Object, options)); @@ -97,7 +97,7 @@ public void GivenAnExternalAppOutgoing_WhenInitialized_ExpectParametersToBeValid { var options = Options.Create(new PluginConfiguration { - Configuration = { { "ReplaceTags", "SOPClassUID" } } + RemoteAppConfigurations = { { "ReplaceTags", "SOPClassUID" } } }); Assert.Throws(() => new ExternalAppOutgoing(null, null, null)); Assert.Throws(() => new ExternalAppOutgoing(null, _serviceScopeFactory.Object, options)); diff --git a/src/InformaticsGateway/appsettings.json b/src/InformaticsGateway/appsettings.json index aca527be8..2a4f6e86b 100755 --- a/src/InformaticsGateway/appsettings.json +++ b/src/InformaticsGateway/appsettings.json @@ -97,8 +97,8 @@ "dicomWeb": { "plugins": [] }, - "PluginConfiguration": { - "Configuration": { + "plugins": { + "remoteApp": { "ReplaceTags": "StudyInstanceUID, AccessionNumber, SeriesInstanceUID, SOPInstanceUID" } }