diff --git a/Dockerfile b/Dockerfile index adfcd84..0595021 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,6 @@ FROM mcr.microsoft.com/dotnet/sdk:6.0 +WORKDIR indico-client-csharp COPY . ./ RUN dotnet restore RUN dotnet build --no-restore -c Release diff --git a/Examples/SubmissionFilterExample/Program.cs b/Examples/SubmissionFilterExample/Program.cs index 05e4404..93a20dd 100644 --- a/Examples/SubmissionFilterExample/Program.cs +++ b/Examples/SubmissionFilterExample/Program.cs @@ -23,10 +23,10 @@ public static async Task Main() var workflowIds = new List() { 3106 }; // Example 1 - // List all submissions that are complete or failed - var orFilter = new OrFilter + // List all submissions that are COMPLETE and not retrieved + var andFilter = new AndFilter { - Or = new List + And = new List { new SubmissionFilter { @@ -34,40 +34,69 @@ public static async Task Main() }, new SubmissionFilter { - Status = SubmissionStatus.FAILED, + Retrieved = false, } } }; - var submissions = await submissionClient.ListAsync(submissionIds, workflowIds, orFilter, limit: 10); + submissions = await submissionClient.ListAsync(submissionIds, workflowIds, andFilter, limit: 10); Console.WriteLine(submissions); // Example 2 - // List all submissions that are COMPLETE and FAILED - var andFilter = new AndFilter + // List all submissions that are complete and not retrieved or failed and not retrieved + var orFilter = new OrFilter { - And = new List + Or = new List { - new SubmissionFilter + new AndFilter { - Status = SubmissionStatus.COMPLETE, + And = new List + { + new SubmissionFilter + { + Status = SubmissionStatus.COMPLETE, + }, + new SubmissionFilter + { + Retrieved = false, + } + } }, - new SubmissionFilter + new AndFilter { - Status = SubmissionStatus.FAILED, + And = new List + { + new SubmissionFilter + { + Status = SubmissionStatus.FAILED, + }, + new SubmissionFilter + { + Retrieved = false, + } + } } } }; - submissions = await submissionClient.ListAsync(submissionIds, workflowIds, andFilter, limit: 10); + var submissions = await submissionClient.ListAsync(submissionIds, workflowIds, orFilter, limit: 10); Console.WriteLine(submissions); // Example 3 // List all submissions that are retrieved and have a filename that contains 'property' - var subFilter = new SubmissionFilter + var subFilter = new AndFilter { - Retrieved = true, - InputFilename = "property" + And = new List + { + new SubmissionFilter + { + Retrieved = true, + }, + new SubmissionFilter + { + InputFilename = "property", + } + } }; submissions = await submissionClient.ListAsync(submissionIds, workflowIds, subFilter, limit: 10); @@ -80,10 +109,19 @@ public static async Task Main() From = "2022-01-01", To = DateTime.Now.ToString("yyyy-MM-dd") }; - subFilter = new SubmissionFilter + subFilter = new AndFilter { - CreatedAt = dateRangeFilter, - UpdatedAt = dateRangeFilter + And = new List + { + new SubmissionFilter + { + CreatedAt = dateRangeFilter, + }, + new SubmissionFilter + { + UpdatedAt = dateRangeFilter, + }, + } }; submissions = await submissionClient.ListAsync(submissionIds, workflowIds, subFilter, limit: 10); @@ -91,10 +129,19 @@ public static async Task Main() // Example 5 // List all submissions that are not in progress of being reviewed and are completed - subFilter = new SubmissionFilter + subFilter = new AndFilter { - Status = SubmissionStatus.COMPLETE, - ReviewInProgress = false + And = new List + { + new SubmissionFilter + { + Status = SubmissionStatus.COMPLETE, + }, + new SubmissionFilter + { + ReviewInProgress = false, + } + } }; submissions = await submissionClient.ListAsync(submissionIds, workflowIds, subFilter, limit: 10); diff --git a/IndicoV2.Abstractions/Submissions/Models/FilterConverter.cs b/IndicoV2.Abstractions/Submissions/Models/FilterConverter.cs index 4c93c54..b229395 100644 --- a/IndicoV2.Abstractions/Submissions/Models/FilterConverter.cs +++ b/IndicoV2.Abstractions/Submissions/Models/FilterConverter.cs @@ -22,7 +22,7 @@ public static ssSubmissionFilter ConvertToSs(this IFilter filter) { ssFilter.Filetype = submissionFilter.FileType.Select(x => (FileType)Enum.Parse(typeof(FileType), x)).ToList(); } - if (string.IsNullOrEmpty(submissionFilter.InputFilename)) + if (!string.IsNullOrEmpty(submissionFilter.InputFilename)) { ssFilter.InputFilename = submissionFilter.InputFilename; } diff --git a/IndicoV2.IntegrationTests/Submissions/SubmissionClientTests.cs b/IndicoV2.IntegrationTests/Submissions/SubmissionClientTests.cs index 9edb84a..5cc1f73 100644 --- a/IndicoV2.IntegrationTests/Submissions/SubmissionClientTests.cs +++ b/IndicoV2.IntegrationTests/Submissions/SubmissionClientTests.cs @@ -315,6 +315,62 @@ public async Task ListSubmissions_SubmissionFilterUpdatedAt_ShouldFetchSubmissio } + [Test] + public async Task ListSubmissions_SubmissionOrAndFilter_ShouldFetchSubmissions() + { + // Arrange + var listData = await _dataHelper.Submissions().ListAnyAsync(_workflowId); + + var filters = new OrFilter + { + Or = new List + { + new AndFilter + { + And = new List + { + new SubmissionFilter + { + Status = SubmissionStatus.COMPLETE, + }, + new SubmissionFilter + { + Retrieved = false, + } + } + }, + new AndFilter + { + And = new List + { + new SubmissionFilter + { + Status = SubmissionStatus.FAILED, + }, + new SubmissionFilter + { + Retrieved = false, + } + } + } + } + }; + // Act + var submissions = await _submissionsClient.ListAsync(null, new List { listData.workflowId }, filters, 0, 10); + + submissions.Should().NotBeNull(); + submissions.PageInfo.Should().NotBeNull(); + submissions.Data.Should().NotBeNull(); + foreach (var submission in submissions.Data) + { + submission.Id.Should().BeGreaterThan(0); + submission.Status.Should().BeOfType(); + submission.Status.Should().Match(status => status == SubmissionStatus.COMPLETE || status == SubmissionStatus.FAILED); + submission.Retrieved.Should().BeFalse(); + } + } + + [Test] public async Task GenerateSubmissionResultAsync_ShouldReturnJob() diff --git a/IndicoV2/IndicoV2.csproj b/IndicoV2/IndicoV2.csproj index 49c5beb..4228ca4 100644 --- a/IndicoV2/IndicoV2.csproj +++ b/IndicoV2/IndicoV2.csproj @@ -8,7 +8,7 @@ - 2.0.1 + 6.0.0 $(AssemblyVersion)-preview.$([System.DateTime]::UtcNow.ToString(yyMMddHHmm)) $(TargetsForTfmSpecificBuildOutput);IncludeP2POutput