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`.
This commit is contained in:
2026-10-10 11:34:17 +02:00
parent 88456e7f87
commit b44be4f9e2
3 changed files with 19 additions and 12 deletions

View File

@@ -1,6 +1,7 @@
using DigitalData.TaskFlow.Application.Common.Factories; using DigitalData.TaskFlow.Application.Common.Factories;
using DigitalData.TaskFlow.Application.Common.Interfaces; using DigitalData.TaskFlow.Application.Common.Interfaces;
using DigitalData.TaskFlow.Domain.Common; using DigitalData.TaskFlow.Domain.Common;
using DigitalData.TaskFlow.Domain.Enums;
using DigitalData.TaskFlow.Domain.Workflows; using DigitalData.TaskFlow.Domain.Workflows;
using FluentValidation; using FluentValidation;
using MediatR; using MediatR;
@@ -44,6 +45,20 @@ public sealed class GetWorkflowsQueryHandler(IWorkflowRepository workflowReposit
{ {
var data = await workflowRepository.GetAsync(request.WisagId, cancellationToken); 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); return ApiEnvelopeFactory.Create(data);
} }
} }

View File

@@ -16,12 +16,7 @@ public sealed class DocumentRepository : IDocumentRepository
/// <returns>Binary document payload.</returns> /// <returns>Binary document payload.</returns>
public Task<DocumentBinaryResult> GetAsync(string id, CancellationToken cancellationToken) public Task<DocumentBinaryResult> GetAsync(string id, CancellationToken cancellationToken)
{ {
return Task.FromResult(new DocumentBinaryResult throw new NotSupportedException(
{ "Document retrieval source (DB/DMS) is not finalized yet. Configure final integration before enabling GetAsync.");
Content = [],
ContentType = "application/octet-stream",
FileName = $"{id}.bin",
Length = 0
});
} }
} }

View File

@@ -94,10 +94,7 @@ public sealed class WorkflowRepository(TaskFlowDbContext dbContext) : IWorkflowR
CloseWorkflowDecision decision, CloseWorkflowDecision decision,
CancellationToken cancellationToken) CancellationToken cancellationToken)
{ {
return Task.FromResult(new CloseWorkflowResult throw new NotSupportedException(
{ "Closing write procedure is not finalized yet. Configure final DB procedure mapping before enabling CloseAsync.");
ProcessId = processId,
IsClosed = true
});
} }
} }