Skip to content

Commit

Permalink
Regenerate EF DB migration code
Browse files Browse the repository at this point in the history
  • Loading branch information
mocsharp committed Aug 16, 2023
1 parent bbced00 commit fa9dbeb
Show file tree
Hide file tree
Showing 24 changed files with 552 additions and 499 deletions.
8 changes: 8 additions & 0 deletions src/Api/DestinationApplicationEntity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
* limitations under the License.
*/

using System.Collections.Generic;

namespace Monai.Deploy.InformaticsGateway.Api
{
/// <summary>
Expand All @@ -36,5 +38,11 @@ public class DestinationApplicationEntity : BaseApplicationEntity
/// Gets or sets the port to connect to.
/// </summary>
public int Port { get; set; }

/// <summary>
/// Gets or sets remote application executions.
/// </summary>
public virtual List<RemoteAppExecution> RemoteAppExecutions { get; set; } = new();
public virtual List<DestinationApplicationEntityRemoteAppExecution> DestinationApplicationEntityRemoteAppExecutions { get; set; } = new();
}
}
28 changes: 28 additions & 0 deletions src/Api/DestinationApplicationEntityRemoteAppExecution.cs
Original file line number Diff line number Diff line change
@@ -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!;
}
}
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -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
{
/// <summary>
/// TODO: include description of class and all properties

Check warning on line 24 in src/Api/RemoteAppExecution.cs

View workflow job for this annotation

GitHub Actions / unit-test

Complete the task associated to this 'TODO' comment.

Check warning on line 24 in src/Api/RemoteAppExecution.cs

View workflow job for this annotation

GitHub Actions / unit-test

Complete the task associated to this 'TODO' comment.

Check warning on line 24 in src/Api/RemoteAppExecution.cs

View workflow job for this annotation

GitHub Actions / unit-test

Complete the task associated to this 'TODO' comment.
/// /// </summary>
public class RemoteAppExecution
{
[JsonPropertyName("_id")]
public string Id { get; set; } = default!;

/// <summary>
/// Gets or sets exported destinations
/// </summary>
public virtual List<DestinationApplicationEntity> ExportDetails { get; set; } = new();
public virtual List<DestinationApplicationEntityRemoteAppExecution> 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<DestinationApplicationEntity> ExportDetails { get; set; } = new();

public List<string> Files { get; set; } = new();
public FileExportStatus Status { get; set; }
public Dictionary<string, string> OriginalValues { get; set; } = new();
public Dictionary<string, string> ProxyValues { get; set; } = new();
}

/// <summary>
/// TODO: maybe use internal for testing?

Check warning on line 50 in src/Api/RemoteAppExecution.cs

View workflow job for this annotation

GitHub Actions / unit-test

Complete the task associated to this 'TODO' comment.

Check warning on line 50 in src/Api/RemoteAppExecution.cs

View workflow job for this annotation

GitHub Actions / unit-test

Complete the task associated to this 'TODO' comment.
/// </summary>
public class RemoteAppExecutionTest
{
[JsonPropertyName("_id")]
Expand Down
7 changes: 7 additions & 0 deletions src/Configuration/InformaticsGatewayConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,12 @@ public class InformaticsGatewayConfiguration
[ConfigurationKeyName("database")]
public DatabaseConfiguration Database { get; set; }

/// <summary>
/// Represents the <c>pluginConfiguration</c> section of the configuration file.
/// </summary>
[ConfigurationKeyName("plugins")]
public PluginConfiguration PluginConfigurations { get; set; }

public InformaticsGatewayConfiguration()
{
Dicom = new DicomConfiguration();
Expand All @@ -86,6 +92,7 @@ public InformaticsGatewayConfiguration()
Messaging = new MessageBrokerConfiguration();
Database = new DatabaseConfiguration();
Hl7 = new Hl7Configuration();
PluginConfigurations = new PluginConfiguration();
}
}
}
4 changes: 3 additions & 1 deletion src/Configuration/PluginConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,13 @@
*/

