Skip to content

Commit 79eeb1b

Browse files
authored
Merge pull request #508 from Project-MONAI/AI-382
Ai 382
2 parents eb841e4 + 959816b commit 79eeb1b

39 files changed

+757
-182
lines changed

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ ENV DEBIAN_FRONTEND=noninteractive
3535
RUN apt-get clean \
3636
&& apt-get update \
3737
&& apt-get install -y --no-install-recommends curl \
38-
&& apt-get install -y libc-dev # this is a workaround for Mongo encryption library
38+
&& apt-get install -y libc6-dev=2.35-0ubuntu3.6 # this is a workaround for Mongo encryption library
3939
RUN rm -rf /var/lib/apt/lists
4040

4141

doc/dependency_decisions.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -583,7 +583,7 @@
583583
- Microsoft.NET.ILLink.Tasks
584584
- :versions:
585585
- 8.0.0
586-
- 8.0.1
586+
- 8.0.1
587587
:when: 2022-10-14T23:37:16.793Z
588588
:who: mocsharp
589589
:why: MIT (https://github.com/dotnet/runtime/raw/main/LICENSE.TXT)

src/Api/HL7DestinationEntity.cs

100644100755
Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ namespace Monai.Deploy.InformaticsGateway.Api.Models
2525
/// {
2626
/// "name": "MYPACS",
2727
/// "hostIp": "10.20.100.200",
28-
/// "aeTitle": "MONAIPACS",
2928
/// "port": 1104
3029
/// }
3130
/// </code>
@@ -36,5 +35,10 @@ public class HL7DestinationEntity : BaseApplicationEntity
3635
/// Gets or sets the port to connect to.
3736
/// </summary>
3837
public int Port { get; set; }
38+
39+
public override string ToString()
40+
{
41+
return $"Name: {Name}/Host: {HostIp}/Port: {Port}";
42+
}
3943
}
4044
}

src/Api/Models/BaseApplicationEntity.cs

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,6 @@ public class BaseApplicationEntity : MongoDBEntityBase
3535
/// </summary>
3636
public string Name { get; set; } = default!;
3737

38-
/// <summary>
39-
/// Gets or sets the AE Title (AET) used to identify itself in a DICOM association.
40-
/// </summary>
41-
public string AeTitle { get; set; } = default!;
4238

4339
/// <summary>
4440
/// Gets or set the host name or IP address of the AE Title.
@@ -62,13 +58,10 @@ public class BaseApplicationEntity : MongoDBEntityBase
6258

6359
public BaseApplicationEntity()
6460
{
65-
SetDefaultValues();
6661
}
6762

68-
public void SetDefaultValues()
63+
public virtual void SetDefaultValues()
6964
{
70-
if (string.IsNullOrWhiteSpace(Name))
71-
Name = AeTitle;
7265
}
7366

7467
public void SetAuthor(ClaimsPrincipal user, EditMode editMode)
@@ -90,7 +83,7 @@ public void SetAuthor(ClaimsPrincipal user, EditMode editMode)
9083

9184
public override string ToString()
9285
{
93-
return $"Name: {Name}/AET: {AeTitle}/Host: {HostIp}";
86+
return $"Name: {Name} /Host: {HostIp}";
9487
}
9588
}
9689
}

src/Api/Models/DestinationApplicationEntity.cs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,30 @@ namespace Monai.Deploy.InformaticsGateway.Api.Models
3232
/// </example>
3333
public class DestinationApplicationEntity : BaseApplicationEntity
3434
{
35+
public DestinationApplicationEntity() : base()
36+
{
37+
SetDefaultValues();
38+
}
39+
3540
/// <summary>
3641
/// Gets or sets the port to connect to.
3742
/// </summary>
3843
public int Port { get; set; }
44+
45+
/// <summary>
46+
/// Gets or sets the AE Title (AET) used to identify itself in a DICOM association.
47+
/// </summary>
48+
public string AeTitle { get; set; } = default!;
49+
50+
public override void SetDefaultValues()
51+
{
52+
if (string.IsNullOrWhiteSpace(Name))
53+
Name = AeTitle;
54+
}
55+
56+
public override string ToString()
57+
{
58+
return $"Name: {Name}/AET: {AeTitle}/Host: {HostIp}/Port: {Port}";
59+
}
3960
}
4061
}

src/Api/SourceApplicationEntity.cs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,5 +33,25 @@ namespace Monai.Deploy.InformaticsGateway.Api
3333
/// </example>
3434
public class SourceApplicationEntity : BaseApplicationEntity
3535
{
36+
public SourceApplicationEntity() : base()
37+
{
38+
SetDefaultValues();
39+
}
40+
41+
/// <summary>
42+
/// Gets or sets the AE Title (AET) used to identify itself in a DICOM association.
43+
/// </summary>
44+
public string AeTitle { get; set; } = default!;
45+
46+
public override void SetDefaultValues()
47+
{
48+
if (string.IsNullOrWhiteSpace(Name))
49+
Name = AeTitle;
50+
}
51+
52+
public override string ToString()
53+
{
54+
return $"Name: {Name}/AET: {AeTitle}/Host: {HostIp}";
55+
}
3656
}
3757
}

