| | | 1 | | using Elsa.Workflows.Runtime.Entities; |
| | | 2 | | |
| | | 3 | | namespace Elsa.Workflows.Runtime.Filters; |
| | | 4 | | |
| | | 5 | | /// <summary> |
| | | 6 | | /// Represents a filter for triggers. |
| | | 7 | | /// </summary> |
| | | 8 | | public class TriggerFilter |
| | | 9 | | { |
| | | 10 | | /// <summary> |
| | | 11 | | /// Gets or sets the ID of the trigger to find. |
| | | 12 | | /// </summary> |
| | 1412 | 13 | | public string? Id { get; set; } |
| | | 14 | | |
| | | 15 | | /// <summary> |
| | | 16 | | /// Gets or sets the IDs of the triggers to find. |
| | | 17 | | /// </summary> |
| | 1420 | 18 | | public ICollection<string>? Ids { get; set; } |
| | | 19 | | |
| | | 20 | | /// <summary> |
| | | 21 | | /// Gets or sets the ID of the workflow definition. |
| | | 22 | | /// </summary> |
| | 2566 | 23 | | public string? WorkflowDefinitionId { get; set; } |
| | | 24 | | |
| | | 25 | | /// <summary> |
| | | 26 | | /// Gets or sets the ID of the workflow definition version. |
| | | 27 | | /// </summary> |
| | 1412 | 28 | | public string? WorkflowDefinitionVersionId { get; set; } |
| | | 29 | | |
| | | 30 | | /// <summary> |
| | | 31 | | /// Gets or sets the IDs of the workflow definitions. |
| | | 32 | | /// </summary> |
| | 1412 | 33 | | public ICollection<string>? WorkflowDefinitionIds { get; set; } |
| | | 34 | | |
| | | 35 | | /// <summary> |
| | | 36 | | /// Gets or sets the IDs of the workflow definition versions. |
| | | 37 | | /// </summary> |
| | 1412 | 38 | | public ICollection<string>? WorkflowDefinitionVersionIds { get; set; } |
| | | 39 | | |
| | | 40 | | /// <summary> |
| | | 41 | | /// Gets or sets the name of the trigger to find. |
| | | 42 | | /// </summary> |
| | 1428 | 43 | | public string? Name { get; set; } |
| | | 44 | | |
| | | 45 | | /// <summary> |
| | | 46 | | /// Gets or sets the names of the triggers to find. |
| | | 47 | | /// </summary> |
| | 1416 | 48 | | public ICollection<string>? Names { get; set; } |
| | | 49 | | |
| | | 50 | | /// <summary> |
| | | 51 | | /// Gets or sets the hash of the trigger to find. |
| | | 52 | | /// </summary> |
| | 1655 | 53 | | public string? Hash { get; set; } |
| | | 54 | | |
| | | 55 | | /// <summary> |
| | | 56 | | /// Get or sets if the triggers to find is a tenant agnostic search |
| | | 57 | | /// </summary> |
| | 1243 | 58 | | public bool TenantAgnostic { get; set; } |
| | | 59 | | |
| | | 60 | | /// <summary> |
| | | 61 | | /// Applies the filter to the specified query. |
| | | 62 | | /// </summary> |
| | | 63 | | public IQueryable<StoredTrigger> Apply(IQueryable<StoredTrigger> queryable) |
| | | 64 | | { |
| | 695 | 65 | | if (Id != null) queryable = queryable.Where(x => x.Id == Id); |
| | 699 | 66 | | if (Ids != null) queryable = queryable.Where(x => Ids.Contains(x.Id)); |
| | 1341 | 67 | | if (WorkflowDefinitionId != null) queryable = queryable.Where(x => x.WorkflowDefinitionId == WorkflowDefinitionI |
| | 695 | 68 | | if (WorkflowDefinitionIds != null) queryable = queryable.Where(x => WorkflowDefinitionIds.Contains(x.WorkflowDef |
| | 695 | 69 | | if (WorkflowDefinitionVersionId != null) queryable = queryable.Where(x => x.WorkflowDefinitionVersionId == Workf |
| | 695 | 70 | | if (WorkflowDefinitionVersionIds != null) queryable = queryable.Where(x => WorkflowDefinitionVersionIds.Contains |
| | 704 | 71 | | if (Name != null) queryable = queryable.Where(x => x.Name == Name); |
| | 697 | 72 | | if (Names != null) queryable = queryable.Where(x => Names.Contains(x.Name!)); |
| | 723 | 73 | | if (Hash != null) queryable = queryable.Where(x => x.Hash == Hash); |
| | 695 | 74 | | return queryable; |
| | | 75 | | } |
| | | 76 | | |
| | 1 | 77 | | public static TriggerFilter ByNames(IEnumerable<string> names) => new() |
| | 1 | 78 | | { |
| | 1 | 79 | | Names = names.ToList() |
| | 1 | 80 | | }; |
| | | 81 | | } |