Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix up for migrations and accessionId #1007

Merged
merged 2 commits into from
Jul 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,21 @@

namespace Monai.Deploy.WorkflowManager.Common.Contracts.Migrations
{
public class M003_WorkflowRevision_addDataRetension : DocumentMigration<WorkflowRevision>

Check warning on line 23 in src/WorkflowManager/Contracts/Migrations/M003_WorkflowRevision_addDataRetension.cs

View workflow job for this annotation

GitHub Actions / sonarscanner

Rename class 'M003_WorkflowRevision_addDataRetension' to match pascal case naming rules, consider using 'M003WorkflowRevisionaddDataRetension'. (https://rules.sonarsource.com/csharp/RSPEC-101)
{
public M003_WorkflowRevision_addDataRetension() : base("1.0.3") { }

public override void Up(BsonDocument document)
{
var workflow = document["Workflow"].AsBsonDocument;
workflow.Add("DataRetentionDays", -1, true);
try
{
var workflow = document["Workflow"].AsBsonDocument;
workflow.Add("DataRetentionDays", -1, true);
}
catch
{// can ignore we dont want failures stopping startup !
}

}

public override void Down(BsonDocument document)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,22 +20,29 @@

namespace Monai.Deploy.WorkflowManager.Common.Contracts.Migrations
{
public class M004_WorkflowRevision_addConditions : DocumentMigration<WorkflowRevision>

Check warning on line 23 in src/WorkflowManager/Contracts/Migrations/M004_WorkflowRevision_addConditions.cs

View workflow job for this annotation

GitHub Actions / sonarscanner

Rename class 'M004_WorkflowRevision_addConditions' to match pascal case naming rules, consider using 'M004WorkflowRevisionaddConditions'. (https://rules.sonarsource.com/csharp/RSPEC-101)
{
public M004_WorkflowRevision_addConditions() : base("1.0.4") { }

public override void Up(BsonDocument document)
{
var workflow = document["Workflow"].AsBsonDocument;
workflow.Add("Conditions", new BsonArray { });
try
{
var workflow = document["Workflow"].AsBsonDocument;
workflow.Add("Predicate", new BsonArray { });
}
catch
{ // can ignore we dont want failures stopping startup !
}

}

public override void Down(BsonDocument document)
{
try
{
var workflow = document["Workflow"].AsBsonDocument;
workflow.Remove("Conditions");
workflow.Remove("Predicate");
}
catch
{ // can ignore we dont want failures stopping startup !
Expand Down
4 changes: 3 additions & 1 deletion src/WorkflowManager/Storage/Services/DicomService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -123,14 +123,14 @@
var dict = new Dictionary<string, DicomValue>(StringComparer.OrdinalIgnoreCase);
try
{
if (items is null || items.Any() is false)

Check warning on line 126 in src/WorkflowManager/Storage/Services/DicomService.cs

View workflow job for this annotation

GitHub Actions / sonarscanner

Remove the unnecessary Boolean literal(s). (https://rules.sonarsource.com/csharp/RSPEC-1125)
{
return null;
}

foreach (var filePath in items.Select(item => item.FilePath))
{
if (filePath.EndsWith(".dcm.json") is false)

Check warning on line 133 in src/WorkflowManager/Storage/Services/DicomService.cs

View workflow job for this annotation

GitHub Actions / sonarscanner

Remove the unnecessary Boolean literal(s). (https://rules.sonarsource.com/csharp/RSPEC-1125)
{
continue;
}
Expand Down Expand Up @@ -160,8 +160,8 @@

public async Task<IEnumerable<string>> GetDicomPathsForTaskAsync(string outputDirectory, string bucketName)
{
ArgumentNullException.ThrowIfNullOrWhiteSpace(outputDirectory, nameof(outputDirectory));

Check warning on line 163 in src/WorkflowManager/Storage/Services/DicomService.cs

View workflow job for this annotation

GitHub Actions / sonarscanner

Remove this argument from the method call; it hides the caller information. (https://rules.sonarsource.com/csharp/RSPEC-3236)
ArgumentNullException.ThrowIfNullOrWhiteSpace(bucketName, nameof(bucketName));

Check warning on line 164 in src/WorkflowManager/Storage/Services/DicomService.cs

View workflow job for this annotation

GitHub Actions / sonarscanner

Remove this argument from the method call; it hides the caller information. (https://rules.sonarsource.com/csharp/RSPEC-3236)

var files = await _storageService.ListObjectsAsync(bucketName, outputDirectory, true);

Expand All @@ -172,9 +172,9 @@

public async Task<string> GetAnyValueAsync(string keyId, string payloadId, string bucketId)
{
ArgumentNullException.ThrowIfNullOrWhiteSpace(keyId, nameof(keyId));

Check warning on line 175 in src/WorkflowManager/Storage/Services/DicomService.cs

View workflow job for this annotation

GitHub Actions / sonarscanner

Remove this argument from the method call; it hides the caller information. (https://rules.sonarsource.com/csharp/RSPEC-3236)
ArgumentNullException.ThrowIfNullOrWhiteSpace(payloadId, nameof(payloadId));

Check warning on line 176 in src/WorkflowManager/Storage/Services/DicomService.cs

View workflow job for this annotation

GitHub Actions / sonarscanner

Remove this argument from the method call; it hides the caller information. (https://rules.sonarsource.com/csharp/RSPEC-3236)
ArgumentNullException.ThrowIfNullOrWhiteSpace(bucketId, nameof(bucketId));

Check warning on line 177 in src/WorkflowManager/Storage/Services/DicomService.cs

View workflow job for this annotation

GitHub Actions / sonarscanner

Remove this argument from the method call; it hides the caller information. (https://rules.sonarsource.com/csharp/RSPEC-3236)

var path = $"{payloadId}/dcm";
var listOfFiles = await _storageService.ListObjectsAsync(bucketId, path, true);
Expand All @@ -196,7 +196,7 @@

public async Task<string> GetAllValueAsync(string keyId, string payloadId, string bucketId)
{
ArgumentNullException.ThrowIfNullOrWhiteSpace(keyId, nameof(keyId));

Check warning on line 199 in src/WorkflowManager/Storage/Services/DicomService.cs

View workflow job for this annotation

GitHub Actions / sonarscanner

Remove this argument from the method call; it hides the caller information. (https://rules.sonarsource.com/csharp/RSPEC-3236)
ArgumentNullException.ThrowIfNullOrWhiteSpace(payloadId, nameof(payloadId));
ArgumentNullException.ThrowIfNullOrWhiteSpace(bucketId, nameof(bucketId));

Expand Down Expand Up @@ -305,7 +305,9 @@

if (dict.TryGetValue(DicomTagConstants.AccessionNumberTag, out var value))
{
return JsonConvert.SerializeObject(value.Value);
var accession = JsonConvert.SerializeObject(value.Value);
accession = accession.Replace("[\"", "").Replace("\"]", "");
return accession;
}
return null;
}
Expand Down
Loading