Skip to content

Commit fa9dbeb

Browse files
committed
Regenerate EF DB migration code
1 parent bbced00 commit fa9dbeb

24 files changed

+552
-499
lines changed

src/Api/DestinationApplicationEntity.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
* limitations under the License.
1616
*/
1717

18+
using System.Collections.Generic;
19+
1820
namespace Monai.Deploy.InformaticsGateway.Api
1921
{
2022
/// <summary>
@@ -36,5 +38,11 @@ public class DestinationApplicationEntity : BaseApplicationEntity
3638
/// Gets or sets the port to connect to.
3739
/// </summary>
3840
public int Port { get; set; }
41+
42+
/// <summary>
43+
/// Gets or sets remote application executions.
44+
/// </summary>
45+
public virtual List<RemoteAppExecution> RemoteAppExecutions { get; set; } = new();
46+
public virtual List<DestinationApplicationEntityRemoteAppExecution> DestinationApplicationEntityRemoteAppExecutions { get; set; } = new();
3947
}
4048
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/*
2+
* Copyright 2023 MONAI Consortium
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
18+
namespace Monai.Deploy.InformaticsGateway.Api
19+
{
20+
public class DestinationApplicationEntityRemoteAppExecution
21+
{
22+
public string DestinationApplicationEntityName { get; set; } = default!;
23+
public DestinationApplicationEntity DestinationApplicationEntity { get; set; } = default!;
24+
25+
public string RemoteAppExecutionId { get; set; } = default!;
26+
public RemoteAppExecution RemoteAppExecution { get; set; } = default!;
27+
}
28+
}

src/Api/Storage/RemoteAppExecution.cs renamed to src/Api/RemoteAppExecution.cs

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2021-2023 MONAI Consortium
2+
* Copyright 2023 MONAI Consortium
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -17,26 +17,38 @@
1717
using System;
1818
using System.Collections.Generic;
1919
using System.Text.Json.Serialization;
20-
using Monai.Deploy.Messaging.Events;
2120

22-
namespace Monai.Deploy.InformaticsGateway.Api.Storage
21+
namespace Monai.Deploy.InformaticsGateway.Api
2322
{
23+
/// <summary>
24+
/// TODO: include description of class and all properties
25+
/// /// </summary>
2426
public class RemoteAppExecution
2527
{
2628
[JsonPropertyName("_id")]
2729
public string Id { get; set; } = default!;
30+
31+
/// <summary>
32+
/// Gets or sets exported destinations
33+
/// </summary>
34+
public virtual List<DestinationApplicationEntity> ExportDetails { get; set; } = new();
35+
public virtual List<DestinationApplicationEntityRemoteAppExecution> DestinationApplicationEntityRemoteAppExecutions { get; set; } = new();
36+
2837
public DateTime RequestTime { get; set; } = DateTime.UtcNow;
2938
public string ExportTaskId { get; set; } = string.Empty;
3039
public string WorkflowInstanceId { get; set; } = string.Empty;
3140
public string CorrelationId { get; set; } = string.Empty;
3241
public string? StudyUid { get; set; }
3342
public string? OutgoingUid { get { return Id; } set { Id = value ?? ""; } }
34-
public List<DestinationApplicationEntity> ExportDetails { get; set; } = new();
43+
3544
public List<string> Files { get; set; } = new();
36-
public FileExportStatus Status { get; set; }
3745
public Dictionary<string, string> OriginalValues { get; set; } = new();
3846
public Dictionary<string, string> ProxyValues { get; set; } = new();
3947
}
48+
49+
/// <summary>
50+
/// TODO: maybe use internal for testing?
51+
/// </summary>
4052
public class RemoteAppExecutionTest
4153
{
4254
[JsonPropertyName("_id")]

src/Configuration/InformaticsGatewayConfiguration.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,12 @@ public class InformaticsGatewayConfiguration
7676
[ConfigurationKeyName("database")]
7777
public DatabaseConfiguration Database { get; set; }
7878

79+
/// <summary>
80+
/// Represents the <c>pluginConfiguration</c> section of the configuration file.
81+
/// </summary>
82+
[ConfigurationKeyName("plugins")]
83+
public PluginConfiguration PluginConfigurations { get; set; }
84+
7985
public InformaticsGatewayConfiguration()
8086
{
8187
Dicom = new DicomConfiguration();
@@ -86,6 +92,7 @@ public InformaticsGatewayConfiguration()
8692
Messaging = new MessageBrokerConfiguration();
8793
Database = new DatabaseConfiguration();
8894
Hl7 = new Hl7Configuration();
95+
PluginConfigurations = new PluginConfiguration();
8996
}
9097
}
9198
}

src/Configuration/PluginConfiguration.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,13 @@
1515
*/
1616