using System.Collections.Generic;
using Microsoft.Extensions.Configuration;

namespace Monai.Deploy.InformaticsGateway.Configuration
{
public class PluginConfiguration
{
public Dictionary<string, string> Configuration { get; set; } = new();
[ConfigurationKeyName("remoteApp")]
public Dictionary<string, string> RemoteAppConfigurations { get; set; } = new();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
Original file line number Diff line number Diff line change
@@ -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<DestinationApplicationEntityRemoteAppExecution>
{
public void Configure(EntityTypeBuilder<DestinationApplicationEntityRemoteAppExecution> 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);

}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -29,6 +30,18 @@ internal class RemoteAppExecutionConfiguration : IEntityTypeConfiguration<Remote
{
public void Configure(EntityTypeBuilder<RemoteAppExecution> builder)
{
var stringValueComparer = new ValueComparer<List<string>>(
(c1, c2) => c1.SequenceEqual(c2),
c => c.Aggregate(0, (a, v) => HashCode.Combine(a, v.GetHashCode())),
c => c.ToList());
var destAeValueComparer = new ValueComparer<List<DestinationApplicationEntity>>(
(c1, c2) => c1.SequenceEqual(c2),
c => c.Aggregate(0, (a, v) => HashCode.Combine(a, v.GetHashCode())),
c => c.ToList());
var dictValueComparer = new ValueComparer<Dictionary<string, string>>(
(c1, c2) => c1!.Equals(c2),
c => c.GetHashCode(),
c => c.ToDictionary(entry => entry.Key, entry => entry.Value));
var jsonSerializerSettings = new JsonSerializerOptions
{
DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull
Expand All @@ -38,24 +51,25 @@ public void Configure(EntityTypeBuilder<RemoteAppExecution> 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<Dictionary<string, string>>(v, jsonSerializerSettings));
v => JsonSerializer.Deserialize<Dictionary<string, string>>(v, jsonSerializerSettings))
.Metadata.SetValueComparer(dictValueComparer);
builder.Property(j => j.ProxyValues)
.HasConversion(
v => JsonSerializer.Serialize(v, jsonSerializerSettings),
v => JsonSerializer.Deserialize<Dictionary<string, string>>(v, jsonSerializerSettings));
v => JsonSerializer.Deserialize<Dictionary<string, string>>(v, jsonSerializerSettings))
.Metadata.SetValueComparer(dictValueComparer);

builder.Property(j => j.Files)
.HasConversion(
v => JsonSerializer.Serialize(v, jsonSerializerSettings),
v => JsonSerializer.Deserialize<List<string>>(v, jsonSerializerSettings));
v => JsonSerializer.Deserialize<List<string>>(v, jsonSerializerSettings))
.Metadata.SetValueComparer(stringValueComparer);

builder.HasIndex(p => p.OutgoingUid, "idx_outgoing_key");

}
}

Expand Down
2 changes: 2 additions & 0 deletions src/Database/EntityFramework/InformaticsGatewayContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ public InformaticsGatewayContext(DbContextOptions<InformaticsGatewayContext> opt
public virtual DbSet<DicomAssociationInfo> DicomAssociationHistories { get; set; }
public virtual DbSet<VirtualApplicationEntity> VirtualApplicationEntities { get; set; }
public virtual DbSet<RemoteAppExecution> RemoteAppExecutions { get; set; }
public virtual DbSet<DestinationApplicationEntityRemoteAppExecution> RemtoeAppExecutionDestinations { get; set; }

protected override void OnModelCreating(ModelBuilder modelBuilder)
{
Expand All @@ -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)
Expand Down
46 changes: 0 additions & 46 deletions src/Database/EntityFramework/Migrations/20230808233742_R4_0.4.0.cs

This file was deleted.

Loading

0 comments on commit fa9dbeb

Please sign in to comment.