From 1bcb32b6b019700d3dfb41dc487ad5cb78cfeeb5 Mon Sep 17 00:00:00 2001 From: Lillie Dae Date: Thu, 21 Sep 2023 10:45:28 +0100 Subject: [PATCH] code comment changes Signed-off-by: Lillie Dae --- docs/api/rest/dicom-association.md | 4 ++-- .../{EndpointSettings.cs => HttpEndpointSettings.cs} | 2 +- src/Configuration/InformaticsGatewayConfiguration.cs | 6 ------ src/InformaticsGateway/Logging/Log.0.General.cs | 3 --- .../Logging/Log.8000.HttpServices.cs | 6 ++++++ src/InformaticsGateway/Program.cs | 1 + .../Services/Http/DicomAssociationInfoController.cs | 12 ++++++------ .../Services/Http/PagedApiControllerBase.cs | 6 +++--- .../Http/DicomAssociationInfoControllerTest.cs | 4 ++-- 9 files changed, 21 insertions(+), 23 deletions(-) rename src/Configuration/{EndpointSettings.cs => HttpEndpointSettings.cs} (96%) diff --git a/docs/api/rest/dicom-association.md b/docs/api/rest/dicom-association.md index 5b40a6ee3..1b2ffc5a2 100644 --- a/docs/api/rest/dicom-association.md +++ b/docs/api/rest/dicom-association.md @@ -16,10 +16,10 @@ # DICOM Association information -The `/dai' endpoint is for retrieving a list of information regarding dicom +The `/dicom-associations' endpoint is for retrieving a list of information regarding dicom associations. -## GET /dai/ +## GET /dicom-associations/ #### Query Parameters diff --git a/src/Configuration/EndpointSettings.cs b/src/Configuration/HttpEndpointSettings.cs similarity index 96% rename from src/Configuration/EndpointSettings.cs rename to src/Configuration/HttpEndpointSettings.cs index 100bc1150..d62a045a6 100644 --- a/src/Configuration/EndpointSettings.cs +++ b/src/Configuration/HttpEndpointSettings.cs @@ -19,7 +19,7 @@ namespace Monai.Deploy.InformaticsGateway.Configuration { - public class EndpointSettings + public class HttpEndpointSettings { [ConfigurationKeyName("defaultPageSize")] public int DefaultPageSize { get; set; } = 10; diff --git a/src/Configuration/InformaticsGatewayConfiguration.cs b/src/Configuration/InformaticsGatewayConfiguration.cs index 7d53f856e..b7bfd77d2 100644 --- a/src/Configuration/InformaticsGatewayConfiguration.cs +++ b/src/Configuration/InformaticsGatewayConfiguration.cs @@ -82,11 +82,6 @@ public class InformaticsGatewayConfiguration [ConfigurationKeyName("plugins")] public PlugInConfiguration PlugInConfigurations { get; set; } - /// - /// Represents the endpointSettings section of the configuration file. - /// - [ConfigurationKeyName("endpointSettings")] - public EndpointSettings EndpointSettings { get; set; } public InformaticsGatewayConfiguration() { @@ -99,7 +94,6 @@ public InformaticsGatewayConfiguration() Database = new DatabaseConfiguration(); Hl7 = new Hl7Configuration(); PlugInConfigurations = new PlugInConfiguration(); - EndpointSettings = new EndpointSettings(); } } } diff --git a/src/InformaticsGateway/Logging/Log.0.General.cs b/src/InformaticsGateway/Logging/Log.0.General.cs index ea8b72052..fa610c15e 100644 --- a/src/InformaticsGateway/Logging/Log.0.General.cs +++ b/src/InformaticsGateway/Logging/Log.0.General.cs @@ -59,8 +59,5 @@ public static partial class Log [LoggerMessage(EventId = 13, Level = LogLevel.Critical, Message = "Failed to start {ServiceName}.")] public static partial void ServiceFailedToStart(this ILogger logger, string serviceName, Exception ex); - - [LoggerMessage(EventId = 14, Level = LogLevel.Error, Message = "Unexpected error occurred in GET /dai API..")] - public static partial void DAIControllerGetAllAsyncError(this ILogger logger, Exception ex); } } diff --git a/src/InformaticsGateway/Logging/Log.8000.HttpServices.cs b/src/InformaticsGateway/Logging/Log.8000.HttpServices.cs index a494082c4..48fcdd325 100644 --- a/src/InformaticsGateway/Logging/Log.8000.HttpServices.cs +++ b/src/InformaticsGateway/Logging/Log.8000.HttpServices.cs @@ -173,5 +173,11 @@ public static partial class Log [LoggerMessage(EventId = 8204, Level = LogLevel.Error, Message = "Failed to store FHIR resource.")] public static partial void ErrorStoringFhirResource(this ILogger logger, Exception ex); + + // + // Dicom Associations Controller. + // + [LoggerMessage(EventId = 8300, Level = LogLevel.Error, Message = "Unexpected error occurred in GET /dicom-associations API..")] + public static partial void DicomAssociationsControllerGetError(this ILogger logger, Exception ex); } } diff --git a/src/InformaticsGateway/Program.cs b/src/InformaticsGateway/Program.cs index 9c3c95336..d0fa5d970 100644 --- a/src/InformaticsGateway/Program.cs +++ b/src/InformaticsGateway/Program.cs @@ -97,6 +97,7 @@ internal static IHostBuilder CreateHostBuilder(string[] args) => .ConfigureServices((hostContext, services) => { services.AddOptions().Bind(hostContext.Configuration.GetSection("InformaticsGateway")); + services.AddOptions().Bind(hostContext.Configuration.GetSection("InformaticsGateway:httpEndpointSettings")); services.AddOptions().Bind(hostContext.Configuration.GetSection("InformaticsGateway:messaging")); services.AddOptions().Bind(hostContext.Configuration.GetSection("InformaticsGateway:storage")); services.AddOptions().Bind(hostContext.Configuration.GetSection("MonaiDeployAuthentication")); diff --git a/src/InformaticsGateway/Services/Http/DicomAssociationInfoController.cs b/src/InformaticsGateway/Services/Http/DicomAssociationInfoController.cs index 3c1e066f4..d794cecff 100644 --- a/src/InformaticsGateway/Services/Http/DicomAssociationInfoController.cs +++ b/src/InformaticsGateway/Services/Http/DicomAssociationInfoController.cs @@ -32,16 +32,16 @@ namespace Monai.Deploy.InformaticsGateway.Services.Http { - [Route("dai")] + [Route("dicom-associations")] public class DicomAssociationInfoController : PagedApiControllerBase { - private const string Endpoint = "/dai"; + private const string Endpoint = "/dicom-associations"; private readonly ILogger _logger; private readonly IDicomAssociationInfoRepository _dicomRepo; private readonly IUriService _uriService; public DicomAssociationInfoController(ILogger logger, - IOptions options, + IOptions options, IDicomAssociationInfoRepository dicomRepo, IUriService uriService) : base(options) { @@ -63,13 +63,13 @@ public async Task GetAllAsync([FromQuery] TimeFilter filter) try { var route = Request?.Path.Value ?? string.Empty; - var pageSize = filter.PageSize ?? EndpointOptions.Value.EndpointSettings.DefaultPageSize; + var pageSize = filter.PageSize ?? EndpointOptions.Value.DefaultPageSize; var validFilter = new TimeFilter( filter.StartTime, filter.EndTime, filter.PageNumber ?? 0, pageSize, - EndpointOptions.Value.EndpointSettings.MaxPageSize); + EndpointOptions.Value.MaxPageSize); var pagedData = await _dicomRepo.GetAllAsync( validFilter.GetSkip(), @@ -83,7 +83,7 @@ public async Task GetAllAsync([FromQuery] TimeFilter filter) } catch (Exception e) { - _logger.DAIControllerGetAllAsyncError(e); + _logger.DicomAssociationsControllerGetError(e); return Problem($"Unexpected error occurred: {e.Message}", Endpoint, InternalServerError); } } diff --git a/src/InformaticsGateway/Services/Http/PagedApiControllerBase.cs b/src/InformaticsGateway/Services/Http/PagedApiControllerBase.cs index 22c807607..09db23ea7 100644 --- a/src/InformaticsGateway/Services/Http/PagedApiControllerBase.cs +++ b/src/InformaticsGateway/Services/Http/PagedApiControllerBase.cs @@ -27,9 +27,9 @@ namespace Monai.Deploy.InformaticsGateway.Services.Http { public class PagedApiControllerBase : ApiControllerBase { - protected readonly IOptions EndpointOptions; + protected readonly IOptions EndpointOptions; - public PagedApiControllerBase(IOptions options) + public PagedApiControllerBase(IOptions options) { EndpointOptions = options ?? throw new ArgumentNullException(nameof(options)); } @@ -51,7 +51,7 @@ public PagedResponse> CreatePagedResponse(IEnumerable paged Guard.Against.Null(route, nameof(route)); Guard.Against.Null(uriService, nameof(uriService)); - var pageSize = validFilter.PageSize ?? EndpointOptions.Value.EndpointSettings.DefaultPageSize; + var pageSize = validFilter.PageSize ?? EndpointOptions.Value.DefaultPageSize; var response = new PagedResponse>(pagedData, validFilter.PageNumber ?? 0, pageSize); response.SetUp(validFilter, totalRecords, uriService, route); diff --git a/src/InformaticsGateway/Test/Services/Http/DicomAssociationInfoControllerTest.cs b/src/InformaticsGateway/Test/Services/Http/DicomAssociationInfoControllerTest.cs index 94403b3cf..1558ec691 100644 --- a/src/InformaticsGateway/Test/Services/Http/DicomAssociationInfoControllerTest.cs +++ b/src/InformaticsGateway/Test/Services/Http/DicomAssociationInfoControllerTest.cs @@ -38,7 +38,7 @@ public class DicomAssociationInfoControllerTest private readonly Mock> _logger; private Mock _loggerFactory; private readonly DicomAssociationInfoController _controller; - private readonly IOptions _options; + private readonly IOptions _options; private readonly Mock _repo; private readonly UriService _uriService; @@ -48,7 +48,7 @@ public DicomAssociationInfoControllerTest() _logger = new Mock>(); _repo = new Mock(); _loggerFactory.Setup(p => p.CreateLogger(It.IsAny())).Returns(_logger.Object); - _options = Options.Create(new InformaticsGatewayConfiguration()); + _options = Options.Create(new HttpEndpointSettings()); _uriService = new UriService(new Uri("https://test.com/")); _controller = new DicomAssociationInfoController(_logger.Object, _options, _repo.Object, _uriService);