Skip to content

Commit 4da107e

Browse files
jackschofield23mocsharp
authored andcommitted
update export request event (#31)
* update export request event Signed-off-by: Jack Schofield <[email protected]>
1 parent bd913b3 commit 4da107e

File tree

3 files changed

+19
-51
lines changed

3 files changed

+19
-51
lines changed

src/Messaging/Events/ExportCompleteEvent.cs

Lines changed: 7 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@ namespace Monai.Deploy.Messaging.Events
1111
public class ExportCompleteEvent : EventBase
1212
{
1313
/// <summary>
14-
/// Gets or sets the workflow ID generated by the Workflow Manager.
14+
/// Gets or sets the workflow instanceID generated by the Workflow Manager.
1515
/// </summary>
16-
[JsonProperty(PropertyName = "workflow_id")]
16+
[JsonProperty(PropertyName = "workflow_instance_id")]
1717
[Required]
18-
public string WorkflowId { get; set; } = default!;
18+
public string WorkflowInstanceId { get; set; } = default!;
1919

2020
/// <summary>
2121
/// Gets or sets the export task ID generated by the Workflow Manager.
@@ -44,26 +44,15 @@ public ExportCompleteEvent()
4444
Status = ExportStatus.Unknown;
4545
}
4646

47-
public ExportCompleteEvent(ExportRequestEvent exportRequest)
47+
public ExportCompleteEvent(ExportRequestEvent exportRequest, ExportStatus exportStatus)
4848
{
4949
Guard.Against.Null(exportRequest, nameof(exportRequest));
50+
Guard.Against.Null(exportStatus, nameof(exportStatus));
5051

51-
WorkflowId = exportRequest.WorkflowId;
52+
WorkflowInstanceId = exportRequest.WorkflowInstanceId;
5253
ExportTaskId = exportRequest.ExportTaskId;
5354
Message = string.Join(System.Environment.NewLine, exportRequest.ErrorMessages);
54-
55-
if (exportRequest.FailedFiles == 0)
56-
{
57-
Status = ExportStatus.Success;
58-
}
59-
else if (exportRequest.FailedFiles == exportRequest.Files.Count())
60-
{
61-
Status = ExportStatus.Failure;
62-
}
63-
else
64-
{
65-
Status = ExportStatus.PartialFailure;
66-
}
55+
Status = exportStatus;
6756
}
6857
}
6958
}

src/Messaging/Events/ExportRequestEvent.cs

Lines changed: 5 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@ namespace Monai.Deploy.Messaging.Events
99
public class ExportRequestEvent : EventBase
1010
{
1111
/// <summary>
12-
/// Gets or sets the workflow ID generated by the Workflow Manager.
12+
/// Gets or sets the workflow instance ID generated by the Workflow Manager.
1313
/// </summary>
14-
[JsonProperty(PropertyName = "workflow_id")]
14+
[JsonProperty(PropertyName = "workflow_instance_id")]
1515
[Required]
16-
public string WorkflowId { get; set; } = default!;
16+
public string WorkflowInstanceId { get; set; } = default!;
1717

1818
/// <summary>
1919
/// Gets or sets the export task ID generated by the Workflow Manager.
@@ -34,9 +34,9 @@ public class ExportRequestEvent : EventBase
3434
/// For DIMSE, the named DICOM destination.
3535
/// For ACR, the Transaction ID in the original inference request.
3636
/// </summary>
37-
[JsonProperty(PropertyName = "destination")]
37+
[JsonProperty(PropertyName = "destinations")]
3838
[Required]
39-
public string Destination { get; set; } = default!;
39+
public string[] Destinations { get; set; } = default!;
4040

4141
/// <summary>
4242
/// Gets or set the correlation ID.
@@ -47,16 +47,6 @@ public class ExportRequestEvent : EventBase
4747
[Required]
4848
public string CorrelationId { get; set; } = default!;
4949

50-
/// <summary>
51-
/// Gets or set number of files exported successfully.
52-
/// </summary>
53-
public int SucceededFiles { get; set; } = 0;
54-
55-
/// <summary>
56-
/// Gets or sets number of files failed to export.
57-
/// </summary>
58-
public int FailedFiles { get; set; } = 0;
59-
6050
/// <summary>
6151
/// Gets or sets the delivery tag or acknowledge token for the task.
6252
/// </summary>
@@ -67,12 +57,6 @@ public class ExportRequestEvent : EventBase
6757
/// </summary>
6858
public string MessageId { get; set; } = default!;
6959

70-
/// <summary>
71-
/// Gets whether the export task is completed or not based on file count.
72-
/// </summary>
73-
public bool IsCompleted
74-
{ get { return (SucceededFiles + FailedFiles) == Files.Count(); } }
75-
7660
/// <summary>
7761
/// Gets or sets error messages related to this export task.
7862
/// </summary>

src/Messaging/Test/ExportCompleteEventTest.cs

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,22 +11,17 @@ namespace Monai.Deploy.Messaging.Test
1111
{
1212
public class ExportCompleteEventTest
1313
{
14-
[Theory(DisplayName = "Shall generate ExportCompleteMessageTest from ExportRequestMessage")]
15-
[InlineData(1, 0, ExportStatus.Success)]
16-
[InlineData(0, 5, ExportStatus.Failure)]
17-
[InlineData(3, 3, ExportStatus.PartialFailure)]
18-
public void ShallGenerateExportCompleteMessageTestFromExportRequestMessage(int successded, int fialure, ExportStatus status)
14+
[Fact(DisplayName = "Shall generate ExportCompleteMessageTest from ExportRequestMessage")]
15+
public void ShallGenerateExportCompleteMessageTestFromExportRequestMessage()
1916
{
2017
var exportRequestMessage = new ExportRequestEvent
2118
{
2219
CorrelationId = Guid.NewGuid().ToString(),
2320
DeliveryTag = Guid.NewGuid().ToString(),
24-
Destination = Guid.NewGuid().ToString(),
21+
Destinations = new string[] { Guid.NewGuid().ToString() },
2522
ExportTaskId = Guid.NewGuid().ToString(),
2623
MessageId = Guid.NewGuid().ToString(),
27-
WorkflowId = Guid.NewGuid().ToString(),
28-
SucceededFiles = successded,
29-
FailedFiles = fialure,
24+
WorkflowInstanceId = Guid.NewGuid().ToString(),
3025
};
3126
exportRequestMessage.Files = new List<string>()
3227
{
@@ -48,12 +43,12 @@ public void ShallGenerateExportCompleteMessageTestFromExportRequestMessage(int s
4843

4944
exportRequestMessage.AddErrorMessages(errors);
5045

51-
var exportCompleteMessage = new ExportCompleteEvent(exportRequestMessage);
46+
var exportCompleteMessage = new ExportCompleteEvent(exportRequestMessage, ExportStatus.Success);
5247

53-
Assert.Equal(exportRequestMessage.WorkflowId, exportCompleteMessage.WorkflowId);
48+
Assert.Equal(exportRequestMessage.WorkflowInstanceId, exportCompleteMessage.WorkflowInstanceId);
5449
Assert.Equal(exportRequestMessage.ExportTaskId, exportCompleteMessage.ExportTaskId);
5550
Assert.Equal(string.Join(System.Environment.NewLine, errors), exportCompleteMessage.Message);
56-
Assert.Equal(status, exportCompleteMessage.Status);
51+
Assert.Equal(ExportStatus.Success, exportCompleteMessage.Status);
5752
}
5853

5954
[Fact(DisplayName = "Validation shall throw on error")]

0 commit comments

Comments
 (0)