Add filtering enhancements and clean up code inconsistencies
Introduced new filtering capabilities such as `Names`, `Statuses`, `SubStatuses`, and `SearchTerm` for workflow instance filters. Simplified object initialization syntax and removed unnecessary attributes, improving code readability. Added missing dependencies and API service registrations to ensure completeness.
This commit is contained in:
parent
861fe40f66
commit
7cc638b86f
|
|
@ -2,6 +2,7 @@ using Elsa.Api.Client.Options;
|
|||
using Elsa.Api.Client.Resources.ActivityDescriptorOptions.Contracts;
|
||||
using Elsa.Api.Client.Resources.ActivityDescriptors.Contracts;
|
||||
using Elsa.Api.Client.Resources.ActivityExecutions.Contracts;
|
||||
using Elsa.Api.Client.Resources.Alterations.Contracts;
|
||||
using Elsa.Api.Client.Resources.Features.Contracts;
|
||||
using Elsa.Api.Client.Resources.Identity.Contracts;
|
||||
using Elsa.Api.Client.Resources.IncidentStrategies.Contracts;
|
||||
|
|
@ -68,6 +69,7 @@ public static class DependencyInjectionExtensions
|
|||
services.AddApi<IJavaScriptApi>(builderOptions);
|
||||
services.AddApi<IExpressionDescriptorsApi>(builderOptions);
|
||||
services.AddApi<IWorkflowContextProviderDescriptorsApi>(builderOptions);
|
||||
services.AddApi<IAlterationsApi>(builderOptions);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
using Elsa.Api.Client.Resources.WorkflowInstances.Enums;
|
||||
using Elsa.Api.Client.Shared.Models;
|
||||
|
||||
namespace Elsa.Api.Client.Resources.Alterations.Models;
|
||||
|
|
@ -16,11 +17,26 @@ public class AlterationWorkflowInstanceFilter
|
|||
/// The correlation IDs of the workflow instances that this plan applies to.
|
||||
/// </summary>
|
||||
public IEnumerable<string>? CorrelationIds { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// A collection of names associated with the workflow instances being filtered.
|
||||
/// </summary>
|
||||
public ICollection<string>? Names { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// A search term used to filter workflow instances based on matching criteria.
|
||||
/// </summary>
|
||||
public string? SearchTerm { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// A collection of timestamp filters used for filtering data based on specified timestamp columns and operators.
|
||||
/// </summary>
|
||||
public IEnumerable<TimestampFilter>? TimestampFilters { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The IDs of the workflow definitions that this plan applies to.
|
||||
/// </summary>
|
||||
public ICollection<string>? DefinitionIds { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The IDs of the workflow definitions that this plan applies to.
|
||||
|
|
@ -37,6 +53,16 @@ public class AlterationWorkflowInstanceFilter
|
|||
/// </summary>
|
||||
public bool? IsSystem { get; set; } = false;
|
||||
|
||||
/// <summary>
|
||||
/// Represents the workflow statuses included in the filter.
|
||||
/// </summary>
|
||||
public ICollection<WorkflowStatus>? Statuses { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// A collection of sub-statuses used to filter workflow instances by their specific sub-state.
|
||||
/// </summary>
|
||||
public ICollection<WorkflowSubStatus>? SubStatuses { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Represents a collection of filters for activities.
|
||||
/// </summary>
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
using Elsa.Workflows;
|
||||
using Elsa.Workflows.Management.Models;
|
||||
using JetBrains.Annotations;
|
||||
|
||||
|
|
@ -19,11 +20,26 @@ public class AlterationWorkflowInstanceFilter
|
|||
/// </summary>
|
||||
public IEnumerable<string>? CorrelationIds { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// A collection of names associated with the workflow instances being filtered.
|
||||
/// </summary>
|
||||
public ICollection<string>? Names { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// A search term used to filter workflow instances based on matching criteria.
|
||||
/// </summary>
|
||||
public string? SearchTerm { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// A collection of timestamp filters used for filtering data based on specified timestamp columns and operators.
|
||||
/// </summary>
|
||||
public IEnumerable<TimestampFilter>? TimestampFilters { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The IDs of the workflow definitions that this plan applies to.
|
||||
/// </summary>
|
||||
public ICollection<string>? DefinitionIds { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The IDs of the workflow definitions that this plan applies to.
|
||||
/// </summary>
|
||||
|
|
@ -38,6 +54,16 @@ public class AlterationWorkflowInstanceFilter
|
|||
/// Whether the workflow instances to match are system workflows. Defaults to <c>false</c>.
|
||||
/// </summary>
|
||||
public bool? IsSystem { get; set; } = false;
|
||||
|
||||
/// <summary>
|
||||
/// Represents the workflow statuses included in the filter.
|
||||
/// </summary>
|
||||
public ICollection<WorkflowStatus>? Statuses { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// A collection of sub-statuses used to filter workflow instances by their specific sub-state.
|
||||
/// </summary>
|
||||
public ICollection<WorkflowSubStatus>? SubStatuses { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Represents a collection of filters for activities.
|
||||
|
|
|
|||
|
|
@ -17,12 +17,16 @@ public class WorkflowInstanceFinder(IWorkflowInstanceStore workflowInstanceStore
|
|||
var workflowInstanceFilter = new WorkflowInstanceFilter
|
||||
{
|
||||
Ids = filter.WorkflowInstanceIds?.ToList(),
|
||||
DefinitionIds = filter.DefinitionIds,
|
||||
DefinitionVersionIds = filter.DefinitionVersionIds?.ToList(),
|
||||
CorrelationIds = filter.CorrelationIds?.ToList(),
|
||||
HasIncidents = filter.HasIncidents,
|
||||
IsSystem = filter.IsSystem,
|
||||
TimestampFilters = filter.TimestampFilters?.ToList(),
|
||||
WorkflowStatus = WorkflowStatus.Running
|
||||
WorkflowStatuses = filter.Statuses?.ToList(),
|
||||
WorkflowSubStatuses = filter.SubStatuses?.ToList(),
|
||||
Names = filter.Names?.ToList(),
|
||||
SearchTerm = filter.SearchTerm,
|
||||
};
|
||||
var activityExecutionFilters = filter.ActivityFilters?.Select(x => new ActivityExecutionRecordFilter
|
||||
{
|
||||
|
|
|
|||
|
|
@ -30,7 +30,6 @@ public class DefaultAlterationPlanScheduler : IAlterationPlanScheduler
|
|||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
[RequiresUnreferencedCode("The type of the object to be deserialized is not known at compile time.")]
|
||||
public async Task<string> SubmitAsync(AlterationPlanParams planParams, CancellationToken cancellationToken = default)
|
||||
{
|
||||
if(string.IsNullOrWhiteSpace(planParams.Id))
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ public class MassTransitWorkflowDispatcher(
|
|||
var workflowGraph = await workflowDefinitionService.FindWorkflowGraphAsync(request.DefinitionId, request.VersionOptions, cancellationToken);
|
||||
|
||||
if (workflowGraph == null)
|
||||
throw new Exception($"Workflow definition with definition ID '{request.DefinitionId} and version {request.VersionOptions}' not found");
|
||||
throw new($"Workflow definition with definition ID '{request.DefinitionId} and version {request.VersionOptions}' not found");
|
||||
|
||||
var workflow = workflowGraph.Workflow;
|
||||
var createWorkflowInstanceRequest = new CreateWorkflowInstanceRequest
|
||||
|
|
@ -178,7 +178,7 @@ public class MassTransitWorkflowDispatcher(
|
|||
private async Task<ISendEndpoint> GetSendEndpointAsync(DispatchWorkflowOptions? options = default)
|
||||
{
|
||||
var endpointName = endpointChannelFormatter.FormatEndpointName(options?.Channel);
|
||||
var sendEndpoint = await bus.GetSendEndpoint(new Uri($"queue:{endpointName}"));
|
||||
var sendEndpoint = await bus.GetSendEndpoint(new($"queue:{endpointName}"));
|
||||
return sendEndpoint;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -101,6 +101,11 @@ public class WorkflowInstanceFilter
|
|||
/// </summary>
|
||||
public ICollection<TimestampFilter>? TimestampFilters { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Filter workflow instances by name.
|
||||
/// </summary>
|
||||
public List<string>? Names { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Applies the filter to the specified query.
|
||||
/// </summary>
|
||||
|
|
@ -119,6 +124,7 @@ public class WorkflowInstanceFilter
|
|||
if (filter.ParentWorkflowInstanceIds != null) query = query.Where(x => x.ParentWorkflowInstanceId != null && filter.ParentWorkflowInstanceIds.Contains(x.ParentWorkflowInstanceId));
|
||||
if (!string.IsNullOrWhiteSpace(filter.CorrelationId)) query = query.Where(x => x.CorrelationId == filter.CorrelationId);
|
||||
if (filter.CorrelationIds != null) query = query.Where(x => filter.CorrelationIds.Contains(x.CorrelationId!));
|
||||
if (filter.Names != null) query = query.Where(x => filter.Names.Contains(x.Name!));
|
||||
if (filter.WorkflowStatus != null) query = query.Where(x => x.Status == filter.WorkflowStatus);
|
||||
if (filter.WorkflowSubStatus != null) query = query.Where(x => x.SubStatus == filter.WorkflowSubStatus);
|
||||
if (filter.WorkflowStatuses != null) query = query.Where(x => filter.WorkflowStatuses.Contains(x.Status));
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ public static class WorkflowDispatcherExtensions
|
|||
/// </summary>
|
||||
public static Task<DispatchWorkflowResponse> DispatchAsync(this IWorkflowDispatcher workflowDispatcher, DispatchWorkflowDefinitionRequest request, CancellationToken cancellationToken = default)
|
||||
{
|
||||
return workflowDispatcher.DispatchAsync(request, new DispatchWorkflowOptions(), cancellationToken);
|
||||
return workflowDispatcher.DispatchAsync(request, new(), cancellationToken);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -23,7 +23,7 @@ public static class WorkflowDispatcherExtensions
|
|||
/// </summary>
|
||||
public static Task<DispatchWorkflowResponse> DispatchAsync(this IWorkflowDispatcher workflowDispatcher, DispatchWorkflowInstanceRequest request, CancellationToken cancellationToken = default)
|
||||
{
|
||||
return workflowDispatcher.DispatchAsync(request, new DispatchWorkflowOptions(), cancellationToken);
|
||||
return workflowDispatcher.DispatchAsync(request, new(), cancellationToken);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -31,7 +31,7 @@ public static class WorkflowDispatcherExtensions
|
|||
/// </summary>
|
||||
public static Task<DispatchWorkflowResponse> DispatchAsync(this IWorkflowDispatcher workflowDispatcher, DispatchTriggerWorkflowsRequest request, CancellationToken cancellationToken = default)
|
||||
{
|
||||
return workflowDispatcher.DispatchAsync(request, new DispatchWorkflowOptions(), cancellationToken);
|
||||
return workflowDispatcher.DispatchAsync(request, new(), cancellationToken);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -39,6 +39,6 @@ public static class WorkflowDispatcherExtensions
|
|||
/// </summary>
|
||||
public static Task<DispatchWorkflowResponse> DispatchAsync(this IWorkflowDispatcher workflowDispatcher, DispatchResumeWorkflowsRequest request, CancellationToken cancellationToken = default)
|
||||
{
|
||||
return workflowDispatcher.DispatchAsync(request, new DispatchWorkflowOptions(), cancellationToken);
|
||||
return workflowDispatcher.DispatchAsync(request, new(), cancellationToken);
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue