From cfac318d7ce9bfbee89d3bbd08869fb4de9eda29 Mon Sep 17 00:00:00 2001 From: Sipke Schoorstra Date: Wed, 7 Feb 2024 15:51:21 +0100 Subject: [PATCH] Update WorkflowDefinitionManager to handle dependencies This update modifies how WorkflowDefinitionManager fetches and handles workflow definitions. It now considers both the latest and published workflow definitions rather than only the published ones. It also removes the dependency id from the list of workflows to consider. A redundant workflow validator from the WorkflowDefinitionPublisher is also removed. --- .../Services/WorkflowDefinitionManager.cs | 9 ++++++--- .../Services/WorkflowDefinitionPublisher.cs | 1 - 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/modules/Elsa.Workflows.Management/Services/WorkflowDefinitionManager.cs b/src/modules/Elsa.Workflows.Management/Services/WorkflowDefinitionManager.cs index ac1041bb0..b544f5c21 100644 --- a/src/modules/Elsa.Workflows.Management/Services/WorkflowDefinitionManager.cs +++ b/src/modules/Elsa.Workflows.Management/Services/WorkflowDefinitionManager.cs @@ -126,12 +126,15 @@ public class WorkflowDefinitionManager : IWorkflowDefinitionManager { var updatedWorkflowDefinitions = new List(); - var publishedWorkflowDefinitions = (await _store.FindManyAsync(new WorkflowDefinitionFilter + var workflowDefinitions = (await _store.FindManyAsync(new WorkflowDefinitionFilter { - VersionOptions = VersionOptions.Published + VersionOptions = VersionOptions.LatestAndPublished }, cancellationToken)).ToList(); + + // Remove the dependency from the list of workflow definitions to consider. + workflowDefinitions = workflowDefinitions.Where(x => x.DefinitionId != dependency.DefinitionId).ToList(); - foreach (var definition in publishedWorkflowDefinitions) + foreach (var definition in workflowDefinitions) { var root = _activitySerializer.Deserialize(definition.StringData!); var graph = await _activityVisitor.VisitAsync(root, cancellationToken); diff --git a/src/modules/Elsa.Workflows.Management/Services/WorkflowDefinitionPublisher.cs b/src/modules/Elsa.Workflows.Management/Services/WorkflowDefinitionPublisher.cs index 240b0d920..dd37fe833 100644 --- a/src/modules/Elsa.Workflows.Management/Services/WorkflowDefinitionPublisher.cs +++ b/src/modules/Elsa.Workflows.Management/Services/WorkflowDefinitionPublisher.cs @@ -31,7 +31,6 @@ public class WorkflowDefinitionPublisher : IWorkflowDefinitionPublisher public WorkflowDefinitionPublisher( IWorkflowDefinitionService workflowDefinitionService, IWorkflowDefinitionStore workflowDefinitionStore, - IWorkflowValidator workflowValidator, INotificationSender notificationSender, IIdentityGenerator identityGenerator, IActivitySerializer activitySerializer,