1717
using System.Collections.Generic;
18+
using Microsoft.Extensions.Configuration;
1819

1920
namespace Monai.Deploy.InformaticsGateway.Configuration
2021
{
2122
public class PluginConfiguration
2223
{
23-
public Dictionary<string, string> Configuration { get; set; } = new();
24+
[ConfigurationKeyName("remoteApp")]
25+
public Dictionary<string, string> RemoteAppConfigurations { get; set; } = new();
2426
}
2527
}

src/Database/Api/Repositories/IRemoteAppExecutionRepository.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* limitations under the License.
1515
*/
1616

17-
using Monai.Deploy.InformaticsGateway.Api.Storage;
17+
using Monai.Deploy.InformaticsGateway.Api;
1818

1919
namespace Monai.Deploy.InformaticsGateway.Database.Api.Repositories
2020
{
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
/*
2+
* Copyright 2021-2022 MONAI Consortium
3+
* Copyright 2021 NVIDIA Corporation
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
using Microsoft.EntityFrameworkCore;
19+
using Microsoft.EntityFrameworkCore.Metadata.Builders;
20+
using Monai.Deploy.InformaticsGateway.Api;
21+
22+
namespace Monai.Deploy.InformaticsGateway.Database.EntityFramework.Configuration
23+
{
24+
25+
internal class DestinationApplicationEntityRemoteAppExecutionConfiguration : IEntityTypeConfiguration<DestinationApplicationEntityRemoteAppExecution>
26+
{
27+
public void Configure(EntityTypeBuilder<DestinationApplicationEntityRemoteAppExecution> builder)
28+
{
29+
builder.HasKey(dr => new { dr.DestinationApplicationEntityName, dr.RemoteAppExecutionId });
30+
builder.HasOne(bc => bc.RemoteAppExecution)
31+
.WithMany(b => b.DestinationApplicationEntityRemoteAppExecutions)
32+
.HasForeignKey(bc => bc.RemoteAppExecutionId);
33+
builder.HasOne(bc => bc.DestinationApplicationEntity)
34+
.WithMany(c => c.DestinationApplicationEntityRemoteAppExecutions)
35+
.HasForeignKey(bc => bc.DestinationApplicationEntityName);
36+
37+
}
38+
}
39+
}

src/Database/EntityFramework/Configuration/RemoteAppExecutionConfiguration.cs

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
using Microsoft.EntityFrameworkCore;
2020
using Microsoft.EntityFrameworkCore.ChangeTracking;
2121
using Microsoft.EntityFrameworkCore.Metadata.Builders;
22+
using Monai.Deploy.InformaticsGateway.Api;
2223
using Monai.Deploy.InformaticsGateway.Api.Storage;
2324

2425
namespace Monai.Deploy.InformaticsGateway.Database.EntityFramework.Configuration
@@ -29,6 +30,18 @@ internal class RemoteAppExecutionConfiguration : IEntityTypeConfiguration<Remote
2930
{
3031
public void Configure(EntityTypeBuilder<RemoteAppExecution> builder)
3132
{
33+
var stringValueComparer = new ValueComparer<List<string>>(
34+
(c1, c2) => c1.SequenceEqual(c2),
35+
c => c.Aggregate(0, (a, v) => HashCode.Combine(a, v.GetHashCode())),
36+
c => c.ToList());
37+
var destAeValueComparer = new ValueComparer<List<DestinationApplicationEntity>>(
38+
(c1, c2) => c1.SequenceEqual(c2),
39+
c => c.Aggregate(0, (a, v) => HashCode.Combine(a, v.GetHashCode())),
40+
c => c.ToList());
41+
var dictValueComparer = new ValueComparer<Dictionary<string, string>>(
42+
(c1, c2) => c1!.Equals(c2),
43+
c => c.GetHashCode(),
44+
c => c.ToDictionary(entry => entry.Key, entry => entry.Value));
3245
var jsonSerializerSettings = new JsonSerializerOptions
3346
{
3447
DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull
@@ -38,24 +51,25 @@ public void Configure(EntityTypeBuilder<RemoteAppExecution> builder)
3851

3952
builder.Property(j => j.OutgoingUid).IsRequired();
4053
builder.Property(j => j.ExportTaskId).IsRequired();
41-
//builder.Property(j => j.Status).IsRequired();
4254
builder.Property(j => j.CorrelationId).IsRequired();
4355
builder.Property(j => j.OriginalValues)
4456
.HasConversion(
4557
v => JsonSerializer.Serialize(v, jsonSerializerSettings),
46-
v => JsonSerializer.Deserialize<Dictionary<string, string>>(v, jsonSerializerSettings));
58+
v => JsonSerializer.Deserialize<Dictionary<string, string>>(v, jsonSerializerSettings))
59+
.Metadata.SetValueComparer(dictValueComparer);
4760
builder.Property(j => j.ProxyValues)
4861
.HasConversion(
4962
v => JsonSerializer.Serialize(v, jsonSerializerSettings),
50-
v => JsonSerializer.Deserialize<Dictionary<string, string>>(v, jsonSerializerSettings));
63+
v => JsonSerializer.Deserialize<Dictionary<string, string>>(v, jsonSerializerSettings))
64+
.Metadata.SetValueComparer(dictValueComparer);
5165

5266
builder.Property(j => j.Files)
5367
.HasConversion(
5468
v => JsonSerializer.Serialize(v, jsonSerializerSettings),
55-
v => JsonSerializer.Deserialize<List<string>>(v, jsonSerializerSettings));
69+
v => JsonSerializer.Deserialize<List<string>>(v, jsonSerializerSettings))
70+
.Metadata.SetValueComparer(stringValueComparer);
5671

5772
builder.HasIndex(p => p.OutgoingUid, "idx_outgoing_key");
58-
5973
}
6074
}
6175

src/Database/EntityFramework/InformaticsGatewayContext.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ public InformaticsGatewayContext(DbContextOptions<InformaticsGatewayContext> opt
4242
public virtual DbSet<DicomAssociationInfo> DicomAssociationHistories { get; set; }
4343
public virtual DbSet<VirtualApplicationEntity> VirtualApplicationEntities { get; set; }
4444
public virtual DbSet<RemoteAppExecution> RemoteAppExecutions { get; set; }
45+
public virtual DbSet<DestinationApplicationEntityRemoteAppExecution> RemtoeAppExecutionDestinations { get; set; }
4546

4647
protected override void OnModelCreating(ModelBuilder modelBuilder)
4748
{
@@ -56,6 +57,7 @@ protected override void OnModelCreating(ModelBuilder modelBuilder)
5657
modelBuilder.ApplyConfiguration(new DicomAssociationInfoConfiguration());
5758
modelBuilder.ApplyConfiguration(new VirtualApplicationEntityConfiguration());
5859
modelBuilder.ApplyConfiguration(new RemoteAppExecutionConfiguration());
60+
modelBuilder.ApplyConfiguration(new DestinationApplicationEntityRemoteAppExecutionConfiguration());
5961
}
6062

6163
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)

src/Database/EntityFramework/Migrations/20230808233742_R4_0.4.0.cs

Lines changed: 0 additions & 46 deletions
This file was deleted.

0 commit comments

Comments
 (0)