Skip to content

Commit 22cdee9

Browse files
neildsouthwoodheadio
authored andcommitted
adding endpoint to get AETitles by AeTitle
Signed-off-by: Neil South <[email protected]>
1 parent 630dceb commit 22cdee9

File tree

7 files changed

+54
-12
lines changed

7 files changed

+54
-12
lines changed

src/Common/packages.lock.json

-6
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,6 @@
3434
"resolved": "17.2.3",
3535
"contentHash": "VcozGeE4SxIo0cnXrDHhbrh/Gb8KQnZ3BvMelvh+iw0PrIKtuuA46U2Xm4e4pgnaWFgT4RdZfTpWl/WPRdw0WQ=="
3636
},
37-
"System.IO.Abstractions": {
38-
"type": "Direct",
39-
"requested": "[17.2.3, )",
40-
"resolved": "17.2.3",
41-
"contentHash": "VcozGeE4SxIo0cnXrDHhbrh/Gb8KQnZ3BvMelvh+iw0PrIKtuuA46U2Xm4e4pgnaWFgT4RdZfTpWl/WPRdw0WQ=="
42-
},
4337
"System.Threading.Tasks.Dataflow": {
4438
"type": "Direct",
4539
"requested": "[6.0.0, )",

src/Database/Api/Repositories/ISourceApplicationEntityRepository.cs

+2
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ public interface ISourceApplicationEntityRepository
2525

2626
Task<SourceApplicationEntity?> FindByNameAsync(string name, CancellationToken cancellationToken = default);
2727

28+
Task<SourceApplicationEntity[]?> FindByAETAsync(string name, CancellationToken cancellationToken = default);
29+
2830
Task<SourceApplicationEntity> AddAsync(SourceApplicationEntity item, CancellationToken cancellationToken = default);
2931

3032
Task<SourceApplicationEntity> UpdateAsync(SourceApplicationEntity entity, CancellationToken cancellationToken = default);

src/Database/EntityFramework/Repositories/SourceApplicationEntityRepository.cs

+10
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,16 @@ public async Task<bool> ContainsAsync(Expression<Func<SourceApplicationEntity, b
8787
}).ConfigureAwait(false);
8888
}
8989

90+
public async Task<SourceApplicationEntity[]?> FindByAETAsync(string aeTitle, CancellationToken cancellationToken = default)
91+
{
92+
Guard.Against.NullOrWhiteSpace(aeTitle);
93+
94+
return await _retryPolicy.ExecuteAsync(async () =>
95+
{
96+
return await _dataset.Where(p => p.AeTitle.Equals(aeTitle)).ToArrayAsync(cancellationToken).ConfigureAwait(false);
97+
}).ConfigureAwait(false);
98+
}
99+
90100
public async Task<SourceApplicationEntity> RemoveAsync(SourceApplicationEntity entity, CancellationToken cancellationToken = default)
91101
{
92102
Guard.Against.Null(entity);

src/Database/MongoDB/Repositories/SourceApplicationEntityRepository.cs

+10
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,16 @@ public async Task<List<SourceApplicationEntity>> ToListAsync(CancellationToken c
9797
}).ConfigureAwait(false);
9898
}
9999

100+
public async Task<SourceApplicationEntity[]?> FindByAETAsync(string aeTitle, CancellationToken cancellationToken = default)
101+
{
102+
return await _retryPolicy.ExecuteAsync(async () =>
103+
{
104+
return (await _collection
105+
.Find(x => x.AeTitle == aeTitle)
106+
.ToListAsync(cancellationToken).ConfigureAwait(false)).ToArray();
107+
}).ConfigureAwait(false);
108+
}
109+
100110
public async Task<SourceApplicationEntity> AddAsync(SourceApplicationEntity item, CancellationToken cancellationToken = default)
101111
{
102112
Guard.Against.Null(item);

src/DicomWebClient/packages.lock.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -1248,8 +1248,8 @@
12481248
"monai.deploy.informaticsgateway.client.common": {
12491249
"type": "Project",
12501250
"dependencies": {
1251-
"Ardalis.GuardClauses": "4.0.1",
1252-
"System.Text.Json": "6.0.7"
1251+
"Ardalis.GuardClauses": "[4.0.1, )",
1252+
"System.Text.Json": "[6.0.7, )"
12531253
}
12541254
}
12551255
}

src/InformaticsGateway/Services/Http/SourceAeTitleController.cs

+26
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,32 @@ public async Task<ActionResult<SourceApplicationEntity>> GetAeTitle(string name)
8888
}
8989
}
9090

91+
[HttpGet("/getbyaetitle/{aeTitle}")]
92+
[Produces("application/json")]
93+
[ProducesResponseType(StatusCodes.Status200OK)]
94+
[ProducesResponseType(StatusCodes.Status404NotFound)]
95+
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
96+
[ActionName(nameof(GetAeTitleByAET))]
97+
public async Task<ActionResult<SourceApplicationEntity>> GetAeTitleByAET(string aeTitle)
98+
{
99+
try
100+
{
101+
var sourceApplicationEntity = await _repository.FindByAETAsync(aeTitle, HttpContext.RequestAborted).ConfigureAwait(false);
102+
103+
if (sourceApplicationEntity is null)
104+
{
105+
return NotFound();
106+
}
107+
108+
return Ok(sourceApplicationEntity);
109+
}
110+
catch (Exception ex)
111+
{
112+
_logger.ErrorListingSourceApplicationEntities(ex);
113+
return Problem(title: "Error querying DICOM sources.", statusCode: (int)System.Net.HttpStatusCode.InternalServerError, detail: ex.Message);
114+
}
115+
}
116+
91117
[HttpPost]
92118
[Consumes(MediaTypeNames.Application.Json)]
93119
[ProducesResponseType(StatusCodes.Status201Created)]

src/InformaticsGateway/appsettings.Development.json

+4-4
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,15 @@
1717
"messaging": {
1818
"publisherSettings": {
1919
"endpoint": "localhost",
20-
"username": "rabbitmq",
21-
"password": "rabbitmq",
20+
"username": "admin",
21+
"password": "admin",
2222
"virtualHost": "monaideploy",
2323
"exchange": "monaideploy"
2424
},
2525
"subscriberSettings": {
2626
"endpoint": "localhost",
27-
"username": "rabbitmq",
28-
"password": "rabbitmq",
27+
"username": "admin",
28+
"password": "admin",
2929
"virtualHost": "monaideploy",
3030
"exchange": "monaideploy",
3131
"exportRequestQueue": "export_tasks"

0 commit comments

Comments
 (0)