From b44be4f9e2f3e05e7543399e22a8011f007eede9 Mon Sep 17 00:00:00 2001 From: TekH Date: Sat, 10 Oct 2026 11:34:17 +0200 Subject: [PATCH] Enhance workflow handling and enforce stricter exceptions Enhanced `GetWorkflowsQueryHandler` to validate listing data in workflow sources and return appropriate responses. Updated `DocumentRepository.GetAsync` and `WorkflowRepository.CloseAsync` to throw `NotSupportedException` for unimplemented functionality, ensuring these methods cannot be used until finalized. Added `DigitalData.TaskFlow.Domain.Enums` dependency to support new logic in `GetWorkflowsQueryHandler`. --- .../Queries/GetWorkflows/GetWorkflowsQuery.cs | 15 +++++++++++++++ .../Repositories/DocumentRepository.cs | 9 ++------- .../Repositories/WorkflowRepository.cs | 7 ++----- 3 files changed, 19 insertions(+), 12 deletions(-) diff --git a/src/core/DigitalData.TaskFlow.Application/Features/Workflows/Queries/GetWorkflows/GetWorkflowsQuery.cs b/src/core/DigitalData.TaskFlow.Application/Features/Workflows/Queries/GetWorkflows/GetWorkflowsQuery.cs index cc118d4..78a3e16 100644 --- a/src/core/DigitalData.TaskFlow.Application/Features/Workflows/Queries/GetWorkflows/GetWorkflowsQuery.cs +++ b/src/core/DigitalData.TaskFlow.Application/Features/Workflows/Queries/GetWorkflows/GetWorkflowsQuery.cs @@ -1,6 +1,7 @@ using DigitalData.TaskFlow.Application.Common.Factories; using DigitalData.TaskFlow.Application.Common.Interfaces; using DigitalData.TaskFlow.Domain.Common; +using DigitalData.TaskFlow.Domain.Enums; using DigitalData.TaskFlow.Domain.Workflows; using FluentValidation; using MediatR; @@ -44,6 +45,20 @@ public sealed class GetWorkflowsQueryHandler(IWorkflowRepository workflowReposit { var data = await workflowRepository.GetAsync(request.WisagId, cancellationToken); + var hasListingData = data.Sources + .SelectMany(source => source switch + { + FerdinandSourceBlock ferdinand => ferdinand.Listing, + ContractsSourceBlock contracts => contracts.Listing, + _ => [] + }) + .Any(); + + if (!hasListingData) + { + return ApiEnvelopeFactory.Create(data, MetaCode.NoOpenWorkflows); + } + return ApiEnvelopeFactory.Create(data); } } diff --git a/src/infrastructure/DigitalData.TaskFlow.Infrastructure/Repositories/DocumentRepository.cs b/src/infrastructure/DigitalData.TaskFlow.Infrastructure/Repositories/DocumentRepository.cs index 646b891..234353e 100644 --- a/src/infrastructure/DigitalData.TaskFlow.Infrastructure/Repositories/DocumentRepository.cs +++ b/src/infrastructure/DigitalData.TaskFlow.Infrastructure/Repositories/DocumentRepository.cs @@ -16,12 +16,7 @@ public sealed class DocumentRepository : IDocumentRepository /// Binary document payload. public Task GetAsync(string id, CancellationToken cancellationToken) { - return Task.FromResult(new DocumentBinaryResult - { - Content = [], - ContentType = "application/octet-stream", - FileName = $"{id}.bin", - Length = 0 - }); + throw new NotSupportedException( + "Document retrieval source (DB/DMS) is not finalized yet. Configure final integration before enabling GetAsync."); } } diff --git a/src/infrastructure/DigitalData.TaskFlow.Infrastructure/Repositories/WorkflowRepository.cs b/src/infrastructure/DigitalData.TaskFlow.Infrastructure/Repositories/WorkflowRepository.cs index 09b4ee2..e550d7c 100644 --- a/src/infrastructure/DigitalData.TaskFlow.Infrastructure/Repositories/WorkflowRepository.cs +++ b/src/infrastructure/DigitalData.TaskFlow.Infrastructure/Repositories/WorkflowRepository.cs @@ -94,10 +94,7 @@ public sealed class WorkflowRepository(TaskFlowDbContext dbContext) : IWorkflowR CloseWorkflowDecision decision, CancellationToken cancellationToken) { - return Task.FromResult(new CloseWorkflowResult - { - ProcessId = processId, - IsClosed = true - }); + throw new NotSupportedException( + "Closing write procedure is not finalized yet. Configure final DB procedure mapping before enabling CloseAsync."); } }