src/Api/Storage/Payload.cs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,6 @@ public TimeSpan Elapsed
8686

8787
public int FilesFailedToUpload { get => Files.Count(p => p.IsUploadFailed); }
8888

89-
public string DestinationFolder { get; set; } = string.Empty;
90-
9189
public Payload(string key, string correlationId, string? workflowInstanceId, string? taskId, DataOrigin dataTrigger, uint timeout)
9290
{
9391
Guard.Against.NullOrWhiteSpace(key, nameof(key));
@@ -108,7 +106,7 @@ public Payload(string key, string correlationId, string? workflowInstanceId, str
108106
DataTrigger = dataTrigger;
109107
}
110108

111-
public Payload(string key, string correlationId, string? workflowInstanceId, string? taskId, DataOrigin dataTrigger, uint timeout, string? payloadId = null, string? DestinationFolder = null) :
109+
public Payload(string key, string correlationId, string? workflowInstanceId, string? taskId, DataOrigin dataTrigger, uint timeout, string? payloadId) :
112110
this(key, correlationId, workflowInstanceId, taskId, dataTrigger, timeout)
113111
{
114112
Guard.Against.NullOrWhiteSpace(key, nameof(key));
@@ -121,7 +119,6 @@ public Payload(string key, string correlationId, string? workflowInstanceId, str
121119
{
122120
PayloadId = Guid.Parse(payloadId);
123121
}
124-
DestinationFolder ??= string.Empty;
125122
}
126123

127124
public void Add(FileStorageMetadata value)

src/Api/Test/HL7DestinationEntityTest.cs

100644100755
Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -21,34 +21,23 @@ namespace Monai.Deploy.InformaticsGateway.Api.Test
2121
{
2222
public class HL7DestinationEntityTest
2323
{
24-
[Fact]
25-
public void GivenAMonaiApplicationEntity_WhenNameIsNotSet_ExepectSetDefaultValuesToBeUsed()
26-
{
27-
var entity = new HL7DestinationEntity
28-
{
29-
AeTitle = "AET",
30-
};
31-
32-
entity.SetDefaultValues();
3324

34-
Assert.Equal(entity.AeTitle, entity.Name);
35-
}
3625

3726
[Fact]
3827
public void GivenAMonaiApplicationEntity_WhenNameIsSet_ExepectSetDefaultValuesToNotOverwrite()
3928
{
4029
var entity = new HL7DestinationEntity
4130
{
42-
AeTitle = "AET",
31+
Port = 1104,
4332
HostIp = "IP",
4433
Name = "Name"
4534
};
4635

4736
entity.SetDefaultValues();
4837

49-
Assert.Equal("AET", entity.AeTitle);
5038
Assert.Equal("IP", entity.HostIp);
5139
Assert.Equal("Name", entity.Name);
40+
Assert.Equal(1104, entity.Port);
5241
}
5342
}
5443
}

src/Api/Test/BaseApplicationEntityTest.cs renamed to src/Api/Test/SourceBaseApplicationEntityTest.cs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,16 @@
1414
* limitations under the License.
1515
*/
1616

17-
using Monai.Deploy.InformaticsGateway.Api.Models;
1817
using Xunit;
1918

2019
namespace Monai.Deploy.InformaticsGateway.Api.Test
2120
{
22-
public class BaseApplicationEntityTest
21+
public class SourceBaseApplicationEntityTest
2322
{
2423
[Fact]
2524
public void GivenABaseApplicationEntity_WhenNameIsNotSet_ExpectSetDefaultValuesToSetName()
2625
{
27-
var entity = new BaseApplicationEntity
26+
var entity = new SourceApplicationEntity
2827
{
2928
AeTitle = "AET",
3029
HostIp = "IP"
@@ -38,7 +37,7 @@ public void GivenABaseApplicationEntity_WhenNameIsNotSet_ExpectSetDefaultValuesT
3837
[Fact]
3938
public void GivenABaseApplicationEntity_WhenNameIsSet_ExpectSetDefaultValuesToNotSetName()
4039
{
41-
var entity = new BaseApplicationEntity
40+
var entity = new SourceApplicationEntity
4241
{
4342
AeTitle = "AET",
4443
HostIp = "IP",

src/Configuration/ValidationExtensions.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,7 @@ public static bool IsValid(this HL7DestinationEntity hl7destinationEntity, out I
6666

6767
var valid = true;
6868
valid &= !string.IsNullOrWhiteSpace(hl7destinationEntity.Name);
69-
valid &= IsAeTitleValid(hl7destinationEntity.GetType().Name, hl7destinationEntity.AeTitle, validationErrors);
70-
valid &= IsValidHostNameIp(hl7destinationEntity.AeTitle, hl7destinationEntity.HostIp, validationErrors);
69+
valid &= IsValidHostNameIp(hl7destinationEntity.Name, hl7destinationEntity.HostIp, validationErrors);
7170
valid &= IsPortValid(hl7destinationEntity.GetType().Name, hl7destinationEntity.Port, validationErrors);
7271

7372
return valid;

src/Database/DatabaseMigrationManager.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ private static Type[] FindMatchingTypesFromAssemblies(Assembly[] assemblies)
6868
}
6969
}
7070

71-
return matchingTypes.ToArray();
71+
return [.. matchingTypes];
7272
}
7373
}
7474
}

src/Database/EntityFramework/Configuration/HL7DestinationEntityConfiguration.cs

100644100755
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ internal class HL7DestinationEntityConfiguration : IEntityTypeConfiguration<HL7D
2626
public void Configure(EntityTypeBuilder<HL7DestinationEntity> builder)
2727
{
2828
builder.HasKey(j => j.Name);
29-
builder.Property(j => j.AeTitle).IsRequired();
3029
builder.Property(j => j.Port).IsRequired();
3130
builder.Property(j => j.HostIp).IsRequired();
3231
builder.Property(j => j.CreatedBy).IsRequired(false);
@@ -35,7 +34,7 @@ public void Configure(EntityTypeBuilder<HL7DestinationEntity> builder)
3534
builder.Property(j => j.DateTimeUpdated).IsRequired(false);
3635

3736
builder.HasIndex(p => p.Name, "idx_destination_name").IsUnique();
38-
builder.HasIndex(p => new { p.Name, p.AeTitle, p.HostIp, p.Port }, "idx_source_all").IsUnique();
37+
builder.HasIndex(p => new { p.Name, p.HostIp, p.Port }, "idx_source_all").IsUnique();
3938

4039
builder.Ignore(p => p.Id);
4140
}

src/Database/EntityFramework/EfDatabaseMigrationManager.cs

100644100755
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public IHost Migrate(IHost host)
3737
catch (Exception ex)
3838
{
3939
var logger = scope.ServiceProvider.GetService<ILogger>();
40-
logger?.Log(LogLevel.Critical, "Failed to migrate database", ex);
40+
logger?.Log(LogLevel.Critical, message: "Failed to migrate database", exception: ex);
4141
throw;
4242
}
4343
}

src/Database/EntityFramework/Migrations/20221116172042_R3_0.3.4.cs

100644100755
Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ namespace Monai.Deploy.InformaticsGateway.Database.Migrations
66
{
77
public partial class R3_034 : Migration
88
{
9+
private static readonly string[] StorageMetadataWrapperEntitiesColumns = ["CorrelationId", "Identity"];
10+
private static readonly string[] StorageMetadataWrapperColumns = ["CorrelationId", "Identity"];
11+
912
protected override void Up(MigrationBuilder migrationBuilder)
1013
{
1114
migrationBuilder.DropTable(
@@ -87,7 +90,7 @@ protected override void Up(MigrationBuilder migrationBuilder)
8790
migrationBuilder.CreateIndex(
8891
name: "idx_storagemetadata_ids",
8992
table: "StorageMetadataWrapperEntities",
90-
columns: new[] { "CorrelationId", "Identity" });
93+
columns: StorageMetadataWrapperEntitiesColumns);
9194

9295
migrationBuilder.CreateIndex(
9396
name: "idx_storagemetadata_uploaded",
@@ -166,7 +169,7 @@ protected override void Down(MigrationBuilder migrationBuilder)
166169
migrationBuilder.CreateIndex(
167170
name: "idx_storagemetadata_ids",
168171
table: "StorageMetadataWrapper",
169-
columns: new[] { "CorrelationId", "Identity" });
172+
columns: StorageMetadataWrapperColumns);
170173

171174
migrationBuilder.CreateIndex(
172175
name: "idx_storagemetadata_uploaded",

src/Database/EntityFramework/Migrations/20231204113501_Hl7DEstinationAndConfig.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ namespace Monai.Deploy.InformaticsGateway.Database.Migrations
77
{
88
public partial class Hl7DEstinationAndConfig : Migration
99
{
10+
private static readonly string[] HL7DestinationEntitiesColumns = ["Name", "AeTitle", "HostIp", "Port"];
11+
1012
protected override void Up(MigrationBuilder migrationBuilder)
1113
{
1214
migrationBuilder.CreateTable(
@@ -58,7 +60,7 @@ protected override void Up(MigrationBuilder migrationBuilder)
5860
migrationBuilder.CreateIndex(
5961
name: "idx_source_all_HL7Destination",
6062
table: "HL7DestinationEntities",
61-
columns: new[] { "Name", "AeTitle", "HostIp", "Port" },
63+
columns: HL7DestinationEntitiesColumns,
6264
unique: true);
6365
}
6466

0 commit comments

Comments
 (0)