Skip to content

Commit

Permalink
code comment changes
Browse files Browse the repository at this point in the history
Signed-off-by: Lillie Dae <lillie.dae@answerdigital.com>
  • Loading branch information
lillie-dae committed Sep 21, 2023
1 parent 2a8bb5d commit 1bcb32b
Show file tree
Hide file tree
Showing 9 changed files with 21 additions and 23 deletions.
4 changes: 2 additions & 2 deletions docs/api/rest/dicom-association.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

namespace Monai.Deploy.InformaticsGateway.Configuration
{
public class EndpointSettings
public class HttpEndpointSettings
{
[ConfigurationKeyName("defaultPageSize")]
public int DefaultPageSize { get; set; } = 10;
Expand Down
6 changes: 0 additions & 6 deletions src/Configuration/InformaticsGatewayConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,6 @@ public class InformaticsGatewayConfiguration
[ConfigurationKeyName("plugins")]
public PlugInConfiguration PlugInConfigurations { get; set; }

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

public InformaticsGatewayConfiguration()
{
Expand All @@ -99,7 +94,6 @@ public InformaticsGatewayConfiguration()
Database = new DatabaseConfiguration();
Hl7 = new Hl7Configuration();
PlugInConfigurations = new PlugInConfiguration();
EndpointSettings = new EndpointSettings();
}
}
}
3 changes: 0 additions & 3 deletions src/InformaticsGateway/Logging/Log.0.General.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
6 changes: 6 additions & 0 deletions src/InformaticsGateway/Logging/Log.8000.HttpServices.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
1 change: 1 addition & 0 deletions src/InformaticsGateway/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ internal static IHostBuilder CreateHostBuilder(string[] args) =>
.ConfigureServices((hostContext, services) =>
{
services.AddOptions<InformaticsGatewayConfiguration>().Bind(hostContext.Configuration.GetSection("InformaticsGateway"));
services.AddOptions<HttpEndpointSettings>().Bind(hostContext.Configuration.GetSection("InformaticsGateway:httpEndpointSettings"));
services.AddOptions<MessageBrokerServiceConfiguration>().Bind(hostContext.Configuration.GetSection("InformaticsGateway:messaging"));
services.AddOptions<StorageServiceConfiguration>().Bind(hostContext.Configuration.GetSection("InformaticsGateway:storage"));
services.AddOptions<AuthenticationOptions>().Bind(hostContext.Configuration.GetSection("MonaiDeployAuthentication"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<DicomAssociationInfoController> _logger;
private readonly IDicomAssociationInfoRepository _dicomRepo;
private readonly IUriService _uriService;

public DicomAssociationInfoController(ILogger<DicomAssociationInfoController> logger,
IOptions<InformaticsGatewayConfiguration> options,
IOptions<HttpEndpointSettings> options,
IDicomAssociationInfoRepository dicomRepo,
IUriService uriService) : base(options)
{
Expand All @@ -63,13 +63,13 @@ public async Task<IActionResult> 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(),
Expand All @@ -83,7 +83,7 @@ public async Task<IActionResult> GetAllAsync([FromQuery] TimeFilter filter)
}
catch (Exception e)

Check warning on line 84 in src/InformaticsGateway/Services/Http/DicomAssociationInfoController.cs

View check run for this annotation

Codecov / codecov/patch

src/InformaticsGateway/Services/Http/DicomAssociationInfoController.cs#L84

Added line #L84 was not covered by tests
{
_logger.DAIControllerGetAllAsyncError(e);
_logger.DicomAssociationsControllerGetError(e);
return Problem($"Unexpected error occurred: {e.Message}", Endpoint, InternalServerError);

Check warning on line 87 in src/InformaticsGateway/Services/Http/DicomAssociationInfoController.cs

View check run for this annotation

Codecov / codecov/patch

src/InformaticsGateway/Services/Http/DicomAssociationInfoController.cs#L86-L87

Added lines #L86 - L87 were not covered by tests
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ namespace Monai.Deploy.InformaticsGateway.Services.Http
{
public class PagedApiControllerBase : ApiControllerBase
{
protected readonly IOptions<InformaticsGatewayConfiguration> EndpointOptions;
protected readonly IOptions<HttpEndpointSettings> EndpointOptions;

public PagedApiControllerBase(IOptions<InformaticsGatewayConfiguration> options)
public PagedApiControllerBase(IOptions<HttpEndpointSettings> options)
{
EndpointOptions = options ?? throw new ArgumentNullException(nameof(options));
}
Expand All @@ -51,7 +51,7 @@ public PagedResponse<IEnumerable<T>> CreatePagedResponse<T>(IEnumerable<T> 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<IEnumerable<T>>(pagedData, validFilter.PageNumber ?? 0, pageSize);

response.SetUp(validFilter, totalRecords, uriService, route);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public class DicomAssociationInfoControllerTest
private readonly Mock<ILogger<DicomAssociationInfoController>> _logger;
private Mock<ILoggerFactory> _loggerFactory;
private readonly DicomAssociationInfoController _controller;
private readonly IOptions<InformaticsGatewayConfiguration> _options;
private readonly IOptions<HttpEndpointSettings> _options;
private readonly Mock<IDicomAssociationInfoRepository> _repo;
private readonly UriService _uriService;

Expand All @@ -48,7 +48,7 @@ public DicomAssociationInfoControllerTest()
_logger = new Mock<ILogger<DicomAssociationInfoController>>();
_repo = new Mock<IDicomAssociationInfoRepository>();
_loggerFactory.Setup(p => p.CreateLogger(It.IsAny<string>())).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);
Expand Down

0 comments on commit 1bcb32b

Please sign in to comment.